﻿:root {
  color-scheme: dark;
  --paper: #ffecdb;
  --soft: #dec3b5;
  --night: #20171e;
  --ink: #271b28;
  --iron: #382936;
  --copper: #bc826c;
  --gold: #ffdb91;
  --ice: #a4e8e2;
  --amber: #ffb785;
  --wide: "Century Gothic", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  background: var(--night);
  color: var(--paper);
  font: 16px/1.5 system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button { font: 750 0.9375rem/1.2 system-ui, sans-serif; color: inherit; cursor: pointer; min-height: 44px; }
a { color: inherit; text-underline-offset: .23em; }
:is(button, a, summary):focus-visible { outline: 3px solid #fff4bc; outline-offset: -4px; }

.game {
  --bevel: 24px;
  --canopy: 64px;
  --control-rail: 72px;
  --pad-size: 54px;
  --safe-top: 0px;
  --safe-right: 0px;
  --safe-bottom: 0px;
  --safe-left: 0px;
  position: relative;
  isolation: isolate;
  width: min(1640px, calc(100% - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  height: calc(100dvh - 26px - env(safe-area-inset-top));
  min-height: 390px;
  margin: max(10px, env(safe-area-inset-top)) auto 0;
  border: 8px solid var(--copper);
  border-color: #dbab87 #9f675c #774958 #ba7d69;
  clip-path: polygon(var(--bevel) 0, calc(100% - var(--bevel)) 0, 100% var(--bevel),
    100% calc(100% - var(--bevel)), calc(100% - var(--bevel)) 100%, var(--bevel) 100%,
    0 calc(100% - var(--bevel)), 0 var(--bevel));
  background: #291e2b;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.game:focus { outline: none; }
.game::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: auto var(--safe-right) var(--safe-bottom) var(--safe-left);
  height: var(--control-rail);
  pointer-events: none;
  border-top: 3px double #bc826c;
  background:
    repeating-linear-gradient(90deg, transparent 0 25px, #b881793a 25px 27px, transparent 27px 32px) 0 5px / auto 5px no-repeat,
    linear-gradient(#3c2a38, #281d2a);
}

#arena {
  position: absolute;
  inset: calc(var(--safe-top) + var(--canopy)) var(--safe-right) auto var(--safe-left);
  display: block;
  width: calc(100% - var(--safe-left) - var(--safe-right));
  height: calc(100% - var(--canopy) - var(--control-rail) - var(--safe-top) - var(--safe-bottom));
}

html.game-expanded, html.game-expanded body { overflow: hidden; overscroll-behavior: none; }
.game:is(:fullscreen, .fullscreen-fallback) {
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  margin: 0;
}
.game:fullscreen { max-width: none; max-height: none; }
.game.fullscreen-fallback { position: fixed; z-index: 10; }

.scene-title {
  position: absolute;
  z-index: 4;
  inset: calc(var(--safe-top) + 10px) auto auto calc(var(--safe-left) + 18px);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1px .4em;
  max-width: calc(34% - 20px - 2 * var(--safe-left));
  margin: 0;
  font: 900 clamp(1.28rem, 2.55vw, 2.25rem)/1.04 var(--wide);
  letter-spacing: .025em;
  color: var(--gold);
}
.scene-title span { font-size: .56em; font-weight: 720; letter-spacing: .045em; color: var(--soft); }

.game-tools {
  position: absolute;
  z-index: 8;
  inset: calc(var(--safe-top) + 7px) calc(var(--safe-right) + 10px) auto auto;
  display: flex;
  align-items: center;
  gap: 7px;
}
.round-tool {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-height: 44px;
  padding: 0;
  border: 1px solid #d6a78b;
  border-radius: 50%;
  color: var(--gold);
  background: #3e2a36;
  box-shadow: inset 0 0 0 3px #241925, 0 2px #1a131d;
  cursor: pointer;
}
.round-tool:hover, .round-tool[aria-expanded=true], .round-tool[aria-pressed=true] {
  color: #281d28;
  background: var(--gold);
  box-shadow: inset 0 0 0 3px #c38968, 0 2px #1a131d;
}
.menu-icon { width: 17px; height: 2px; background: currentColor; box-shadow: 0 -5px, 0 5px; }
.pause-icon { width: 13px; height: 16px; border: solid currentColor; border-width: 0 3px; }
.fullscreen-icon {
  width: 18px;
  height: 16px;
  border: 2px solid currentColor;
  clip-path: polygon(0 0, 34% 0, 34% 30%, 66% 30%, 66% 0, 100% 0, 100% 34%,
    70% 34%, 70% 66%, 100% 66%, 100% 100%, 66% 100%, 66% 70%, 34% 70%,
    34% 100%, 0 100%, 0 66%, 30% 66%, 30% 34%, 0 34%);
}
[aria-pressed=true] .fullscreen-icon {
  border: 0;
  clip-path: none;
  background:
    linear-gradient(currentColor 0 0) 0 5px / 7px 2px,
    linear-gradient(currentColor 0 0) 5px 0 / 2px 7px,
    linear-gradient(currentColor 0 0) 100% 5px / 7px 2px,
    linear-gradient(currentColor 0 0) 11px 0 / 2px 7px,
    linear-gradient(currentColor 0 0) 0 9px / 7px 2px,
    linear-gradient(currentColor 0 0) 5px 100% / 2px 7px,
    linear-gradient(currentColor 0 0) 100% 9px / 7px 2px,
    linear-gradient(currentColor 0 0) 11px 100% / 2px 7px;
  background-repeat: no-repeat;
}

.hud {
  position: absolute;
  z-index: 3;
  inset: calc(var(--safe-top) + 6px) max(calc(var(--safe-right) + 118px), 29%) auto max(calc(var(--safe-left) + 125px), 29%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(67px, 9vw, 112px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.game[data-mode=menu] .hud { display: none; }
.nameplate {
  --team: var(--ice);
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--team);
  font-size: .9375rem;
  font-weight: 760;
  white-space: nowrap;
}
.nameplate.amber { --team: var(--amber); justify-self: start; }
.nameplate .role:empty { display: none; }
.team-mark {
  flex: 0 0 12px;
  height: 12px;
  background: var(--team);
  clip-path: polygon(26% 0, 74% 0, 100% 26%, 100% 74%, 74% 100%, 26% 100%, 0 74%, 0 26%);
}
.amber .team-mark { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.role {
  padding: 1px 5px;
  border: 1px solid #e6bb73;
  border-radius: 2px;
  background: #412b2a;
  color: var(--gold);
  font-size: .875rem;
  font-weight: 850;
  line-height: 1.15;
}
.role.protected { border-style: dashed; background: #654139; }
.clock {
  min-width: 0;
  padding: 3px 8px 4px;
  border: 1px solid #a17270;
  border-radius: 3px;
  background: #211823;
  color: #ffe8d1;
  text-align: center;
  font: 800 1.7rem/1 ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.clock-track { display: block; margin-top: 3px; background: #714c54; height: 2px; }
.clock-track i { display: block; height: 2px; background: #f2ba8a; transform-origin: left center; }
.last-seconds .clock { color: #ffbb9f; border-color: #e58d77; }
.passes {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 5px 1px;
  border-radius: 0 0 3px 3px;
  background: #291e2b;
  color: #ffdcc8;
  font: 700 .875rem/1.3 system-ui, sans-serif;
  white-space: nowrap;
}
.pass-tally { font: 800 .875rem/1.15 ui-monospace, Consolas, monospace; }
.pass-tally.ice { color: var(--ice); }
.pass-tally.amber { color: var(--amber); }

.yard-menu {
  z-index: 7;
  position: absolute;
  inset: calc(var(--safe-top) + 60px) calc(var(--safe-right) + 10px) auto auto;
  width: min(265px, calc(100% - var(--safe-left) - var(--safe-right) - 24px));
  max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 74px);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 8px 12px;
  border: 2px solid var(--copper);
  border-block-start: 5px solid var(--gold);
  background: #302333;
  box-shadow: 6px 6px #200f20b0;
}
.language-switch { display: grid; }
.language-switch span {
  padding: 7px 10px 0;
  border-top: 1px solid #8e6269;
  color: var(--gold);
  font-weight: 800;
}
:is(.language-switch, .yard-menu) a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 5px 10px;
  color: var(--paper);
}
.language-switch a[aria-current=page] { background: #50404b; color: var(--gold); font-weight: 800; }
.yard-menu a:hover { background: #503847; }

.overlay {
  position: absolute;
  z-index: 2;
  inset: calc(var(--safe-top) + var(--canopy)) var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid;
  min-height: 0;
  padding: 10px clamp(14px, 4vw, 60px);
}
.panel { min-width: 0; max-height: 100%; }
.panel-title {
  margin: 0;
  color: var(--paper);
  font: 900 clamp(1.9rem, 4.3vw, 4.1rem)/1 var(--wide);
  letter-spacing: -.025em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.panel-copy { margin: 8px 0 0; color: var(--soft); text-wrap: pretty; }
.menu-actions { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.primary, .secondary, .settings button, .key-grid button {
  padding: 5px 14px;
  border: 1px solid #b18377;
  border-radius: 3px;
  background: #3e2a37;
  box-shadow: 0 3px #221522;
  overflow-wrap: anywhere;
}
.primary { border-color: #ffe3b2; background: var(--gold); color: #271925; }
.primary:hover { background: #ffe9be; }
.secondary:hover, .settings button:hover, .key-grid button:hover { background: #5b3e50; }
.primary:active, .secondary:active, .settings button:active, .key-grid button:active {
  transform: translateY(2px);
  box-shadow: 0 1px #1d1421;
}
.primary:focus-visible { outline-color: #2a1c2b; }

#menu {
  align-items: end;
  padding-block-end: clamp(24px, 6vh, 58px);
  background: linear-gradient(0deg, #211722 1%, #211722c9 20%, transparent 52%);
}
.entry {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 27%);
  align-items: end;
  gap: clamp(18px, 4vw, 72px);
  padding: 14px 0 13px clamp(16px, 3vw, 38px);
  border-left: 6px solid var(--gold);
  background: linear-gradient(90deg, #30222ef5, #30222ed1 67%, transparent);
}
.entry .panel-copy { max-width: 52ch; color: #ffe8d7; }
.entry .menu-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry .primary { grid-column: 1 / -1; }
.entry button { min-height: 52px; text-align: start; padding-inline: 16px; }
.entry .primary { box-shadow: 0 4px #a67858; }
.entry .secondary { border-color: #9dc7c6; background: #263d43; color: #d3fff2; }
.entry .secondary:hover { background: #37545a; }

#cup-menu {
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: #20131e9c;
}
.cup-panel {
  width: min(100%, 630px);
  max-height: none;
  padding: clamp(10px, 2vw, 22px);
  border: 2px solid var(--copper);
  border-left: 6px solid var(--gold);
  background: #30222e;
}
.cup-heading, .cup-stages, .cup-rivals { display: grid; gap: 6px; margin-bottom: 8px; }
.cup-heading { grid-template-columns: 1fr auto; align-items: center; }
.cup-heading .panel-title { color: var(--gold); font-size: clamp(1.6rem, 3vw, 2.45rem); }
.cup-stages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cup-rivals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cup-panel button { padding: 5px 8px; overflow-wrap: anywhere; }
.cup-stages button { padding-inline: 3px; }
.cup-panel button:disabled { cursor: default; opacity: .7; box-shadow: none; }
.cup-panel [aria-pressed=true] { border-color: var(--gold); background: #fece98; color: #281d2a; }
.cup-rivals button { min-height: 51px; }
.cup-rivals button small { display: block; font-size: .875rem; font-weight: 550; }
.cup-detail { border-top: 1px solid var(--copper); padding-top: 6px; }
.cup-caption { margin: 0; color: var(--ice); font-weight: 800; }
.cup-detail .panel-copy { margin-top: 2px; }
.cup-detail ul { margin: 5px 0 8px; padding-left: 1.15em; font-size: .875rem; }
.cup-detail .earned { color: var(--ice); }

#pause-menu, #key-menu {
  align-items: center;
  justify-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-block: 14px;
  background: linear-gradient(110deg, #20131e9c, #1d161f4d);
}
.pause-panel, .key-panel {
  width: min(100%, 704px);
  max-height: none;
  background: #2f2231;
  border: 2px solid var(--copper);
  border-bottom: 6px solid #916153;
  box-shadow: 8px 8px #170f1bbf;
}
.pause-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: stretch; }
.pause-actions { padding: clamp(14px, 2.8vw, 34px); border-right: 3px double #a46d65; }
.pause-actions .panel-title, .key-panel .panel-title { font-size: clamp(1.75rem, 3.4vw, 3rem); color: var(--gold); }
.pause-actions .menu-actions { margin-top: 14px; }
.pause-actions .primary { flex-basis: 100%; }
.pause-actions .secondary { flex: 1 1 0; }
.settings { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; padding: 10px; }
.settings button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: start;
  font-size: .875rem;
  box-shadow: none;
}
.settings button span { flex: none; color: #edd0cb; font-weight: 750; }
.settings button[aria-pressed=true] span { color: var(--ice); }

.key-panel { padding: clamp(12px, 3vw, 27px); }
.key-grid { display: grid; gap: 8px; margin: 10px 0 12px; }
.key-grid > div { display: grid; grid-template-columns: minmax(58px, auto) repeat(3, minmax(0, 1fr)); align-items: center; gap: 5px; }
.key-grid strong { font-size: .875rem; }
.key-grid button { padding: 3px 5px; font-size: .875rem; }
.key-grid .pressed { background: #765b43; color: #ffefd7; }
.key-grid button[aria-pressed=true] { border-color: var(--gold); color: var(--gold); }

#result {
  align-items: start;
  padding-block-start: clamp(22px, 5vh, 52px);
  background: linear-gradient(180deg, #24182274, transparent 72%);
}
.result-panel {
  --outcome: #edac97;
  width: min(100%, 690px);
  padding: 14px clamp(14px, 3vw, 31px) 24px;
  border-top: 5px solid var(--outcome);
  background: #30222e;
  box-shadow: inset 0 -8px #76555a;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
}
.game[data-mode=won] .result-panel { --outcome: var(--gold); }
.result-label { margin: 0 0 5px; color: var(--outcome); font-weight: 800; }
.result-panel .panel-title { font-size: clamp(1.8rem, 3.45vw, 3.55rem); }
.result-panel .menu-actions { margin-top: 13px; }
.result-panel .primary { min-width: min(100%, 136px); }

.dock {
  position: absolute;
  z-index: 2;
  inset: auto calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 7px) calc(var(--safe-left) + 10px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.game:not(.duo) .dock { justify-content: flex-end; }
.pad { --key-color: var(--ice); display: flex; gap: 6px; }
.pad.amber { --key-color: var(--amber); }
.pad button {
  width: var(--pad-size);
  height: var(--pad-size);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  border: 1px solid #b48b82;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: linear-gradient(#493948, #2d2432);
  color: var(--key-color);
  transition: background-color 100ms, transform 100ms;
  pointer-events: auto;
}
.pad button:hover { background: #51424f; }
.pad .pressed { transform: translateY(2px); background: #4a3e50; border-color: var(--key-color); }
.dock-note { align-self: center; margin: 0 auto 0 2px; color: var(--soft); font-size: .875rem; font-weight: 650; }
.game.duo .dock-note { display: none; }
.direction { display: inline-block; width: 14px; height: 14px; border: solid currentColor; border-width: 3px 3px 0 0; transform: translateX(-1px) rotate(45deg); }
.direction.left { transform: translateX(1px) rotate(-135deg); }
.direction.up { transform: translateY(2px) rotate(-45deg); }
.jump-label { font-size: .875rem; line-height: 1.1; }
.lesson {
  position: absolute;
  z-index: 1;
  top: calc(var(--safe-top) + var(--canopy) + 10px);
  left: 50%;
  width: max-content;
  max-width: calc(100% - var(--safe-left) - var(--safe-right) - 20px);
  transform: translateX(-50%);
  padding: 6px 12px;
  border-bottom: 2px solid var(--copper);
  background: #2a1c29;
  color: #ffdfc8;
  text-align: center;
  font-size: .875rem;
  font-weight: 650;
  pointer-events: none;
}
.game.cup-open { touch-action: pan-y; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.low-motion *, .low-motion *::before { transition: none !important; animation: none !important; }

.guide, .legal {
  width: min(calc(100% - 36px), 1110px);
  margin-inline: auto;
  padding-block: 14px 58px;
}
.guide { scroll-margin-block-start: 12px; }
.rules-link { color: var(--gold); font-weight: 750; }
.rules-link:hover { color: var(--paper); }
.guide-shortcut, .guide-return {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 12px;
  border-inline-start: 3px solid var(--copper);
  text-decoration-color: var(--copper);
}
.guide:has(.guide-return:not([hidden])) > .guide-shortcut { display: none; }

.prose-section {
  position: relative;
  width: min(68%, 670px);
  border-top: 2px solid #a37165;
  padding-block: 22px 28px;
  margin-block-start: 22px;
}
.prose-section:nth-of-type(even) { margin-inline-start: auto; }
.prose-section:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(100% + clamp(24px, 6vw, 100px));
  width: clamp(74px, 13vw, 148px);
  aspect-ratio: 1;
  top: 50%;
  background: url("/favicon.svg") center / 100% no-repeat;
  filter: drop-shadow(0 10px 0 #100d14) drop-shadow(0 0 32px #dd9b524d);
  transform: translateY(-50%) rotate(9deg);
  pointer-events: none;
}
.prose-section:nth-of-type(even)::after {
  left: auto;
  right: calc(100% + clamp(24px, 6vw, 100px));
  transform: translateY(-50%) rotate(-9deg);
}
.prose-section:nth-of-type(3n + 2)::after {
  background:
    radial-gradient(circle closest-side, #97e4d7 70%, #251e29 74% 100%) 50% 21% / 22% 22% no-repeat,
    radial-gradient(circle closest-side, #a0606b 80%, transparent 85%) 50% 43% / 19% 19% no-repeat,
    radial-gradient(circle closest-side, #794354 80%, transparent 85%) 50% 65% / 19% 19% no-repeat,
    linear-gradient(#d09b82, #935864) 34% 17% / 4% 68% no-repeat,
    linear-gradient(110deg, #5c3946, #302333) 50% 0 / 46% 80% no-repeat,
    linear-gradient(#6f4651, #432c39) 50% 100% / 15% 23% no-repeat;
}
.prose-section:nth-of-type(3n)::after {
  aspect-ratio: 2;
  background:
    radial-gradient(circle, #482c3a 13%, transparent 15%) 0 42% / 18% 72% repeat-x,
    linear-gradient(#ffdf9e 12%, #ddab84 14% 30%, #a46860 34% 100%) 50% 19% / 100% 24% no-repeat,
    repeating-linear-gradient(130deg, #343744 0 12px, #b08070 12px 15px, #343744 15px 26px) 50% 62% / 84% 29% no-repeat,
    linear-gradient(90deg, #594054 10%, transparent 10% 90%, #594054 90%) 50% 95% / 75% 23% no-repeat;
}
.prose-section p, .prose-section li { color: var(--soft); line-height: 1.67; }
.legal h1 {
  margin: 0 0 14px;
  font: 900 clamp(2.1rem, 5vw, 4.1rem)/1.04 var(--wide);
  color: var(--gold);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.guide h2, .legal h2 { margin: 0 0 10px; font: 800 clamp(1.25rem, 2.15vw, 1.65rem)/1.2 var(--wide); }
.prose-section p { margin: 0 0 15px; }
.guide ul { margin: 0 0 15px; padding-inline-start: 1.45rem; }
.guide li { padding-inline-start: .25rem; margin-bottom: 8px; }
.guide li::marker { color: var(--gold); }
.guide table { width: 100%; margin: 0 0 15px; border-collapse: collapse; text-align: start; }
.guide :is(th, td) { padding: 6px 7px; border-bottom: 1px solid #825b62; text-align: start; }
kbd { color: #ffe8d5; font: 700 .89em ui-monospace, Consolas, monospace; }

.site-footer {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: clamp(162px, 22vw, 270px);
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  align-items: end;
  background:
    radial-gradient(ellipse at 30% 110%, #d1936e, transparent 64%),
    linear-gradient(180deg, transparent 0, #513241 70%, #935c59);
}
.site-footer::before {
  position: absolute;
  content: "";
  z-index: -1;
  inset: 0;
  background: #291e2a;
  clip-path: polygon(0 47%, 5% 47%, 5% 35%, 17% 35%, 17% 48%, 27% 48%, 38% 25%, 62% 25%, 73% 48%,
    85% 48%, 85% 31%, 95% 31%, 95% 45%, 100% 45%, 100% 100%, 0 100%);
}
.site-footer::after {
  position: absolute;
  content: "";
  z-index: -1;
  inset: 23% 0 0;
  background:
    linear-gradient(90deg, transparent 8%, #a87969 8% 24%, transparent 24% 76%, #a87969 76% 92%, transparent 92%) 0 42% / 100% 3px no-repeat,
    linear-gradient(90deg, transparent 37%, #c39475 37% 63%, transparent 63%) 0 25% / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, #211822 0 13px, #69464f 13px 15px, #211822 15px 26px) 0 70% / 100% 10px no-repeat,
    linear-gradient(180deg, transparent 70%, #211822 71%);
}
.footer-nav, .footer-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 22px; }
.site-footer a { display: flex; min-height: 44px; align-items: center; color: var(--paper); }
.footer-nav > span { color: var(--soft); }
.site-footer a:hover, .legal a:hover { color: var(--gold); }

.legal-banner { position: relative; }
.legal-stage {
  --legal-bevel: 20px;
  position: relative;
  min-height: clamp(142px, 19vw, 250px);
  padding: 22px clamp(16px, 4vw, 52px);
  display: grid;
  align-content: end;
  border: 8px solid var(--copper);
  border-color: #dbab87 #9f675c #774958 #ba7d69;
  clip-path: polygon(var(--legal-bevel) 0, calc(100% - var(--legal-bevel)) 0, 100% var(--legal-bevel),
    100% calc(100% - var(--legal-bevel)), calc(100% - var(--legal-bevel)) 100%, var(--legal-bevel) 100%,
    0 calc(100% - var(--legal-bevel)), 0 var(--legal-bevel));
  background:
    linear-gradient(0deg, #241b28 0%, #241b28c9 32%, transparent 100%),
    repeating-linear-gradient(90deg, transparent 0 113px, #815c5d 113px 116px, #382a38 116px 125px, transparent 125px 192px),
    radial-gradient(ellipse at 70% 8%, #85716b, #3e3948 45%, #28232e 80%);
}
.legal-stage h1 { margin-bottom: 0; }
.legal-stage .rules-link { display: inline-flex; align-items: center; min-height: 44px; width: fit-content; color: var(--paper); }
.legal-tools { position: absolute; z-index: 2; right: 12px; top: 10px; }
.legal-tools summary { list-style: none; }
.legal-tools summary::-webkit-details-marker { display: none; }
.legal-tools .yard-menu { top: 52px; right: 0; width: min(245px, calc(100vw - 85px)); max-height: 340px; }

@media (max-width: 900px), (any-pointer: coarse) {
  .game { --pad-size: 64px; --control-rail: 81px; }
  .game .dock-note { display: none; }
  .game:not(.duo) .pad { width: 100%; }
  .game.duo .pad { width: clamp(216px, 42%, 340px); }
  .pad button[data-control=jump] {
    width: 76px;
    margin-inline-start: auto;
    border-color: var(--key-color);
    background: var(--key-color);
    color: #201b24;
  }
  .pad button[data-control=jump].pressed { background: #ffecd2; }
}

@media (max-width: 720px) and (orientation: portrait) {
  .game { --canopy: 103px; --bevel: 18px; width: calc(100% - 12px); height: calc(100dvh - 16px - env(safe-area-inset-top)); margin-top: max(6px, env(safe-area-inset-top)); border-width: 7px; }
  .game[data-mode=menu] { --canopy: 59px; }
  .scene-title {
    inset-inline-start: calc(var(--safe-left) + 10px);
    max-width: calc(100% - var(--safe-left) - var(--safe-right) - 130px);
    align-content: start;
    font-size: clamp(1.3rem, 5.3vw, 1.7rem);
  }
  .scene-title span { font-size: .7em; line-height: 1.15; }
  .hud { inset: calc(var(--safe-top) + 55px) calc(var(--safe-right) + 6px) auto calc(var(--safe-left) + 6px); gap: 6px; }
  .nameplate { font-size: .875rem; gap: 4px; }
  .role { padding-inline: 3px; }
  .clock { font-size: 1.45rem; }
  .passes { line-height: 1.1; }
  .game-tools { right: calc(var(--safe-right) + 6px); top: calc(var(--safe-top) + 4px); }
  .dock { inset-inline: calc(var(--safe-left) + 8px) calc(var(--safe-right) + 8px); }
  .entry { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-block: 10px; padding-inline-start: 11px; }
  .entry .menu-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry .menu-actions button { padding-inline: 9px; }
  .pause-panel { grid-template-columns: minmax(0, 1fr); }
  .pause-actions { border-right: 0; border-bottom: 3px double #a46d65; }
  .pause-actions .primary { flex: 1 1 100%; }
  .settings button { padding-inline: 9px; }
  .result-panel .primary { min-width: 0; }
}

@media (max-width: 374px) and (orientation: portrait) {
  .game { --canopy: 86px; }
  .hud { top: calc(var(--safe-top) + 52px); }
  .lesson { top: calc(var(--safe-top) + var(--canopy) + 24px); }
  .key-grid > div { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .key-grid strong { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .prose-section { width: calc(100% - 14px); margin-block-start: 15px; padding-block-end: 0; }
  .prose-section:not(:last-child)::after, .prose-section:nth-of-type(even)::after {
    position: relative;
    display: block;
    left: auto;
    right: auto;
    top: auto;
    width: 77px;
    margin: 20px auto 28px;
    transform: rotate(9deg);
  }
  .legal { width: calc(100% - 26px); }
}

@media (max-width: 480px) {
  .game.duo { --control-rail: 151px; }
  .game.duo .dock { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .game.duo .pad { width: 100%; }
}

@media (max-height: 510px) and (orientation: landscape) {
  .game { --canopy: 58px; --bevel: 18px; min-height: 235px; height: calc(100dvh - 12px); margin-top: 6px; border-width: 7px; }
  .game:not(:fullscreen, .fullscreen-fallback) { --safe-left: env(safe-area-inset-left); --safe-right: env(safe-area-inset-right); }
  .scene-title { font-size: clamp(1.1rem, 3vw, 1.55rem); }
  #menu { padding-block-end: 12px; }
  .entry {
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: 16px;
    padding: 8px 0 8px 14px;
  }
  .entry .panel-title { font-size: clamp(1.25rem, 5.5vh, 1.9rem); }
  .entry .panel-copy { margin-top: 4px; line-height: 1.35; }
  .entry .menu-actions { display: flex; }
  .entry button { min-width: 44px; min-height: 44px; padding-inline: 12px; overflow-wrap: normal; }
  .pause-actions .panel-title, .key-panel .panel-title { font-size: clamp(1.6rem, 4.5vh, 2.35rem); }
  .result-panel .panel-title { font-size: clamp(1.6rem, 5.8vh, 2.25rem); }
  #result {
    align-items: end;
    padding-block: 8px 12px;
    background: linear-gradient(0deg, #241822ab, transparent 56%);
  }
  .result-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, .75fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 14px 12px;
  }
  .result-panel .panel-copy { margin-top: 4px; }
  .result-panel .menu-actions { justify-content: flex-end; margin-top: 0; }
  .result-panel .primary { min-width: 0; }
  .pause-actions, .key-panel { padding: 10px 14px; }
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-block: 6px; }
  .lesson { top: calc(var(--safe-top) + var(--canopy) + 3px); }
}

@media (max-width: 700px) and (max-height: 510px) and (orientation: landscape) {
  #menu { padding: 8px clamp(14px, 2.7vw, 22px); }
  .entry { grid-template-columns: minmax(0, 1fr); gap: 4px; padding-block: 5px; }
  .entry-sign { display: flex; align-items: baseline; gap: 12px; }
  .entry .panel-title { flex: 0 0 auto; max-width: 36%; }
  .entry .panel-copy { margin-top: 0; line-height: 1.25; }
  .entry .primary { flex-grow: 1; }
}

@media (max-width: 580px) and (orientation: landscape) {
  .hud { inset-inline: 22% 26%; grid-template-columns: minmax(0, 1fr) 62px minmax(0, 1fr); }
  .nameplate { gap: 3px; font-size: .875rem; }
  .team-mark { display: none; }
  .scene-title { max-width: max(80px, calc(24% - var(--safe-left))); }
  .pause-actions .menu-actions { margin-top: 7px; }
  .result-panel { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .result-panel .menu-actions { justify-content: flex-start; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #rival-hint {
    top: auto;
    bottom: calc(var(--safe-bottom) + 10px);
    z-index: 2;
    max-width: calc(100% - var(--safe-left) - var(--safe-right) - 280px);
    font-weight: 600;
  }
  .cup-panel { padding-block: 6px; }
  .cup-heading, .cup-stages, .cup-rivals { margin-bottom: 4px; }
  .cup-detail { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
  .cup-detail :is(.cup-caption, .panel-copy, ul) { grid-column: 1; }
  .cup-detail button { grid-column: 2; grid-row: 1 / 4; align-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; }
}
