/* ---------- Pan-African Nations Cup: game UI ---------- */
:root {
  --night: #0a1420;
  --night-2: #0f1d2d;
  --panel: rgba(13, 24, 37, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #f4f1ea;
  --muted: #9fb0bf;
  --gold: #e3a922;
  --gold-2: #ffcf5a;
  --green: #1e9a55;
  --red: #d2452f;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Arial Black", "Arial Bold", "Helvetica Neue", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font: 15px/1.45 var(--font); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- flags ---------- */
.flag { display: inline-block; width: 30px; height: 20px; border-radius: 3px; overflow: hidden; flex: none; vertical-align: middle;
  background: linear-gradient(135deg, var(--a, #555) 0 55%, var(--b, #999) 55%); box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
.flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flag.xs { width: 22px; height: 15px; border-radius: 2px; }
.flag.sm { width: 26px; height: 18px; }
.flag.lg { width: 64px; height: 43px; border-radius: 5px; }

/* ---------- screens & panels ---------- */
#screens { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  background: linear-gradient(180deg, rgba(10,20,32,.55), rgba(10,20,32,.92) 70%); }
#screens[hidden] { display: none; }
.screen { min-height: 100%; padding: 20px 16px calc(28px + var(--safe-b)); max-width: 1080px; margin: 0 auto; }
.screen.center { display: flex; align-items: center; justify-content: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; max-width: 460px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; color: var(--gold); font-weight: 700; margin: 0 0 6px; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; }

.loader { text-align: center; color: var(--muted); }
.loader span { display: inline-block; width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- title ---------- */
.screen.title { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 120%, rgba(30,154,85,.25), transparent 60%); }
.title-wrap { width: 100%; max-width: 440px; text-align: center; }
.kente { height: 10px; border-radius: 3px; margin: 0 auto 22px; width: 160px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 14px, var(--green) 14px 22px, var(--red) 22px 30px, #111 30px 34px); }
.game-title { font-family: var(--display); font-weight: 900; font-size: clamp(2rem, 8vw, 3.2rem); line-height: 1; letter-spacing: -.01em; text-transform: uppercase; margin-bottom: 28px;
  background: linear-gradient(180deg, #fff 30%, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 4px 30px rgba(227,169,34,.25); }
.menu { display: flex; flex-direction: column; gap: 10px; }
.mrow { display: flex; gap: 10px; }
.mbtn { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 15px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 1.05rem; transition: transform .1s, border-color .15s; }
.mbtn span { display: flex; flex-direction: column; }
.mbtn small { font-weight: 500; font-size: .8rem; color: var(--muted); }
.mbtn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1c1405; border-color: transparent; }
.mbtn.primary small { color: #4d3a0e; }
.mbtn:hover { border-color: var(--gold); }
.mbtn:active { transform: scale(.98); }
.mbtn.small { justify-content: center; font-size: .92rem; padding: 12px; }
.source { margin-top: 20px; font-size: .78rem; color: var(--muted); }

/* ---------- bars / tabs ---------- */
.bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 8px 0 12px; background: linear-gradient(var(--night) 70%, transparent); }
.bar h2 { margin: 0; font-size: 1.25rem; }
.back, .iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 1.5rem; line-height: 1; display: grid; place-items: center; flex: none; }
.hub-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hub-title small { color: var(--gold); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-title span { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; position: sticky; top: 60px; z-index: 2; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 9px; font-weight: 700; font-size: .88rem; color: var(--muted); }
.tabs button.on { background: var(--gold); color: #1c1405; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 10px; border: 1px solid var(--gold); background: var(--gold); color: #1c1405; font-weight: 800; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--gold); }
.btn.danger { color: #ff9f8c; border-color: rgba(210,69,47,.6); background: transparent; }
.btn.big { padding: 15px 30px; font-size: 1.08rem; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.actions.col { flex-direction: column; }
.actions.col .btn { width: 100%; }
.seg { display: inline-flex; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--night); }

/* ---------- team picker ---------- */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; padding-bottom: 80px; }
.pgroup { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.pgroup h3 { font-size: .78rem; color: var(--gold); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 6px; }
.pteam { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 8px; border: 0; border-radius: 8px; background: none; text-align: left; }
.pteam:hover { background: rgba(255,255,255,.07); }
.pteam:active { background: rgba(227,169,34,.2); }
.pteam.taken { opacity: .35; }
.pname { flex: 1; font-weight: 700; }
.prating { font-weight: 800; font-size: .85rem; background: rgba(255,255,255,.08); border-radius: 6px; padding: 2px 7px; font-variant-numeric: tabular-nums; }
.pfoot { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--night) 35%); }
.picked { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }

/* ---------- hub ---------- */
.nextcard { background: radial-gradient(ellipse at 50% 0, rgba(30,154,85,.35), transparent 70%), var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 18px; text-align: center; margin-bottom: 16px; }
.nextcard h2 { font-size: 1.4rem; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 14px 0 6px; }
.vs .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vs .side b { font-size: 1.1rem; }
.vs .side small { color: var(--muted); }
.vs .v { font-family: var(--display); font-size: 1.4rem; color: var(--gold); }
.champline { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 0; }
.champline h2 { margin: 0; font-size: 1.6rem; }
.cols { display: grid; gap: 14px; margin-bottom: 16px; }
.fx { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.fx h3 { font-size: .78rem; color: var(--gold); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 4px; }
.fxg { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 8px 0 0; text-align: center; }
.mrow-item { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.mrow-item:last-child { border-bottom: 0; }
.mrow-item.mine { background: rgba(227,169,34,.12); border-radius: 8px; }
.mrow-item .tm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mrow-item .home { justify-content: flex-end; text-align: right; }
.mrow-item .tm.win { font-weight: 800; }
.mrow-item .sc { font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; min-width: 56px; display: flex; flex-direction: column; line-height: 1.1; }
.mrow-item .sc small { font-weight: 500; font-size: .68rem; color: var(--muted); }

.gtables { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.gtable { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.gtable h3 { font-size: .78rem; color: var(--gold); text-transform: uppercase; letter-spacing: .12em; }
.gtable h3 small { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
.gtable table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.gtable th { font-size: .7rem; color: var(--muted); font-weight: 600; padding: 4px; text-align: center; }
.gtable td { padding: 6px 4px; text-align: center; border-top: 1px solid var(--line); }
.gtable .l { text-align: left; white-space: nowrap; }
.gtable tr.q td:first-child { box-shadow: inset 3px 0 var(--green); }
.gtable tr.q3 td:first-child { box-shadow: inset 3px 0 var(--gold); }
.gtable tr.me { background: rgba(227,169,34,.13); }
.thirds { margin-bottom: 10px; max-width: 620px; }
.legend { font-size: .78rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.legend span { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.legend .q { background: var(--green); } .legend .q3 { background: var(--gold); margin-left: 10px; }

.bracket { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; touch-action: pan-x pan-y; }
.bcol { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.bcol h3 { font-size: .72rem; color: var(--gold); text-transform: uppercase; letter-spacing: .1em; text-align: center; }
.bcol.finals { justify-content: center; gap: 24px; }
.bmatch { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.bmatch.tbd { padding: 14px; text-align: center; color: var(--muted); font-size: .85rem; }
.bteam { display: flex; align-items: center; gap: 7px; padding: 6px 8px; font-size: .85rem; color: var(--muted); }
.bteam + .bteam { border-top: 1px solid var(--line); }
.bteam span:not(.flag) { flex: 1; font-weight: 700; }
.bteam b { font-variant-numeric: tabular-nums; }
.bteam sup { font-size: .65rem; color: var(--muted); margin-left: 2px; }
.bteam.win { color: var(--ink); }
.bteam.me { background: rgba(227,169,34,.15); }
.empty { text-align: center; padding: 40px 10px; }
@media (max-width: 640px) { .bracket { grid-template-columns: repeat(4, 150px); } }

/* ---------- result / champion ---------- */
.result, .champ { width: 100%; max-width: 560px; text-align: center; }
.result h1 { font-family: var(--display); font-size: 2.6rem; text-transform: uppercase; }
.result h1.win { color: var(--gold-2); } .result h1.loss { color: #ff9f8c; }
.fscore { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 8px 0 14px; }
.fscore div { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fscore > span { font-family: var(--display); font-size: 2.4rem; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: center; }
.fscore small { font-family: var(--font); font-size: .8rem; color: var(--muted); }
.scorers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: .85rem; color: var(--muted); }
.scorers ul { list-style: none; margin: 0; padding: 0; }
.scorers ul:first-child { text-align: right; }
.stats { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; margin-top: 14px; }
.srow { display: grid; grid-template-columns: 60px 1fr 60px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.srow span { color: var(--muted); font-size: .85rem; }
.srow + .srow { border-top: 1px solid var(--line); }
.champ h1 { font-family: var(--display); font-size: clamp(1.6rem, 6vw, 2.4rem); text-transform: uppercase; color: var(--gold-2); }
.trophy { width: 130px; height: 160px; filter: drop-shadow(0 10px 30px rgba(255,207,90,.4)); animation: rise 1.2s ease-out both; }
@keyframes rise { from { transform: translateY(30px) scale(.8); opacity: 0; } }
.final-score { color: var(--muted); }
.podium { display: flex; justify-content: center; gap: 22px; margin-top: 8px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; left: calc(var(--x) * 1%); width: 8px; height: 14px; background: var(--c); border-radius: 2px; animation: fall 3.5s linear var(--d) infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- modal ---------- */
#modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(4,9,15,.65); backdrop-filter: blur(3px); touch-action: pan-y; }
#modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 440px; max-height: calc(100% - 20px); overflow-y: auto; background: var(--night-2); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.5); text-align: center; }
.modal-card h2 { font-size: 1.35rem; }
.field { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 14px 0; }
.field > span { font-weight: 700; font-size: .9rem; }
.help-grid { display: grid; grid-template-columns: 1fr; gap: 6px; text-align: left; }
.help-grid h3 { font-size: .8rem; color: var(--gold); text-transform: uppercase; letter-spacing: .1em; margin: 6px 0 4px; }
.help-grid ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.help-grid li { margin: 3px 0; }
.ht-score { font-family: var(--display); font-size: 1.8rem; }
.pens { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.prow { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05); border-radius: 10px; padding: 8px 12px; }
.prow > b:last-child { margin-left: auto; font-size: 1.2rem; }
.pdots { display: flex; gap: 5px; margin-left: 8px; }
.pdots i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); }
.pdots i.g { background: var(--green); border-color: var(--green); }
.pdots i.m { background: var(--red); border-color: var(--red); }
.pmsg { min-height: 1.4em; font-weight: 800; color: var(--gold-2); }
.ptask { color: var(--muted); margin: 4px 0 8px; }
.pgoal { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border: 3px solid #fff; border-bottom: 0; padding: 10px 8px 14px; border-radius: 4px 4px 0 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 1px, transparent 1px 12px), repeating-linear-gradient(0deg, rgba(255,255,255,.07) 0 1px, transparent 1px 12px); }
.pgoal .btn { padding: 18px 6px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud[hidden] { display: none; }
#hud button, #touch { pointer-events: auto; }
.scorebug { position: absolute; top: max(10px, env(safe-area-inset-top)); left: calc(10px + var(--safe-l)); display: flex; flex-direction: column; gap: 3px; }
.scorebug .stage { font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); font-weight: 800; text-shadow: 0 1px 3px #000; }
.sb-main { display: flex; align-items: center; gap: 7px; background: rgba(8,14,22,.85); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-weight: 800; font-size: .95rem; }
.sb-main .sc { background: var(--ink); color: var(--night); border-radius: 5px; padding: 1px 8px; font-variant-numeric: tabular-nums; font-family: var(--display); }
.sb-main .dash { margin: 0 4px; opacity: .6; }
.sb-main .clock { margin-left: 6px; color: var(--gold-2); font-variant-numeric: tabular-nums; }
#radar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 168px; height: 108px; border-radius: 6px; opacity: .92; }
.pausebtn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: calc(10px + var(--safe-r)); width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: rgba(8,14,22,.8); display: flex; align-items: center; justify-content: center; gap: 5px; }
.pausebtn span { width: 5px; height: 16px; background: var(--ink); border-radius: 2px; }
.pinfo { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: calc(10px + var(--safe-r)); text-align: right; font-size: .8rem; font-weight: 700; text-shadow: 0 1px 3px #000; }
.stam { width: 110px; height: 5px; background: rgba(0,0,0,.5); border-radius: 3px; margin-top: 4px; margin-left: auto; overflow: hidden; }
.stam i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); background-size: 110px 100%; transition: width .2s; }
#banner { position: absolute; left: 50%; top: 26%; transform: translate(-50%, -10px); font-family: var(--display); font-size: clamp(1.2rem, 4.5vw, 2.4rem); text-transform: uppercase; text-align: center; white-space: nowrap; color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.4), 0 0 30px rgba(0,0,0,.6); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; max-width: 94vw; overflow: hidden; text-overflow: ellipsis; }
#banner.show { opacity: 1; transform: translate(-50%, 0); }
#banner.good { color: var(--gold-2); } #banner.bad { color: #ffb4a6; }
.keys { position: absolute; bottom: calc(10px + var(--safe-b)); left: 50%; transform: translateX(-50%); font-size: .75rem; color: rgba(255,255,255,.75); background: rgba(8,14,22,.6); padding: 5px 10px; border-radius: 8px; white-space: nowrap; }
.keys kbd { font: inherit; font-weight: 800; background: rgba(255,255,255,.12); padding: 0 5px; border-radius: 4px; }
body.touch .keys { display: none; }

/* touch controls */
#touch { display: none; }
body.touch #touch { display: block; }
#joyZone { position: absolute; left: 0; bottom: 0; width: 50%; height: 62%; touch-action: none; }
#joyBase { position: absolute; left: calc(90px + var(--safe-l)); top: calc(100% - 100px - var(--safe-b)); width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); opacity: .55; transition: opacity .15s; }
#joyBase.on { opacity: 1; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.75); transform: translate(-50%,-50%); box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.tbtns { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); width: 210px; height: 190px; }
.tb { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); font-weight: 900; font-size: .74rem; letter-spacing: .04em; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); touch-action: none; display: grid; place-items: center; }
.tb.down { transform: scale(.92); filter: brightness(1.25); }
.tb.b { width: 88px; height: 88px; right: 0; bottom: 34px; background: rgba(210,69,47,.75); }
.tb.a { width: 74px; height: 74px; right: 98px; bottom: 0; background: rgba(30,154,85,.78); }
.tb.sprint { width: 64px; height: 64px; right: 112px; bottom: 98px; background: rgba(227,169,34,.7); color: #1c1405; text-shadow: none; }
@media (max-height: 430px) {
  #radar { width: 126px; height: 81px; }
  .tbtns { transform: scale(.85); transform-origin: bottom right; }
  #joyBase { transform: scale(.85); }
}
@media (max-width: 560px) and (orientation: portrait) {
  #radar { top: auto; bottom: calc(220px + var(--safe-b)); width: 120px; height: 77px; opacity: .8; }
  .pinfo { top: calc(max(10px, env(safe-area-inset-top)) + 54px); }
}

#toast { position: absolute; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--night); padding: 10px 16px; border-radius: 10px; font-weight: 700; opacity: 0; transition: .25s; pointer-events: none; z-index: 30; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* display font always heavy, even where Arial Black isn't installed */
.game-title, .result h1, .fscore > span, .champ h1, .ht-score, #banner, .vs .v, .sb-main .sc { font-weight: 900; }
.pinfo:empty, .pinfo.hide { display: none; }
