:root {
  color-scheme: light;
  --ink: #192e26;
  --forest: #223f32;
  --moss: #395344;
  --muted: #4c5d4d;
  --light: #fff9eb;
  --cream: #f4ecd8;
  --paper: #f9f2e2;
  --line: #c9bd9e;
  --blue: #244e78;
  --blue-wash: #e6edf2;
  --red: #943d31;
  --red-wash: #f4e3d8;
  --gold: #f2ca74;
  --body: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  --display: Georgia, "Times New Roman", serif;
  font: 16px/1.45 var(--body);
  background: var(--cream);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 290px;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--cream);
  background-image: url("assets/paper.svg");
}
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled, button[aria-disabled="true"] { cursor: default; }
button, summary, select { touch-action: manipulation; }
button:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid #176283;
  outline-offset: 3px;
  position: relative;
  z-index: 3;
}
[data-focus]:focus { outline: none; }
[hidden] { display: none !important; }
svg { display: block; width: 23px; height: 23px; flex: none; }
img { max-width: 100%; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--display); }
.frame { width: min(100% - 96px, 1456px); margin-inline: auto; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-inner {
  width: min(100% - 96px, 1456px);
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 76px;
  gap: 12px;
}
.wordmark, .top-actions { display: flex; align-items: center; gap: 12px; }
.wordmark { font-family: var(--display); font-weight: bold; font-size: 1.42rem; letter-spacing: -.035em; white-space: nowrap; padding: 2px 6px 2px 0; min-height: 44px; border: 0; border-radius: 4px; background: transparent; }
.wordmark:hover > span:last-child { text-decoration: underline; text-underline-offset: .15em; }
.mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--ink); color: var(--cream); border-radius: 4px; }
.mark svg { width: 24px; height: 24px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  min-height: 48px;
  padding: .55em 1em;
  border: 1px solid transparent;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: .01em;
  text-align: center;
}
.button svg { width: 20px; height: 20px; }
.button.primary { background: var(--ink); color: var(--light); border-color: var(--ink); box-shadow: 0 3px 0 #0f2019; }
.button.primary:hover:not(:disabled) { background: var(--moss); }
.button.primary:active:not(:disabled) { box-shadow: none; transform: translateY(2px); }
.button.primary:disabled { background: #d7d1bf; border-color: #bcb29d; box-shadow: none; color: #536054; }
.button.secondary { border-color: #a9a487; background: var(--light); }
.button.secondary:disabled { opacity: .48; }
.button.secondary:hover:not(:disabled), .button.plain:hover { background: #e8dfc7; }
.button.plain { background: transparent; }
.top-actions .button { padding-inline: 9px; }
.top-actions .button + .button { border-left-color: var(--line); border-top-left-radius: 0; border-bottom-left-radius: 0; padding-left: 14px; }

.home { margin-top: clamp(24px, 5vh, 60px); }
.hero {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  min-height: clamp(480px, 72vh, 738px);
  border: 1px solid #8e9b77;
  background: var(--paper) url("assets/paper.svg");
  position: relative;
}
.hero-copy {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
  padding: clamp(27px, 5vh, 68px) clamp(26px, 5.2vw, 90px);
  min-width: 0;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3e5546;
  font-size: .79rem;
  font-weight: 800;
  letter-spacing: .145em;
  text-transform: uppercase;
}
.eyebrow > span { width: 18px; height: 2px; background: #ac6933; flex: none; }
.hero h1 {
  margin-block: 22px 24px;
  font-size: clamp(50px, 7.3vw, 125px);
  line-height: .97;
  letter-spacing: -.075em;
}
.hero h1 span { color: var(--forest); font-style: italic; }
.hero-subtitle { margin: 0 0 10px; font-size: clamp(1.13rem, 1.7vw, 1.48rem); font-weight: 800; }
.hero-lead { color: var(--muted); line-height: 1.5; font-size: clamp(1.05rem, 1.55vw, 1.45rem); max-width: 27ch; }
.hero-button { min-width: min(100%, 218px); padding: 14px 21px; margin-top: 30px; min-height: 58px; justify-content: space-between; font-size: 1.07rem; }
.home-mode { margin-top: 22px; color: var(--muted); display: flex; gap: 9px; align-items: center; font-weight: bold; font-size: .89rem; }
.home-mode svg { width: 19px; height: 19px; }
.hero-art {
  background: #627745 url("assets/stadium.jpg") center center / cover no-repeat;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-left: 1px solid #8e9b77;
}
.hero-art::before {
  content: "";
  position: absolute;
  inset: auto -12% 1% -12%;
  height: 39%;
  border: 2px solid #fff0c8b3;
  transform: perspective(350px) rotateX(56deg);
  transform-origin: bottom;
}
.hero-art img { position: absolute; object-fit: contain; object-position: center bottom; filter: drop-shadow(2px 12px 7px #3a351e65); }
.hero-lion { height: 64%; width: 47%; left: 4%; bottom: 13%; }
.hero-fox { height: 51%; width: 40%; left: 53%; bottom: 10%; }
.hero-ball { position: absolute; width: clamp(38px, 6vw, 84px); left: 45%; bottom: 13%; filter: drop-shadow(3px 8px 3px #312c206a); transform: rotate(-17deg); }
.hero-ball svg { width: 100%; height: auto; }
.art-caption {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--cream);
  padding: 9px 16px;
  font-size: .85rem;
  font-weight: bold;
  letter-spacing: .04em;
}
.art-caption svg { width: 16px; height: 16px; }
.home-footer { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-block: 16px; color: var(--muted); font-size: .87rem; }

.flow { padding-block: 14px 22px; max-width: 1180px; }
.step-header .back { margin-left: -10px; }
.step-title { padding-block: 4px 14px; }
.step-title h1 { font-size: clamp(2.6rem, 5.2vw, 4.35rem); line-height: 1.02; letter-spacing: -.065em; margin-block: .12em .12em; }
.step-title > p:last-child { color: var(--muted); font-size: 1.05rem; }
.setup-layout { display: grid; grid-template-columns: minmax(0, 2.45fr) minmax(210px, 1fr); align-items: start; gap: 24px; }
.paper { border: 1px solid var(--line); background: var(--paper); padding: clamp(14px, 2.1vw, 26px); }
fieldset { padding: 0; border: 0; min-width: 0; margin: 0 0 17px; }
legend { font-weight: 800; font-size: 1.13rem; margin-bottom: 9px; padding: 0; }
.mode-grid, .range-grid, .operation-grid { display: grid; gap: 9px; }
.mode-grid { grid-template-columns: repeat(2, 1fr); }
.range-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.operation-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mode-choice, .range-choice, .operation { position: relative; cursor: pointer; }
:is(.mode-choice, .range-choice, .operation) > input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
:is(.mode-choice, .range-choice, .operation) > span { display: grid; border: 1px solid var(--line); background: #fff8e9; border-radius: 4px; }
:is(.mode-choice, .range-choice, .operation) > input:checked + span { background: #e1e9d8; border-color: #477350; box-shadow: inset 0 0 0 1px #477350; }
:is(.mode-choice, .range-choice, .operation) > input:focus-visible + span { outline: 3px solid #176283; outline-offset: 2px; }
.mode-choice .mode-box { grid-template-columns: auto 1fr; column-gap: .75rem; align-items: center; min-height: 76px; padding: 10px 13px; }
.mode-box i { grid-row: span 2; background: #344f40; color: var(--light); padding: 7px; border-radius: 4px; align-self: center; }
.mode-box small { color: var(--muted); font-size: .83rem; }
.range-choice > span { min-height: 48px; display: grid; place-items: center; font-weight: 700; font-size: clamp(.72rem, 1.35vw, 1rem); }
.operation > span { min-height: 51px; grid-auto-flow: column; justify-content: center; align-items: center; gap: 7px; font-weight: 700; }
.operation b { font-size: 1.5rem; line-height: .8; }
.settings-note { font-size: .87rem; margin-top: 7px; min-height: 22px; color: var(--muted); }
.advanced { border-top: 1px solid var(--line); }
.advanced > summary { cursor: pointer; font-weight: 700; min-height: 48px; display: flex; justify-content: space-between; align-items: center; padding-top: 7px; gap: 8px; }
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary svg { width: 21px; height: 21px; }
.advanced[open] > summary svg { transform: rotate(180deg); }
.advanced-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding-block: 9px 15px; }
.exercise-details { border-top: 1px solid var(--line); padding-bottom: 5px; }
.exercise-details > summary { min-height: 44px; padding-block: 10px; cursor: pointer; font-weight: 800; }
.exercise-details > div { padding-bottom: 10px; }
.exercise-option { display: flex; gap: 7px; align-items: center; padding: 6px 8px; min-height: 44px; cursor: pointer; }
.exercise-option input { width: 18px; height: 18px; flex: none; accent-color: var(--forest); }
.exercise-option span { min-width: 0; }
.exercise-option small { display: block; color: var(--muted); line-height: 1.25; }
.focus-group { margin: 10px 0; }
.focus-options, .exercise-ops { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 4px; }
.focus-options .exercise-option { background: #fff9eb; border: 1px solid var(--line); border-radius: 3px; }
.focus-options .exercise-option:has(input:checked) { background: #e6ecdc; border-color: #52775d; }
.row-picker { display: flex; flex-wrap: wrap; margin-top: 8px; }
.row-picker .exercise-option { border: 1px solid var(--line); border-radius: 3px; margin: 0 3px 3px 0; }
.exercise-preview { margin-top: 8px; padding: 9px 12px; background: #e9eee2; border-left: 3px solid #507358; }
.exercise-preview h3 { margin: 0; font-size: .99rem; }
.exercise-preview ul { padding: 0; margin: 5px 0 0; list-style: none; }
.exercise-preview li { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .87rem; }
.select-field { display: grid; gap: 5px; font-weight: 700; }
select { min-height: 44px; padding: 5px 8px; background: var(--light); border: 1px solid #a9a487; border-radius: 4px; color: var(--ink); width: 100%; }
.check-line { display: flex; align-items: center; gap: 8px; min-height: 44px; align-self: end; font-weight: 700; }
.check-line input { width: 21px; height: 21px; accent-color: var(--ink); }
.preset { border-top: 1px solid var(--line); padding-top: 13px; }
.preset h2 { font-family: var(--body); font-size: 1rem; padding-bottom: 8px; }
.preset-row { display: grid; grid-template-columns: 1fr minmax(66px, auto) minmax(92px, auto); align-items: center; gap: 7px; padding-block: 3px; }
#preset-feedback { min-height: 1.5em; padding-top: 5px; color: var(--muted); }
.setup-side { min-width: 0; }
.arena-options { display: grid; gap: 7px; }
.arena-choice { position: relative; display: grid; border: 1px solid #7d8c76; border-radius: 4px; background: var(--arena-image) center 38% / cover; color: white; isolation: isolate; overflow: hidden; }
.arena-choice input { position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.arena-choice span { padding: 9px; min-height: clamp(82px, 10.3vh, 118px); display: flex; align-items: end; background: linear-gradient(0deg,#11261ee8,#11261e00 62%); font-weight: 800; border: 2px solid transparent; }
.arena-choice input:checked + span { border-color: var(--gold); }
.arena-choice input:checked + span::before { content: "✓"; padding-right: 7px; color: var(--gold); }
.arena-choice:focus-within { outline: 3px solid #176283; outline-offset: 2px; }
.setup-side #solo-style legend { margin-bottom: 4px; }
.setup-side #solo-style .select-field > span { display: none; }
.setup-ticket { z-index: 2; width: 100%; background: var(--ink); color: var(--light); padding: 16px; }
.setup-ticket > b { display: flex; align-items: center; gap: 7px; letter-spacing: .07em; text-transform: uppercase; font-size: .83rem; }
.setup-ticket > b svg { width: 17px; height: 17px; }
.setup-ticket p { margin: 8px 0 14px; font-size: .95rem; }
.setup-ticket .button.primary { width: 100%; justify-content: space-between; color: var(--ink); background: var(--gold); border-color: var(--gold); }
.setup-ticket .button.primary:hover { background: #ffdb8d; }

.team-flow { --team: var(--blue); --wash: var(--blue-wash); }
.team-flow[data-team="red"] { --team: var(--red); --wash: var(--red-wash); }
.team-flow .step-title { padding-bottom: 8px; }
.team-flow .step-title h1 { color: var(--team); font-size: clamp(2.6rem, 4.7vw, 3.9rem); }
.team-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-block: 7px 15px; }
.slot { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 54px; padding: 6px 10px; border: 1px dashed #9b9980; border-radius: 4px; }
.slot.filled { background: var(--wash); border: 1px solid var(--team); color: var(--team); text-align: left; }
.slot.filled img { width: 38px; height: 41px; object-fit: contain; flex: none; }
.slot.filled[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--team); }
.slot.filled[aria-pressed="true"] small { font-weight: 800; }
.slot b, .slot small { display: block; line-height: 1.16; }
.slot b { overflow-wrap: anywhere; }
.slot small { margin-top: 3px; font-size: .77rem; }
.slot svg { width: 17px; height: 17px; }
.animal-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.animal-card {
  position: relative;
  border: 1px solid var(--line);
  padding: 10px 4px 0;
  min-width: 0;
  border-radius: 4px;
  display: grid;
  justify-items: center;
  grid-template-rows: 1fr auto;
  background: linear-gradient(124deg, #eee9d9 0 57%, #fff8e9 57% 59%, #f7eedc 59%);
}
.animal-card:not(:disabled):hover { border-color: var(--team); background-color: var(--wash); }
.animal-card[aria-pressed="true"] { background-color: var(--wash); border-color: var(--team); box-shadow: inset 0 0 0 2px var(--team); }
.animal-card:disabled img { opacity: .45; }
.animal-card img { object-fit: contain; height: clamp(85px, 13vh, 146px); width: 100%; pointer-events: none; }
.jersey { position: absolute; top: 7px; left: 8px; color: var(--team); font: italic 900 clamp(1.05rem,2.25vw,1.8rem)/1 var(--body); }
.selected-icon { display: none; position: absolute; top: 5px; right: 5px; background: var(--team); color: white; border-radius: 3px; padding: 2px; }
.selected-icon svg { width: 16px; height: 16px; }
.animal-card[aria-pressed="true"] .selected-icon { display: block; }
.animal-name { font-weight: 800; display: grid; align-content: center; min-height: 33px; width: 100%; }
.animal-name small { font-size: .72rem; color: var(--muted); font-weight: normal; }
.flow-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.flow-footer .primary { min-width: 150px; }
#lineup-note { min-width: 0; color: var(--muted); }

body[data-view="match"] { background-color: #233b30; }
body[data-view="match"] #app { min-height: 100dvh; height: 100dvh; display: flex; flex-direction: column; }
body[data-view="match"] .topbar { background: #192e26; color: var(--light); border-color: #4c6151; }
body[data-view="match"] .topbar-inner { min-height: 57px; width: min(100% - 36px, 1600px); }
body[data-view="match"] .mark { color: var(--ink); background: var(--gold); width: 34px; height: 34px; }
body[data-view="match"] .top-actions .button:hover { background: #354e40; }
body[data-view="match"] .top-actions .button + .button { border-left-color: #607162; }
body[data-view="match"] .top-actions .button[aria-pressed="false"] { color: #b6c4b8; }
body[data-view="match"] .top-actions .button[aria-pressed="true"] { color: #f5d894; }
body[data-view="match"] button:focus-visible { outline-color: #efb653; }
.match-shell { width: min(100% - 36px, 1600px); padding-block: 8px; flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(210px, 1fr) auto auto; }
.arena { position: relative; min-height: 0; }
[data-arena="forest"] { --arena-image: url("assets/stadium.jpg"); }
[data-arena="champions"] { --arena-image: url("assets/champions.jpg"); }
[data-arena="street"] { --arena-image: url("assets/street.jpg"); }
.stadium {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  height: 100%;
  border: 1px solid #84946b;
  border-radius: 5px 5px 0 0;
  background: #395344 var(--arena-image) center 62% / cover no-repeat;
}
[data-arena="champions"] .stadium { border-color: #6b8190; background-position: center 64%; }
[data-arena="street"] .stadium { border-color: #9c7d65; background-position: center 60%; }
.pitch-lines { width: 100%; height: 100%; position: absolute; inset: 0; stroke: #fff2ca; stroke-width: 2.8; opacity: .73; }
.center-mark { fill: #fff2ca; }
.goals-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.goal { --net-color: #e9e3ca; --frame-color: #fff4d6; }
.goal-shadow { fill: #202820; opacity: .23; }
.goal-net { transform-box: fill-box; transform-origin: center; }
.net-surface { fill: #d7d0ad; opacity: .09; }
.net-mesh, .net-outline, .goal-frame, .goal-frame-shadow { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.net-mesh { stroke: var(--net-color); stroke-width: .85; opacity: .79; }
.net-outline { stroke: var(--net-color); stroke-width: 2; opacity: .8; }
.goal-frame-shadow { stroke: #434a40; stroke-width: 6.3; opacity: .83; }
.goal-frame { stroke: var(--frame-color); stroke-width: 4.1; }
[data-arena="champions"] .goal { --net-color: #d5e0df; --frame-color: #f0f5f4; }
[data-arena="street"] .goal { --net-color: #ded8cb; --frame-color: #ebe2d3; }
.footballer {
  position: absolute;
  width: clamp(40px, 9.2%, 150px);
  height: calc(30.5% * var(--scale));
  transform: translate(-50%, -100%);
  transform-origin: 50% 95%;
  pointer-events: none;
}
.footballer::after { content: ""; z-index: -1; position: absolute; bottom: -1%; left: 13%; width: 75%; height: 8%; background: #34432660; border-radius: 50%; filter: blur(2px); }
.footballer img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; transform-origin: 50% 88%; }
.footballer.red { --lean: 13deg; }
.footballer.blue { --lean: -13deg; }
.footballer.on-ball::before { content: ""; position: absolute; inset: auto 17% -3%; height: 12%; border: 1.5px solid #fff3c9; border-radius: 50%; opacity: .8; }
.passing img { animation: kick 440ms ease-out; }
.shooting img { animation: shot 560ms ease-out; }
.saving img { animation: save 500ms ease-in-out; }
.cheering img { animation: cheer 660ms var(--delay) ease-in-out 2; }
@keyframes kick { 0%, 100% { transform: none; } 36% { transform: translateY(-8%) rotate(var(--lean)); } }
@keyframes shot { 0%, 100% { transform: none; } 28% { transform: rotate(calc(-.52 * var(--lean))); } 56% { transform: translateY(-12%) rotate(var(--lean)); } }
@keyframes save { 0%, 100% { transform: none; } 54% { transform: translateY(-12%) rotate(var(--lean)); } }
@keyframes cheer { 0%, 100% { transform: none; } 38% { transform: translateY(calc(-1 * var(--jump))) rotate(7deg); } 66% { transform: rotate(-4deg); } }
.stadium[data-phase="goal"][data-scoring="blue"] .goal-red .goal-net,
.stadium[data-phase="goal"][data-scoring="red"] .goal-blue .goal-net { animation: net-ripple 460ms ease-out; }
@keyframes net-ripple { 24% { transform: translate(2%, -3%) scaleY(1.09) skewY(-4deg); } 57% { transform: translate(-1%, 1%) skewY(2deg); } }
.frozen *, .frozen *::after { animation-play-state: paused !important; }
.ball, .ball-shadow { position: absolute; z-index: 2; left: 50%; top: 72%; pointer-events: none; }
.ball { width: clamp(23px, 3.2vw, 54px); transform: translate(-50%, -91%); }
.ball svg { width: 100%; height: auto; }
.ball-shadow { width: clamp(18px, 2.8vw, 43px); height: 8px; background: #2f3c26bb; border-radius: 50%; filter: blur(2px); transform: translate(-50%, -50%); }
.scoreboard { position: absolute; z-index: 4; left: 50%; top: 3px; transform: translateX(-50%); width: clamp(158px, 19.2%, 230px); isolation: isolate; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.referee { height: clamp(40px, 9.1vh, 83px); width: auto; object-fit: contain; margin-bottom: -4px; filter: drop-shadow(0 3px 3px #2b261c6c); }
.arena:has(.stadium[data-phase="goal"]) .referee { animation: referee-call 520ms ease-out; }
@keyframes referee-call { 40% { transform: rotate(-7deg) translateY(-5px); } }
.scoreline {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr .95fr 1fr;
  text-align: center;
  color: var(--light);
  background: #263d32;
  padding: 4px;
  gap: 4px;
  border: 1px solid #dcd7ad;
  box-shadow: 0 3px 12px #242b206e;
  border-radius: 6px;
}
.scoreline div { display: grid; align-content: center; padding: 3px 2px; }
.scoreline .blue, .final-score .blue { background: var(--blue); }
.scoreline .red, .final-score .red { background: var(--red); }
.scoreline div > span { font-size: .77rem; font-weight: 800; }
.scoreline strong { font: bold clamp(1.25rem, 3.35vh, 2.05rem)/.95 var(--body); font-variant-numeric: tabular-nums; }
.score-middle b { font-size: .82rem; color: var(--gold); white-space: nowrap; }
.field-message {
  position: absolute;
  z-index: 5;
  top: 69%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--gold);
  padding: 8px 20px;
  border-radius: 5px;
  box-shadow: 0 7px 20px #13241cb0;
  color: var(--light);
  background: var(--ink);
  white-space: nowrap;
  font: 800 clamp(1.45rem, 3.65vw, 3.5rem)/1.1 var(--body);
  letter-spacing: -.025em;
}
[data-phase="goal"][data-scoring="blue"] .field-message { background: var(--blue); }
[data-phase="goal"][data-scoring="red"] .field-message { background: var(--red); }

.math-deck { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
[data-mode="solo"] .math-deck { grid-template-columns: minmax(240px, 1fr) minmax(0, 1.25fr); }
.solo-panel {
  --turn: #943d31;
}
.computer-tracker { display: grid; gap: 6px; padding: 8px; }
.solo-label { display: flex; align-items: center; gap: 8px; font-size: clamp(1rem, 1.55vw, 1.4rem); font-weight: 800; }
.turn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--turn); flex: none; }
.solo-panel p { color: var(--muted); line-height: 1.35; max-width: 30ch; }
.solo-panel p:empty { display: none; }
.computer-tracker progress { width: 100%; height: 8px; accent-color: var(--red); }
.rules-credit { margin-top: 14px; font-size: .88rem; }
.rules-credit a { color: var(--blue); }
.math-panel {
  --team: var(--blue);
  --wash: var(--blue-wash);
  background: var(--paper);
  border-top: 5px solid var(--team);
  border-radius: 3px 3px 5px 5px;
  padding: 11px 12px 12px;
  display: grid;
  grid-template-columns: minmax(0, .94fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.math-panel.red { --team: var(--red); --wash: var(--red-wash); }
.team-name { display: flex; align-items: center; gap: 5px; color: var(--team); font-size: 1rem; white-space: nowrap; }
.team-name svg { width: 16px; height: 16px; }
.team-name span { margin-left: .25em; font-weight: bold; }
.problem { font-weight: 900; font-size: clamp(1.45rem, 3.25vw, 3.65rem); color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.17; min-height: 1.17em; margin-block: 3px 4px; overflow-wrap: anywhere; }
.problem > span { display: inline-block; white-space: nowrap; }
.problem.long-problem { font-size: clamp(1.18rem, 2.15vw, 2.6rem); }
.answer-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 39px; }
.answer {
  background: var(--wash);
  border: 1px solid color-mix(in srgb, var(--team) 68%, white);
  color: var(--team);
  border-radius: 4px;
  padding: 3px 8px;
  min-width: 65px;
  min-height: 39px;
  font-weight: 800;
  font-size: clamp(1.18rem, 2.3vw, 2.4rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.06;
}
.answer.wrong { background: #f8e6b2; border-color: #906a1c; }
.answer.correct { background: #d8eed7; color: #194429; border-color: #498261; }
.answer.long-answer { font-size: clamp(1.15rem, 2vw, 2rem); }
.panel-feedback { font-size: clamp(.69rem, 1vw, .9rem); color: #614917; line-height: 1.15; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(44px, 1fr)); gap: 4px; touch-action: none; user-select: none; }
.key {
  width: 100%;
  min-width: 44px;
  min-height: clamp(44px, 6.1vh, 65px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #a8a07e;
  border-radius: 4px;
  box-shadow: none;
  background: #fff9ea;
  font-size: clamp(1.28rem, 2.75vw, 2.5rem);
  font-weight: 800;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.key-submit { background: var(--team); color: white; border-color: var(--team); }
.key-delete { background: var(--wash); }
.key[aria-disabled="true"] { opacity: .57; }
.key:hover:not([aria-disabled="true"]):not(.key-submit) { background: #eee5ce; }
.key:active:not([aria-disabled="true"]) { transform: translateY(2px); box-shadow: none; }
.rotate-hint { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.game-dialog {
  color: var(--ink);
  background: var(--paper) url("assets/paper.svg");
  width: min(535px, calc(100% - 32px));
  border: 1px solid #b1aa8d;
  border-top: 6px solid var(--forest);
  border-radius: 5px;
  box-shadow: 0 12px 35px #0e1c16a6;
  padding: 0;
}
.game-dialog::backdrop { background: #172a22b8; }
.dialog-body { padding: clamp(18px, 5vw, 32px); }
.dialog-body h2 { font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.05; letter-spacing: -.04em; margin-bottom: 14px; }
.dialog-body > p { color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.rules-list { padding-left: 21px; }
.rules-list li { padding-bottom: 7px; }
.keyboard-help summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; gap: 6px; font-weight: 700; }
.keyboard-help p { color: var(--muted); }
.result-board { padding: 14px; border-radius: 5px; background: #294239 var(--arena-image) center 67% / cover; }
.final-score { width: max-content; margin: 0 auto; display: flex; gap: 10px; align-items: center; padding: 4px; border: 1px solid #dcd7ad; border-radius: 5px; background: #1d3129; color: white; font-weight: 800; font-size: 1.8rem; }
.final-score > div { min-width: 57px; text-align: center; padding: 3px 6px; display: grid; line-height: 1.08; border-radius: 3px; }
.final-score small { font-size: .73rem; }
.winner-team { display: flex; align-items: end; justify-content: space-between; gap: 6px; margin-top: 8px; }
.winner-team img { width: 24%; height: 107px; object-fit: contain; object-position: bottom; filter: drop-shadow(0 3px 3px #1e251cc0); }
.match-stats { margin-top: 10px; font-size: .93rem; }
.match-stats summary { min-height: 44px; align-content: center; cursor: pointer; font-weight: 700; }
.match-stats table { width: 100%; border-collapse: collapse; }
.match-stats th, .match-stats td { padding: 4px; text-align: left; border-bottom: 1px solid var(--line); }

.calm *, .calm *::before, .calm *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 1210px) {
  .math-panel { grid-template-columns: minmax(0, 1fr); gap: 7px; padding: 7px 10px 10px; }
  .math-panel .panel-info { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 44px; }
  .math-panel .panel-info:has(.long-problem) { grid-template-columns: minmax(0, 1fr) auto; }
  .panel-info:has(.long-problem) .team-name { grid-column: 1 / -1; }
  .panel-info:has(.long-problem) .problem { text-align: left; }
  .problem { text-align: center; font-size: clamp(1.28rem, 3.5vw, 2.8rem); }
  .team-name { font-size: .86rem; }
  .panel-feedback { max-width: 62px; }
}
@media (max-width: 950px) {
  .frame, .topbar-inner { width: calc(100% - 40px); }
  body[data-view="match"] .top-actions { gap: 1px; }
  body[data-view="match"] .top-actions .button { min-width: 44px; padding-inline: 8px; }
  body[data-view="match"] .top-actions .button:not(.home-button) span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
  .hero-copy { padding: 25px; }
  .hero h1 { font-size: clamp(50px, 7.8vw, 94px); }
  .setup-layout { grid-template-columns: minmax(0, 1fr) minmax(185px, .42fr); gap: 12px; }
  .operation > span { gap: 4px; font-size: .86rem; }
  .animal-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (orientation: portrait) {
  .match-shell { max-height: 1000px; }
  [data-mode="duel"] .rotate-hint { display: block; padding-block: 8px; color: var(--cream); font-size: .79rem; }
}
@media (max-width: 720px) and (orientation: portrait), (max-width: 605px) {
  .frame, .topbar-inner { width: calc(100% - 24px); }
  .topbar-inner { min-height: 60px; }
  .wordmark { gap: 6px; font-size: 1rem; }
  .mark { width: 33px; height: 33px; }
  .top-actions { gap: 3px; }
  .top-actions .button { padding-inline: 6px; font-size: .84rem; }
  .top-actions .button + .button { padding-left: 7px; }
  .home { margin-top: 12px; }
  .hero { display: flex; flex-direction: column; min-height: 0; }
  .hero-copy { padding: 21px 19px 24px; }
  .hero h1 { font-size: clamp(40px, 11vw, 77px); margin-block: 13px 11px; }
  .hero h1 span { display: inline; }
  .hero-lead { font-size: 1.04rem; }
  .hero-button { margin-top: 18px; min-height: 50px; }
  .home-mode { margin-top: 15px; }
  .hero-art { min-height: clamp(240px, 58vw, 365px); border-left: 0; border-top: 1px solid #8e9b77; }
  .home-footer { font-size: .75rem; }
  .setup-layout { grid-template-columns: minmax(0, 1fr); }
  .setup-side { min-height: 0; }
  .range-grid { grid-template-columns: repeat(3, 1fr); }
  .flow { padding-top: 11px; }
  .step-title { padding-block: 6px 15px; }
  .slots { grid-template-columns: repeat(2, 1fr); }
  .animal-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .animal-name { font-size: .83rem; }
  body[data-view="match"] .topbar-inner, .match-shell { width: calc(100% - 16px); }
  body[data-view="match"] .top-actions { gap: 0; }
  body[data-view="match"] .top-actions .button { min-width: 44px; padding: 6px; }
  body[data-view="match"] .top-actions .button span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
  .match-shell { grid-template-rows: minmax(155px, 1fr) auto auto; }
  .stadium { background-size: cover; background-position: center 70%; }
  .scoreboard { width: min(49%, 170px); flex-direction: row; align-items: end; }
  .referee { height: 32px; width: 32px; margin: 0 -3px 1px 0; z-index: 1; }
  .scoreline strong { font-size: 1.25rem; }
  .scoreline div > span, .score-middle b { font-size: .64rem; }
  .footballer { width: 14%; height: calc(28% * var(--scale)); }
  .math-deck, [data-mode="solo"] .math-deck { grid-template-columns: minmax(0, 1fr); }
  .solo-panel { gap: 2px; }
  .solo-panel p { font-size: .84rem; max-width: none; }
  .math-panel .panel-info { grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px; }
  .key { min-height: 44px; }
  .keypad { gap: 3px; }
  .problem { font-size: clamp(1rem, 5vw, 1.8rem); }
  .math-panel { padding-inline: 5px; }
  .team-name { font-size: .77rem; }
  .team-name svg { display: none; }
  .answer { min-width: 40px; }
  .panel-feedback { display: none; }
  .answer-wrap:has(.wrong) .panel-feedback { display: block; max-width: 45px; font-size: .62rem; }
}
@media (max-width: 370px) {
  body[data-view="match"] .match-rules { display: none; }
  .rules-button span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
  .button.rules-button { min-width: 44px; }
  .mode-choice .mode-box { padding: 6px; column-gap: 5px; }
  .mode-box i { padding: 4px; }
  .operation > span { grid-auto-flow: row; gap: 1px; text-align: center; }
}
@media (orientation: landscape) and (max-height: 710px) {
  .match-shell { grid-template-rows: minmax(140px, 1fr) auto auto; }
  .key { min-height: 44px; }
  .math-panel { padding-block: 6px 8px; }
  .match-shell { padding-block: 6px; }
}
