* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f4f7fb;
  background: #101522;
  font-synthesis: none;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(circle at top, rgba(87, 227, 194, 0.12), transparent 25%),
    radial-gradient(circle at bottom right, rgba(116, 142, 255, 0.16), transparent 30%),
    linear-gradient(180deg, #0d1422 0%, #0d1320 30%, #101522 100%);
}

button, select, input { font: inherit; }

.game { width: min(940px, 100%); }

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #57e3c2;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .2em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.game-options { display: flex; align-items: end; gap: 12px; }
.difficulty-control, .match-title-control {
  display: grid;
  gap: 6px;
  color: #aab8cd;
  font-size: .8rem;
  text-align: left;
}

select, input, .button {
  border: 1px solid #354258;
  border-radius: 9px;
  background: rgba(26, 36, 53, 0.92);
  color: #f4f7fb;
}

select, input { min-height: 38px; padding: 8px 10px; }

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: center;
  margin: 0 0 18px;
}
.settings-row > * { flex: 1 1 180px; }
.match-title-control { min-width: 160px; }

.player-names {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 14px;
  margin: -4px 0 18px;
}
.player-names[hidden] { display: none; }
.player-names label {
  display: grid;
  gap: 6px;
  width: min(220px, 36%);
  color: #aab8cd;
  font-size: .78rem;
  text-align: left;
}
.player-names input { width: 100%; }
.player-names input:focus-visible, select:focus-visible, input:focus-visible, .button:focus-visible { outline: 2px solid #57e3c2; outline-offset: 3px; }
.versus { padding-bottom: 10px; color: #57e3c2; font-size: .72rem; font-weight: 800; letter-spacing: .15em; }

.scoreboard {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  margin-bottom: 12px;
}

.score-card {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 62px;
  max-width: 180px;
  color: #aab8cd;
  font-size: .78rem;
}
.score-card span { overflow: hidden; max-width: 180px; text-overflow: ellipsis; white-space: nowrap; }
.score-card strong { color: #fff; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.score-divider { color: #53627a; font-size: 1.5rem; }
.best-score { position: absolute; right: 0; color: #8594aa; font-size: .7rem; font-weight: 800; letter-spacing: .1em; }
.best-score strong { margin-left: 5px; color: #f4c96b; }
.game-duration {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  margin: -4px 0 12px;
  color: #8594aa;
  font-size: .72rem;
  letter-spacing: .06em;
}
.game-duration time { color: #f4f7fb; font-variant-numeric: tabular-nums; font-weight: 700; }

.court-wrap { position: relative; }
canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #354258;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(12, 17, 28, 0.9), rgba(20, 29, 44, 0.95));
  box-shadow: 0 18px 55px rgba(5, 8, 14, 0.7);
  touch-action: none;
  outline: none;
}
canvas:focus-visible { border-color: #57e3c2; }

.game-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 12px;
  background: rgba(12, 18, 32, 0.7);
  text-align: center;
  transition: opacity .2s ease, visibility .2s ease;
}
.game-message.is-hidden { opacity: 0; visibility: hidden; }
.message-kicker { color: #57e3c2; font-size: .68rem; font-weight: 800; letter-spacing: .2em; }
.game-message strong { font-size: clamp(1.7rem, 5vw, 2.7rem); }
.game-message span:last-child { color: #c0cada; font-size: .9rem; }

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.button {
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: #57e3c2; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { border-color: #57e3c2; background: #57e3c2; color: #10201f; font-weight: 800; }
.button-primary:hover:not(:disabled) { background: #7aefd3; }
.sound-button[aria-pressed="true"] { border-color: #f4c96b; color: #f4c96b; }
.help { margin: 14px 0 0; color: #91a0b7; font-size: .82rem; text-align: center; }
kbd { display: inline-block; padding: 1px 5px; border: 1px solid #45536b; border-radius: 4px; color: #e2e8f0; font: inherit; }

@media (max-width: 560px) {
  body { padding: 20px 12px; }
  .game-header { align-items: start; }
  .game-options { flex-direction: column; align-items: stretch; gap: 8px; }
  .settings-row { flex-direction: column; align-items: stretch; }
  .player-names { gap: 8px; }
  .player-names label { width: 42%; }
  .best-score { position: static; margin-left: 6px; }
  .scoreboard { gap: 13px; }
  .button { padding: 0 12px; }
  .help { line-height: 1.8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
