:root {
  --ink: #102c35;
  --ink-deep: #071b21;
  --paper: #f4e4b3;
  --paper-light: #fff2c6;
  --red: #e84b35;
  --blue: #2b6e82;
  color: var(--paper);
  background: var(--ink);
  font-family: "Courier New", "Noto Sans Mono CJK SC", monospace;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 10%, rgb(43 110 130 / 0.32), transparent 34rem),
    linear-gradient(145deg, #0b2229, var(--ink) 62%, #0b252e);
}

body::before {
  position: fixed;
  z-index: 10;
  inset: 0;
  background-image:
    repeating-radial-gradient(circle at 17% 23%, rgb(244 228 179 / 0.1) 0 0.45px, transparent 0.8px 4px),
    repeating-linear-gradient(91deg, transparent 0 3px, rgb(0 0 0 / 0.035) 3px 4px);
  background-size: 7px 7px, 11px 11px;
  content: "";
  opacity: 0.2;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

button,
select,
input {
  min-width: 48px;
  min-height: 48px;
  font: inherit;
}

button,
select,
input {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--paper-light);
  outline-offset: 4px;
  box-shadow: 0 0 0 7px var(--red);
}

.topbar {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0;
  padding: 0 0 40px;
}

.brand {
  display: grid;
  color: var(--paper);
  text-decoration: none;
}

.brand span,
.eyebrow {
  margin: 0;
  color: rgb(244 228 179 / 0.72);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.brand strong {
  color: var(--paper-light);
  font-family: Impact, "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0.06em;
}

.sound-button,
.secondary-button,
#clear-history-button {
  padding: 10px 15px;
  border: 2px solid var(--paper);
  color: var(--paper);
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  transition: color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.sound-button:hover,
.secondary-button:hover,
#clear-history-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--red);
}

.sound-button[aria-pressed="true"] {
  color: var(--paper-light);
  border-color: var(--red);
  box-shadow: inset 0 0 0 2px rgb(232 75 53 / 0.35);
}

.arcade-shell {
  width: min(1120px, calc(100% - 48px));
  min-width: 0;
  margin: 0 auto;
  padding: 26px 0 64px;
}

.lobby-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.6fr);
  align-items: end;
  gap: clamp(24px, 6vw, 88px);
  margin-bottom: 28px;
}

h1,
h2 {
  margin: 0;
  color: var(--paper-light);
  font-family: Impact, "Arial Black", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.025em;
  line-height: 0.95;
}

h1 {
  margin-top: 9px;
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  text-shadow: 3px 2px 0 var(--red), -3px -2px 0 var(--blue);
}

h2 {
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.lobby-intro {
  margin: 0;
  color: rgb(244 228 179 / 0.78);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.8;
}

.player-panel {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto minmax(300px, 0.8fr);
  align-items: center;
  gap: 16px 24px;
  margin-bottom: 24px;
  padding: 18px 22px;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent calc(100% - 24px), rgb(16 44 53 / 0.13) 0) 0 0 / 100% 100%,
    var(--paper);
  border: 2px solid var(--ink-deep);
  box-shadow: 7px 7px 0 var(--blue);
}

.player-panel .eyebrow {
  color: var(--blue);
}

.player-identity {
  display: grid;
  min-width: 0;
  gap: 4px;
}

#player-nickname {
  overflow-wrap: anywhere;
  font-family: Impact, "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
}

#player-code {
  color: rgb(16 44 53 / 0.68);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.connection-status {
  padding: 7px 10px;
  color: var(--paper);
  background: var(--red);
  font-size: 0.7rem;
  font-weight: 900;
}

.connection-status.is-online {
  background: var(--blue);
}

.rename-player-form {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
}

.rename-player-form label {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  font-weight: 900;
}

.nickname-input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--paper-light);
  border: 2px solid var(--ink);
}

.rename-player-form button {
  min-height: 48px;
  padding: 9px 13px;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 900;
}

