/* Grandeur FC — styles.css
   Night-stadium arcade look. Screens toggle via .active; the game stage keeps a
   16:9 canvas responsive with an absolutely-positioned HUD overlay. */

:root {
  --bg0: #070c1f;
  --bg1: #0e1a40;
  --panel: rgba(16, 26, 60, 0.82);
  --panel-solid: #101a3c;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ffdc3c;
  --accent2: #39d353;
  --red: #e5484d;
  --blue: #4f8fe9;
  --text: #eef2ff;
  --muted: #9fb0d8;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2c66 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

#app { position: fixed; inset: 0; display: flex; }

.screen {
  display: none;
  position: absolute; inset: 0;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 14px;
  animation: fade .25s ease;
}
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- shared bits ---------------- */
.big-btn {
  border: none; cursor: pointer;
  background: linear-gradient(180deg, #22336e, #16224c);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 26px; font-size: 20px; font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform .08s ease, filter .15s ease;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 220px;
}
.big-btn .sub { font-size: 12px; font-weight: 600; color: var(--muted); }
.big-btn:hover { filter: brightness(1.12); }
.big-btn:active { transform: translateY(2px) scale(.99); }
.big-btn.primary { background: linear-gradient(180deg, #ffe680, #f2b705); color: #241c00; border-color: #ffdd77; }
.big-btn.primary .sub { color: #4a3a00; }

.ghost-btn {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.ghost-btn:hover { color: var(--text); }

.icon-btn {
  background: rgba(255, 255, 255, 0.08); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  width: 42px; height: 42px; font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

kbd {
  background: #223; border: 1px solid #445; border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: inherit;
}

/* ---------------- menu ---------------- */
.menu-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 34px; max-width: 460px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  backdrop-filter: blur(6px); position: relative;
}
.crest { font-size: 54px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.title {
  margin: 0; font-size: 40px; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(180deg, #fff, #ffd84a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.tagline { margin: -6px 0 8px; color: var(--muted); font-weight: 600; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; align-items: center; }
.how { width: 100%; margin-top: 6px; color: var(--muted); font-size: 14px; }
.how summary { cursor: pointer; font-weight: 700; color: var(--text); padding: 6px 0; }
.how ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.5; }
.how kbd { margin: 0 1px; }
.menu-card .btn-mute { position: absolute; top: 12px; right: 12px; }
.brand { color: var(--muted); font-size: 13px; }
.brand a { color: var(--accent); text-decoration: none; }

/* ---------------- setup ---------------- */
.setup-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; width: 100%; max-width: 620px;
  display: flex; flex-direction: column; gap: 18px;
}
.setup-card h2 { margin: 0; text-align: center; font-size: 24px; }
.players { display: flex; align-items: center; gap: 14px; }
.player-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.p-label { font-weight: 800; font-size: 14px; letter-spacing: .5px; }
.p-label.side-l { color: var(--red); }
.p-label.side-r { color: var(--blue); }
.flag-preview {
  width: 108px; height: 72px; border-radius: 8px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.35); background: #223;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.flag-preview svg { width: 100%; height: 100%; display: block; }
.flag-name { font-size: 13px; color: var(--muted); min-height: 16px; font-weight: 600; }
.pick-btn {
  background: #2a3a72; color: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.pick-btn:hover { filter: brightness(1.15); }
.name-input {
  width: 100%; background: #0c1024; color: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; text-align: center;
}
.name-input:read-only { opacity: .7; }
.vs-badge { font-weight: 900; color: var(--accent); font-size: 20px; }

.difficulty { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.diff-label { color: var(--muted); font-weight: 700; font-size: 14px; }
.diff-btns { display: flex; gap: 8px; }
.diff-btn {
  background: rgba(255,255,255,0.06); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px; font-weight: 700; cursor: pointer; font-size: 14px;
}
.diff-btn.active { background: var(--accent); color: #241c00; border-color: #ffdd77; }
.setup-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------------- flag picker ---------------- */
.flagpicker { position: fixed; inset: 0; display: none; z-index: 40; }
.flagpicker.open { display: block; }
.fp-backdrop { position: absolute; inset: 0; background: rgba(4, 8, 20, 0.72); backdrop-filter: blur(3px); }
.fp-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(680px, 94vw); max-height: 84vh; display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 16px;
}
.fp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fp-head h3 { margin: 0; font-size: 18px; }
.fp-search {
  width: 100%; background: #0c1024; color: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 15px; margin-bottom: 12px;
}
.fp-grid {
  overflow-y: auto; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  padding-right: 4px;
}
.flag-cell {
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 4px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: transform .06s ease, background .1s ease;
}
.flag-cell:hover { background: rgba(255,255,255,0.14); transform: translateY(-2px); }
.flag-thumb { width: 60px; height: 40px; border-radius: 4px; overflow: hidden; border: 1px solid rgba(255,255,255,.25); }
.flag-thumb svg { width: 100%; height: 100%; display: block; }
.flag-nm { font-size: 11px; text-align: center; line-height: 1.1; color: var(--muted); }

/* ---------------- game ---------------- */
#screen-game { justify-content: flex-start; padding: 8px; gap: 8px; }
.hud-top {
  width: 100%; max-width: 1000px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.scorebox {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 12px; flex: 1; min-width: 0;
}
.scorebox.right { justify-content: flex-end; }
.scorebox.serving { box-shadow: 0 0 0 2px var(--accent) inset; }
.sb-flag { width: 34px; height: 23px; border-radius: 3px; overflow: hidden; border: 1px solid rgba(255,255,255,.3); flex: none; }
.sb-flag svg { width: 100%; height: 100%; display: block; }
.sb-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-score {
  font-weight: 900; font-size: 24px; color: var(--accent);
  min-width: 26px; text-align: center; font-variant-numeric: tabular-nums;
}
.hud-mid { display: flex; gap: 6px; flex: none; }

.stage {
  position: relative; width: 100%; max-width: 1000px; aspect-ratio: 16 / 9;
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
#game-canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.turn-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(6, 10, 24, 0.8); border: 1px solid var(--line);
  padding: 8px 18px; border-radius: 999px; font-weight: 800; font-size: 15px;
  pointer-events: none; white-space: nowrap; opacity: 1; transition: opacity .2s;
}
.turn-banner:empty { opacity: 0; }
.turn-banner.p1 { color: #ffb3b3; }
.turn-banner.p2 { color: #b3d1ff; }

.game-foot {
  width: 100%; max-width: 1000px; display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.prompt { min-height: 20px; color: var(--accent); font-weight: 700; font-size: 15px; text-align: center; }
.controls { display: flex; align-items: center; justify-content: center; gap: 20px; min-height: 118px; }

.shoot-btn {
  display: none;
  background: linear-gradient(180deg, #ff6a3d, #e5344d);
  color: #fff; border: none; border-radius: 14px;
  padding: 20px 40px; font-size: 22px; font-weight: 900; letter-spacing: 1px;
  cursor: pointer; box-shadow: var(--shadow);
  animation: pulse 1s infinite ease-in-out;
}
.shoot-btn.show { display: inline-block; }
@keyframes pulse { 50% { transform: scale(1.05); filter: brightness(1.1); } }

.jump-btn {
  display: none;
  background: linear-gradient(180deg, #4f9fe9, #2f6fd6);
  color: #fff; border: none; border-radius: 14px;
  padding: 20px 44px; font-size: 22px; font-weight: 900; letter-spacing: 1px;
  cursor: pointer; box-shadow: var(--shadow);
  animation: pulse 0.7s infinite ease-in-out;
}
.jump-btn.show { display: inline-block; }
/* shown but not actionable (ball heading to the other goal, or already committed) */
.jump-btn.disabled, .jump-btn:disabled {
  animation: none; cursor: default;
  opacity: 0.4; filter: grayscale(0.5);
  box-shadow: none;
}

/* ---------------- game over ---------------- */
.go-flag { width: 140px; height: 93px; border-radius: 10px; overflow: hidden; border: 3px solid var(--accent); box-shadow: var(--shadow); }
.go-flag svg { width: 100%; height: 100%; display: block; }
.go-score { color: var(--muted); font-weight: 800; font-size: 18px; letter-spacing: 1px; margin: -4px 0 6px; }

/* ---------------- responsive ---------------- */
@media (max-width: 640px) {
  .title { font-size: 32px; }
  .players { gap: 8px; }
  .player-col { padding: 10px; }
  .flag-preview { width: 92px; height: 61px; }
  .big-btn { min-width: 180px; font-size: 18px; padding: 14px 20px; }
  .sb-name { font-size: 13px; max-width: 90px; }
  .shoot-btn { padding: 16px 28px; font-size: 19px; }
  .setup-actions { flex-direction: column-reverse; }
  .setup-actions .big-btn, .setup-actions .ghost-btn { width: 100%; }
}
@media (max-height: 560px) {
  .controls { min-height: 92px; }
  .zone-grid { grid-template-rows: repeat(3, 28px); }
}
