:root {
  color-scheme: dark;
  --background: #0c1323;
  --surface: #151f34;
  --surface-strong: #1c2942;
  --line: #33415f;
  --text: #f4f7fb;
  --muted: #aab6cb;
  --accent: #72d7e7;
  --accent-strong: #34b7cc;
  --x-color: #ff806f;
  --o-color: #72d7e7;
  --success: #91e6b3;
  --warning: #ffc46b;
  --radius: 18px;
  --shadow: 0 24px 80px rgb(1 6 18 / 0.42);
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 88% 12%, rgb(52 183 204 / 0.14), transparent 28rem),
    radial-gradient(circle at 8% 88%, rgb(255 128 111 / 0.10), transparent 30rem),
    var(--background);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.site-shell {
  min-height: 100dvh;
}

.game-home {
  position: relative;
  width: min(1040px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(32px, 7vw, 84px) 0;
  display: grid;
  align-content: center;
  gap: clamp(36px, 7vw, 72px);
}

.account-button {
  position: absolute;
  top: 28px;
  right: 0;
  min-width: 190px;
  min-height: 54px;
  padding: 8px 12px 8px 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.account-button:hover {
  border-color: #52617f;
  background: #19263e;
  transform: translateY(-2px);
}

.account-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #07171c;
  background: var(--accent);
  font-size: 0.88rem;
  font-weight: 850;
}

.account-button-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.account-button-copy small {
  color: var(--muted);
  font-size: 0.72rem;
}

.account-button-copy strong {
  overflow: hidden;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coin-balance {
  margin-left: auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--warning);
  background: rgb(255 196 107 / 0.12);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.account-dialog {
  position: fixed;
  inset: 0;
  width: min(460px, calc(100% - 32px));
  max-width: 460px;
  max-height: min(760px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 0.06);
}

.account-dialog::backdrop {
  background: rgb(3 8 18 / 0.78);
  backdrop-filter: blur(5px);
}

.account-dialog-shell {
  position: relative;
  padding: 30px;
}

.account-close-button {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 6px 8px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.account-close-button:hover {
  color: var(--text);
}

.account-dialog-header {
  padding-right: 52px;
}

.account-dialog-header > p:first-child {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
}

.account-dialog-header h2 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.035em;
}

.account-dialog-header > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.account-tabs {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 3px);
  background: rgb(12 19 35 / 0.58);
}

.account-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: calc(var(--radius) - 8px);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}

.account-tabs button[aria-selected="true"] {
  color: var(--text);
  background: var(--surface-strong);
}

.account-form {
  margin-top: 22px;
  display: grid;
  gap: 16px;
}

.account-field {
  display: grid;
  gap: 7px;
}

.account-field > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.account-field > small {
  color: var(--muted);
  font-size: 0.74rem;
}

.account-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 5px);
  color: var(--text);
  background: var(--surface-strong);
}

.account-field input:focus-visible,
.account-button:focus-visible,
.account-close-button:focus-visible,
.account-tabs button:focus-visible {
  outline: 3px solid rgb(114 215 231 / 0.42);
  outline-offset: 2px;
}

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

