:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  --shell: #10161c;
  --line: #2d3a44;
  --ink: #f0f7fb;
  --muted: #a8b8c4;
  --blue: #70dcff;
  --orange: #ff9b6e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 45% 0%, #243441 0, transparent 48%), var(--shell);
  color: var(--ink);
}

.arena {
  --rim-width: min(100%, 1140px, max(510px, (100dvh - 168px) * 1000 / 580));
  width: var(--rim-width);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.masthead, .controls, .utilities, .keyboard, .score {
  display: flex;
  align-items: center;
}

.masthead, .controls { justify-content: space-between; gap: 12px; }

h1, h2, .score output, .callout {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4.3vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -.025em;
  white-space: nowrap;
}

h1 span { color: var(--blue); }
.utilities { gap: 7px; }

button {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }

.utility {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #19252d;
  color: var(--ink);
  white-space: nowrap;
  font-size: .875rem;
}

.utility:not(:disabled):hover { background: #273c49; }

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 49px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(90deg, #142a36, #161e25 42%, #161e25 58%, #32241f);
}

.side-blue { color: var(--blue); }
.side-orange { color: var(--orange); }

.score {
  justify-content: space-between;
  gap: 10px;
  padding: 0 clamp(10px, 3vw, 26px);
  font-weight: 800;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .075em;
}

.score output { font-size: 2rem; line-height: 1; letter-spacing: 0; }
.target { margin: 0; padding: 0 10px; color: var(--muted); font-size: .875rem; }
.target strong { color: var(--ink); }

.rink {
  position: relative;
  aspect-ratio: 1000 / 580;
  border-radius: 14px;
  overflow: hidden;
  background: #0b141d;
  box-shadow: 0 12px 32px #0007;
}

canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #06101a54;
  padding: 16px;
}

.match-card {
  width: min(100%, 360px);
  padding: clamp(16px, 4vw, 34px);
  border: 1px solid #526674;
  border-radius: 15px;
  background: #111d27;
  box-shadow: 0 14px 36px #0007;
  text-align: center;
}

.card-label { margin: 0; font-size: .875rem; font-weight: 700; color: var(--blue); }
h2 { margin: 8px 0 18px; font-size: clamp(2rem, 6vw, 3.6rem); line-height: 1; }

.primary, .text-button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
}

.primary { background: var(--blue); color: #092230; }
.primary:hover { background: #a1ecff; }
.text-button { display: block; margin: 5px auto -6px; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--ink); }

.callout {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 90%;
  transform: translate(-50%, -50%);
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(2rem, 8vw, 5.5rem);
  line-height: 1;
  color: white;
  text-shadow: 0 3px 0 #253b4c, 0 4px 14px #112b47;
  pointer-events: none;
}

.overlay:not([hidden]) + .callout { visibility: hidden; }

.controls { min-height: 32px; color: var(--muted); font-size: .875rem; }
.controls p { margin: 0; text-align: center; }
.keyboard { gap: 8px; }
.keyboard span { display: flex; gap: 3px; }

kbd {
  display: grid;
  place-items: center;
  min-width: 23px;
  min-height: 25px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #19252d;
  color: var(--ink);
  font: 700 .875rem system-ui, sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (orientation: portrait) {
  .arena { --rim-width: min(100%, max(290px, (100dvh - 178px) * 580 / 1000)); }
  .rink { aspect-ratio: 580 / 1000; }
}

@media (max-width: 560px) {
  .controls { flex-wrap: wrap; row-gap: 5px; }
  .controls p { order: 1; width: 100%; }
}

@media (pointer: coarse) {
  .controls { justify-content: center; }
  .keyboard { display: none; }
}

@media (orientation: landscape) and (max-height: 520px) {
  body { padding-block: 6px; }
  .arena { --rim-width: min(100%, max(320px, (100dvh - 120px) * 1000 / 580)); gap: 4px; }
  h1 { font-size: 1.55rem; }
  .scoreboard { min-height: 33px; }
  .score output { font-size: 1.55rem; }
  .controls { min-height: 22px; }
}
