:root {
  --bg: #ffffff;
  --ink: #000000;
  --muted: #858585;
  --panel: #ffffff;
  --line: #eeeeee;
  --field: #f4f4f4;
  --button-primary-bg: #000000;
  --button-primary-text: #ffffff;
  --button-secondary-bg: #f7f7f7;
  --button-secondary-border: #c8c8c8;
  --button-secondary-text: #000000;
  --card-border: #000000;
  --status-blue: #001dff;
  --modal-scrim: rgba(255, 255, 255, 0.58);
  --dark-cell: #000000;
  --light-cell: #606060;
  --white-piece: #a6ff00;
  --black-piece: #18b9e8;
  --king-on-white: #000000;
  --king-on-black: #000000;
  --capture-dot: #777777;
  --selected-ring: rgba(0, 0, 0, 0.72);
  --board-radius: clamp(28px, 4vw, 56px);
  --board-shadow: none;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-ui-theme="dark"] {
  --bg: #302e2e;
  --ink: #ffffff;
  --muted: #a8a4a4;
  --panel: #302e2e;
  --line: #8c8a8a;
  --field: #444141;
  --button-primary-bg: #000000;
  --button-primary-text: #ffffff;
  --button-secondary-bg: #656463;
  --button-secondary-border: #656463;
  --button-secondary-text: #ffffff;
  --card-border: #d7d2cf;
  --status-blue: #ff72dc;
  --modal-scrim: rgba(48, 46, 46, 0.62);
  color-scheme: dark;
}

body[data-theme="midnight"] {
  --dark-cell: #000000;
  --light-cell: #5f5f5d;
  --white-piece: #ffffff;
  --black-piece: #3fb7d6;
  --king-on-white: #000000;
  --king-on-black: #000000;
  --capture-dot: #7e7e7d;
  --selected-ring: rgba(63, 183, 214, 0.84);
  --board-shadow: none;
}

body[data-theme="sand"] {
  --dark-cell: #c8bbad;
  --light-cell: #f1f1f1;
  --white-piece: #ffffff;
  --black-piece: #927d66;
  --king-on-white: #c8bbad;
  --king-on-black: #d3c6b8;
  --capture-dot: #ffffff;
  --selected-ring: rgba(146, 125, 102, 0.82);
  --board-shadow: none;
}

body[data-theme="sky"] {
  --dark-cell: #94c5d8;
  --light-cell: #f2eee8;
  --white-piece: #ffffff;
  --black-piece: #3d85a3;
  --king-on-white: #94c5d8;
  --king-on-black: #9fcfe0;
  --capture-dot: #3d85a3;
  --selected-ring: rgba(62, 131, 159, 0.75);
  --board-shadow: none;
}

body[data-theme="lime"] {
  --dark-cell: #0f4d3b;
  --light-cell: #e7c49d;
  --white-piece: #ffffff;
  --black-piece: #1fa57d;
  --king-on-white: #0f4d3b;
  --king-on-black: #0f4d3b;
  --capture-dot: #1fa57d;
  --selected-ring: rgba(31, 165, 125, 0.82);
  --board-shadow: none;
}

body[data-theme="walnut"] {
  --dark-cell: #9d8062;
  --light-cell: #d2c0aa;
  --white-piece: #ffffff;
  --black-piece: #302e2b;
  --king-on-white: #9d8062;
  --king-on-black: #9d8062;
  --capture-dot: #d2c0aa;
  --selected-ring: rgba(48, 46, 43, 0.78);
  --board-shadow: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

.site-header,
.site-footer {
  position: fixed;
  left: clamp(20px, 2vw, 36px);
  z-index: 5;
  color: var(--ink);
}

.site-header {
  top: 22px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
}

.site-footer {
  bottom: 22px;
  display: flex;
  gap: clamp(38px, 5vw, 83px);
  font-size: 13px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 52px;
  border: 1px solid var(--button-secondary-border);
  border-radius: 8px;
  color: var(--button-secondary-text);
  background: var(--button-secondary-bg);
  cursor: pointer;
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    background 140ms ease;
}

button:hover {
  opacity: 0.82;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--button-primary-bg);
  color: var(--button-primary-text);
  background: var(--button-primary-bg);
}

button.primary:hover {
  background: var(--button-primary-bg);
  opacity: 0.9;
}

button.danger {
  border-color: var(--button-primary-bg);
  color: var(--button-primary-text);
  background: var(--button-primary-bg);
}

button.danger:hover {
  background: var(--button-primary-bg);
  opacity: 0.9;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 23px;
  color: var(--ink);
  background: var(--field);
}