.account-username {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.account-username strong {
  color: var(--text);
}

.account-message {
  min-height: 1.45em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.account-message[data-state="error"] {
  color: var(--x-color);
}

.account-message[data-state="success"] {
  color: var(--success);
}

.account-footnote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.wallet-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.wallet-heading,
.admin-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wallet-heading > div {
  display: grid;
  gap: 2px;
}

.wallet-heading small {
  color: var(--muted);
  font-size: 0.76rem;
}

.wallet-heading strong {
  color: var(--warning);
  font-size: 1.65rem;
  font-variant-numeric: tabular-nums;
}

.redeem-form {
  margin-top: 16px;
}

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

.redeem-row input {
  min-width: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-shell {
  width: min(920px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 40px 0 64px;
}

.admin-header {
  margin: 34px 0 28px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
}

.admin-header p {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.admin-header > div > p {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 750;
}

.admin-header h1 {
  margin: 0;
  font-size: 2.15rem;
  letter-spacing: -0.04em;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.generated-code {
  margin-top: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid rgb(145 230 179 / 0.42);
  border-radius: var(--radius);
  background: rgb(35 71 59 / 0.54);
}

.generated-code span {
  color: var(--muted);
  font-size: 0.8rem;
}

.generated-code strong {
  margin-right: auto;
  color: var(--success);
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.admin-code-section {
  margin-top: 30px;
}

.admin-list-heading h2 {
  margin: 0;
  font-size: 1.25rem;
}

.admin-code-list {
  margin-top: 12px;
  border-block: 1px solid var(--line);
}

.admin-code-row {
  min-height: 72px;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-code-row + .admin-code-row {
  border-top: 1px solid var(--line);
}

.admin-code-row > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.admin-code-row strong {
  letter-spacing: 0.06em;
}

.admin-code-row span,
.admin-empty-state {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-empty-state {
  margin: 0;
  padding: 28px 0;
  text-align: center;
}

.home-copy {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(20px, 4vw, 44px);
}

.home-mark {
  width: clamp(92px, 15vw, 150px);
  aspect-ratio: 1;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 0.06);
}

.home-mark span {
  display: grid;
  place-items: center;
  font-size: clamp(1.7rem, 5vw, 3.4rem);
  font-weight: 850;
}

.home-mark span:first-child {
  color: #101828;
  background: var(--accent);
}

.home-mark span:last-child {
  color: var(--x-color);
}

.home-kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
}

.home-copy h1 {
  max-width: 13ch;
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 0.98;
}

.home-copy div > p:last-child {
  max-width: 48ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.65;
}

.game-picker {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.game-choice {
  min-width: 0;
  min-height: 250px;
  padding: clamp(20px, 4vw, 32px);
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 1fr);
  align-items: center;
  gap: clamp(18px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  text-align: left;
  background: rgb(21 31 52 / 0.88);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.game-choice:hover {
  border-color: #52617f;
  background: #19263e;
  transform: translateY(-3px);
}

.game-choice:active {
  transform: translateY(-1px) scale(0.99);
}

.game-choice:focus-visible,
.back-button:focus-visible {
  outline: 3px solid rgb(114 215 231 / 0.42);
  outline-offset: 4px;
}

.choice-preview {
  aspect-ratio: 1;
  display: grid;
}

.tic-preview {
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #3b4c6d;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-strong);
}

.tic-preview i {
  display: grid;
  place-items: center;
  border: 1px solid #3b4c6d;
  color: var(--x-color);
  font-size: clamp(1.1rem, 3vw, 2.2rem);
  font-style: normal;
  font-weight: 850;
}

.tic-preview i:nth-child(3n) {
  color: var(--o-color);
}

.gomoku-preview {
  position: relative;
  border: 1px solid #dab57d;
  border-radius: var(--radius);
  background:
    linear-gradient(rgb(83 62 37 / 0.72) 1px, transparent 1px),
    linear-gradient(90deg, rgb(83 62 37 / 0.72) 1px, transparent 1px),
    #c8a36a;
  background-size: 16.666% 16.666%;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.28);
}

.gomoku-preview i {
  position: absolute;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #172033;
  box-shadow: 0 3px 7px rgb(37 24 12 / 0.28);
}

.gomoku-preview i:nth-child(1) { left: 17%; top: 17%; }
.gomoku-preview i:nth-child(2) { left: 33%; top: 33%; background: #edf1f4; }
.gomoku-preview i:nth-child(3) { left: 49%; top: 33%; }
.gomoku-preview i:nth-child(4) { left: 65%; top: 33%; background: #edf1f4; }
.gomoku-preview i:nth-child(5) { left: 49%; top: 49%; }
.gomoku-preview i:nth-child(6) { left: 49%; top: 65%; background: #edf1f4; }
.gomoku-preview i:nth-child(7) { left: 65%; top: 65%; }

.choice-copy {
  display: grid;
  align-content: center;
  gap: 12px;
}

.choice-copy strong {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.choice-copy small {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.choice-copy > span {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 750;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
}

.control-panel {
  display: grid;
  gap: 24px;
}

.back-button {
  width: max-content;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.back-button:hover {
  color: var(--accent);
}

.hero-copy {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-mark {
  width: 66px;
  height: 66px;
  flex: 0 0 auto;
  margin: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--x-color);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.15em;
}

.brand-mark span {
  color: var(--o-color);
}

.brand-mark.gomoku-brand {
  color: #101828;
  background: var(--accent);
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.hero-copy div > p {
  max-width: 24ch;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.status-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(21 31 52 / 0.82);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
}

.status-card[data-result="player-win"] {
  border-color: rgb(145 230 179 / 0.55);
  background: rgb(27 61 51 / 0.72);
}

.status-card[data-result="ai-win"] {
  border-color: rgb(255 128 111 / 0.55);
}

.status-card[data-result="x-win"],
.status-card[data-result="x_win"] {
  border-color: rgb(255 128 111 / 0.62);
  background: rgb(67 42 48 / 0.72);
}

.status-card[data-result="o-win"],
.status-card[data-result="o_win"] {
  border-color: rgb(114 215 231 / 0.62);
  background: rgb(31 64 75 / 0.72);
}

.status-label,
.arena-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.status-text {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 760;
}

.mark-info {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.settings {
  display: grid;
  gap: 18px;
}

.online-room-actions,
.online-room-session {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(21 31 52 / 0.72);
}

.online-room-session[hidden] {
  display: none !important;
}

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

#room-code-input {
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 5px);
  color: var(--text);
  background: var(--surface-strong);
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#room-code-input::placeholder {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
}

#room-code-input:focus-visible {
  outline: 3px solid rgb(114 215 231 / 0.42);
  outline-offset: 2px;
}

.online-room-session p,
.online-room-message {
  margin: 0;
}

.undo-request {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgb(255 196 107 / 0.45);
  border-radius: var(--radius);
  background: rgb(71 52 25 / 0.5);
}

.undo-request p {
  margin: 0 0 10px;
  color: var(--warning);
  font-size: 0.84rem;
  line-height: 1.45;
}

.wager-picker {
  display: grid;
  gap: 8px;
}

.segmented-control.four-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wager-balance-note,
.room-wager-display,
.room-settlement-message,
.disconnect-countdown,
.room-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.room-preview {
  padding-top: 12px;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.room-preview p:first-child {
  color: var(--text);
}

.room-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.room-settlement-message {
  color: var(--success);
}

.disconnect-countdown {
  color: var(--warning);
}

.undo-request-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.undo-request-actions .button:only-child,
.undo-request-actions .button:not([hidden]):last-child:first-child {
  grid-column: 1 / -1;
}

#room-code-display {
  color: var(--accent);
  font-size: 1.2rem;
  letter-spacing: 0.14em;
}

.room-session-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.online-room-message {
  min-height: 1.35em;
  margin-top: 8px;
  color: var(--warning);
  font-size: 0.8rem;
  line-height: 1.45;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(21 31 52 / 0.72);
}

.segmented-control.two-options {
  grid-template-columns: repeat(2, 1fr);
}

.segmented-control label {
  position: relative;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: calc(var(--radius) - 7px);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.segmented-control input:checked + span {
  color: #07171c;
  background: var(--accent);
}

.segmented-control input:disabled + span {
  cursor: not-allowed;
  opacity: 0.48;
}

.segmented-control input:focus-visible + span,
.button:focus-visible,
.cell:focus-visible {
  outline: 3px solid rgb(114 215 231 / 0.42);
  outline-offset: 3px;
}

.segmented-control label:active span {
  transform: scale(0.98);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}

.scoreboard div {
  padding: 14px 8px;
  text-align: center;
}

.scoreboard div + div {
  border-left: 1px solid var(--line);
}

.score-name {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.scoreboard strong {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.button:active {
  transform: scale(0.98);
}

.button.primary {
  color: #07171c;
  background: var(--accent);
}

.button.primary:hover {
  background: #91e2ed;
}

.button.secondary {
  border-color: var(--line);
  background: transparent;
}

.button.secondary:hover {
  border-color: #52617f;
  background: var(--surface);
}

.button.danger {
  border-color: rgb(255 128 111 / 0.45);
  color: var(--x-color);
  background: transparent;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.game-panel {
  position: relative;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  background: rgb(21 31 52 / 0.88);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.arena-heading {
  min-height: 44px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.arena-heading div {
  display: grid;
}

.arena-heading strong {
  font-size: 1.1rem;
}

.thinking-label {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(4px);
}

.connection-label {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.game-panel.is-thinking .thinking-label {
  opacity: 1;
  transform: translateY(0);
  animation: thinking-pulse 900ms ease-in-out infinite alternate;
}

.game-panel.is-thinking {
  cursor: wait;
}

.game-panel.is-syncing {
  cursor: wait;
}

.game-panel.is-thinking .board {
  pointer-events: none;
}

.game-panel.is-syncing .board {
  pointer-events: none;
}

.game-panel.is-thinking .cell {
  opacity: 0.76;
}

.board {
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.7vw, 14px);
}

.board.gomoku-board {
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid #ddb77d;
  border-radius: calc(var(--radius) - 3px);
  background:
    linear-gradient(rgb(81 60 35 / 0.72) 1px, transparent 1px),
    linear-gradient(90deg, rgb(81 60 35 / 0.72) 1px, transparent 1px),
    #c8a36a;
  background-position: calc(100% / 30) calc(100% / 30);
  background-size: calc(100% / 15) calc(100% / 15);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.28);
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #3b4c6d;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
  cursor: pointer;
  font-size: clamp(3rem, 9vw, 5.7rem);
  font-weight: 800;
  line-height: 1;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.cell::before {
  content: attr(data-mark);
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  line-height: 1;
}

.cell:hover[aria-disabled="false"] {
  border-color: var(--accent-strong);
  background: #22314d;
}

.cell:active[aria-disabled="false"] {
  background: #17233a;
}

.cell[aria-disabled="true"] {
  cursor: default;
}

.cell.mark-x {
  color: var(--x-color);
}

.cell.mark-o {
  color: var(--o-color);
}

.cell.just-played::before {
  animation: place-mark 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.cell.next-to-remove::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid var(--warning);
  border-radius: calc(var(--radius) - 7px);
  pointer-events: none;
  animation: expiry-pulse 780ms ease-in-out infinite alternate;
}

.cell.winner {
  border-color: var(--success);
  background: rgb(42 83 68 / 0.78);
}

.cell.winner::before {
  animation: winner-pop 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--win-order, 0) * 80ms);
}

.gomoku-cell {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0;
}

.gomoku-cell:hover[aria-disabled="false"] {
  border: 0;
  background: rgb(255 255 255 / 0.16);
}

.gomoku-cell:active[aria-disabled="false"] {
  background: rgb(255 255 255 / 0.24);
}

.gomoku-cell::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 0;
  height: 0;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
}

.gomoku-cell.star-point::before {
  width: clamp(3px, 0.7vw, 6px);
  height: clamp(3px, 0.7vw, 6px);
  border-radius: 50%;
  background: rgb(77 54 30 / 0.88);
}

.gomoku-cell::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 9%;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 120ms ease, transform 160ms ease;
  pointer-events: none;
}

.gomoku-cell.mark-x,
.gomoku-cell.mark-o {
  --piece-color: #172033;
}

.gomoku-cell.mark-o {
  --piece-color: #edf1f4;
}

.gomoku-cell.mark-x::after,
.gomoku-cell.mark-o::after {
  opacity: 1;
  transform: scale(1);
  background: var(--piece-color);
  box-shadow: 0 2px 5px rgb(51 33 16 / 0.34), inset 0 1px 1px rgb(255 255 255 / 0.2);
}

.gomoku-cell.candidate::after {
  opacity: 0.5;
  transform: scale(0.82);
  background: var(--piece-color);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.72);
}

.gomoku-cell.last-move::after {
  background: radial-gradient(circle, #ff806f 0 12%, var(--piece-color) 14%);
}

.gomoku-cell.winner {
  border: 0;
  background: rgb(145 230 179 / 0.24);
}

.gomoku-cell.winner::after {
  animation: winner-pop 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--win-order, 0) * 45ms);
}

.gomoku-cell.just-played::before {
  animation: none;
}

.gomoku-cell.just-played::after {
  animation: place-mark 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.gomoku-note .expiry-swatch {
  border: 0;
  border-radius: 50%;
  background: var(--x-color);
}

.game-note {
  margin: 18px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.expiry-swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid var(--warning);
  border-radius: 5px;
}

@keyframes place-mark {
  from {
    transform: scale(0.84);
  }
  to {
    transform: scale(1);
  }
}

@keyframes winner-pop {
  0% {
    transform: scale(0.92);
  }
  55% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes expiry-pulse {
  from {
    opacity: 0.42;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes thinking-pulse {
  to {
    opacity: 0.48;
  }
}

@media (max-width: 760px) {
  .admin-shell {
    width: min(560px, calc(100% - 28px));
    padding: 28px 0 44px;
  }

  .admin-header {
    align-items: start;
    flex-direction: column;
    gap: 12px;
  }

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

  .redeem-row {
    grid-template-columns: 1fr;
  }

  .generated-code {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .game-home {
    width: min(560px, calc(100% - 28px));
    align-content: start;
    padding: 34px 0;
  }

  .account-button {
    position: static;
    justify-self: end;
    margin-bottom: -18px;
  }

  .account-dialog {
    width: calc(100% - 28px);
    max-width: 460px;
  }

  .home-copy {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .home-mark {
    width: 74px;
  }

  .home-copy h1 {
    font-size: clamp(2.15rem, 10vw, 3.6rem);
  }

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

  .game-choice {
    min-height: 0;
  }

  .app-shell {
    width: min(560px, calc(100% - 28px));
    padding: 26px 0 34px;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .control-panel {
    gap: 18px;
  }

  .game-panel {
    grid-row: 2;
  }
}

@media (max-width: 420px) {
  .game-home {
    width: min(100% - 20px, 400px);
    padding-top: 22px;
  }

  .account-button {
    width: 100%;
    min-width: 0;
    margin-bottom: -8px;
  }

  .account-dialog-shell {
    padding: 24px 18px 20px;
  }

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

  .admin-form,
  .admin-code-row,
  .room-preview-actions {
    grid-template-columns: 1fr;
  }

  .admin-form {
    display: grid;
  }

  .admin-code-row {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented-control.four-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-copy {
    grid-template-columns: 1fr;
  }

  .home-mark {
    width: 68px;
  }

  .game-choice {
    grid-template-columns: 108px minmax(0, 1fr);
    padding: 16px;
  }

  .app-shell {
    width: min(100% - 20px, 400px);
    padding-top: 18px;
  }

  .hero-copy {
    gap: 13px;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
  }

  .game-panel {
    padding: 16px;
    border-radius: var(--radius);
  }

  .arena-heading {
    margin-bottom: 15px;
  }

  .board {
    gap: 8px;
  }

  .cell {
    border-radius: calc(var(--radius) - 5px);
  }

  .gomoku-cell {
    border-radius: 0;
  }

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

@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;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .game-panel {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
