/* 20K Game Night — Mini App styles.
   Branded dark base with an electric-cyan accent (the game is the star). Telegram
   theme params tint the chrome where sensible; the game screens stay committed to
   the brand look. Animations use transform/opacity ONLY (cheap Android WebViews). */

:root {
  /* brand palette — dark, but high-contrast and bright enough to read at a glance */
  --bg: #10162a;
  --surface: #1c2745;
  --surface-2: #263255;
  --surface-3: #324068;
  --line: #3c4a72;
  --text: #f3f7ff;
  --muted: #b6c1de;
  --cyan: #2ff0e6;
  --cyan-strong: #4df6ff;
  --cyan-dim: #17b6c4;
  --glow: 0 0 0 1px rgba(47, 240, 230, .45), 0 0 26px -6px rgba(47, 240, 230, .6);
  --survived: #48f0b4;
  --eliminated: #ff6f89;
  --warn: #ffcf5e;

  /* Telegram theme params are copied onto these by js/tg.js when present */
  --tg-bg: var(--bg);
  --tg-text: var(--text);

  --radius: 16px;
  --radius-sm: 10px;
  --pad: 16px;
  --tap: 52px; /* min touch target */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

/* ---- reusable bits ---- */
.title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }
.brandmark {
  font-weight: 900; letter-spacing: .12em; font-size: .8rem; text-transform: uppercase;
  color: var(--cyan);
}
.center { align-items: center; text-align: center; justify-content: center; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: .8rem; color: var(--muted);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

/* buttons */
.btn {
  appearance: none; border: 0; width: 100%; min-height: var(--tap);
  border-radius: var(--radius-sm); font: inherit; font-weight: 700;
  color: #04222a; background: var(--cyan); cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
  padding: 12px 16px;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--cyan); }
.btn.danger { background: var(--eliminated); color: #2a0710; }

.linkish { color: var(--cyan); background: none; border: 0; font: inherit; cursor: pointer; padding: 8px; }

/* ---- countdown ring / bar ---- */
.timer {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem;
}
.timer .secs { color: var(--cyan); }
.timer.low .secs { color: var(--warn); }
.timer.closing .secs { color: var(--eliminated); }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--cyan);
  transform-origin: left center; transition: transform .25s linear; }
.bar.low > i { background: var(--warn); }
.bar.closing > i { background: var(--eliminated); }

/* ---- options ---- */
.options { display: grid; gap: 10px; margin-top: 8px; }
.option {
  display: flex; align-items: center; gap: 14px; text-align: left;
  min-height: var(--tap); width: 100%;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font: inherit; font-weight: 600;
  padding: 12px 14px; cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.option:active { transform: scale(.99); }
.option .key {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 800;
  background: var(--surface-3); color: var(--cyan);
}
.option.chosen { border-color: var(--cyan); box-shadow: var(--glow); background: var(--surface-2); }
.option[disabled] { opacity: .6; cursor: default; }
.option .content { flex: 1; }
/* spectator: same look, read-only (a div, not a button — nothing to tap) */
.option.spec { cursor: default; }
.option.spec:active { transform: none; }

/* spectator "watching live" pill */
.pill.watching { color: var(--cyan); border-color: var(--cyan-dim); }

/* ---- big status screens (survived / eliminated / winner) ---- */
.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.hero .glyph { font-size: 3.4rem; line-height: 1; }
.hero.survived .headline { color: var(--survived); }
.hero.eliminated .headline { color: var(--eliminated); }
.hero.winner .headline { color: var(--cyan); }
.headline { font-size: 2rem; font-weight: 900; letter-spacing: -.02em; margin: 0; }

/* ---- receipt ---- */
.receipt {
  background: var(--surface); border: 1px dashed var(--cyan-dim);
  border-radius: var(--radius-sm); padding: 14px; font-size: .85rem;
}
.receipt .row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.receipt .row b { color: var(--muted); font-weight: 600; }
.receipt .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* ---- banner (transient states) ---- */
.banner {
  margin: 0; padding: 10px 16px; text-align: center; font-weight: 700; font-size: .9rem;
  background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--line);
}
.banner.warn { background: #3a2f12; color: var(--warn); }
.banner.info { background: #10303a; color: var(--cyan); }
.banner.bad { background: #3a141f; color: var(--eliminated); }

/* ---- status bar ---- */
.statusbar {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 8px; color: var(--muted); font-size: .75rem;
  border-top: 1px solid var(--line);
}
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--survived); }
.net-dot.stale { background: var(--warn); }
.net-dot.down { background: var(--eliminated); }

/* ---- rules / gating overlay ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(6, 9, 18, .82);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
  padding: 0; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
/* `display: flex` above beats the browser's built-in [hidden] -> display:none,
   which left this dark blurred layer covering EVERY screen (the "too dim /
   can't see" bug). Hidden must always win. */
.overlay[hidden] { display: none !important; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; border: 1px solid var(--line);
  max-height: 88vh; overflow: auto; padding: 22px var(--pad) calc(22px + var(--safe-bottom));
}
.sheet h2 { margin: 0 0 4px; font-size: 1.3rem; }
.sheet .disclaimer {
  margin-top: 16px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: .82rem;
}

/* ---- spinner (transform-only) ---- */
.spinner { width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--cyan);
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* NOTE: no screen-enter fade — a per-frame opacity animation replaying on each
   render read as a dim flicker. Screens simply appear at full brightness. */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
