/* World Cup Arena — landing hero + chalk-pitch game theme */
:root {
  --bg: #0a1020;
  --bg2: #0e1830;
  --panel: #131f38;
  --panel2: #1b2b4d;
  --line: #2a3c61;
  --text: #eef3fd;
  --muted: #9cadcf;
  --accent: #2fd574;
  --accent2: #1fae5c;
  --gold-1: #fff3c4;
  --gold-2: #f7c948;
  --gold-3: #c98a12;
  --gold: #f5c542;
  --red: #ff5d6c;
  --pitch1: #1c7a3f;
  --pitch2: #176835;
  --chalk: rgba(255, 255, 255, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }
body {
  background:
    radial-gradient(1100px 500px at 50% -150px, #16244447 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.45;
}

main { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 16px 20px 56px; }

/* ====== chalk-drawn pitch backdrop (all game screens) ====== */
#field-bg { display: none; }
body.in-game {
  background:
    radial-gradient(1200px 700px at 50% -200px, rgba(255, 255, 255, .07), transparent 60%),
    linear-gradient(180deg, #0f5e30 0%, #0c4f28 45%, #0a401f 100%);
}
body.in-game #field-bg {
  display: block; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg,
    rgba(255, 255, 255, .025) 0 90px, transparent 90px 180px);
}
.fb-line { position: absolute; left: 0; right: 0; top: 50%; height: 3px; background: var(--chalk); }
.fb-circle {
  position: absolute; left: 50%; top: 50%; width: min(46vw, 420px); aspect-ratio: 1;
  border: 3px solid var(--chalk); border-radius: 50%; transform: translate(-50%, -50%);
}
.fb-spot {
  position: absolute; left: 50%; top: 50%; width: 10px; height: 10px;
  background: var(--chalk); border-radius: 50%; transform: translate(-50%, -50%);
}
.fb-box { position: absolute; left: 50%; width: min(60vw, 560px); height: 130px; border: 3px solid var(--chalk); }
.fb-box.top { top: -3px; transform: translateX(-50%); border-top: 0; }
.fb-box.bottom { bottom: -3px; transform: translateX(-50%); border-bottom: 0; }

/* ====== top bar ====== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px; border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(8, 13, 26, .72); backdrop-filter: blur(8px);
}
body.in-game .topbar { background: rgba(6, 38, 19, .72); }
.logo { font-size: 1.1rem; font-weight: 800; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.logo-main em {
  font-style: normal;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ====== screens ====== */
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ====== buttons ====== */
button { font: inherit; cursor: pointer; color: inherit; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 45%, var(--gold-3) 100%);
  color: #3a2800; font-weight: 900; letter-spacing: 2px; text-transform: uppercase;
  border: 1px solid #ffe9a0; border-radius: 12px; padding: 14px 38px;
  box-shadow: 0 8px 26px rgba(247, 201, 72, .35), inset 0 1px 0 #fff8;
  transition: transform .08s ease, filter .15s;
}
.btn-gold:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-gold.big { font-size: 1.05rem; width: 100%; margin-top: 26px; }
.btn-secondary {
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 12px; padding: 10px 18px; font-weight: 600;
}
.btn-secondary:hover { background: rgba(255, 255, 255, .13); }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost {
  background: none; border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px; padding: 7px 14px; color: var(--muted);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, .4); }

