:root {
  --bg1: #1e1b4b; --bg2: #4c1d95; --bg3: #db2777;
  --panel: rgba(15, 23, 42, 0.82);
  --accent: #facc15; --accent2: #22d3ee;
  --text: #f8fafc; --muted: #cbd5e1;
  --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 { margin: 0; height: 100%; overflow: hidden; background: var(--bg1); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-user-select: none; user-select: none; }
body { background: radial-gradient(120% 80% at 50% 0%, var(--bg3) 0%, var(--bg2) 40%, var(--bg1) 100%); overscroll-behavior: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* HUD */
.hud { position: fixed; top: var(--safe-top); left: 0; right: 0; display: flex; justify-content: center; align-items: center; padding: 8px 12px; pointer-events: none; z-index: 5; }
.hud .score { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 999px; padding: 6px 14px; backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(0,0,0,0.35); }
.hud .score b { font-size: 26px; min-width: 28px; text-align: center; }
.hud .clock { display: flex; flex-direction: column; align-items: center; line-height: 1; padding: 0 6px; }
.hud .clock em { font-style: normal; font-size: 10px; color: var(--accent); letter-spacing: 1px; }
.hud .clock i { font-style: normal; font-size: 16px; font-variant-numeric: tabular-nums; }
.pausebtn { position: absolute; right: 12px; top: 8px; pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--panel); color: #fff; font-weight: 800; font-size: 14px; letter-spacing: -2px; }

.banner { position: fixed; top: 20%; left: 50%; transform: translate(-50%, -50%) scale(1); z-index: 6; pointer-events: none;
  font-size: clamp(30px, 9vw, 64px); font-weight: 900; letter-spacing: 2px; text-align: center; padding: 8px 24px; border-radius: 16px;
  color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 0 30px rgba(0,0,0,0.4); animation: pop 0.35s cubic-bezier(.2,1.6,.4,1); }
.banner.goal { color: var(--accent); }
.banner.bad { color: #fb7185; }
.banner.warn { color: #fdba74; font-size: clamp(24px, 7vw, 48px); }
.banner.info { color: var(--accent2); font-size: clamp(20px, 6vw, 40px); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* Menus */
.ui { position: fixed; inset: 0; z-index: 10; overflow-y: auto; background: rgba(10, 10, 30, 0.55); backdrop-filter: blur(6px);
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); }
.screen { max-width: 480px; margin: 0 auto; background: var(--panel); border-radius: 22px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.45); }
.screen.center { text-align: center; }
.logo { display: flex; flex-direction: column; font-size: clamp(42px, 13vw, 72px); font-weight: 900; line-height: 0.9; letter-spacing: -1px; margin: 12px 0 8px; }
.logo .accent { color: var(--accent); }
.tagline { color: var(--muted); margin: 0 0 22px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1; }
.btn { border: none; border-radius: 14px; padding: 14px 18px; font-size: 17px; font-weight: 700; color: #fff; background: rgba(255,255,255,0.12); cursor: pointer; transition: transform .08s; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, #f59e0b, #f43f5e); box-shadow: 0 8px 20px rgba(244,63,94,0.35); }
.btn.big { width: 100%; font-size: 20px; padding: 16px; margin-top: 12px; }
.btn.small { padding: 8px 12px; font-size: 14px; }
h2 { margin: 6px 0 12px; font-size: 26px; }
h3 { margin: 18px 0 8px; font-size: 16px; color: var(--accent2); text-transform: uppercase; letter-spacing: 1px; }
h4 { margin: 0 0 6px; color: var(--accent); }
.muted { color: var(--muted); font-size: 14px; }
.help { padding-left: 18px; line-height: 1.45; color: #e2e8f0; }
.help li { margin-bottom: 10px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; letter-spacing: 1px; }
.badge i { width: 18px; height: 18px; border-radius: 50%; background: var(--p); box-shadow: inset 0 0 0 4px var(--s); display: inline-block; }
.badge.big { flex-direction: column; font-size: 14px; }
.badge.big i { width: 56px; height: 56px; box-shadow: inset 0 0 0 10px var(--s), 0 6px 18px rgba(0,0,0,0.4); }

.hubhead { display: flex; align-items: center; gap: 14px; }
.hubhead h2 { margin: 0; font-size: 20px; }
.hubhead .btn { margin-left: auto; }
.tabs { display: flex; gap: 6px; margin: 16px 0; background: rgba(255,255,255,0.08); border-radius: 12px; padding: 4px; }
.tab { flex: 1; border: none; background: transparent; color: var(--muted); padding: 10px; border-radius: 9px; font-weight: 700; }
.tab.on { background: rgba(255,255,255,0.16); color: #fff; }

.matchup { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0; }
.matchup .side { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; text-align: center; }
.matchup .side small { color: var(--muted); }
.matchup .vs { font-weight: 900; color: var(--accent); font-size: 20px; }

.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 7px 3px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); }
.table .name { text-align: left; white-space: nowrap; }
.table .name .badge { vertical-align: middle; margin-right: 2px; }
.table .name .badge i { width: 14px; height: 14px; box-shadow: inset 0 0 0 3px var(--s); }
.table tr.me { background: rgba(250,204,21,0.15); }
.results { list-style: none; padding: 0; margin: 0; }
.results li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.results li small { margin-left: auto; color: var(--muted); }

.bracket { display: flex; flex-direction: column; gap: 14px; }
.tie { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.06); margin-bottom: 6px; }
.tie span:last-child { text-align: right; justify-content: flex-end; }
.tie span { display: inline-flex; }
.tie .w { color: var(--accent); }
.tie.me { outline: 2px solid rgba(250,204,21,0.5); }

.slider { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.slider span { display: flex; justify-content: space-between; font-weight: 700; }
.slider small { color: var(--muted); font-weight: 400; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.result-title { font-size: 40px; margin: 4px 0; }
.scoreline { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 48px; margin: 12px 0; }
.stats { margin: 10px auto; font-size: 15px; }
.stats th { color: var(--muted); font-weight: 400; padding: 4px 14px; }
.stats td { font-weight: 800; padding: 4px 14px; }
.summary p { font-size: 16px; }

/* Training */
.levels { display: flex; flex-direction: column; gap: 8px; }
.level { display: flex; align-items: center; gap: 12px; text-align: left; border: none; border-radius: 14px; padding: 10px 12px; background: rgba(255,255,255,0.08); color: #fff; cursor: pointer; }
.level .num { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: rgba(255,255,255,0.14); flex: none; }
.level.done .num { background: #22c55e; color: #052e16; }
.level.locked { opacity: 0.45; }
.level .txt { display: flex; flex-direction: column; }
.level .txt small { color: var(--muted); }
.hint { font-size: 17px; line-height: 1.45; margin: 8px 0 14px; }
.hud .obj { font-size: 11px; letter-spacing: 2px; color: var(--muted); }


/* Formation picker on the coach's board */
.formations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 6px; }
.fcard { border: none; background: rgba(255,255,255,0.08); border-radius: 12px; padding: 8px 6px 6px; color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; outline: 2px solid transparent; }
.fcard.on { background: rgba(250,204,21,0.16); outline-color: var(--accent); }
.fcard b { font-size: 11px; font-weight: 700; letter-spacing: 0.2px; text-align: center; line-height: 1.2; }
.fdia { position: relative; display: block; width: 100%; aspect-ratio: 30 / 27; border-radius: 7px;
  background: linear-gradient(180deg, rgba(74,222,128,0.13), rgba(74,222,128,0.05));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16); }
.fdia .fp { position: absolute; width: 15%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); }
.fdia .fp.g { background: #fcd34d; }
.fdia .fp.d { background: #93c5fd; }
.fdia .fp.f { background: #fb7185; }
.fblurb { margin: 0 0 6px; min-height: 2.4em; }
.slider .ends { display: flex; justify-content: space-between; margin-top: -2px; }
