:root {
  --bg: #0b0c10;
  --sheet: #16171d;
  --cell: #1e1f26;
  --text: #f5f6fa;
  --muted: #8b90a0;
  --line: rgba(255, 255, 255, 0.08);
  --amber: #f5a623;
  --sky: #4ecdc4;
  --pink: #ff6b9d;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }

/* Экраны: только .is-open виден (не полагаемся на HTML hidden) */
.screen { display: none; }
.screen.is-open { display: block; }
.screen-game.is-open {
  display: flex !important;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; border: none; cursor: pointer; color: inherit; background: none; padding: 0; }

.screen {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  min-height: 100vh;
}

/* HUD */
.hud { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hud-left { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 18px; font-weight: 800; color: #1a1200;
  background: linear-gradient(160deg, #ffd56a, var(--amber));
  box-shadow: 0 4px 14px rgba(245,166,35,.35);
}
.logo-title { font-weight: 800; font-size: 16px; letter-spacing: -.02em; }
.logo-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: #2c2d35; border: 1.5px solid var(--line);
}

.dev-banner {
  margin: 8px 0; padding: 8px 12px; border-radius: 10px;
  background: rgba(245,166,35,.12); color: var(--amber);
  font-size: 12px; font-weight: 600; text-align: center;
}

.hello {
  margin: 12px 0 16px;
  font-size: 15px; font-weight: 500; color: var(--muted);
}

/* Game pick cards */
.game-pick { display: flex; flex-direction: column; gap: 12px; }
.pick-card {
  text-align: left;
  border-radius: 20px;
  padding: 18px 16px;
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
  transition: transform .12s ease;
}
.pick-card:active { transform: scale(.98); }
.pick-flappy {
  background: linear-gradient(145deg, #1a3a4a 0%, #0f1a22 100%);
}
.pick-doodle {
  background: linear-gradient(145deg, #3a1a40 0%, #1a0f20 100%);
}
.pick-emoji {
  grid-row: 1 / span 3;
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; font-size: 28px;
  background: rgba(255,255,255,.08); align-self: center;
}
.pick-title {
  font-size: 18px; font-weight: 800; letter-spacing: -.02em;
}
.pick-desc {
  font-size: 12px; color: rgba(255,255,255,.55); line-height: 1.35; margin-top: 2px;
}
.pick-best {
  font-size: 12px; font-weight: 700; color: var(--amber); margin-top: 6px;
}

.row-actions { margin: 14px 0 8px; }
.btn-soft {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 14px;
  background: var(--sheet);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-soft:active { opacity: .85; }

.section { margin-top: 20px; }
.section-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-bar h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.seg {
  display: flex; padding: 2px; border-radius: 9px;
  background: rgba(120,120,128,.2); gap: 2px;
}
.seg-btn {
  min-width: 40px; height: 28px; padding: 0 10px;
  border-radius: 7px; font-size: 14px; font-weight: 700; color: var(--muted);
}
.seg-btn.active {
  color: var(--text); background: rgba(120,120,128,.36);
}

.sheet {
  background: var(--sheet);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-row {
  display: grid;
  grid-template-columns: 28px 36px 1fr auto;
  gap: 10px; align-items: center;
  padding: 11px 14px; min-height: 52px;
}
.rank-row + .rank-row { border-top: .5px solid var(--line); }
.rank-num { font-size: 13px; font-weight: 800; color: var(--muted); text-align: center; }
.rank-row:nth-child(1) .rank-num { color: var(--amber); }
.rank-av {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: #3a3a3c;
}
.rank-row:nth-child(1) .rank-av {
  background: linear-gradient(135deg, #ffd56a, var(--amber)); color: #1a1200;
}
.rank-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-size: 14px; font-weight: 800; color: var(--amber); }
.rank-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* GAME SCREEN */
.screen-game {
  padding: calc(8px + var(--safe-t)) 0 calc(8px + var(--safe-b));
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
  background: radial-gradient(ellipse at 50% 0%, #1a1440 0%, #07090f 55%);
}
.game-top {
  display: grid;
  grid-template-columns: 44px 1fr 64px;
  align-items: center;
  padding: 0 10px 8px;
  gap: 8px;
  flex-shrink: 0;
}
.btn-back {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.08);
  font-size: 24px; font-weight: 400; line-height: 1;
}
.game-title { text-align: center; font-weight: 800; font-size: 15px; }
.game-score {
  text-align: right; font-weight: 800; font-size: 20px; color: var(--amber);
  font-variant-numeric: tabular-nums;
}
#game {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  flex: 1 1 auto;
  min-height: 240px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: #5ec8ff;
  border-radius: 18px;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 16px 40px rgba(0,0,0,0.45);
}
.screen-game .game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 8px;
  touch-action: none;
}
.tap-hint {
  text-align: center;
  color: rgba(255,255,255,.45);
  font-size: 12px;
  font-weight: 600;
  margin: 8px 0 0;
  flex-shrink: 0;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: rgba(0,0,0,.55);
  padding: 20px;
}
.game-overlay.is-open {
  display: grid;
}
.overlay-card {
  width: min(320px, 100%);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px 20px 18px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.overlay-emoji { font-size: 40px; margin-bottom: 6px; }
.overlay-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.overlay-score {
  margin: 10px 0 4px;
  font-size: 40px; font-weight: 800; color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.overlay-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; min-height: 1.2em; }
.main-btn {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  font-size: 16px; font-weight: 800;
  color: #1a1200;
  background: linear-gradient(180deg, #ffd56a, var(--amber));
  box-shadow: 0 8px 22px rgba(245,166,35,.35);
  margin-bottom: 8px;
}
.main-btn:active { transform: scale(.98); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  z-index: 60; max-width: min(340px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 700; text-align: center;
  background: rgba(28,28,30,.94); border: 1px solid var(--line);
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
  display: none;
}
.toast.show {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