input::placeholder {
  color: #777777;
  opacity: 1;
}

body[data-ui-theme="dark"] input::placeholder {
  color: #a8a4a4;
}

.icon-button {
  position: fixed;
  top: 24px;
  right: 34px;
  z-index: 9;
  display: grid;
  place-items: center;
  width: 45px;
  min-height: 45px;
  height: 45px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.icon-button:hover {
  background: transparent;
  opacity: 0.72;
}

body[data-screen="game"] .theme-toggle {
  right: 250px;
}

.sound-toggle {
  right: 91px;
}

body[data-screen="game"] .sound-toggle {
  right: 307px;
}

.theme-toggle {
  position: fixed;
}

.theme-icon,
.sound-icon {
  position: absolute;
  width: 30px;
  height: 30px;
  transition:
    filter 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.sound-on-icon {
  opacity: 1;
  transform: scale(1);
}

.sound-off-icon {
  opacity: 0;
  transform: scale(0.72);
}

body[data-sound="off"] .sound-on-icon {
  opacity: 0;
  transform: scale(0.72);
}

body[data-sound="off"] .sound-off-icon {
  opacity: 1;
  transform: scale(1);
}

.sun-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.moon-icon {
  opacity: 0;
  transform: scale(0.72) rotate(-20deg);
}

body[data-ui-theme="dark"] .sun-icon {
  opacity: 0;
  transform: scale(0.72) rotate(20deg);
}

body[data-ui-theme="dark"] .moon-icon {
  filter: invert(1);
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

body[data-ui-theme="dark"] .sound-icon {
  filter: invert(1);
}

#roomInput {
  text-transform: uppercase;
}

.app {
  display: grid;
  grid-template-columns: minmax(288px, 423px) minmax(468px, 792px);
  align-items: center;
  gap: clamp(72px, 9vw, 153px);
  width: min(1332px, calc(100vw - 58px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 72px 0;
}

body[data-screen="game"] .app {
  position: relative;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  gap: 48px 0;
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  padding: 72px 0 84px;
}

.side-panel {
  display: grid;
  gap: 52px;
  align-content: center;
}

body[data-screen="game"] .side-panel {
  position: absolute;
  top: clamp(120px, 18vh, 190px);
  left: clamp(36px, 6vw, 120px);
  z-index: 2;
  width: min(270px, 24vw);
  align-self: auto;
  align-content: start;
  gap: 28px;
  padding-top: 0;
}

.eyebrow {
  display: none;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(40px, 3.6vw, 52px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: 0;
}

.status {
  min-height: auto;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.35;
}

body[data-screen="game"] .status {
  margin-top: 22px;
  color: var(--muted);
  font-size: 20px;
}

.room-code-inline {
  min-height: 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  border-radius: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.room-code-inline:hover {
  color: var(--ink);
  background: transparent;
  opacity: 1;
}

.room-actions,
.join-form {
  display: grid;
  gap: 16px;
}

.join-form {
  grid-template-columns: 1fr auto;
  gap: 16px;
}

.join-form button {
  min-width: 128px;
  padding: 0 29px;
}

.game-actions {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  justify-self: center;
  width: min(720px, 100%);
}

.game-actions button {
  width: 220px;
}

.game-actions .icon-action {
  display: inline-flex;
  gap: 22px;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.action-icon {
  width: 34px;
  aspect-ratio: 1;
  background: currentColor;
  content: "";
}

.surrender-action .action-icon {
  -webkit-mask: url("/flag-banner-light.svg") center / contain no-repeat;
  mask: url("/flag-banner-light.svg") center / contain no-repeat;
}

.draw-action .action-icon {
  -webkit-mask: url("/handshake-light.svg") center / contain no-repeat;
  mask: url("/handshake-light.svg") center / contain no-repeat;
}

.game-actions .shake-button {
  width: 70px;
  min-width: 70px;
  min-height: 52px;
  padding: 0;
  border-color: var(--button-secondary-border);
  border-radius: 8px;
  background:
    url("/hand-fist-light.svg") center / 31px 31px no-repeat,
    var(--button-secondary-bg);
}

.game-actions .shake-button:hover {
  opacity: 0.9;
}

.style-picker {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 74px;
}

.style-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 31px;
  min-height: 31px;
  height: 31px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
}

.style-swatch:hover {
  background: transparent;
  opacity: 0.78;
}

.style-swatch::before {
  position: absolute;
  inset: -5px;
  border: 2px solid transparent;
  border-radius: 50%;
  content: "";
}

.style-swatch.is-selected::before {
  border-color: currentColor;
}

.style-swatch span {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: currentColor;
}

.style-swatch[data-theme="midnight"] {
  color: #000000;
}

.style-swatch[data-theme="sand"] {
  color: #c8bbad;
}

.style-swatch[data-theme="sky"] {
  color: #94c5d8;
}

.style-swatch[data-theme="lime"] {
  color: #0f4d3b;
}

.style-swatch[data-theme="walnut"] {
  color: #9d8062;
}

.room-card,
.player-strip,
.score-card {
  display: grid;
  gap: 11px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel);
}

body[data-screen="game"] .room-card {
  display: none !important;
}

body[data-screen="game"] .player-strip {
  position: fixed;
  top: 28px;
  right: 36px;
  z-index: 8;
  display: flex;
  align-items: center;
  width: max-content;
  gap: 16px;
  border-color: var(--card-border);
  border-radius: 999px;
  padding: 8px 18px 8px 17px;
  background: var(--panel);
}

body[data-screen="game"] .player-strip::before {
  display: block;
  width: 12px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ff3b30;
  content: "";
}

body[data-screen="game"] .player-strip.is-online::before {
  background: #20c997;
}

body[data-screen="game"] .player-strip.is-waiting::before {
  background: #ff3b30;
}

body[data-screen="game"] .player-strip > div:first-child,
body[data-screen="game"] .player-strip > div:last-child {
  display: none;
}

.room-card {
  grid-template-columns: 1fr auto;
}

.player-strip {
  grid-template-columns: repeat(3, 1fr);
}

.score-card {
  grid-template-columns: 1fr auto 1fr;
}

.score-card > div:last-child {
  text-align: right;
}

.room-card span,
.player-strip span,
.score-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.room-card strong,
.player-strip strong,
.score-card strong {
  font-size: 18px;
}

body[data-screen="game"] .player-strip span,
body[data-screen="game"] .player-strip strong {
  display: inline;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

body[data-screen="game"] .player-strip span {
  margin-right: 10px;
  color: var(--muted);
  font-weight: 500;
}

.match-card {
  display: grid;
  align-content: space-between;
  width: 224px;
  min-height: 180px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 18px 16px 16px;
  color: var(--ink);
  background: var(--panel);
}

.match-card span {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.match-card strong {
  font-size: 48px;
  line-height: 1;
}

.match-card b {
  font-size: 14px;
  line-height: 1.2;
}

.thinking-text {
  margin: -8px 0 0;
  color: var(--status-blue);
  font-size: 14px;
}

.opponent-thinking {
  margin: 14px 0 0;
  width: 224px;
  font-weight: 400;
  line-height: 1.25;
  text-transform: none;
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  width: 224px;
  margin-top: 28px;
}

.captured-pieces[hidden] {
  display: none;
}

.opponent-captured {
  margin-top: 34px;
}

.captured-piece {
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
}

.captured-piece.white {
  border: 1px solid var(--muted);
  color: transparent;
  background: var(--white-piece);
}

.captured-piece.black {
  color: var(--black-piece);
}

.captured-piece.is-new {
  animation: captured-piece-arrive 360ms cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}

@keyframes captured-piece-arrive {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.55);
  }

  70% {
    opacity: 1;
    transform: translateY(2px) scale(1.12);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animated-dots::after {
  display: inline-block;
  width: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
  content: "";
  animation: thinking-dots 1.2s steps(4, end) infinite;
}

@keyframes thinking-dots {
  0% {
    content: "";
  }

  25% {
    content: ".";
  }

  50% {
    content: "..";
  }

  75%,
  100% {
    content: "...";
  }
}

.opponent-stack {
  position: absolute;
  top: calc(clamp(120px, 18vh, 190px) + 162px);
  right: clamp(36px, 6vw, 120px);
}

.score-text {
  align-self: center;
  justify-self: center;
  font-size: 25px !important;
}

.board-shell {
  display: grid;
  place-items: center;
}

body[data-screen="game"] .board-shell {
  grid-column: 1 / -1;
  grid-row: 1;
  justify-self: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(738px, calc(100vw - 29px), calc(100vh - 58px));
  aspect-ratio: 1;
  border: clamp(12px, 1.7vw, 22px) solid var(--dark-cell);
  border-radius: var(--board-radius);
  box-shadow: var(--board-shadow);
  background: var(--dark-cell);
  overflow: hidden;
}

body[data-screen="game"] .board {
  width: min(650px, calc(100vw - 32px), calc(100vh - 210px));
}

.board.is-shaking {
  animation: board-shake 340ms linear both;
}

.board.is-shaking-loop {
  animation: board-shake 260ms linear infinite;
}

@keyframes board-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  12% {
    transform: translate3d(-1.4px, 0.8px, 0) rotate(-0.16deg);
  }

  24% {
    transform: translate3d(1.2px, -0.7px, 0) rotate(0.13deg);
  }

  36% {
    transform: translate3d(-0.8px, -1.1px, 0) rotate(0.08deg);
  }

  48% {
    transform: translate3d(1.5px, 0.6px, 0) rotate(-0.12deg);
  }

  60% {
    transform: translate3d(-1px, 0.9px, 0) rotate(0.15deg);
  }

  74% {
    transform: translate3d(0.9px, -1px, 0) rotate(-0.09deg);
  }

  88% {
    transform: translate3d(-0.6px, 0.4px, 0) rotate(0.05deg);
  }
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--light-cell);
}

.cell.dark {
  background: var(--dark-cell);
}

.cell:hover {
  background: var(--light-cell);
}

.cell.dark:hover {
  background: var(--dark-cell);
}

.cell.coord::after {
  display: none;
}

.cell.selected {
  outline: clamp(3px, 0.45vw, 5px) solid var(--selected-ring);
  outline-offset: calc(clamp(3px, 0.45vw, 5px) * -1);
}

.cell.waiting-piece {
  cursor: pointer;
}

.cell.capture-target::before {
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--capture-dot);
  content: "";
}

.cell:disabled {
  cursor: default;
  opacity: 1;
}

.piece {
  position: relative;
  display: grid;
  place-items: center;
  width: 74%;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: none;
  pointer-events: none;
  will-change: transform;
}

.piece.is-arriving {
  animation: piece-arrive 320ms cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

@keyframes piece-arrive {
  from {
    transform: translate(
        calc(var(--move-dx, 0) * 135.135%),
        calc(var(--move-dy, 0) * 135.135%)
      )
      scale(0.985);
  }

  72% {
    transform: translate(0, 0) scale(1.015);
  }

  to {
    transform: translate(0, 0) scale(1);
  }
}

.piece.white {
  border: 0;
  background: var(--white-piece);
}

.piece.black {
  border: 0;
  background: var(--black-piece);
}

.piece.king::after {
  width: 52%;
  aspect-ratio: 43 / 33;
  background: currentColor;
  -webkit-mask: url("/crown.svg") center / contain no-repeat;
  mask: url("/crown.svg") center / contain no-repeat;
  color: var(--king-on-white);
  content: "";
}

.piece.black.king::after {
  color: var(--king-on-black);
}

@media (prefers-reduced-motion: reduce) {
  .board.is-shaking-loop,
  .board.is-shaking,
  .captured-piece.is-new,
  .piece.is-arriving {
    animation: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(62, 131, 159, 0.22);
  border-radius: 8px;
  padding: 14px 18px;
  color: #ffffff;
  background: rgba(47, 113, 141, 0.96);
  box-shadow: 0 14px 36px rgba(37, 75, 92, 0.22);
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(37, 75, 92, 0.18);
}

.modal-backdrop.result-backdrop,
.modal-backdrop.soft-backdrop {
  backdrop-filter: blur(10px);
  background: var(--modal-scrim);
}

.modal {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(37, 75, 92, 0.22);
}

.result-backdrop .modal {
  width: min(520px, calc(100vw - 40px));
  border: 0;
  border-radius: 14px;
  padding: 62px 44px 52px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.soft-backdrop .modal {
  width: min(520px, calc(100vw - 40px));
  border: 0;
  border-radius: 14px;
  padding: 46px 44px 42px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.modal h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.result-backdrop .modal h2 {
  color: var(--ink);
  font-size: clamp(38px, 4.2vw, 56px);
  font-weight: 400;
  line-height: 1.15;
  white-space: pre-line;
}

.soft-backdrop .modal h2 {
  color: var(--ink);
  font-size: clamp(30px, 3.2vw, 42px);
  font-weight: 400;
  line-height: 1.15;
}

.modal p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.4;
}

.modal-input {
  width: 100%;
  margin-top: 24px;
}

.result-backdrop .modal p {
  display: none;
}

.soft-backdrop .modal p {
  max-width: 360px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 18px;
}

.name-backdrop {
  backdrop-filter: blur(10px);
  background: var(--modal-scrim);
}

.name-backdrop .modal {
  width: min(420px, calc(100vw - 40px));
  border: 0;
  border-radius: 14px;
  padding: 34px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.name-backdrop .modal h2 {
  font-size: clamp(30px, 3.2vw, 42px);
  font-weight: 400;
}

.name-backdrop .modal-actions {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 22px;
}

.result-backdrop .modal-actions,
.soft-backdrop .modal-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.result-backdrop .modal-actions button,
.soft-backdrop .modal-actions button {
  min-width: 150px;
  min-height: 58px;
  padding: 0 34px;
}

.result-backdrop .modal-actions button.secondary,
.soft-backdrop .modal-actions button.secondary {
  border-color: var(--button-secondary-border);
  color: var(--button-secondary-text);
  background: var(--button-secondary-bg);
}

.result-backdrop .modal-actions button.secondary:hover,
.soft-backdrop .modal-actions button.secondary:hover {
  background: var(--button-secondary-bg);
  opacity: 0.82;
}

.modal-actions button:only-child {
  grid-column: 1 / -1;
}

@media (max-width: 820px) {
  .site-header {
    top: 18px;
    left: 28px;
  }

  .theme-toggle {
    top: 12px;
    right: 16px;
  }

  .sound-toggle {
    top: 12px;
    right: 67px;
  }

  .site-footer {
    position: static;
    margin: 0 28px 24px;
  }

  .app {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 28px;
    width: min(560px, calc(100vw - 56px));
    padding: 92px 0 28px;
  }

  body[data-screen="game"] .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 22px;
    width: min(650px, calc(100vw - 48px));
    padding: 84px 0 28px;
  }

  .side-panel {
    gap: 22px;
  }

  body[data-screen="game"] .side-panel {
    position: static;
    width: auto;
    gap: 12px;
    padding-top: 0;
  }

  body[data-screen="game"] .side-panel > div:first-child {
    display: none;
  }

  body[data-screen="game"] .player-strip {
    top: 18px;
    right: 16px;
  }

  body[data-screen="game"] .theme-toggle {
    top: 62px;
    right: 16px;
  }

  body[data-screen="game"] .sound-toggle {
    top: 62px;
    right: 67px;
  }

  h1 {
    font-size: clamp(42px, 12vw, 58px);
    line-height: 1.04;
  }

  .status {
    min-height: auto;
    margin-top: 16px;
    font-size: 18px;
  }

  .room-actions,
  .join-form {
    gap: 14px;
  }

  .join-form {
    grid-template-columns: 1fr;
  }

  .join-form button {
    width: 100%;
  }

  .style-picker {
    gap: 18px;
    justify-content: flex-start;
    margin-top: 38px;
  }

  .board {
    justify-self: center;
    width: min(100%, 520px);
    border-width: 6px;
  }

  body[data-screen="game"] .board-shell,
  body[data-screen="game"] .opponent-stack,
  body[data-screen="game"] .game-actions {
    grid-column: auto;
  }

  body[data-screen="game"] .side-panel {
    grid-row: 3;
  }

  body[data-screen="game"] .board-shell {
    grid-row: 2;
  }

  body[data-screen="game"] .opponent-stack {
    grid-row: 1;
    position: static;
    transform: none;
    justify-self: start;
    width: 100%;
  }

  body[data-screen="game"] .game-actions {
    grid-row: 4;
    width: 100%;
  }

  body[data-screen="game"] .game-actions button:not(.shake-button) {
    width: min(220px, 100%);
  }

  body[data-screen="game"] .game-actions .shake-button {
    width: 70px;
    min-width: 70px;
  }

  body[data-screen="game"] .match-card {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-content: center;
    width: 100%;
    min-height: 112px;
    padding: 24px 30px;
  }

  body[data-screen="game"] .match-card span {
    grid-column: 1 / 2;
    grid-row: 1;
    align-self: start;
    font-size: 18px;
  }

  body[data-screen="game"] .match-card b {
    grid-column: 1 / 2;
    grid-row: 2;
    align-self: end;
    font-size: 20px;
  }

  body[data-screen="game"] .match-card strong {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    font-size: 56px;
  }

  body[data-screen="game"] .thinking-text,
  body[data-screen="game"] .opponent-thinking {
    width: 100%;
    margin: 0;
    font-size: 18px;
  }

  body[data-screen="game"] .captured-pieces {
    width: 100%;
    margin-top: 12px;
    gap: 8px 10px;
  }

  body[data-screen="game"] .captured-piece {
    width: 20px;
  }
}

@media (max-width: 460px) {
  .player-strip,
  .room-card,
  .score-card,
  .modal-actions {
    grid-template-columns: 1fr;
  }

  .app {
    width: min(100%, calc(100vw - 40px));
  }

  h1 {
    font-size: clamp(40px, 13vw, 52px);
  }

  .score-card > div:last-child {
    text-align: left;
  }
}