/* ====== landing hero ====== */
#screen-home.active { display: flex; flex-direction: column; min-height: calc(100vh - 130px); }
.hero {
  position: relative; flex: 1; overflow: hidden; border-radius: 22px;
  min-height: 540px;
  display: flex; align-items: center;
  background:
    radial-gradient(900px 420px at 78% 8%, rgba(122, 158, 255, .16), transparent 60%),
    radial-gradient(700px 320px at 14% 4%, rgba(122, 158, 255, .12), transparent 60%),
    linear-gradient(180deg, #060b18 0%, #0b1430 52%, #122448 74%, #16335c 100%);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.hero-lights {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(140px 90px at 12% 6%, rgba(255, 244, 200, .35), transparent 70%),
    radial-gradient(140px 90px at 38% 2%, rgba(255, 244, 200, .28), transparent 70%),
    radial-gradient(140px 90px at 64% 2%, rgba(255, 244, 200, .28), transparent 70%),
    radial-gradient(140px 90px at 90% 6%, rgba(255, 244, 200, .35), transparent 70%);
}
.hero-sparks {
  position: absolute; inset: 0; pointer-events: none; opacity: .8;
  background-image:
    radial-gradient(2px 2px at 82% 64%, #ffd76a 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 48%, #ffb84d 50%, transparent 51%),
    radial-gradient(3px 3px at 74% 78%, #ffcf5e 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 72%, #ffe28a 50%, transparent 51%),
    radial-gradient(2px 2px at 68% 56%, #ffc14f 50%, transparent 51%),
    radial-gradient(3px 3px at 96% 58%, #ff9f3d 50%, transparent 51%);
}
.hero-pitch {
  position: absolute; left: -12%; right: -12%; bottom: -2px; height: 36%;
  transform: perspective(620px) rotateX(48deg); transform-origin: bottom center;
  background:
    linear-gradient(rgba(255, 255, 255, .25), rgba(255, 255, 255, .25)) 50% 0 / 3px 100% no-repeat,
    radial-gradient(closest-side at 50% 0, transparent 96%, rgba(255, 255, 255, .25) 97% 100%, transparent 100%) 50% -90px / 280px 280px no-repeat,
    repeating-linear-gradient(90deg, var(--pitch1) 0 9%, var(--pitch2) 9% 18%);
  border-top: 2px solid rgba(255, 255, 255, .3);
}
.hero-content { position: relative; z-index: 2; padding: 48px 56px 140px; max-width: 640px; }
.hero-kicker {
  color: var(--gold-2); font-weight: 800; letter-spacing: 4px; text-transform: uppercase;
  font-size: .8rem; margin-bottom: 10px;
}
.hero-title { line-height: .92; text-transform: uppercase; font-weight: 900; }
.hero-title span { display: block; }
.ht-line1 { font-size: clamp(2.6rem, 7vw, 4.6rem); color: #fff; letter-spacing: 1px;
  text-shadow: 0 4px 24px rgba(0, 0, 0, .6); }
.ht-line2 {
  font-size: clamp(3.4rem, 9.5vw, 6.2rem); letter-spacing: 3px;
  background: linear-gradient(180deg, var(--gold-1) 8%, var(--gold-2) 48%, var(--gold-3) 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(247, 201, 72, .25));
}
.hero-sub {
  margin: 18px 0 26px; font-size: 1.15rem; font-weight: 700; color: #e9efff;
  text-transform: uppercase; letter-spacing: 1px;
}
.hero-cta { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.home-stats { display: flex; gap: 16px; color: var(--muted); font-size: .88rem; flex-wrap: wrap; }
.home-stats b { color: var(--text); }
.credit { margin-top: 18px; text-align: center; color: #5d6f93; font-size: .78rem; }

@media (max-width: 640px) {
  .hero-content { padding: 36px 26px 130px; }
  #screen-home.active { min-height: auto; }
}

/* ====== setup ====== */
#screen-setup.active { display: flex; justify-content: center; }
.setup-card {
  width: 100%; max-width: 660px; margin-top: 12px;
  background: rgba(8, 16, 32, .78); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 20px; padding: 26px 30px 30px; backdrop-filter: blur(6px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}
.setup-head { text-align: center; margin-bottom: 4px; position: relative; }
.setup-head .btn-ghost { position: absolute; left: 0; top: 2px; }
.setup-head h2 { font-size: 1.5rem; }
.tagline { color: var(--muted); font-size: .95rem; }
.setup-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: 2px;
  color: var(--gold-2); margin: 22px 0 10px; text-align: center; font-weight: 800;
}
.mode-cards { display: flex; gap: 12px; justify-content: center; }
.mode-card {
  flex: 1 1 0; display: flex; flex-direction: column; gap: 4px;
  background: rgba(255, 255, 255, .05); border: 2px solid rgba(255, 255, 255, .14);
  border-radius: 14px; padding: 14px; text-align: center;
  transition: border-color .15s, background .15s;
}
.mode-card.sel { border-color: var(--gold-2); background: rgba(247, 201, 72, .10); }
.mode-emoji { font-size: 1.6rem; }
.mode-name { font-weight: 800; font-size: 1.02rem; }
.mode-desc { color: var(--muted); font-size: .8rem; }
.chip-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip {
  background: rgba(255, 255, 255, .05); border: 2px solid rgba(255, 255, 255, .14);
  border-radius: 999px; padding: 8px 18px; font-weight: 700; transition: border-color .15s;
}
.chip.sel { border-color: var(--gold-2); background: rgba(247, 201, 72, .10); color: var(--gold-1); }
@media (max-width: 560px) { .mode-cards { flex-direction: column; } }

/* ====== shared panels (on green backdrop) ====== */
.panel {
  background: rgba(5, 26, 14, .72); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px; padding: 16px; backdrop-filter: blur(3px);
}
.panel h3 { margin-bottom: 10px; }
.panel h4 { margin: 14px 0 6px; color: var(--muted); font-size: .85rem; }
.badge {
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px; padding: 4px 14px; font-size: .85rem; font-weight: 700; color: var(--gold);
  white-space: nowrap;
}

/* ====== draft ====== */
.draft-header {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 14px;
  background: rgba(5, 26, 14, .72); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px; padding: 10px 16px;
}
.dh-item { color: #cfe3d6; }
.dh-item.big-item { font-size: 1.15rem; font-weight: 800; color: #fff; }
.dh-reroll { margin-left: auto; padding: 8px 16px; }

.draft-layout { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .draft-layout { grid-template-columns: 1fr; } }

/* pitch widget */
.pitch-wrap { position: relative; }
.pitch {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 14px; overflow: hidden;
  background: repeating-linear-gradient(0deg, var(--pitch1) 0 12.5%, var(--pitch2) 12.5% 25%);
  border: 2px solid rgba(255, 255, 255, .35);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .35), 0 14px 34px rgba(0, 0, 0, .3);
}
.pitch::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, .4), rgba(255, 255, 255, .4)) 0 50% / 100% 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)) 50% 0 / 44% 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)) 50% 100% / 44% 2px no-repeat;
}
.pitch::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 24%; aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, .4); border-radius: 50%;
  transform: translate(-50%, -50%); z-index: 0; pointer-events: none;
}
.pitch-wrap.small { width: 100%; max-width: 320px; }
.pitch-wrap.center { margin: 0 auto; }

