:root {
  --bg: #0d0722;
  --ink: #f7f2ff;
  --muted: #a497cc;
  --coral: #ff5e6c;
  --gold: #ffc338;
  --mint: #3ef0a8;
  --grape: #8b74ff;
  --sky: #4cc9ff;
  --pink: #ff4fd8;
  --glass: rgba(26, 15, 60, 0.72);
  --stroke: rgba(255, 255, 255, 0.1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app {
  position: fixed;
  inset: 0;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  cursor: pointer;
}

svg {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
}
.screen.ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b));
  overflow-y: auto;
}
.ui-pass {
  pointer-events: none;
}
.ui-pass > * {
  pointer-events: auto;
}

/* ---------- title ---------- */
#title {
  background: radial-gradient(ellipse at 50% 45%, rgba(13, 7, 34, 0.15), rgba(13, 7, 34, 0.75) 70%);
}
.title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(460px, 100%);
  margin: auto 0;
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.logo {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.12em;
  font-weight: 900;
  font-size: clamp(50px, 15.5vw, 104px);
  padding-right: 0.08em;
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-style: italic;
}
.logo-tap {
  color: var(--ink);
  text-shadow: 0 0.06em 0 #4a2fb8, 0 0.12em 0 #2b1773, 0 0.2em 0.4em rgba(0, 0, 0, 0.5);
}
.logo-tock {
  background: linear-gradient(180deg, #fff0a8 0%, #ffc338 45%, #ff8a3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0.06em 0 #b4471a) drop-shadow(0 0.12em 0 #6e2508) drop-shadow(0 0.2em 0.3em rgba(0, 0, 0, 0.5));
}
.logo-clock {
  position: relative;
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  border: 0.075em solid var(--ink);
  box-shadow: 0 0 0.25em rgba(139, 116, 255, 0.9), inset 0 0 0.15em rgba(139, 116, 255, 0.7);
  font-style: normal;
}
.logo-clock i {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 0.06em;
  height: 0.22em;
  margin-left: -0.03em;
  background: var(--gold);
  border-radius: 1em;
  transform-origin: 50% 100%;
  animation: spin 2.2s steps(12) infinite;
}
.tag {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: clamp(15px, 4.2vw, 18px);
  line-height: 1.45;
}
.tag b {
  color: var(--ink);
}

.challenge {
  width: 100%;
  text-align: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 94, 108, 0.2), rgba(255, 79, 216, 0.14));
  border: 1px solid rgba(255, 94, 108, 0.5);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: 0 0 30px rgba(255, 94, 108, 0.2);
}
.challenge-kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--coral);
  margin-bottom: 4px;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  font-weight: 900;
  letter-spacing: 0.08em;
  border-radius: 22px;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  position: relative;
  overflow: hidden;
}
.btn-primary {
  font-size: 24px;
  padding: 20px 28px;
  color: #3a1600;
  background: linear-gradient(180deg, #fff0a0 0%, #ffc338 42%, #ff9a3c 100%);
  box-shadow: 0 7px 0 #b8520f, 0 16px 36px rgba(255, 150, 60, 0.38), inset 0 2px 0 rgba(255, 255, 255, 0.75);
}
.btn-primary svg {
  fill: currentColor;
  stroke: none;
  width: 0.95em;
  height: 0.95em;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 48%, transparent 66%);
  transform: translateX(-120%);
  animation: shine 3.2s ease-in-out infinite 1s;
}
.btn-primary:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #b8520f, 0 8px 18px rgba(255, 150, 60, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.75);
}
.btn-ghost {
  font-size: 17px;
  padding: 16px 24px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-ghost:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible,
.link-btn:focus-visible,
.btn-clip:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.chip:hover {
  background: rgba(255, 255, 255, 0.11);
}
.chip:active {
  transform: scale(0.96);
}
.chip.on {
  border-color: rgba(62, 240, 168, 0.6);
  background: rgba(62, 240, 168, 0.12);
  color: var(--mint);
}
.chip-icon {
  padding: 11px 13px;
}
.chip-icon .i-off,
.chip-icon.off .i-on {
  display: none;
}
.chip-icon.off .i-off {
  display: block;
}
.chip-icon.off {
  color: var(--muted);
}
.cam-preview {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  transform: scaleX(-1);
  margin: -4px 0;
  box-shadow: 0 0 0 2px var(--mint);
}
.cam-preview:not(.hidden) + svg {
  display: none;
}

.stats {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-align: center;
}
.title-foot {
  display: flex;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(164, 151, 204, 0.6);
  padding-top: 12px;
}
.title-foot a {
  color: inherit;
  text-decoration: none;
}
.title-foot a:hover {
  color: var(--ink);
}

/* ---------- in-game ---------- */
.icon-btn {
  position: absolute;
  top: calc(14px + var(--safe-t));
  left: 14px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 18px;
  backdrop-filter: blur(8px);
}
.icon-btn:hover {
  color: var(--ink);
}
.btn-clip {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 79, 216, 0.55);
  background: linear-gradient(135deg, rgba(255, 79, 216, 0.25), rgba(139, 116, 255, 0.25));
  color: var(--ink);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.12em;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 26px rgba(255, 79, 216, 0.3);
  animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}
