/* Goalburst — summery, cheerful chrome over the 3D canvas */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(#7fd0f4 0%, #bfe9ff 45%, #ffe9b8 100%);
  color: #133; user-select: none; -webkit-user-select: none; touch-action: none;
  position: fixed; inset: 0;
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ------------ screens ------------ */
.scr {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 18px;
  padding-top: calc(18px + env(safe-area-inset-top));
  background: radial-gradient(ellipse at 50% -10%, rgba(255,244,200,.92), rgba(150,214,246,.94) 55%, rgba(94,180,228,.96));
  backdrop-filter: blur(3px); overflow-y: auto; touch-action: pan-y;
}
.backlink { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 14px; color: #08536f; text-decoration: none; font-weight: 700; font-size: 14px; }
.game-title {
  font-size: clamp(44px, 11vw, 96px); font-weight: 900; letter-spacing: .02em; line-height: 1;
  color: #ff8a00;
  text-shadow: 0 3px 0 #e05e00, 0 8px 24px rgba(224,94,0,.35);
}
.game-title .burst {
  background: linear-gradient(180deg, #ffd400, #ff5d2e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 3px 0 rgba(190,60,0,.55));
}
.game-sub { font-size: clamp(14px, 3vw, 20px); font-weight: 700; color: #0a5f80; margin-bottom: 6px; text-align: center; }
.scr-h { font-size: clamp(22px, 5vw, 34px); font-weight: 900; color: #085a7a; margin: 4px 0; text-align: center; }

.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 800;
  padding: 12px 26px; border-radius: 999px; font-size: 17px;
  background: #ffffffd9; color: #0a5f80; box-shadow: 0 3px 0 rgba(8,80,110,.25), 0 6px 18px rgba(8,80,110,.15);
  transition: transform .08s;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: linear-gradient(180deg, #ffd23e, #ff9425); color: #5c2c00; box-shadow: 0 3px 0 #d96a00, 0 8px 22px rgba(217,106,0,.35); }
.btn.primary.big { font-size: 20px; padding: 15px 34px; }
.btn.small { font-size: 13px; padding: 8px 16px; }
.btn.on { outline: 3px solid #ff9425; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.ctl-lbl { font-size: 13px; font-weight: 800; color: #0a5f80; }
a.btn { text-decoration: none; display: inline-block; }
#career-strip { font-size: 13px; font-weight: 700; color: #08536f; background: #ffffffb0; border-radius: 12px; padding: 8px 14px; }

/* ------------ nation select ------------ */
.pick-tools { width: min(860px, 96vw); display: flex; flex-direction: column; gap: 8px; }
#nation-search {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 16px; border-radius: 999px;
  border: 2px solid #58b7dd; background: #fff; color: #133; outline: none;
}
.region-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.region-chips .btn { font-size: 12px; padding: 6px 12px; }
.nation-grid {
  width: min(860px, 96vw); flex: 1 1 auto; min-height: 120px; max-height: 52vh; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px;
  padding: 6px; border-radius: 14px; background: rgba(255,255,255,.35); touch-action: pan-y;
}
.nation-card {
  appearance: none; border: 0; cursor: pointer; font: inherit; border-radius: 12px;
  background: #fff; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  box-shadow: 0 2px 6px rgba(8,80,110,.12);
}
.nation-card canvas { width: 48px; height: 32px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.nation-card .nc-name { font-size: 12px; font-weight: 800; color: #113; line-height: 1.15; text-align: center; }
.nation-card .nc-region { font-size: 10px; color: #588; }
.nation-card.on { outline: 3px solid #ff9425; background: #fff6df; }
.sticky-row { position: sticky; bottom: 0; padding: 8px 0 2px; }

/* ------------ cup hub ------------ */
.cup-sub { font-size: 14px; font-weight: 700; color: #08536f; text-align: center; }
.cup-tabs { display: flex; gap: 8px; }
#cup-body { width: min(880px, 96vw); max-height: 56vh; overflow-y: auto; touch-action: pan-y; background: rgba(255,255,255,.5); border-radius: 14px; padding: 10px; }
.grp { margin-bottom: 12px; }
.grp h3 { font-size: 14px; color: #085a7a; margin: 2px 4px 4px; }
.grp table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; font-size: 13px; }
.grp th, .grp td { padding: 5px 8px; text-align: center; }
.grp td:first-child, .grp th:first-child { text-align: left; }
.grp tr.you { background: #fff3d1; font-weight: 800; }
.grp thead { background: #e3f4fc; color: #085a7a; }
.grp .fl { width: 24px; height: 16px; vertical-align: -3px; border-radius: 2px; margin-right: 6px; }
.fixture { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px; font-size: 14px; font-weight: 700; }
.bracket-round { margin-bottom: 10px; }
.bracket-round h3 { font-size: 14px; color: #085a7a; margin: 2px 4px 4px; }
.tie { background: #fff; border-radius: 10px; padding: 6px 10px; margin: 4px 0; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.tie.you { background: #fff3d1; }
.tie .fl { width: 24px; height: 16px; border-radius: 2px; }
.tie .sc { margin-left: auto; font-weight: 900; }

/* ------------ help ------------ */
.help-box { width: min(680px, 94vw); background: rgba(255,255,255,.75); border-radius: 16px; padding: 16px 20px; font-size: 14px; line-height: 1.5; max-height: 62vh; overflow-y: auto; touch-action: pan-y; }
.help-box h3 { color: #b4611c; margin: 10px 0 2px; font-size: 15px; }
.help-box .tip { margin-top: 10px; font-weight: 700; color: #0a5f80; }

/* ------------ HUD ------------ */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.scorebug {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 5px 14px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(9,60,84,.92), rgba(6,42,60,.92)); color: #fff;
  font-weight: 900; font-size: 16px; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  white-space: nowrap;
}
.sb-team { display: flex; align-items: center; gap: 6px; }
.sb-flag { width: 27px; height: 18px; border-radius: 3px; }
.sb-score { color: #ffd23e; font-size: 18px; }
.sb-clock { font-variant-numeric: tabular-nums; color: #9adcff; margin-left: 4px; font-size: 14px; }
.sb-half { font-size: 11px; color: #9adcff; }
.hud-btns { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 10px; display: flex; gap: 6px; pointer-events: auto; }
.hud-btns button {
  appearance: none; border: 0; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(9,60,84,.85); color: #fff; font-size: 17px; cursor: pointer;
}
#banner {
  position: absolute; top: 26%; left: 50%; transform: translate(-50%,-50%) scale(0);
  font-size: clamp(34px, 9vw, 76px); font-weight: 900; letter-spacing: .04em;
  color: #fff; text-shadow: 0 4px 0 #d96a00, 0 10px 30px rgba(0,0,0,.4);
  -webkit-text-stroke: 2px #ff8a00; opacity: 0; white-space: nowrap;
}
#banner.pop { animation: bpop 2.2s ease-out forwards; }
@keyframes bpop {
  0% { transform: translate(-50%,-50%) scale(.2); opacity: 0; }
  12% { transform: translate(-50%,-50%) scale(1.12); opacity: 1; }
  20% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.05); opacity: 0; }
}
#sub-banner {
  position: absolute; top: 36%; left: 50%; transform: translateX(-50%);
  font-size: clamp(15px, 3.6vw, 26px); font-weight: 800; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.55); opacity: 0; transition: opacity .3s; white-space: nowrap;
}
#sub-banner.show { opacity: 1; }
#replay-tag {
  position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 46px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px;
  background: rgba(20,20,30,.8); color: #ffd23e; font-weight: 900; font-size: 13px; letter-spacing: .12em;
  pointer-events: auto;
}
.rp-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff3b3b; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }
#btn-skip { appearance: none; border: 0; background: #ffd23e; color: #4a2c00; font: inherit; font-weight: 900; font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer; }
#power-wrap {
  position: absolute; bottom: 24%; left: 50%; transform: translateX(-50%);
  width: min(280px, 60vw); height: 12px; border-radius: 999px; background: rgba(0,0,0,.4); overflow: hidden;
}
#power-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #7fe084, #ffd23e 60%, #ff5d2e); }
#radar {
  position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: 141px; height: 96px; border-radius: 8px; opacity: .92; pointer-events: none;
}
@media (max-width: 720px) { #radar { width: 108px; height: 74px; } }

/* touch */
#touch-ui { position: absolute; inset: 0; pointer-events: none; }
#stick {
  position: absolute; left: 4%; bottom: max(5%, env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.5); pointer-events: auto;
}
#stick-nub { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.65); transform: translate(-50%,-50%); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
#tbtns { position: absolute; right: 3%; bottom: max(4%, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, 74px); gap: 10px; pointer-events: auto; }
.tbtn {
  appearance: none; border: 0; width: 74px; height: 74px; border-radius: 50%; cursor: pointer;
  font-weight: 900; font-size: 13px; color: #fff; background: rgba(9,60,84,.72);
  box-shadow: 0 3px 10px rgba(0,0,0,.3); touch-action: none;
}
.tbtn.pass { background: rgba(28,146,74,.85); }
.tbtn.shoot { background: rgba(224,84,26,.88); }
.tbtn.sprint { background: rgba(240,180,20,.88); color: #4a2c00; grid-column: span 2; height: 46px; width: auto; border-radius: 999px; }
/* Defending: PASS/SHOOT relabel to SWITCH/TACKLE (main.js) and take the colours
   of what they now do, while the two attacking-only buttons fade back. They
   still work on a loose ball, so fade rather than hide. */
.tbtn { transition: opacity .18s, background .18s; }
#tbtns.defending .tbtn.pass { background: rgba(14,127,184,.88); }
#tbtns.defending .tbtn.shoot { background: rgba(120,74,166,.88); }
#tbtns.defending #t-lob, #tbtns.defending #t-thru { opacity: .42; }

/* ------------ overlay ------------ */
#overlay { position: fixed; inset: 0; z-index: 40; background: rgba(8,42,66,.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; }
#overlay .panel {
  width: min(480px, 92vw); max-height: 86vh; overflow-y: auto; background: linear-gradient(180deg, #fffef5, #ffeccc);
  border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}
#ov-title { font-size: 26px; font-weight: 900; color: #b4611c; }
#ov-rows { font-size: 15px; line-height: 1.6; color: #234; width: 100%; }
#ov-rows table { width: 100%; border-collapse: collapse; font-size: 13px; }
#ov-rows td { padding: 3px 6px; }
.ov-leave { font-size: 13px; color: #08536f; font-weight: 700; }

/* ------------ loading ------------ */
#loading {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; font-weight: 800; color: #085a7a;
  background: linear-gradient(#7fd0f4, #ffe9b8);
}
#loadbar { width: min(320px, 70vw); height: 12px; border-radius: 999px; background: rgba(255,255,255,.6); overflow: hidden; }
#loadbar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ffd23e, #ff8a00); transition: width .15s; }
#loadnote { font-size: 12px; font-weight: 600; color: #4a89a5; }

@media (max-width: 560px) {
  .nation-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  #tbtns { grid-template-columns: repeat(2, 62px); gap: 8px; }
  .tbtn { width: 62px; height: 62px; font-size: 11px; }
  .scorebug { font-size: 13px; gap: 5px; padding: 4px 10px; }
  .sb-score { font-size: 15px; }
}