.rename-player-form :disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ticket-wall {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.game-ticket {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px 22px;
  padding: clamp(22px, 4vw, 34px);
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgb(16 44 53 / 0.05) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
  border: 2px solid var(--ink-deep);
  box-shadow: 7px 7px 0 var(--red);
  text-align: left;
  transition: color 160ms ease, box-shadow 160ms ease, opacity 160ms ease, scale 160ms ease;
}

.game-ticket::after {
  position: absolute;
  top: 0;
  right: 18px;
  bottom: 0;
  border-right: 2px dashed rgb(16 44 53 / 0.25);
  content: "";
}

.game-ticket:hover,
.game-ticket:focus-within,
.game-ticket.is-selected {
  color: var(--ink-deep);
  box-shadow: 11px 11px 0 var(--red), inset 0 0 0 4px rgb(16 44 53 / 0.14);
  scale: 1.012;
}

.game-ticket--featured {
  grid-column: 1 / -1;
  min-height: 190px;
  background:
    radial-gradient(circle at 74% 50%, rgb(232 75 53 / 0.15), transparent 18rem),
    linear-gradient(rgb(16 44 53 / 0.05) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
}

.game-ticket--blue {
  box-shadow: 7px 7px 0 var(--blue);
}

.ticket-number {
  grid-column: 1;
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.ticket-title {
  grid-column: 1 / -1;
  color: inherit;
  font-family: Impact, "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: clamp(2rem, 5vw, 4.2rem);
  letter-spacing: 0.04em;
  line-height: 1;
}

.ticket-copy {
  grid-column: 1;
  color: rgb(16 44 53 / 0.72);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.5;
}

.ticket-meta {
  display: grid;
  grid-column: 1;
  gap: 4px;
  color: var(--blue);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.5;
}

.ticket-actions {
  display: grid;
  grid-column: 2;
  grid-row: 1 / 5;
  align-self: end;
  justify-self: end;
  gap: 8px;
  padding-right: 24px;
}

.ticket-select-button,
.leaderboard-button {
  min-height: 48px;
  padding: 10px 13px;
  border: 2px solid var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.ticket-select-button {
  color: var(--red);
  background: var(--ink);
}

.leaderboard-button {
  color: var(--ink);
  background: transparent;
}

.ticket-select-button:hover,
.ticket-select-button.is-selected,
.ticket-select-button[aria-pressed="true"] {
  color: var(--paper-light);
  background: var(--red);
}

.leaderboard-button:hover {
  color: var(--paper);
  background: var(--blue);
}

.history-panel {
  margin-top: 38px;
  padding: clamp(20px, 4vw, 32px);
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink-deep);
  box-shadow: 8px 8px 0 var(--blue);
}

.history-panel .eyebrow {
  color: var(--blue);
}

.history-panel h2 {
  margin-top: 5px;
  color: var(--ink);
}

.history-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 2px dashed rgb(16 44 53 / 0.38);
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.history-actions label {
  font-size: 0.7rem;
  font-weight: 900;
}

.history-actions select,
.history-actions button {
  padding: 9px 12px;
  border: 2px solid var(--ink);
  color: var(--paper);
  background: var(--ink);
}

#clear-history-button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 14px;
  padding: 14px;
  color: var(--paper);
  background: var(--ink);
  border-left: 5px solid var(--red);
}

.history-game,
.history-score,
.history-time,
.history-badge {
  min-width: 0;
}

.history-score {
  color: #ffdf72;
  font-weight: 900;
}

.history-time {
  color: rgb(244 228 179 / 0.68);
  font-size: 0.68rem;
}

.history-badge {
  color: #ffdf72;
  font-size: 0.66rem;
  font-weight: 900;
}

.history-empty {
  margin: 18px 0 0;
  color: rgb(16 44 53 / 0.68);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.instructions-screen {
  display: grid;
  min-height: min(720px, calc(100vh - 120px));
  place-items: center;
}

.rules-ticket {
  width: min(760px, 100%);
  padding: clamp(28px, 7vw, 68px);
  color: var(--ink);
  background:
    linear-gradient(rgb(16 44 53 / 0.05) 1px, transparent 1px) 0 0 / 100% 30px,
    var(--paper);
  border: 3px solid var(--ink-deep);
  box-shadow: 10px 10px 0 var(--red);
}

.rules-ticket .eyebrow {
  color: var(--blue);
}

.rules-ticket h2 {
  margin: 9px 0 24px;
  color: var(--ink);
}

.rules-copy {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  line-height: 1.8;
}

.rules-meta,
.stage-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 26px 0;
}

.rules-meta > div {
  padding: 15px;
  border: 2px solid var(--ink);
}

.rules-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.secondary-button--dark {
  color: var(--ink);
  border-color: var(--ink);
}

.secondary-button--dark:hover {
  color: var(--paper);
  background: var(--ink);
}

dt {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

dd {
  margin: 7px 0 0;
}

.primary-button {
  padding: 13px 20px;
  color: var(--paper-light);
  background: var(--red);
  border: 2px solid var(--ink-deep);
  box-shadow: 5px 5px 0 var(--ink-deep);
  cursor: pointer;
  font-weight: 900;
  transition: color 140ms ease, box-shadow 140ms ease, opacity 140ms ease, scale 140ms ease;
}

.primary-button:hover {
  color: #fff;
  box-shadow: 8px 8px 0 var(--blue);
  scale: 1.015;
}

.stage-screen {
  min-width: 0;
}

.stage-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

#stage-game-title {
  margin: 0;
  color: var(--paper-light);
  font-family: Impact, "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.7rem, 5vw, 3.5rem);
  letter-spacing: 0.05em;
}

.stage-stats {
  grid-template-columns: repeat(2, auto);
  margin: 0;
}

.stage-stats > div {
  min-width: 110px;
  padding: 10px 15px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink-deep);
}

.stage-stats strong {
  color: var(--red);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
}

.stage-screen.is-warning #stage-timer {
  color: #ffdf72;
  text-shadow: 0 0 12px var(--red);
}