.btn-clip:active {
  transform: translateX(-50%) scale(0.95);
}

/* ---------- panels ---------- */
#over,
#daily-done {
  background: rgba(8, 4, 20, 0.55);
  backdrop-filter: blur(6px);
}
.panel {
  width: min(420px, 100%);
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 20px 18px;
  border-radius: 28px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--coral);
}
.panel-title {
  font-size: clamp(38px, 11vw, 52px);
  font-weight: 900;
  line-height: 1;
  font-style: italic;
  text-shadow: 0 4px 0 #2b1773, 0 0 30px rgba(139, 116, 255, 0.6);
}
.newbest {
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--pink));
  color: #2a0d24;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.18em;
  animation: pulse 1s ease-in-out infinite;
}
.taunt {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
  max-width: 320px;
}
.over-body {
  display: flex;
  gap: 14px;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  margin: 4px 0 6px;
}
.clip-wrap {
  position: relative;
  width: 112px;
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  overflow: hidden;
  background: #120a2c;
  border: 1px solid var(--stroke);
  flex: none;
  box-shadow: 0 0 24px rgba(255, 79, 216, 0.25);
}
.clip-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.clip-loading {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  text-align: center;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.clip-wrap.loading .clip-loading {
  display: grid;
}
.clip-wrap.loading video {
  visibility: hidden;
}
.statgrid {
  flex: 1;
  display: grid;
  gap: 8px;
  align-content: center;
  max-width: 220px;
}
.statgrid.two {
  grid-template-columns: 1fr 1fr;
  max-width: none;
  width: 100%;
}
.statgrid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.statgrid span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--muted);
}
.statgrid b {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.challenge-result {
  width: 100%;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 94, 108, 0.12);
  color: var(--coral);
}
.challenge-result.win {
  background: rgba(62, 240, 168, 0.12);
  color: var(--mint);
}
.link-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  padding: 8px 16px;
}
.link-btn:hover {
  color: var(--ink);
}
.daily-grid {
  display: flex;
  gap: 8px;
  margin: 6px 0;
}
.daily-grid span {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 0 18px rgba(255, 255, 255, 0.08);
  animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}
.daily-grid span:nth-child(2) { animation-delay: 0.08s; }
.daily-grid span:nth-child(3) { animation-delay: 0.16s; }
.daily-grid span:nth-child(4) { animation-delay: 0.24s; }
.daily-grid span:nth-child(5) { animation-delay: 0.32s; }
.daily-next {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- share sheet ---------- */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5, 2, 14, 0);
  transition: background 0.2s;
}
.sheet.open {
  background: rgba(5, 2, 14, 0.7);
}
.sheet-card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 18px calc(16px + var(--safe-b));
  border-radius: 28px 28px 0 0;
  background: #170d3a;
  border: 1px solid var(--stroke);
  border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet.open .sheet-card {
  transform: none;
}
@media (min-width: 700px) {
  .sheet {
    align-items: center;
  }
  .sheet-card {
    border-radius: 28px;
    border-bottom: 1px solid var(--stroke);
  }
}
.sheet-video {
  height: min(42vh, 360px);
  aspect-ratio: 9 / 16;
  border-radius: 18px;
  background: #0b0620;
  object-fit: cover;
  box-shadow: 0 0 30px rgba(255, 79, 216, 0.25);
}
.sheet-title {
  font-size: 24px;
  font-weight: 900;
  font-style: italic;
  text-align: center;
}
.sheet-note {
  margin: -4px 0 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-align: center;
}

/* ---------- misc ---------- */
.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: calc(18px + var(--safe-t));
  transform: translate(-50%, -20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a0f3d;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.rotate {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-weight: 800;
  font-size: 18px;
}
.rotate .logo-clock {
  font-size: 90px;
}
@media (orientation: landscape) and (max-height: 480px) and (pointer: coarse) {
  .rotate {
    display: flex;
  }
}
.cam-src,
.rec-canvas {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px !important;
  height: 2px !important;
  opacity: 0.01;
  pointer-events: none;
  z-index: -1;
}
#safe-probe {
  position: fixed;
  visibility: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateX(var(--tx, 0)) scale(0.6);
  }
  to {
    opacity: 1;
  }
}
.btn-clip {
  --tx: -50%;
}
@keyframes shine {
  0%, 60% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  50% {
    transform: scale(1.06);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
