:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #010303;
  color: #f7fff9;
  --bg: #010303;
  --ink: #f7fff9;
  --mint: #9fffe2;
  --ufo: #76e6cf;
  --ufo-deep: #0f4b43;
  --panel: rgba(1, 8, 7, 0.9);
  --panel-strong: rgba(2, 14, 12, 0.96);
  --line: rgba(159, 255, 226, 0.2);
  --line-strong: rgba(159, 255, 226, 0.55);
  --soft: rgba(247, 255, 249, 0.74);
  --muted: rgba(247, 255, 249, 0.52);
  --cell: min(5.1vw, 4.7vh, 35px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background:
    repeating-linear-gradient(90deg, rgba(159, 255, 226, 0.025) 0 1px, transparent 1px 78px),
    repeating-linear-gradient(0deg, rgba(159, 255, 226, 0.022) 0 1px, transparent 1px 78px),
    linear-gradient(145deg, #000 0%, #020807 54%, #000 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 34%, rgba(159, 255, 226, 0.045) 35%, transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 32%, rgba(0, 0, 0, 0.32));
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.binary-rain {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: screen;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(12px, 2vw, 22px);
  padding: clamp(14px, 3vw, 34px);
  overflow: hidden;
}

.topbar {
  width: min(1040px, 100%);
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1,
.lobby h2,
p {
  margin-top: 0;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 6vw, 70px);
  font-weight: 950;
  line-height: 0.86;
}

.topbar img {
  width: clamp(54px, 7vw, 86px);
  height: auto;
  filter: drop-shadow(0 0 18px rgba(159, 255, 226, 0.48));
}

.player-summary {
  display: grid;
  gap: 4px;
  margin-left: auto;
  border: 1px solid rgba(159, 255, 226, 0.18);
  border-radius: 8px;
  background: rgba(1, 9, 8, 0.72);
  padding: 10px 12px;
  text-align: right;
}

.player-summary p {
  margin: 0;
  color: var(--mint);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.player-summary div,
.player-summary a {
  color: var(--soft);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.player-summary a {
  color: var(--mint);
}

.player-summary a:hover,
.player-summary a:focus-visible {
  color: #fff;
  outline: none;
}

.eyebrow,
.mode-label {
  margin-bottom: 8px;
  color: var(--mint);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-home-link {
  display: inline-flex;
  text-decoration: none;
}

.site-home-link:hover,
.site-home-link:focus-visible {
  color: #fff;
  outline: none;
}

.lobby,
.game {
  width: min(1040px, 100%);
  justify-self: center;
  align-self: center;
}

.lobby {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 28px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(159, 255, 226, 0.13), rgba(118, 230, 207, 0.055) 48%, rgba(255, 255, 255, 0.025)),
    var(--panel);
  padding: clamp(24px, 4vw, 42px);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.46),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
}

.lobby::before,
.status-row::before,
.board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 18%, transparent 82%, rgba(159, 255, 226, 0.12));
  opacity: 0.55;
}

.lobby h2 {
  margin-bottom: 12px;
  max-width: 720px;
  font-size: clamp(34px, 5.2vw, 66px);
  font-weight: 950;
  line-height: 0.92;
}

.lobby-copy p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--soft);
  font-size: clamp(16px, 1.9vw, 21px);
  font-weight: 750;
  line-height: 1.35;
}

.lobby-actions {
  display: grid;
  gap: 10px;
  justify-items: stretch;
}

