/* Grass Stain Soccer — menus and screens.
   Look: a backyard scoreboard. Chunky sticker buttons with hard shadows, paper panels, chalk lines.
   One committed palette (the game world doesn't change with light/dark mode). */
:root {
  --grass: #1F5130;
  --grass-2: #2D6B3F;
  --grass-3: #3E8A50;
  --chalk: #FDFBF3;
  --paper: #FFF6DF;
  --paper-2: #F3E6C4;
  --sun: #FFD23F;
  --tomato: #EF5B3C;
  --sky: #7CC6F2;
  --wood: #9C6B3F;
  --ink: #1D1A16;
  --ink-2: #4A4136;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #10241A; color: var(--chalk); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#app.playing #game { cursor: none; }
#screens { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; display: flex; justify-content: center; align-items: flex-start;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
#screens:empty { pointer-events: none; }
#screens.dim { background: radial-gradient(ellipse at center, rgba(16, 36, 26, 0.55), rgba(10, 22, 16, 0.88)); }

.screen { width: min(1080px, 100%); margin: auto 0; display: flex; flex-direction: column; gap: 18px; animation: pop-in 0.28s ease-out both; }
@keyframes pop-in { from { transform: translateY(10px) scale(0.99); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .btn, .kid-card { animation: none !important; transition: none !important; } }

h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: 0.01em; text-wrap: balance; }
p { margin: 0; line-height: 1.5; }
.eyebrow { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; color: var(--sun); }

/* ---------- buttons */
.btn { font-family: var(--display); font-size: 1.15rem; color: var(--ink); background: var(--sun); border: 3px solid var(--ink); border-radius: 14px;
  padding: 10px 20px; box-shadow: 0 5px 0 var(--ink); cursor: pointer; transition: transform 0.08s, box-shadow 0.08s, background 0.15s; letter-spacing: 0.02em; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.btn:focus-visible, .kid-card:focus-visible, .choice:focus-visible, .swatch:focus-visible, input:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.btn.secondary { background: var(--chalk); }
.btn.danger { background: var(--tomato); color: var(--chalk); }
.btn.ghost { background: transparent; color: var(--chalk); border-color: var(--chalk); box-shadow: 0 4px 0 rgba(0,0,0,0.5); }
.btn.big { font-size: 1.5rem; padding: 14px 26px; border-radius: 18px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.spacer { flex: 1; }

/* ---------- panels */
.panel { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 8px 0 rgba(0,0,0,0.35); padding: 20px; min-width: 0; }
.panel h2 { font-size: 1.6rem; }
.panel .muted { color: var(--ink-2); }
.tag { display: inline-block; font-family: var(--display); background: var(--tomato); color: var(--chalk); padding: 4px 12px; border-radius: 8px; transform: rotate(-2deg); border: 2px solid var(--ink); }
.header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.header h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); text-shadow: 0 3px 0 rgba(0,0,0,0.4); }

/* ---------- title */
.title-screen { align-items: center; text-align: center; gap: 22px; padding-top: 2vh; }
.logo { font-family: var(--display); line-height: 0.88; transform: rotate(-3deg); user-select: none; }
.logo .l1 { display: block; font-size: clamp(3.2rem, 10vw, 7.2rem); color: var(--chalk); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 10px 18px rgba(0,0,0,0.4); }
.logo .l1 .stain { color: #8BC34A; }
.logo .l2 { display: inline-block; margin-top: 6px; font-size: clamp(1.8rem, 5vw, 3.4rem); background: var(--sun); color: var(--ink); padding: 0 18px 4px; border: 3px solid var(--ink);
  border-radius: 12px; box-shadow: 0 6px 0 var(--ink); transform: rotate(4deg); }
.tagline { font-size: 1.1rem; color: var(--chalk); text-shadow: 0 2px 0 rgba(0,0,0,0.5); max-width: 36ch; }
.menu { display: grid; gap: 14px; width: min(380px, 100%); }
.menu .btn { width: 100%; }
.menu .row .btn { width: auto; flex: 1; }
.menu .btn small { display: block; font-family: var(--body); font-weight: 800; font-size: 0.78rem; opacity: 0.75; margin-top: 2px; }
.shelf { display: flex; gap: 6px; align-items: flex-end; justify-content: center; background: linear-gradient(#7A4F2A, #5E3A1E); border: 3px solid var(--ink); border-radius: 12px;
  padding: 10px 16px 6px; box-shadow: 0 6px 0 rgba(0,0,0,0.4); }
.shelf canvas { display: block; }
.shelf-label { font-family: var(--display); font-size: 0.8rem; letter-spacing: 0.1em; color: var(--paper-2); margin-top: 4px; }
.version { position: fixed; right: max(12px, env(safe-area-inset-right, 0px)); bottom: max(8px, env(safe-area-inset-bottom, 0px)); font-size: 0.75rem; opacity: 0.55; }

/* ---------- forms & choices */
.field-label { font-family: var(--display); font-size: 1rem; margin-bottom: 8px; display: block; }
input[type=text] { font-family: var(--display); font-size: 1.3rem; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 12px; background: var(--chalk); color: var(--ink); width: 100%; max-width: 420px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink); position: relative; }
.swatch.on::after { content: ""; position: absolute; inset: -8px; border: 3px solid var(--ink); border-radius: 50%; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.choice { text-align: left; background: var(--chalk); border: 3px solid var(--ink); border-radius: 14px; padding: 12px; cursor: pointer; font-family: var(--body); color: var(--ink); box-shadow: 0 4px 0 var(--ink); min-width: 0; }
.choice.on { background: var(--sun); transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.choice b { font-family: var(--display); font-weight: 400; font-size: 1.15rem; display: block; }
.choice span { font-size: 0.85rem; color: var(--ink-2); }
.choice canvas { width: 100%; height: auto; border-radius: 8px; border: 2px solid var(--ink); display: block; margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

/* ---------- draft */
.draft { display: grid; grid-template-columns: 220px 1fr 220px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .draft { grid-template-columns: 1fr; } }
.roster { background: rgba(10, 22, 16, 0.75); border: 3px solid var(--ink); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.roster h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.roster .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.slot { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.08); border-radius: 10px; padding: 4px 6px; min-height: 46px; font-weight: 800; font-size: 0.9rem; }
.slot canvas { width: 38px; height: 38px; border-radius: 8px; background: rgba(255,255,255,0.12); flex: none; }
.slot.empty { border: 2px dashed rgba(255,255,255,0.25); background: none; color: rgba(255,255,255,0.4); justify-content: center; }
.turn-banner { font-family: var(--display); font-size: 1.4rem; text-align: center; padding: 8px; border-radius: 12px; border: 3px solid var(--ink); background: var(--sun); color: var(--ink); box-shadow: 0 5px 0 var(--ink); }
.turn-banner.them { background: var(--tomato); color: var(--chalk); }
.bench { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kid-card { position: relative; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 8px 10px; cursor: pointer; text-align: left;
  font-family: var(--body); box-shadow: 0 4px 0 var(--ink); transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s; min-width: 0; }
.kid-card:hover:not([disabled]) { transform: translateY(-3px) rotate(-0.6deg); box-shadow: 0 7px 0 var(--ink); }
.kid-card[disabled] { cursor: default; }
.kid-card.taken { opacity: 0; transform: scale(0.8); pointer-events: none; }
.kid-card.flash { animation: flash 0.5s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 6px var(--tomato); } 100% { box-shadow: 0 4px 0 var(--ink); } }
.kid-card .portrait { width: 100%; aspect-ratio: 1.35; max-width: 100%; display: block; border-radius: 10px; background: linear-gradient(#9ED6F5, #CDEBFA 60%, #7CC36B 60%, #64B056); border: 2px solid var(--ink); }
.kid-card .nm { font-family: var(--display); font-size: 1.02rem; line-height: 1.1; margin-top: 6px; overflow-wrap: anywhere; }
.kid-card .nick { font-size: 0.74rem; font-weight: 800; color: var(--tomato); text-transform: uppercase; letter-spacing: 0.05em; }
.kid-card .stars { position: absolute; top: 12px; right: 12px; background: var(--ink); color: var(--sun); font-size: 0.72rem; padding: 2px 6px; border-radius: 8px; letter-spacing: 1px; }
.kid-card .badge { position: absolute; top: 12px; left: 12px; background: var(--chalk); color: var(--ink); font-family: var(--display); font-size: 0.7rem; padding: 2px 6px; border-radius: 6px; border: 2px solid var(--ink); }
.stats { display: grid; grid-template-columns: auto 1fr 1.4em; gap: 2px 6px; align-items: center; margin-top: 6px; font-size: 0.68rem; font-weight: 800; }
.stats .num { font-family: var(--display); font-weight: 400; font-size: 0.82rem; text-align: right; font-variant-numeric: tabular-nums; }
.stats .bar { height: 7px; border-radius: 4px; background: rgba(0,0,0,0.12); overflow: hidden; }
.stats .bar i { display: block; height: 100%; border-radius: 4px; }
.kid-bio { font-size: 0.78rem; color: var(--ink-2); margin-top: 6px; line-height: 1.35; }

/* ---------- lineup + hub */
.lineup { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.lineup .kid-card.gk { background: #E8FFC2; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; }
@media (max-width: 700px) { .vs { grid-template-columns: 1fr; } }
.vs .big { font-family: var(--display); font-size: 2.6rem; color: var(--sun); text-shadow: 0 4px 0 var(--ink); text-align: center; }
.team-chip { display: flex; align-items: center; gap: 10px; background: rgba(10,22,16,0.7); padding: 10px 14px; border-radius: 14px; border: 3px solid var(--ink); min-width: 0; }
.team-chip .crest { width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--ink); flex: none; display: grid; place-items: center; font-family: var(--display); color: var(--chalk); text-shadow: 0 2px 0 rgba(0,0,0,0.4); }
.team-chip b { font-family: var(--display); font-weight: 400; font-size: 1.25rem; display: block; }
.team-chip small { opacity: 0.8; }
.ladder { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 700px) { .ladder { grid-template-columns: repeat(3, 1fr); } }
.rung { background: rgba(10,22,16,0.7); border: 3px solid var(--ink); border-radius: 14px; padding: 8px; text-align: center; font-size: 0.82rem; font-weight: 800; min-width: 0; }
.rung.now { background: var(--sun); color: var(--ink); transform: translateY(-4px); box-shadow: 0 6px 0 var(--ink); }
.rung.won { background: var(--grass-3); }
.rung canvas { display: block; margin: 0 auto 4px; }
.bracket { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .bracket { grid-template-columns: 1fr; } }
.match-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--chalk); border: 2px solid var(--ink); border-radius: 10px; font-weight: 800; color: var(--ink); }
.match-line.you { background: #FFF1B0; }
.match-line .sc { font-family: var(--display); }

/* ---------- results */
.scoreline { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.scoreline .num { font-family: var(--display); font-size: clamp(3rem, 9vw, 5.5rem); color: var(--chalk); text-shadow: 0 6px 0 var(--ink); text-align: center; }
.scorers { font-size: 0.92rem; line-height: 1.6; }
.stat-table { width: 100%; border-collapse: collapse; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-table td { padding: 6px 4px; border-bottom: 2px dashed rgba(0,0,0,0.15); text-align: center; }
.stat-table td:nth-child(2) { color: var(--ink-2); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- how to play / settings */
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
kbd { font-family: var(--display); background: var(--chalk); color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 8px; padding: 2px 8px; font-size: 0.95rem; white-space: nowrap; display: inline-block; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px dashed rgba(0,0,0,0.15); }
.toggle:last-child { border-bottom: 0; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { font-family: var(--display); border: 2px solid var(--ink); background: var(--chalk); color: var(--ink); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: 0.95rem; }
.seg button.on { background: var(--sun); }
.confirm { background: #FFE3DC; border: 2px solid var(--tomato); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- pause */
.pause { width: min(420px, 100%); margin: auto 0; text-align: center; }
.pause .menu { margin: 16px auto 0; }

#toast { position: fixed; left: 50%; top: max(80px, env(safe-area-inset-top, 0px)); transform: translateX(-50%); background: var(--sun); color: var(--ink); font-family: var(--display);
  border: 3px solid var(--ink); border-radius: 12px; padding: 8px 16px; box-shadow: 0 5px 0 var(--ink); z-index: 5; }
.phone-note { display: none; font-size: 0.85rem; background: rgba(0,0,0,0.5); padding: 8px 12px; border-radius: 10px; }
@media (hover: none) and (pointer: coarse) { .phone-note { display: block; } }

.kid-card .badge.hot { background: var(--sun); }
.sortbar button { font-size: 0.85rem; padding: 5px 10px; }
/* formation board */
.board { position: relative; width: 100%; aspect-ratio: 1000 / 560; margin-top: 12px; border: 3px solid var(--ink); border-radius: 16px; overflow: hidden; touch-action: none;
  background: repeating-linear-gradient(90deg, #5DBB4C 0 6.25%, #53AE43 6.25% 12.5%); }
.board-lines { position: absolute; inset: 4%; border: 2px solid rgba(255,255,255,0.75); border-radius: 4px; pointer-events: none; }
.board-lines::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px solid rgba(255,255,255,0.75); }
.board-lines::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14%; aspect-ratio: 1; border: 2px solid rgba(255,255,255,0.75); border-radius: 50%; transform: translate(-50%, -50%); }
.spot { position: absolute; transform: translate(-50%, -50%); }
.chip { display: flex; flex-direction: column; align-items: center; width: 132px; padding: 4px 4px 6px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink); cursor: grab; user-select: none; text-align: center; }
.chip canvas { width: 48px; height: 48px; border-radius: 8px; background: #CDEBFA; }
.chip b { font-family: var(--display); font-weight: 400; font-size: 0.95rem; line-height: 1.1; }
.chip small { font-size: 0.68rem; font-weight: 800; color: var(--ink-2); }
.chip.sel { background: var(--sun); transform: translateY(-3px); }
.chip.offpos { outline: 2px dashed var(--tomato); outline-offset: 2px; }
.chip.ghost { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -50%) rotate(-4deg); opacity: 0.9; }
@media (max-width: 700px) { .chip { width: 68px; } .chip canvas { width: 34px; height: 34px; } .chip small { display: none; } }

.chip-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; width: 100%; margin-top: 4px; }
.chip-stats span { display: flex; flex-direction: column; align-items: center; background: rgba(0,0,0,0.06); border-radius: 5px; padding: 1px 0; }
.chip-stats i { font-style: normal; font-size: 0.5rem; font-weight: 800; letter-spacing: 0.02em; color: var(--ink-2); }
.chip-stats b { font-size: 0.9rem; line-height: 1; font-variant-numeric: tabular-nums; }
.chip-stats span.key { background: var(--sun); outline: 2px solid var(--ink); }
@media (max-width: 700px) { .chip-stats { display: none; } }
