:root{
  font-family:Inter,"Segoe UI",system-ui,-apple-system,sans-serif;
  color:#ece6da;
  background:#1c1d1b;
  color-scheme:dark;
  --panel:#242522;
  --panel-soft:#2b2c29;
  --line:#474741;
  --muted:#98958c;
  --accent:#efe2c8;
}
*{box-sizing:border-box}
body{margin:0;min-height:100vh;background:radial-gradient(circle at 50% 0,#292a27 0,#1f201e 48%,#1a1b19 100%);letter-spacing:.01em}
main{max-width:1180px;margin:auto;padding:22px 30px 30px}
button,select,input{font:inherit}
button{
  border:1px solid #494943;border-radius:5px;background:#252624;padding:8px 11px;color:#d6d0c5;
  font-size:11px;font-weight:600;letter-spacing:.02em;cursor:pointer;
  transition:background .15s,border-color .15s,color .15s,transform .15s;
}
button:hover:not(:disabled){background:#2d2e2b;border-color:#6b6961;color:#f4eee3}
button:active:not(:disabled){transform:translateY(1px)}
button:disabled{opacity:.3;cursor:default}
button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.primary{background:var(--accent);border-color:var(--accent);color:#272824;font-weight:750;box-shadow:none}
.primary:hover:not(:disabled){background:#f6ead4;border-color:#f6ead4;color:#1e1f1d}

header{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:5px}
.eyebrow{margin:0 0 5px;color:#8f8c83;font-size:9px;font-weight:700;letter-spacing:.22em;text-transform:uppercase}
h1{margin:0;color:#f0e9dc;font-size:23px;font-weight:650;letter-spacing:-.035em}
h1 .app-name{font:inherit;color:inherit}
h1 span{margin-left:14px;color:#99968d;font-size:10px;font-weight:600;letter-spacing:.11em;text-transform:uppercase}
.header-actions{display:flex;align-items:center;gap:7px}
.header-actions button{background:transparent;border-color:#45453f;color:#aaa69d;padding:8px 11px}

.scoreboard{position:relative;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:28px;width:min(580px,100%);margin:0 auto;padding:10px 0 11px}
.team{position:relative;font-size:10px;font-weight:720;letter-spacing:.18em}
.team:first-child{text-align:right}.team:last-child{text-align:left}
.team span{margin:0 8px;opacity:.42}
.blue,.coral{color:#e9e3d8}
#score{min-width:110px;text-align:center;color:#f1eadf;font-size:29px;font-weight:680;line-height:1;font-variant-numeric:tabular-nums;letter-spacing:-.04em}
#score .score-value{display:inline-block;color:#f1eadf;font:inherit}#score .score-separator{margin:0 9px;color:#77756e;font-weight:400}
.status{position:relative;display:flex;align-items:center;justify-content:space-between;padding:1px 5px 9px;font-size:10px;font-weight:650;letter-spacing:.1em;text-transform:uppercase}
#turn{color:#f0e9dc}
#phase{color:#aaa69d}
.turn-timer{position:absolute;z-index:2;top:50%;display:flex;align-items:baseline;justify-content:center;gap:2px;width:44px;margin-top:-10px;color:#efe2c8;font-variant-numeric:tabular-nums;letter-spacing:0;transition:color .15s ease,transform .15s ease,opacity .15s ease}
.turn-timer.team-left{right:calc(100% + 9px);left:auto}.turn-timer.team-right{right:auto;left:calc(100% + 9px)}
.turn-timer strong{font-size:20px;font-weight:720;line-height:1}.turn-timer small{color:#97938a;font-size:8px;font-weight:650;text-transform:lowercase}
.turn-timer.urgent{color:#c97863;transform:scale(1.08)}.turn-timer.paused{color:#77746d;transform:none}

canvas{display:block;width:100%;background:#252624;border:1px solid #4a4942;border-radius:7px;box-shadow:0 15px 34px #0b0c0a70;touch-action:none;transition:border-color .15s}
canvas:hover{border-color:#65635b}
#score .score-value.goal-pulse{animation:score-pulse .55s ease}@keyframes score-pulse{50%{transform:scale(1.09);color:#fff4df}}
.team.goal-team-pulse{animation:team-goal-pulse .55s ease}@keyframes team-goal-pulse{50%{opacity:.72}}
.match-end-overlay{position:fixed;z-index:30;inset:0;display:grid;place-items:center;padding:20px;background:#151614b8;backdrop-filter:blur(3px)}
.match-end-overlay section{min-width:min(330px,90vw);padding:24px;border:1px solid #55534c;border-radius:7px;background:#242522;text-align:center;box-shadow:0 18px 45px #090a086e}
.match-end-overlay h2{margin:5px 0 20px;color:#f1eadf;font-size:24px;letter-spacing:.05em}.match-end-actions{display:flex;justify-content:center;gap:8px}.match-end-actions button{min-width:112px}
.tempo{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-top:12px;padding:0 3px;font-size:10px}
.tempo strong{margin-right:5px;color:#9d9a91;text-transform:uppercase;letter-spacing:.12em}
.tempo button{display:inline-flex;align-items:center;gap:7px;padding:5px 10px;background:transparent}
.tempo button .type-icon{width:18px;height:18px;flex:0 0 18px;border-color:#68665f;transform:scale(.82)}
.tempo button[aria-pressed="true"]{background:#353530;border-color:#706d64;color:#eee7dc}
.tempo button[aria-pressed="true"] .type-icon{border-color:#aaa398}
.tempo span{margin-left:7px;color:#96938b;font-variant-numeric:tabular-nums}

.controls{display:flex;align-items:center;gap:7px;margin-top:12px}
.controls #undo{margin-left:auto}
.controls button:not(.primary){background:transparent;border-color:#484842;color:#aaa69d}
.controls .primary{padding-inline:16px}
kbd{margin-left:9px;border:0;background:transparent;opacity:.42;font:inherit}
#hint{min-height:18px;margin:10px 3px 4px;color:#b4afa5;font-size:11px}
footer{display:flex;justify-content:space-between;gap:20px;margin-top:9px;padding-top:9px;border-top:1px solid #3a3a36;color:#89867f;font-size:10px;line-height:1.6}
footer p{margin:0}footer span{color:#7d7a73}

.setup-screen{max-width:940px;padding-top:36px}
.setup-topbar{display:flex;align-items:center;justify-content:space-between;gap:16px}.setup-topbar .eyebrow{margin:0}
.language-switcher{display:flex;gap:3px}.language-switcher button{min-width:38px;padding:5px 8px;background:transparent;color:#918e85}.language-switcher button[aria-pressed="true"]{border-color:#8c877c;background:#353530;color:#f0e9dc}
.setup-screen h1{margin-bottom:24px;font-size:28px}
.setup-primary{display:grid;grid-template-columns:minmax(300px,1.45fr) repeat(2,minmax(150px,.72fr));gap:28px;padding:18px 2px 20px;border-top:1px solid #3b3b36;border-bottom:1px solid #3b3b36}
.setup-control{min-width:0}.setup-control h2{margin-bottom:9px}.setup-control select{background:#252624}
.mode-options{display:flex;align-items:center;gap:20px;min-height:37px}.mode-options label{display:flex;align-items:center;margin:0;white-space:nowrap}.mode-options small{font-size:10px}
.setup-formations{display:grid;grid-template-columns:1fr 1fr;gap:28px;margin-top:20px;padding:0 2px 20px;border-bottom:1px solid #353530}
.rosters{display:grid;grid-template-columns:1fr 1fr;gap:24px}
.setup-screen h2{margin:0 0 12px;color:#c8c1b5;font-size:10px;font-weight:750;letter-spacing:.12em;text-transform:uppercase}
.setup-screen h3{margin:0 0 10px;color:#aaa69d;font-size:11px}
.setup-screen label{display:block;margin:8px 0;color:#d5cfc4;font-size:12px}
.setup-screen small{margin-left:6px;color:#969289}
.setup-screen select{width:100%;padding:9px 10px;border:1px solid #51504a;border-radius:4px;background:#2a2b28;color:#e6dfd3}
.setup-screen>.primary{display:block;margin:18px 0 0 auto}
.player-type-row{display:grid!important;grid-template-columns:76px 24px 1fr!important;align-items:center;min-height:38px;margin:5px 0!important;font-size:11px!important}
#type-setup{margin-top:28px}[hidden]{display:none!important}
.setup-section-heading{display:flex;align-items:end;justify-content:space-between;gap:24px;margin:0 2px 15px;padding-bottom:12px;border-bottom:1px solid #353530}
.setup-section-heading h2{margin:0;color:#e3dccf;font-size:16px;letter-spacing:-.01em;text-transform:none}
.setup-section-heading .eyebrow{margin-bottom:3px;font-size:8px}
.setup-section-heading>p{max-width:430px;margin:0;color:#918e85;font-size:10px;line-height:1.5;text-align:right}
.team-builder{padding:14px 2px 2px;border-top:1px solid #494841;background:transparent}
.team-builder-title{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.team-builder-title h3{margin:0;color:#e3dccf;font-size:12px;letter-spacing:.04em;text-transform:uppercase}
.formation-choice{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:12px;margin:14px 0 9px;padding-top:12px;border-top:1px solid #3d3d38}
.formation-choice label{margin:0;color:#a9a59b;font-size:9px;font-weight:700;letter-spacing:.12em;text-transform:uppercase}
.formation-preview{display:grid;gap:9px}
.mini-pitch{position:relative;height:210px;overflow:hidden;border:1px solid #69645a;border-radius:5px;background:#d9ccb3}
.mini-pitch::before{content:"";position:absolute;inset:8px;border:1px solid #5f5d55aa}
.mini-pitch::after{content:"";position:absolute;top:8px;bottom:8px;left:50%;border-left:1px solid #5f5d5570}
.formation-slot{position:absolute;z-index:1;width:32px;height:32px;min-height:0;padding:0;border:2px solid #eee6d6;border-radius:50%;background:#292b2a;box-shadow:0 3px 7px #17171440;transform:translate(-50%,-50%)}
.formation-slot:hover:not(:disabled){background:#323432;border-color:#fff5df;transform:translate(-50%,-50%)}
.formation-slot.selected{outline:2px solid #c5a968;outline-offset:3px}
.formation-slot .type-icon{margin:auto;border:0}
.formation-slot.team-coral{border-color:#b8b2a7;background:#f1ede4;box-shadow:0 3px 7px #17171438}
.formation-slot.team-coral:hover:not(:disabled){border-color:#fffdf6;background:#faf7ef}
.formation-slot.team-coral .type-icon[data-type="fast"]::before{border-color:#252724}
.formation-slot.team-coral .type-icon[data-type="balanced"]::after{border-color:#252724}
.formation-slot.team-coral .type-icon[data-type="balanced"]::before{background:#252724}
.formation-slot.team-coral .type-icon[data-type="power"]::after{border-color:#252724}
.slot-picker{display:flex;align-items:center;flex-wrap:wrap;gap:5px;padding:9px 0 0;border-top:1px solid #373732;background:transparent}
.slot-picker>span{margin:0 3px;color:#aaa69d;font-size:9px;font-weight:750;letter-spacing:.1em;text-transform:uppercase}
.player-assignment{display:flex;align-items:center;gap:6px;min-height:30px;padding:5px 7px;background:transparent;font-size:9px;font-weight:550}
.player-assignment .type-icon{width:15px;height:15px;transform:scale(.72)}
.player-assignment.assigned{border-color:#bfa96f;background:#37352e;color:#f0e7d6}
.slot-help{margin:0;color:#7f7c74;font-size:9px;text-align:right}

.type-icon,.type-icon[data-type]{position:relative;display:block;width:18px;height:18px;border:1px solid #77736a;border-radius:50%;box-shadow:none;transform:none}
.type-icon::before,.type-icon::after{content:"";position:absolute;display:block}
.type-icon[data-type="fast"]::before{left:3.5px;top:3.5px;width:7px;height:7px;border-top:2px solid #e8e0d4;border-right:2px solid #e8e0d4;transform:rotate(45deg)}
.type-icon[data-type="fast"]::after{display:none}
.type-icon[data-type="balanced"]::after{left:2.5px;top:2.5px;width:9px;height:9px;border:2px solid #e8e0d4;border-radius:50%}
.type-icon[data-type="balanced"]::before{left:6px;top:6px;width:3px;height:3px;border-radius:50%;background:#e8e0d4}
.type-icon[data-type="power"]::after{left:2.5px;top:2.5px;width:9px;height:9px;border:2px solid #e8e0d4;border-radius:1px}

@media(max-width:700px){
  main{padding:15px 10px 22px}header{align-items:flex-start}h1 span{display:block;margin:4px 0 0}.header-actions{align-items:flex-end;flex-direction:column}
  .scoreboard{padding-top:10px;gap:12px}.team span{display:none}.status{font-size:9px}.controls{flex-wrap:wrap}
  .controls button{flex:1 1 130px}.tempo span{width:100%;margin:3px 0 0}.setup-primary,.setup-formations,.rosters{grid-template-columns:1fr}.setup-primary{gap:16px}.setup-formations,.rosters{gap:18px}.mode-options{flex-wrap:wrap;gap:10px 18px}.setup-section-heading{display:block}.setup-section-heading>p{margin-top:6px;text-align:left}.mini-pitch{height:190px}footer{display:block}footer p+p{margin-top:4px}
}
@media(pointer:coarse){
  button,.setup-screen select{min-height:44px}.tempo button{min-width:72px;padding:11px 15px}.controls button{flex:1 1 140px}.header-actions button{min-width:150px}.player-type-row{min-height:48px}
}

.rotate-hint{display:none}

@media (orientation:portrait) and (pointer:coarse){
  #game-screen:not([hidden]) .rotate-hint{
    position:fixed;z-index:20;inset:0;display:grid;place-items:center;padding:24px;
    background:#1c1d1bf2;color:#ece6da;font-size:13px;text-align:center;letter-spacing:.04em;
  }
}

@media (orientation:landscape) and (max-height:600px) and (pointer:coarse){
  #game-screen{
    position:relative;width:100%;max-width:none;height:100dvh;margin:0;
    padding:max(3px,env(safe-area-inset-top)) max(5px,env(safe-area-inset-right)) max(3px,env(safe-area-inset-bottom)) max(5px,env(safe-area-inset-left));
    display:grid;grid-template-columns:68px minmax(0,1fr) 76px;grid-template-rows:28px minmax(0,1fr);
    gap:3px;overflow:hidden;background:#1c1d1b;
  }
  #game-screen header{position:absolute;z-index:5;top:3px;right:max(5px,env(safe-area-inset-right));width:auto;margin:0}
  #game-screen header>div:first-child{display:none}
  #game-screen .header-actions{flex-direction:row;gap:3px}
  #game-screen .header-actions button{
    position:relative;width:27px;min-width:27px;height:23px;min-height:23px;padding:0;overflow:hidden;
    color:transparent;font-size:0;background:#252624e8;
  }
  #game-screen .header-actions button::after{position:absolute;inset:0;display:grid;place-items:center;color:#d8d1c6;font-size:13px}
  #game-screen #new-match::after{content:"⋯";font-size:17px;line-height:1}
  #game-screen #reset::after{content:"↻"}
  #game-screen .scoreboard{grid-column:2;grid-row:1;align-self:center;width:245px;margin:0 auto;padding:0;gap:8px}
  #game-screen .team{font-size:8px;letter-spacing:.13em}
  #game-screen .team span{display:none}
  #game-screen #score{min-width:72px;font-size:20px}
  #game-screen #score span{margin:0 5px}
  #game-screen .status{grid-column:1;grid-row:1 / 3;z-index:2;align-self:start;display:block;padding:6px 2px 0;text-align:center;font-size:7px;line-height:1.5;letter-spacing:.06em}
  #game-screen #turn{display:block}
  #game-screen #phase{display:block;margin-top:3px;color:#85827a;font-size:6px}
  #game-screen .turn-timer{position:fixed;z-index:5;top:32px;right:auto;width:42px;margin:0;transition:left .18s ease,color .15s ease,transform .15s ease,opacity .15s ease}
  #game-screen .turn-timer.team-left{left:max(15px,calc(env(safe-area-inset-left) + 11px))}
  #game-screen .turn-timer.team-right{left:calc(100% - max(19px,calc(env(safe-area-inset-right) + 15px)) - 42px)}
  #game-screen .turn-timer strong{font-size:18px}#game-screen .turn-timer small{font-size:7px}
  #game-screen canvas{
    grid-column:2;grid-row:2;align-self:center;justify-self:center;
    width:auto;height:100%;max-width:100%;max-height:100%;aspect-ratio:1080/664;
  }
  #game-screen .tempo{
    position:absolute;z-index:3;left:max(5px,env(safe-area-inset-left));top:76px;width:62px;
    display:grid;grid-template-columns:repeat(3,1fr);gap:2px;margin:0;padding:0;
  }
  #game-screen .tempo strong{grid-column:1 / 4;margin:0 0 2px;font-size:7px;text-align:center}
  #game-screen .tempo button{display:grid;place-items:center;min-width:0;min-height:28px;padding:0;font-size:0}
  #game-screen .tempo button .type-icon{grid-area:1/1;width:18px;height:18px;margin:0;transform:scale(.72)}
  #game-screen .tempo-label{display:none}
  #game-screen #tempo-info{display:none}
  #game-screen .controls{display:contents}
  #game-screen #undo,#game-screen #clear{
    position:absolute;z-index:4;left:max(16px,calc(env(safe-area-inset-left) + 11px));width:42px;height:38px;min-height:38px;padding:0;
    overflow:hidden;color:transparent;font-size:0;background:#252624e8;
  }
  #game-screen #undo{bottom:51px}#game-screen #clear{bottom:8px}
  #game-screen #undo::after,#game-screen #clear::after{position:absolute;inset:0;display:grid;place-items:center;color:#ddd6ca;font-size:18px}
  #game-screen #undo::after{content:"↶"}#game-screen #clear::after{content:"×";font-size:22px;font-weight:300}
  #game-screen #confirm{
    position:absolute;z-index:4;right:max(8px,calc(env(safe-area-inset-right) + 4px));top:50%;
    width:60px;height:76px;min-height:76px;padding:0;border-radius:8px;overflow:hidden;color:transparent;font-size:0;transform:translateY(-35%);
  }
  #game-screen #confirm::after{content:"▶";position:absolute;inset:0;display:grid;place-items:center;color:#272824;font-size:25px}
  #game-screen #confirm:active:not(:disabled){transform:translateY(calc(-35% + 1px))}
  #game-screen kbd,#game-screen #hint,#game-screen footer{display:none}
}

@media (orientation:landscape) and (max-height:390px) and (pointer:coarse){
  #game-screen{grid-template-columns:62px minmax(0,1fr) 68px;grid-template-rows:24px minmax(0,1fr)}
  #game-screen .scoreboard{width:210px}.scoreboard #score{font-size:18px}
  #game-screen .tempo{top:60px;width:56px}.tempo strong{display:none}
  #game-screen #undo,#game-screen #clear{left:max(12px,calc(env(safe-area-inset-left) + 8px));width:38px;height:34px;min-height:34px}
  #game-screen #undo{bottom:45px}#game-screen #confirm{right:max(5px,env(safe-area-inset-right));width:54px;height:68px;min-height:68px}
}
