:root {
  --bg: #06293b;
  --bg2: #0a3d57;
  --card: #0e4a69;
  --accent: #ffb703;
  --text: #f1fbff;
  --muted: #8fc1d6;
  --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(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: flex; flex-direction: column; }

/* MENU */
#menu { overflow-y: auto; padding-bottom: calc(24px + var(--safe-b));
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%); }
.hero { position: relative; padding: calc(36px + var(--safe-t)) 22px 56px;
  background: linear-gradient(160deg, #0b6e99, #06293b); }
.hero-sub { text-transform: uppercase; letter-spacing: .18em; font-size: 12px; color: var(--accent); font-weight: 700; }
.hero h1 { margin: 4px 0 0; font-size: 46px; line-height: 1; letter-spacing: -.02em; }
.hero-wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 36px; fill: var(--bg2); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 16px 0; }
.card { position: relative; overflow: hidden; min-height: 132px; border-radius: 18px; padding: 14px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: 0 6px 16px rgba(0,0,0,.28); transition: transform .12s; }
.card:active { transform: scale(.97); }
.card:first-child { grid-column: span 2; min-height: 150px; }
.card::before { content: ""; position: absolute; left: -10%; right: -10%; bottom: 0; height: 55%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255,255,255,.22), transparent 70%); }
.card .emoji { position: absolute; top: 12px; right: 14px; font-size: 30px; opacity: .9; }
.card .live { position: absolute; top: 14px; left: 14px; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.35); padding: 3px 8px; border-radius: 99px; }
.card .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff4d4d; animation: pulse 1.4s infinite; }
.card strong { position: relative; font-size: 18px; line-height: 1.15; }
.card small { position: relative; color: rgba(255,255,255,.8); margin-top: 2px; font-size: 12px; }
@keyframes pulse { 50% { opacity: .3; } }

.game-card { margin: 14px 16px 0; padding: 14px 16px; display: flex; align-items: center; gap: 14px;
  border-radius: 18px; background: rgba(255,255,255,.07); border: 1px dashed rgba(255,255,255,.25); }
.game-card .game-emoji { font-size: 34px; }
.game-card strong { display: block; font-size: 17px; }
.game-card small { color: var(--muted); }
.game-card .chev { margin-left: auto; font-size: 28px; color: var(--accent); }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; opacity: .7; }

/* TOPBAR */
.topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) 10px 22px; background: linear-gradient(180deg, rgba(0,0,0,.65), transparent); }
.topbar.solid { position: static; background: var(--bg); padding-bottom: 8px; }
.topbar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar .title strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { color: var(--muted); font-size: 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; background: rgba(0,0,0,.4); font-size: 24px;
  display: flex; align-items: center; justify-content: center; flex: none; }

/* VIEWER */
#viewer { background: #000; }
.stage { position: relative; flex: 1; min-height: 0; background: #000; display: flex; align-items: center; justify-content: center; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.overlay { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; background: rgba(0,10,18,.72); text-align: center; padding: 24px; transition: opacity .25s; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay p { margin: 0; color: var(--muted); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.overlay.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.retry { background: var(--accent); color: #1b1200; font-weight: 700; padding: 10px 22px; border-radius: 99px; }
.side-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 38px; height: 64px; font-size: 30px;
  background: rgba(0,0,0,.3); opacity: .75; }
.side-btn.left { left: 0; border-radius: 0 14px 14px 0; }
.side-btn.right { right: 0; border-radius: 14px 0 0 14px; }

.switcher { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px calc(10px + var(--safe-b)); background: var(--bg);
  scrollbar-width: none; scroll-snap-type: x proximity; }
.switcher::-webkit-scrollbar { display: none; }
.chip { flex: none; scroll-snap-align: center; padding: 10px 16px; border-radius: 99px; background: var(--card);
  font-size: 14px; font-weight: 600; white-space: nowrap; border: 2px solid transparent; }
.chip.active { background: var(--accent); color: #1b1200; }

/* GAME */
#game { background: var(--bg); }
.game-wrap { flex: 1; min-height: 0; position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

@media (min-width: 700px) {
  .cards { max-width: 640px; margin: 0 auto; }
  .game-card, .foot { max-width: 608px; margin-left: auto; margin-right: auto; }
}