.slot {
  position: absolute; transform: translate(-50%, -50%); z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 76px; text-align: center; user-select: none;
}
.slot-chip {
  display: flex; align-items: center; gap: 4px; justify-content: center;
  background: #0d1626; border: 2px solid var(--line); border-radius: 999px;
  padding: 3px 9px; font-size: .8rem; min-width: 40px; min-height: 28px;
}
.slot.filled .slot-chip { border-color: #4a6388; background: #101c30; }
.slot-chip.empty-chip { color: var(--muted); border-style: dashed; }
.slot .slot-role { font-size: .62rem; letter-spacing: 1px; color: rgba(255, 255, 255, .9); font-weight: 700; text-shadow: 0 1px 2px #000; }
.slot-name {
  font-size: .68rem; font-weight: 700; background: rgba(0, 0, 0, .55);
  padding: 1px 6px; border-radius: 6px; max-width: 96px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot.target .slot-chip {
  border-color: var(--gold-2); box-shadow: 0 0 0 4px rgba(247, 201, 72, .3);
  animation: pulse 1s infinite; cursor: pointer;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(247, 201, 72, .15); } }

/* rating tiers */
.r5 { color: #38e08b; } .r4 { color: #9be15d; } .r3 { color: #ffd166; }
.r2 { color: #f4a261; } .r1 { color: #e07a5f; }

/* draw panel */
.draw-panel { display: flex; flex-direction: column; gap: 10px; }
.draw-card {
  background: rgba(5, 26, 14, .72); border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px; padding: 12px 18px;
  display: flex; align-items: center; gap: 14px; min-height: 72px;
}
.draw-card.rolling { animation: shake .25s infinite; }
@keyframes shake { 25% { transform: rotate(.6deg); } 75% { transform: rotate(-.6deg); } }
.draw-flag { font-size: 2.3rem; line-height: 1; }
.draw-name { font-size: 1.25rem; font-weight: 800; }
.draw-year { color: var(--muted); font-size: .85rem; margin-left: auto; }
.draw-hint { color: var(--gold-1); font-weight: 600; min-height: 1.3em; padding-left: 4px; }

.squad-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; align-items: start; }
.squad-group-title {
  font-size: .72rem; letter-spacing: 2px; color: var(--gold-1);
  margin: 2px 0 6px; font-weight: 800;
}
.player-card {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  background: rgba(5, 26, 14, .78); border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px; padding: 7px 10px; margin-bottom: 6px;
  transition: border-color .12s, transform .08s;
}
.player-card:hover:not(:disabled) { border-color: var(--gold-2); transform: translateY(-1px); }
.player-card.picked { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(245, 197, 66, .3); }
.player-card.off { opacity: .35; cursor: not-allowed; }
.pc-role {
  font-size: .65rem; font-weight: 800; color: var(--muted);
  background: rgba(0, 0, 0, .4); border-radius: 6px; padding: 2px 5px; min-width: 28px; text-align: center;
}
.pc-name { font-size: .85rem; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-rating { font-weight: 800; font-size: .95rem; }
.pc-rating.hidden-r { color: var(--muted); }
.pc-cost {
  font-size: .78rem; font-weight: 800; color: var(--gold-1);
  background: rgba(247, 201, 72, .14); border: 1px solid rgba(247, 201, 72, .35);
  border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
.pc-nofit { font-size: .65rem; color: var(--red); }

.budget-badge { color: var(--gold-1); border-color: rgba(247, 201, 72, .5); }
.btn-secondary.free-reroll {
  border-color: var(--gold-2); color: var(--gold-1);
  box-shadow: 0 0 0 3px rgba(247, 201, 72, .18); animation: pulse 1.2s infinite;
}

/* ====== campaign ====== */
.campaign-header { display: flex; align-items: center; gap: 14px; margin: 10px 0 14px; flex-wrap: wrap; }
.campaign-layout { display: grid; grid-template-columns: 1.2fr 1.2fr .9fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .campaign-layout { grid-template-columns: 1fr; } }

.group-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.group-table th, .group-table td { padding: 6px 4px; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.group-table .tl { text-align: left; }
.group-table tr.me td { background: rgba(247, 201, 72, .1); font-weight: 700; }
.group-table tr.qual td:first-child { border-left: 3px solid var(--accent); }
.other-result { color: var(--muted); font-size: .85rem; padding: 3px 0; }

.result-row { padding: 7px 0; border-bottom: 1px dashed rgba(255, 255, 255, .15); font-size: .92rem; }
.rr-label { color: var(--muted); font-size: .8rem; }
.seed-note { color: var(--muted); font-size: .8rem; margin: 10px 0; }
#campaign-right .btn-gold, #campaign-right .btn-primary {
  margin-top: 14px; width: 100%;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 45%, var(--gold-3) 100%);
  color: #3a2800; font-weight: 900; border: 1px solid #ffe9a0; border-radius: 12px; padding: 13px 18px;
  box-shadow: 0 8px 26px rgba(247, 201, 72, .3);
}
.pitch-panel { display: flex; justify-content: center; }

/* ====== match ====== */
#screen-match { max-width: 620px; margin: 0 auto; text-align: center; }
.match-stage { margin: 14px 0 10px; color: var(--gold-1); font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }
.scoreboard {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(5, 26, 14, .8); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 16px; padding: 16px 20px; margin-bottom: 14px;
}
.sb-team { display: flex; align-items: center; gap: 8px; font-weight: 800; min-width: 0; }
.sb-team span:not(.sb-flag) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-flag { font-size: 1.6rem; }
.sb-score { font-size: 2rem; font-weight: 900; color: var(--gold-2); white-space: nowrap; }

.match-events {
  list-style: none; text-align: left; background: rgba(4, 20, 11, .78);
  border: 1px solid rgba(255, 255, 255, .15); border-radius: 14px;
  height: 320px; overflow-y: auto; padding: 12px 16px; margin-bottom: 14px;
}
.ev { padding: 5px 0; border-bottom: 1px dashed rgba(255, 255, 255, .12); font-size: .92rem; }
.ev.msg { color: var(--muted); }
.ev.goal.mine b { color: var(--gold-2); }
.ev-min { display: inline-block; min-width: 34px; color: var(--gold); font-weight: 700; }
.ev-team { color: var(--muted); font-size: .8rem; }
.match-buttons { display: flex; gap: 10px; justify-content: center; }
.match-buttons .btn-gold { padding: 11px 30px; }

/* ====== result ====== */
#screen-result { max-width: 640px; margin: 0 auto; text-align: center; }
.result-head { margin-top: 18px; }
.big-trophy { font-size: 4.5rem; filter: drop-shadow(0 10px 30px rgba(247, 201, 72, .35)); }
.result-head h2 { font-size: 1.9rem; text-transform: uppercase; letter-spacing: 1px; }
.perfect-badge {
  display: inline-block; margin-top: 10px; padding: 8px 18px; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-2), #ffe28a); color: #4d3a00; font-weight: 900;
}
.sub { color: var(--muted); }
.result-record { margin: 14px 0; color: #d7e6dd; }
.result-record b { color: #fff; }
.result-matches {
  text-align: left; background: rgba(5, 26, 14, .75);
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 14px;
  padding: 10px 16px; margin-bottom: 18px;
}
#screen-result h3 { margin: 10px 0; }
.result-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.result-buttons .btn-gold { padding: 12px 30px; }
