:root {
  --bg: #07261d;
  --bg-2: #0b3d2e;
  --card: #10493a;
  --card-2: #15584a;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f7f4;
  --muted: #a9c7bb;
  --accent: #f5c542;
  --accent-ink: #1d1a05;
  --ok: #3ccf7a;
  --bad: #ff6b6b;
  --radius: 14px;
  --SA: #2f7de1; --PL: #8b3fd9; --LL: #e8613c; --BL: #d8343f; --L1: #1fb5a8; --X: #6b7f78;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2), var(--bg)) fixed;
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  background: linear-gradient(var(--bg-2) 70%, transparent);
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: .3px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .ball { display: inline-block; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 10px; height: 38px; min-width: 38px; }
.lang-select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; height: 38px; padding: 0 8px; max-width: 120px; }

.screen { display: none; }
.screen.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.tagline { color: var(--muted); margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 16px 0 8px; }
.section-title { margin: 22px 0 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.pool { margin: 14px 0 0; font-weight: 600; color: var(--accent); }
.pool.empty { color: var(--bad); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.segmented button.on { background: var(--accent); color: var(--accent-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 12px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--lg, var(--X)); }
.chip.on { border-color: var(--lg); background: color-mix(in srgb, var(--lg) 28%, var(--bg)); }
.chip:disabled { opacity: .35; cursor: default; }

.modes { display: grid; gap: 10px; }
.mode-card {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  transition: transform .1s ease, background .15s;
}
.mode-card:active { transform: scale(.98); }
.mode-card:hover { background: var(--card-2); }
.mode-icon { font-size: 28px; }
.mode-text { display: flex; flex-direction: column; }
.mode-text small { color: var(--muted); }
.badge { position: absolute; right: 14px; top: 14px; background: var(--ok); color: #062; border-radius: 999px; width: 24px; height: 24px; display: grid; place-items: center; font-weight: 800; }

/* GAME */
.hud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 14px; font-weight: 600; }
.pill.warn { color: var(--bad); border-color: var(--bad); }

.career { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: step; }
.career li {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--lg, var(--X));
  border-radius: 12px; padding: 10px 12px; min-height: 48px;
}
.career li.hidden { border-left-color: var(--line); color: var(--muted); background: repeating-linear-gradient(45deg, var(--card), var(--card) 10px, var(--bg-2) 10px, var(--bg-2) 20px); }
.career li.new { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.94); opacity: .2; } }
.yr { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.club { font-weight: 700; }
.lg { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--lg) 35%, transparent); white-space: nowrap; }

.info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.info div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.info small { display: block; color: var(--muted); font-size: 12px; }
.info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info .locked b { color: var(--muted); }

.wrongs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.wrongs span { background: color-mix(in srgb, var(--bad) 22%, transparent); border: 1px solid var(--bad); border-radius: 999px; padding: 3px 10px; font-size: 13px; text-decoration: line-through; }

#play { margin-top: 16px; }

.guess-box { position: relative; }
.guess-row { display: flex; gap: 8px; }
#guessInput { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; }
#guessInput:focus { border-color: var(--accent); }
.suggest { list-style: none; margin: 6px 0 0; padding: 0; background: var(--card-2); border-radius: 12px; overflow: hidden; }
.suggest:empty { display: none; }
.suggest li { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.suggest li:last-child { border-bottom: 0; }
.suggest li.sel, .suggest li:hover { background: var(--card); }
.suggest li.tried { color: var(--muted); text-decoration: line-through; }

.game-actions { display: flex; gap: 8px; margin-top: 12px; }
.game-actions .btn { flex: 1; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 16px; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .4; cursor: default; }

.end-panel { margin-top: 16px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; animation: pop .3s ease; }
.end-panel.win { border-color: var(--ok); }
.end-panel.lose { border-color: var(--bad); }
.end-title { font-size: 24px; font-weight: 800; }
.end-name { margin: 4px 0 2px; font-size: 18px; }
.end-sub { color: var(--muted); }
.end-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.end-actions .btn { flex: 1 1 120px; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet-backdrop[hidden] { display: none; }
.sheet { background: var(--bg-2); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats-grid div { background: var(--card); border-radius: 12px; padding: 12px 8px; text-align: center; }
.stats-grid b { display: block; font-size: 24px; }
.stats-grid small { color: var(--muted); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #fff; color: #111; padding: 10px 16px; border-radius: 12px; font-weight: 600; transition: .2s; max-width: calc(100% - 32px); text-align: center; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .info { grid-template-columns: 1fr 1fr; }
  .career li { grid-template-columns: 44px 1fr; }
  .career li .lg { grid-column: 2; justify-self: start; }
}