.canvas-frame {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--ink-deep);
  border: 3px solid var(--paper);
  box-shadow: 10px 10px 0 var(--red);
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  background: #081f26;
  touch-action: none;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: var(--paper-light);
  background: rgb(7 27 33 / 0.86);
  text-align: center;
}

.countdown-overlay span {
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.35em;
}

.countdown-overlay strong {
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(7rem, 24vw, 15rem);
  line-height: 0.9;
  text-shadow: 6px 0 0 var(--red), -5px 0 0 var(--blue);
  animation: countdown-pulse 700ms ease-out both;
}

.result-dialog {
  width: min(620px, calc(100% - 32px));
  max-width: 620px;
  margin: auto;
  padding: 9px;
  color: var(--paper);
  background: var(--paper);
  border: 3px solid var(--ink-deep);
  box-shadow: 12px 12px 0 var(--blue), 0 24px 70px rgb(0 0 0 / 0.58);
}

.result-dialog[open] {
  animation: dialog-in 180ms ease-out both;
}

.result-dialog::backdrop {
  background: rgb(4 20 25 / 0.82);
}

.result-dialog.is-fallback-open {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: clamp(16px, 4vw, 40px);
  place-items: center;
  overflow: auto;
  background: rgb(4 20 25 / 0.9);
  border: 0;
  box-shadow: none;
}

.result-dialog.is-fallback-open .result-panel {
  width: min(100%, 600px);
}

.result-panel {
  padding: clamp(24px, 6vw, 44px);
  color: var(--paper);
  background: var(--ink);
  border: 3px double var(--paper);
}

.result-panel h2 {
  margin: 6px 0 26px;
}

.result-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-block: 2px dashed rgb(244 228 179 / 0.45);
}

.result-score-row span {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.result-score-row strong {
  color: #ffdf72;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(3rem, 12vw, 5.8rem);
  line-height: 0.9;
}

.result-rating {
  display: block;
  min-height: 1em;
  margin-top: 18px;
  color: var(--paper-light);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 2rem;
}

.result-record {
  min-height: 1em;
  color: #ffdf72;
  font-weight: 900;
}

.result-online {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--paper-light);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.5;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.dialog-hint {
  margin: 18px 0 0;
  color: rgb(244 228 179 / 0.64);
  font-size: 0.68rem;
  line-height: 1.5;
  text-align: center;
}

.leaderboard-dialog {
  width: min(920px, calc(100% - 32px));
  max-width: 920px;
  max-height: min(760px, calc(100dvh - 32px));
  margin: auto;
  padding: 9px;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink-deep);
  box-shadow: 12px 12px 0 var(--red), 0 24px 70px rgb(0 0 0 / 0.58);
}

.leaderboard-dialog[open] {
  animation: dialog-in 180ms ease-out both;
}

.leaderboard-dialog::backdrop {
  background: rgb(4 20 25 / 0.82);
}

.leaderboard-dialog.is-fallback-open {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: clamp(12px, 3vw, 32px);
  place-items: center;
  overflow: auto;
  background: rgb(4 20 25 / 0.9);
  border: 0;
  box-shadow: none;
}

.leaderboard-panel {
  display: grid;
  width: 100%;
  max-height: calc(100dvh - 52px);
  min-width: 0;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  padding: clamp(20px, 4vw, 34px);
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgb(16 44 53 / 0.05) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
  border: 3px double var(--ink);
}

.leaderboard-dialog.is-fallback-open .leaderboard-panel {
  width: min(100%, 900px);
}

.leaderboard-heading {
  display: flex;
  min-width: 0;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 2px dashed rgb(16 44 53 / 0.38);
}

.leaderboard-heading .eyebrow {
  color: var(--blue);
}

