:root {
  --bg: #0b0b0f;
  --fg: #f5f5f7;
  --muted: #9a9aa5;
  --accent: #ffd60a;
  --accent-ink: #1a1500;
  --alt: #2a2a33;
  --danger: #ff3b30;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "SF Pro Rounded", sans-serif;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; }

.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
.screen.active { display: flex; }

.logo { font-size: 88px; line-height: 1; }
h1 { font-size: 48px; font-weight: 900; margin: 0; letter-spacing: -1px; }
h2 { font-size: 32px; font-weight: 900; margin: 0; }
.tagline { color: var(--muted); margin: 0 0 12px; max-width: 340px; font-size: 17px; }
.fine { color: var(--muted); font-size: 13px; max-width: 300px; }
.best { color: var(--accent); font-weight: 700; min-height: 1.2em; margin: 4px 0 0; }

.big {
  width: min(100%, 340px);
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 22px;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.big small { font-size: 14px; font-weight: 600; opacity: .75; }
.big.alt { background: var(--alt); color: var(--fg); }
.big:active { transform: scale(.97); }

.link { background: none; color: var(--muted); text-decoration: underline; padding: 8px; }

.row { display: flex; gap: 12px; width: min(100%, 340px); }
.row button { flex: 1; padding: 14px; border-radius: 16px; background: var(--alt); font-weight: 800; font-size: 17px; }

.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 5px solid var(--alt); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-screen { padding: 0; background: #000; position: relative; }
.stage-screen canvas {
  width: min(100vw, calc(100dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  display: block;
}

.quit {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0, 0, 0, .5);
  font-size: 18px;
}

.rec-ui {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 16px;
}
.rec-ui p { margin: 0; text-shadow: 0 1px 6px #000; max-width: 320px; font-weight: 600; }
.rec-btn {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--danger);
  border: 5px solid #fff;
  font-weight: 900; font-size: 15px;
}
.rec-btn.recording { border-radius: 24px; }

#debugSmile {
  position: absolute; bottom: 24px; right: 12px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  user-select: none; -webkit-user-select: none;
}

#resTime { font-size: 64px; font-weight: 900; margin: 0; color: var(--accent); }
#resBest { margin: 0; color: var(--muted); }
#resVideo {
  height: min(38dvh, 380px);
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  background: #000;
}

input.name {
  width: min(100%, 340px);
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--alt);
  background: #15151b;
  color: var(--fg);
  font: inherit;
  font-size: 18px;
  text-align: center;
}
input.name:focus { outline: none; border-color: var(--accent); }
input.name.shake { animation: shake .4s; border-color: var(--danger); }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.linkbox {
  margin: 0;
  max-width: 340px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #15151b;
  font: 14px ui-monospace, monospace;
  word-break: break-all;
}

.board, .mine { width: min(100%, 340px); text-align: left; }
.board h3, .mine h3 {
  margin: 8px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.board ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: #15151b; font-weight: 700;
}
.board li span:last-child { color: var(--muted); font-weight: 600; white-space: nowrap; }
.board li.me { outline: 2px solid var(--accent); }
.board .empty { color: var(--muted); text-align: center; margin: 8px 0; }
.mine-item {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 14px; border-radius: 12px;
  background: #15151b; text-align: left; font-weight: 600;
}

.upload {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.social { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: min(100%, 340px); }
.social:empty { display: none; }
.social a {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--alt);
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.link.danger { color: var(--danger); }
.link:disabled { text-decoration: none; opacity: .7; }

.publish {
  display: flex; gap: 12px; align-items: flex-start;
  width: min(100%, 340px);
  padding: 12px 14px; border-radius: 14px;
  background: #15151b; text-align: left; cursor: pointer;
}
.publish input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.publish span { display: flex; flex-direction: column; gap: 4px; }
.publish small { color: var(--muted); font-size: 12px; line-height: 1.35; }

.feed-screen { justify-content: flex-start; }
.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: #15151b; }
.tabs button { padding: 8px 18px; border-radius: 999px; background: none; color: var(--muted); font-weight: 800; }
.tabs button.active { background: var(--accent); color: var(--accent-ink); }
.feed-list { width: min(100%, 420px); display: flex; flex-direction: column; gap: 10px; }
.feed-list .empty { color: var(--muted); }
.card { display: flex; gap: 12px; padding: 10px; border-radius: 16px; background: #15151b; text-align: left; }
.card .poster {
  width: 84px; aspect-ratio: 9 / 16; border-radius: 10px; object-fit: cover;
  background: #000; flex: none; cursor: pointer;
}
.card .poster-ph { display: flex; align-items: center; justify-content: center; font-size: 40px; }
.card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.card-body strong { font-size: 18px; }
.card-body span { color: var(--muted); font-size: 14px; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.card-actions .try {
  padding: 8px 18px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 900;
}
.card-actions .link { font-size: 13px; padding: 4px; }

.board li .watch {
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; white-space: nowrap;
}
#sendReactionBtn:disabled { opacity: .85; }

.player {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, .92);
}
.player video { height: min(78dvh, 720px); max-width: 100%; aspect-ratio: 9 / 16; border-radius: 16px; background: #000; }

.offscreen { position: fixed; left: -10px; top: -10px; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