.rule-picker {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(159, 255, 226, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(159, 255, 226, 0.08), rgba(255, 255, 255, 0.035)),
    rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.rule-picker span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.rule-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rule-option {
  min-height: 44px;
  border: 1px solid rgba(159, 255, 226, 0.22);
  border-radius: 8px;
  background: rgba(5, 18, 16, 0.82);
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
  font-weight: 950;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.rule-option.is-active {
  border-color: rgba(159, 255, 226, 0.7);
  background: linear-gradient(135deg, rgba(159, 255, 226, 0.94), rgba(247, 255, 249, 0.9));
  color: #03100d;
  box-shadow: 0 12px 28px rgba(159, 255, 226, 0.14);
}

.lobby-status {
  width: min(260px, 100%);
  min-height: 18px;
  margin-bottom: 0;
  color: var(--mint);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.3;
}

.primary-action,
.ghost-action,
.invite button,
.game-actions button {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 950;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.primary-action,
.invite button {
  background:
    linear-gradient(135deg, rgba(247, 255, 249, 0.98), rgba(159, 255, 226, 0.9)),
    #9fffe2;
  color: #03100d;
  padding: 0 20px;
  box-shadow: 0 12px 28px rgba(159, 255, 226, 0.16);
}

.ghost-action,
.game-actions button {
  background: rgba(5, 18, 16, 0.9);
  color: var(--ink);
  padding: 0 14px;
}

.primary-action:hover,
.invite button:hover,
.ghost-action:hover,
.game-actions button:hover,
.rule-option:hover {
  transform: translateY(-1px);
}

.game-actions button.is-pending {
  border-color: rgba(159, 255, 226, 0.72);
  background:
    linear-gradient(135deg, rgba(159, 255, 226, 0.94), rgba(247, 255, 249, 0.88)),
    var(--mint);
  color: #02110e;
  box-shadow: 0 12px 28px rgba(159, 255, 226, 0.15);
}

button:disabled {
  cursor: default;
  opacity: 0.64;
  transform: none;
}

.game {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
}

.status-row,
.game-actions,
.invite,
.board-wrap,
.chat-panel {
  border: 1px solid rgba(159, 255, 226, 0.18);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    0 24px 52px rgba(0, 0, 0, 0.34),
    inset 0 0 34px rgba(159, 255, 226, 0.035);
  backdrop-filter: blur(14px);
}

.play-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 12px;
}

.play-layout > * {
  min-width: 0;
}

.status-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.status {
  margin: 0;
  color: #fff;
  font-size: clamp(17px, 2vw, 23px);
  font-weight: 950;
}

.status-tools,
.game-actions {
  align-items: center;
  gap: 10px;
}

.status-tools {
  display: flex;
  justify-content: flex-end;
}

.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.player-chip,
.timer-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(159, 255, 226, 0.38);
  border-radius: 8px;
  background: rgba(159, 255, 226, 0.08);
  color: var(--mint);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  white-space: nowrap;
}

.player-chip.is-ready {
  border-color: rgba(159, 255, 226, 0.58);
  background: rgba(159, 255, 226, 0.12);
  color: var(--mint);
}

.player-chip.is-danger {
  border-color: rgba(159, 255, 226, 0.66);
  background: rgba(159, 255, 226, 0.14);
  color: var(--mint);
}

.rule-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(159, 255, 226, 0.28);
  border-radius: 8px;
  background: rgba(159, 255, 226, 0.065);
  color: var(--mint);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  white-space: nowrap;
}