.leaderboard-heading h2 {
  margin-top: 5px;
  color: var(--ink);
  font-size: clamp(1.8rem, 5vw, 3.4rem);
  overflow-wrap: anywhere;
}

.leaderboard-close-button {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 9px 14px;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.leaderboard-status {
  min-height: 1.5em;
  margin: 12px 0;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
}

.leaderboard-columns,
.leaderboard-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 4rem minmax(0, 1fr) minmax(4rem, auto) minmax(8.5rem, 0.7fr);
  align-items: center;
  gap: 8px 14px;
}

.leaderboard-columns {
  padding: 0 12px 8px;
  color: rgb(16 44 53 / 0.62);
  font-size: 0.64rem;
  font-weight: 900;
}

.leaderboard-list {
  min-width: 0;
  margin: 0;
  padding: 0 8px 8px 0;
  overflow-x: hidden;
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.leaderboard-row {
  margin-bottom: 8px;
  padding: 11px 12px;
  background: var(--paper-light);
  border-left: 5px solid var(--blue);
}

.leaderboard-row.is-me {
  border-left-color: var(--red);
  box-shadow: inset 0 0 0 2px rgb(232 75 53 / 0.28);
}

.leaderboard-rank,
.leaderboard-score {
  font-variant-numeric: tabular-nums;
}

.leaderboard-rank {
  color: var(--blue);
}

.leaderboard-score {
  color: var(--red);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.35rem;
  text-align: right;
}

.leaderboard-player {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.leaderboard-name,
.leaderboard-code,
.leaderboard-time {
  min-width: 0;
  overflow-wrap: anywhere;
}

.leaderboard-code,
.leaderboard-time {
  color: rgb(16 44 53 / 0.62);
  font-size: 0.64rem;
}

.leaderboard-me {
  min-width: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed rgb(16 44 53 / 0.38);
  list-style: none;
}

.leaderboard-me .leaderboard-row {
  margin: 0;
  background: #ffdf72;
}

@keyframes countdown-pulse {
  from { opacity: 0.2; scale: 0.82; }
  to { opacity: 1; scale: 1; }
}

@keyframes dialog-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (max-width: 720px) {
  .arcade-shell {
    width: min(100% - 28px, 100%);
  }

  .topbar {
    padding-bottom: 30px;
  }

  .arcade-shell {
    padding-top: 20px;
  }

  .lobby-heading {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .player-panel {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .rename-player-form {
    grid-column: 1 / -1;
  }

  .ticket-wall,
  .history-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-ticket--featured {
    grid-column: auto;
    min-height: 0;
  }

  .history-heading,
  .stage-header {
    align-items: stretch;
    flex-direction: column;
  }

  .history-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    justify-content: stretch;
  }

  .history-actions label {
    grid-column: 1 / -1;
  }

  .history-actions select,
  .history-actions button {
    width: 100%;
    min-width: 0;
  }

  .stage-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-stats > div {
    min-width: 0;
  }
}

@media (max-width: 390px) {
  .arcade-shell {
    width: calc(100% - 24px);
  }

  .brand span {
    font-size: 0.55rem;
  }

  .brand strong {
    font-size: 1.2rem;
  }

  .sound-button {
    padding-inline: 10px;
    font-size: 0.66rem;
  }

  .game-ticket,
  .history-panel,
  .rules-ticket,
  .result-panel {
    padding: 20px;
  }

  .player-panel {
    grid-template-columns: minmax(0, 1fr);
    padding: 18px;
  }

  .connection-status {
    justify-self: start;
  }

  .rename-player-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .rename-player-form label {
    grid-column: auto;
  }

  .game-ticket {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-title {
    font-size: 2rem;
  }

  .ticket-actions {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-right: 0;
  }

  .rules-meta,
  .result-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .leaderboard-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
    padding: 5px;
  }

  .leaderboard-panel {
    max-height: calc(100dvh - 26px);
    padding: 14px;
  }

  .leaderboard-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .leaderboard-close-button {
    width: 100%;
  }

  .leaderboard-columns,
  .leaderboard-row {
    grid-template-columns: 2.8rem minmax(0, 1fr) auto;
    gap: 5px 8px;
  }

  .leaderboard-columns span:last-child {
    display: none;
  }

  .leaderboard-time {
    grid-column: 2 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .game-ticket:hover,
  .game-ticket.is-selected,
  .game-ticket[aria-pressed="true"],
  .primary-button:hover,
  .countdown-overlay strong {
    scale: 1;
  }

  .particle,
  [data-particle] {
    display: none !important;
  }
}