.invite {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.invite {
  display: none !important;
}

.invite p {
  margin-bottom: 0;
  color: var(--soft);
  font-size: 13px;
  font-weight: 850;
}

.invite-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.invite input {
  min-width: 0;
  min-height: 46px;
  border: 1px solid rgba(159, 255, 226, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.invite input:focus {
  border-color: var(--line-strong);
}

.disconnect-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: clamp(18px, 5vw, 42px);
  background:
    radial-gradient(circle at center, rgba(159, 255, 226, 0.1), transparent 36%),
    rgba(0, 0, 0, 0.84);
  text-align: center;
  backdrop-filter: blur(14px);
}

.disconnect-overlay > div:first-child {
  width: min(520px, 100%);
  padding: clamp(12px, 4vw, 28px);
}

.disconnect-overlay strong {
  display: block;
  color: #fff;
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 950;
  line-height: 0.92;
}

.disconnect-overlay p:not(.mode-label) {
  max-width: 360px;
  margin: 12px auto 0;
  color: var(--soft);
  font-size: clamp(15px, 2.2vw, 18px);
  font-weight: 850;
  line-height: 1.35;
}

.disconnect-link {
  width: min(440px, 100%);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 18px auto 0;
}

.disconnect-link input {
  min-width: 0;
  min-height: 46px;
  border: 1px solid rgba(159, 255, 226, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.disconnect-link button {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(247, 255, 249, 0.98), rgba(159, 255, 226, 0.9)),
    #9fffe2;
  color: #03100d;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 950;
}

.board-wrap {
  position: relative;
  display: grid;
  justify-content: center;
  overflow: hidden;
  padding: clamp(10px, 1.4vw, 16px);
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-head .mode-label {
  margin: 0;
}

.chat-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.chat-messages {
  min-height: 160px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.chat-empty,
.chat-message {
  margin: 0;
}

.chat-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.chat-message {
  border: 1px solid rgba(159, 255, 226, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 9px;
}

.chat-message div {
  color: var(--mint);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.chat-message p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-form input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(159, 255, 226, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--line-strong);
}

.chat-form button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(247, 255, 249, 0.98), rgba(159, 255, 226, 0.9)),
    #9fffe2;
  color: #03100d;
  cursor: pointer;
  font-weight: 950;
  padding: 0 14px;
}

.chat-form.is-disabled {
  opacity: 0.68;
}

.board-wrap.is-zoomable {
  touch-action: none;
}

.board-wrap.is-zoomed {
  cursor: grab;
}

.board {
  position: relative;
  z-index: 1;
  display: grid;
  --board-size: 15;
  grid-template-columns: repeat(var(--board-size), var(--cell));
  grid-template-rows: repeat(var(--board-size), var(--cell));
  gap: 3px;
  border: 1px solid rgba(159, 255, 226, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(159, 255, 226, 0.12), rgba(118, 230, 207, 0.045)),
    rgba(2, 8, 7, 0.9);
  padding: 8px;
  transform-origin: center;
  will-change: transform;
  box-shadow:
    0 34px 60px rgba(0, 0, 0, 0.44),
    inset 0 0 46px rgba(159, 255, 226, 0.07);
}

.board.is-small-board {
  --cell: clamp(86px, 20vw, 118px);
  gap: 8px;
  padding: 10px;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  border: 1px solid rgba(159, 255, 226, 0.13);
  border-radius: 5px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.07), transparent),
    rgba(255, 255, 255, 0.035);
  color: #fff;
  cursor: pointer;
  font-size: calc(var(--cell) * 0.58);
  font-weight: 950;
  line-height: 1;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.cell:hover {
  border-color: rgba(159, 255, 226, 0.58);
  background: rgba(159, 255, 226, 0.1);
  box-shadow: inset 0 0 18px rgba(159, 255, 226, 0.08);
}

.cell.mark-x {
  color: var(--mint);
  text-shadow: 0 0 14px rgba(159, 255, 226, 0.52);
}

.cell.mark-o {
  color: #d8fff6;
  text-shadow: 0 0 14px rgba(159, 255, 226, 0.44);
}

.cell.is-win {
  border-color: rgba(159, 255, 226, 0.86);
  background: rgba(159, 255, 226, 0.15);
  color: #fff;
  transform: scale(1.04);
  box-shadow: 0 0 18px rgba(159, 255, 226, 0.24);
}

.game-actions {
  padding: 10px;
}

.game-actions span {
  display: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: clamp(14px, 4vw, 36px);
  background:
    radial-gradient(circle at 50% 44%, rgba(159, 255, 226, 0.18), transparent 34%),
    rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
}

.draw-offer-modal {
  z-index: 11;
  background:
    radial-gradient(circle at 50% 44%, rgba(159, 255, 226, 0.2), transparent 34%),
    rgba(0, 0, 0, 0.86);
}

.result-card {
  position: relative;
  width: min(460px, 100%);
  overflow: hidden;
  border: 1px solid rgba(159, 255, 226, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(159, 255, 226, 0.15), rgba(118, 230, 207, 0.06) 48%, rgba(255, 255, 255, 0.025)),
    rgba(1, 9, 8, 0.97);
  padding: clamp(20px, 4vw, 30px);
  text-align: center;
  box-shadow:
    0 36px 90px rgba(0, 0, 0, 0.58),
    inset 0 0 54px rgba(159, 255, 226, 0.05);
}

.draw-offer-card {
  width: min(520px, 100%);
  border-color: rgba(159, 255, 226, 0.56);
  box-shadow:
    0 42px 100px rgba(0, 0, 0, 0.68),
    0 0 54px rgba(159, 255, 226, 0.14),
    inset 0 0 54px rgba(159, 255, 226, 0.06);
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent 24%, transparent 76%, rgba(159, 255, 226, 0.16)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 14px);
  opacity: 0.58;
}

.result-card > * {
  position: relative;
  z-index: 1;
}

.result-card h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 950;
  line-height: 0.9;
}

.result-card p:not(.mode-label) {
  margin-bottom: 20px;
  color: var(--soft);
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 800;
  line-height: 1.4;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-actions button {
  width: 100%;
}

.result-modal.is-win .result-card {
  border-color: rgba(159, 255, 226, 0.58);
  box-shadow:
    0 36px 90px rgba(0, 0, 0, 0.58),
    0 0 48px rgba(159, 255, 226, 0.15),
    inset 0 0 54px rgba(159, 255, 226, 0.06);
}

.result-modal.is-loss .result-card {
  border-color: rgba(159, 255, 226, 0.36);
}

.result-modal.is-draw .result-card {
  border-color: rgba(159, 255, 226, 0.42);
}

.is-hidden {
  display: none;
}

@media (max-width: 980px) {
  .game {
    width: min(720px, 100%);
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    max-height: 180px;
  }
}

@media (max-width: 720px) {
  :root {
    --cell: min(calc((100vw - 48px) / 15), 24px);
  }

  .game-shell {
    height: 100svh;
    min-height: 100svh;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 58px;
    gap: 10px;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .player-summary {
    display: none;
  }

  .topbar h1 {
    font-size: clamp(34px, 11vw, 48px);
    line-height: 0.88;
  }

  .topbar img {
    width: 46px;
  }

  .eyebrow,
  .mode-label {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .game {
    width: min(440px, 100%);
    height: 100%;
    align-self: stretch;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
    overflow: hidden;
  }

  .invite {
    display: none !important;
  }

  .play-layout {
    min-height: 0;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .status-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 11px;
  }

  .status-row > div:first-child {
    min-width: 0;
  }

  .status {
    font-size: clamp(20px, 6vw, 27px);
    line-height: 1.06;
  }

  .status-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 6px;
  }

  .player-chip,
  .timer-chip,
  .rule-chip {
    min-height: 32px;
    padding: 0 8px;
    overflow: hidden;
    font-size: clamp(10px, 2.7vw, 11px);
    text-overflow: ellipsis;
  }

  .lobby {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .lobby-status {
    width: 100%;
  }

  .invite-controls,
  .disconnect-link {
    grid-template-columns: 1fr;
    display: grid;
  }

  .game-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
    background: rgba(1, 9, 8, 0.78);
  }

  .primary-action,
  .ghost-action,
  .invite button,
  .game-actions button,
  .player-chip,
  .timer-chip,
  .rule-chip,
  .result-actions button {
    width: 100%;
  }

  .board-wrap {
    min-height: 0;
    align-content: center;
    align-items: center;
    padding: 6px;
    background: rgba(1, 10, 8, 0.76);
  }

  .chat-panel {
    border-color: rgba(159, 255, 226, 0.14);
    max-height: 168px;
    padding: 9px;
  }

  .chat-head span {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-messages {
    min-height: 70px;
    max-height: 78px;
    gap: 6px;
  }

  .chat-message {
    padding: 7px;
  }

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

  .chat-form input,
  .chat-form button {
    min-height: 38px;
    font-size: 13px;
  }

  .board {
    gap: 2px;
    padding: 5px;
  }

  .board.is-small-board {
    --cell: min(25vw, 88px);
    gap: 7px;
    padding: 7px;
  }

  .cell {
    border-radius: 4px;
  }

  .result-modal {
    place-items: end center;
    padding: 12px;
  }

  .result-card {
    width: 100%;
    padding: 22px 16px 16px;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }

  .draw-offer-modal {
    place-items: center;
  }
}

@media (max-width: 720px) and (max-height: 820px) {
  .chat-panel {
    max-height: 132px;
  }

  .chat-messages {
    max-height: 48px;
  }
}

@media (max-width: 430px) {
  :root {
    --cell: min(calc((100vw - 44px) / 15), 23px);
  }

  .game-actions {
    gap: 8px;
  }

  .game-actions button {
    min-height: 44px;
    padding: 0 8px;
    font-size: 13px;
  }
}

@media (max-width: 430px) and (max-height: 760px) {
  .topbar {
    min-height: 50px;
  }

  .topbar h1 {
    font-size: clamp(30px, 10vw, 40px);
  }

  .topbar img {
    width: 40px;
  }

  .status {
    font-size: clamp(18px, 5.4vw, 23px);
  }

  .board.is-small-board {
    --cell: min(23vw, 80px);
    gap: 6px;
  }
}

@media (max-height: 640px) and (orientation: landscape) {
  :root {
    --cell: min(4.3vw, 3.6vh, 27px);
  }

  .game-shell {
    gap: 8px;
    padding: 10px;
  }

  .topbar h1 {
    font-size: clamp(28px, 6vh, 42px);
  }

  .topbar img {
    width: 46px;
  }

  .status-row,
  .game-actions {
    padding: 8px;
  }

  .result-card {
    width: min(520px, 100%);
    padding: 18px;
  }
}
