:root {
  color-scheme: dark;
  --bg-deep: #040915;
  --panel: rgba(8, 19, 39, 0.88);
  --panel-strong: rgba(9, 22, 45, 0.96);
  --line: rgba(139, 188, 255, 0.2);
  --line-strong: rgba(139, 188, 255, 0.38);
  --text: #f2f7ff;
  --muted: #93a9c7;
  --red: #ff3e69;
  --red-soft: #ff8a9f;
  --blue: #22c9f2;
  --blue-soft: #8eeeff;
  --success: #5fe2b4;
  --warning: #ffcb6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --overshoot: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg-deep);
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #8eeeff;
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.learn-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.learn-actions .command-button { min-width: 0; padding: 12px 8px; line-height: 1.5; }
.learn-actions small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 400; }
.difficulty-options { display: grid; gap: 12px; margin-bottom: 20px; }
.difficulty-option { padding: 20px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: rgba(34,201,242,.06); cursor: pointer; }
.difficulty-option:hover { border-color: var(--blue); background: rgba(34,201,242,.13); }
.difficulty-option strong { display: block; font-size: 20px; }
.difficulty-option span { margin-left: 10px; color: var(--blue-soft); font-size: 12px; font-weight: 400; }
.difficulty-option small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.6; }
.last-action-notice { min-height: 34px; margin: 0 0 8px; color: #d3bf8c; font-size: 12px; line-height: 1.6; }
.cell:disabled { opacity: 1; }
.cell.last-from::before { content: ""; position: absolute; inset: 22%; border: 1px dashed #d5ae5f; border-radius: 50%; opacity: .65; }
.cell.last-to::before { content: ""; position: absolute; inset: 8%; border: 2px solid #ffcd70; border-radius: 8px; box-shadow: inset 0 0 12px #ffcd7022; }
.wall-layer .wall-segment.last-wall { stroke: #ffcd70; filter: drop-shadow(0 0 4px #ffcd7088); }
.tutorial-coach { padding: 16px 18px; margin-bottom: 14px; border: 1px solid #b9954a77; border-radius: 8px; background: #151e2b; }
.coach-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #e3c68b; font-size: 11px; }
.tutorial-coach h2 { margin: 9px 0 6px; font-size: 20px; }
.tutorial-coach p { min-height: 38px; margin: 0; color: #bacbe0; font-size: 13px; line-height: 1.6; }
.tutorial-coach.success { border-color: var(--success); }
.tutorial-coach.success p { color: var(--success); }
.tutorial-mode .player-card, .tutorial-mode .room-chip, .local-mode .social-bar, .local-mode .social-panel, .local-mode .reaction-bubble { display: none; }
.local-mode .room-chip { visibility: hidden; }
.tutorial-mode .game-layout { grid-template-columns: minmax(0, 600px); grid-template-areas: "board"; }
.tutorial-mode .board-stage { width: min(100%, calc(100dvh - 370px)); min-width: 280px; justify-self: center; }
.tutorial-mode .cell.tutorial-target::after { width: 48%; border: 2px solid #ffe09b; background: #f5be4c44; box-shadow: 0 0 20px #efc56e66; }
.tutorial-mode .wall-slot.tutorial-target::after { opacity: 1 !important; border: 2px solid #ffe09b; background: #f5be4c88; box-shadow: 0 0 15px #efc56e88; }
.tutorial-mode .mode-button:not(:disabled) { border-color: #e3c68b; color: #ffe09b; }
@media (max-width: 650px) {
  .tutorial-coach { padding: 12px; margin-bottom: 10px; }
  .tutorial-coach h2 { font-size: 18px; }
  .tutorial-coach p { font-size: 12px; }
  .tutorial-mode .board-stage { width: min(100%, calc(100dvh - 345px)); min-width: min(280px, 100%); }
  .last-action-notice { font-size: 11px; }
}

/* Lobby, matchmaking, and lightweight in-game conversation. */
#matchButton { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#matchButton span { font-size: 12px; font-weight: 400; opacity: .75; }
.lobby-note { margin: 10px 0 20px; color: var(--muted); font-size: 12px; text-align: center; }
.session-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px clamp(12px, 3vw, 42px); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.session-toolbar > div { display: flex; gap: 8px; flex-shrink: 0; }
.session-toolbar .icon-button { min-height: 36px; padding: 6px 12px; }
.social-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.social-bar .icon-button { min-height: 40px; padding: 8px 12px; }
#muteButton { margin-left: auto; color: var(--muted); }
.social-hint { color: var(--muted); font-size: 11px; }
.social-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(1, 7, 16, .32); }
.social-open .social-bar { position: relative; z-index: 92; }
#socialToggle[aria-expanded="true"] { border-color: var(--blue); color: #e2fbff; background: #123348; }
.social-panel { position: fixed; z-index: 93; width: min(352px, calc(100vw - 24px)); max-height: min(360px, calc(100dvh - 24px)); margin: 0; padding: 14px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #365773; border-radius: 16px; background: #0c1c30; box-shadow: 0 18px 64px #0009, inset 0 1px 0 #ffffff0b; animation: socialIn 150ms ease-out; }
.social-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.social-panel-heading > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.social-panel-heading strong { font-size: 15px; }
#socialStatus { color: var(--muted); font-size: 11px; }
.social-panel button { min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: rgba(139,188,255,.06); cursor: pointer; transition: background 150ms, border-color 150ms; }
.social-panel button:hover:not(:disabled) { background: rgba(34,201,242,.14); border-color: var(--blue); }
.social-panel .social-close { flex: 0 0 44px; width: 44px; border-color: transparent; background: transparent; color: var(--muted); font-size: 25px; }
.social-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 12px; padding: 3px; border-radius: 10px; background: #061222; }
.social-tabs button { min-height: 38px; border-color: transparent; background: transparent; color: var(--muted); font-size: 13px; }
.social-tabs button[aria-selected="true"] { border-color: #387081; background: #17364a; color: #b5f3ff; }
.emoji-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.emoji-choices button { display: grid; place-content: center; gap: 3px; min-width: 0; min-height: 66px; padding: 6px 2px; font-size: 29px; line-height: 1.2; }
.emoji-label { color: #afc3d9; font-size: 10px; line-height: 1.4; }
.phrase-choices { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.phrase-choices button { min-width: 0; font-size: 12px; padding: 8px 5px; line-height: 1.4; }
@keyframes socialIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.reaction-bubble { display: block; visibility: hidden; min-height: 52px; margin-top: 14px; padding: 10px 12px; border: 1px solid rgba(139,188,255,.35); border-radius: 10px 10px 10px 2px; color: #e9f7ff; background: #17304c; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.reaction-bubble.show { visibility: visible; animation: toastIn 200ms ease-out; }
.reaction-bubble.emoji { font-size: 34px; line-height: 1.2; text-align: center; }
.match-elapsed { color: var(--blue-soft); font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.match-orbit { display: grid; place-items: center; margin: 22px auto; width: 76px; height: 76px; border: 1px solid var(--line); border-top-color: var(--blue); border-radius: 50%; color: var(--blue-soft); font-size: 30px; animation: matchSpin 3s linear infinite; }
@keyframes matchSpin { to { transform: rotate(360deg); } }
.confirm-dialog { color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel-strong); }
.confirm-dialog::backdrop { background: rgba(1,5,13,.8); backdrop-filter: blur(8px); }
button:disabled { cursor: not-allowed; opacity: .45; }

.ambient-background {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(180deg, rgba(3, 9, 21, 0.24), rgba(3, 8, 18, 0.86)),
    url("assets/bg-arena.png");
  background-size: cover;
  background-position: center;
}

.ambient-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(18, 55, 91, 0.08), transparent 28%, transparent 72%, rgba(91, 24, 43, 0.09)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 22%);
}

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

.screen {
  min-height: 100dvh;
}

.lobby-screen {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 440px);
  grid-template-rows: 1fr auto;
  gap: 40px 72px;
  align-items: center;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 64px 0 32px;
}

.brand-block {
  max-width: 620px;
}

.brand-emblem {
  display: grid;
  grid-template-columns: repeat(2, 18px);
  gap: 5px;
  width: max-content;
  margin-bottom: 26px;
  transform: rotate(45deg);
}

.brand-emblem span {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(137, 219, 255, 0.9);
  background: rgba(21, 79, 113, 0.34);
  box-shadow: 0 0 16px rgba(34, 201, 242, 0.32);
}

.brand-emblem span:nth-child(2),
.brand-emblem span:nth-child(3) {
  border-color: rgba(255, 87, 124, 0.9);
  background: rgba(111, 27, 55, 0.34);
  box-shadow: 0 0 16px rgba(255, 62, 105, 0.28);
}

.eyebrow,
.modal-kicker {
  margin: 0 0 12px;
  color: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(58px, 8vw, 106px);
  line-height: 0.98;
  text-shadow: 0 0 34px rgba(72, 189, 255, 0.25);
}

.brand-subtitle {
  max-width: 480px;
  margin: 24px 0 0;
  color: #b7c8df;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.7;
}

.lobby-panel,
.modal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.lobby-panel {
  padding: 30px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.text-input {
  width: 100%;
  min-height: 50px;
  margin-bottom: 14px;
  padding: 0 15px;
  border: 1px solid rgba(138, 188, 255, 0.24);
  border-radius: 8px;
  color: var(--text);
  background: rgba(2, 10, 24, 0.78);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.text-input:focus {
  border-color: rgba(105, 225, 255, 0.68);
  box-shadow: 0 0 0 4px rgba(34, 201, 242, 0.08);
}

.code-input {
  text-transform: uppercase;
}

.command-button,
.mode-button,
.icon-button,
.rematch-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
  transition:
    transform 90ms ease,
    filter 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.command-button:active,
.mode-button:active,
.icon-button:active,
.rematch-button:active {
  transform: translateY(2px) scale(0.98);
  filter: brightness(0.94);
}

.command-button {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
}

.command-button.primary {
  color: #03111c;
  background: linear-gradient(135deg, #8eeeff, #22c9f2);
  box-shadow: 0 12px 30px rgba(34, 201, 242, 0.2);
}

.command-button.secondary {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.command-button.ghost {
  border-color: var(--line);
  color: #dce9fa;
  background: transparent;
}

.command-button.compact {
  width: auto;
  min-width: 160px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  color: #6e86a6;
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.inline-error {
  min-height: 20px;
  margin: 14px 0 0;
  color: #ff869f;
  font-size: 13px;
}

.rules-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-self: end;
}

.rules-strip span {
  padding: 9px 13px;
  border: 1px solid rgba(139, 188, 255, 0.16);
  border-radius: 999px;
  color: #a8bcd5;
  background: rgba(7, 18, 36, 0.72);
  font-size: 13px;
}

.game-screen {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 10px clamp(14px, 3vw, 42px);
  border-bottom: 1px solid rgba(139, 188, 255, 0.12);
  background: rgba(4, 10, 22, 0.7);
  backdrop-filter: blur(18px);
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.mini-brand-mark {
  width: 25px;
  height: 25px;
  border: 1px solid rgba(128, 224, 255, 0.72);
  background:
    linear-gradient(90deg, rgba(34, 201, 242, 0.5) 0 48%, transparent 48% 52%, rgba(255, 62, 105, 0.5) 52%),
    rgba(6, 20, 42, 0.9);
  box-shadow: 0 0 16px rgba(34, 201, 242, 0.18);
}

.room-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 5px 4px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 17, 35, 0.84);
}

.room-chip > span {
  color: var(--muted);
  font-size: 12px;
}

.room-chip strong {
  min-width: 64px;
  font-size: 17px;
  text-align: center;
}

.icon-button {
  min-height: 32px;
  padding: 0 10px;
  border-color: rgba(139, 188, 255, 0.18);
  color: #c8dbf3;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
}

.turn-pill {
  justify-self: end;
  min-width: 148px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #deebfb;
  background: rgba(8, 20, 40, 0.84);
  font-size: 14px;
  text-align: center;
}

.turn-pill.red-turn {
  border-color: rgba(255, 62, 105, 0.5);
  box-shadow: 0 0 22px rgba(255, 62, 105, 0.14);
}

.turn-pill.blue-turn {
  border-color: rgba(34, 201, 242, 0.5);
  box-shadow: 0 0 22px rgba(34, 201, 242, 0.14);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(160px, 210px) minmax(420px, 760px) minmax(160px, 210px);
  grid-template-areas: "red board blue";
  gap: clamp(14px, 2.6vw, 34px);
  align-items: start;
  justify-content: center;
  flex: 1;
  min-height: 0;
  padding: 22px clamp(12px, 3vw, 42px);
}

.player-card {
  grid-area: red;
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  transition: transform 220ms var(--overshoot), border-color 180ms ease, opacity 180ms ease;
}

.blue-player {
  grid-area: blue;
}

.player-card.active {
  transform: translateY(-4px);
}

.red-player.active {
  border-color: rgba(255, 62, 105, 0.7);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3), 0 0 30px rgba(255, 62, 105, 0.13);
}

.blue-player.active {
  border-color: rgba(34, 201, 242, 0.7);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3), 0 0 30px rgba(34, 201, 242, 0.13);
}

.player-card.self::after {
  content: "你";
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #d9e8fa;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
}

.player-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.player-heading > div {
  min-width: 0;
}

.player-heading strong,
.player-heading small {
  display: block;
}

.player-heading strong {
  font-size: 18px;
}

.player-heading small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-dot {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 18px rgba(255, 62, 105, 0.7);
}

.blue-player .player-dot {
  background: var(--blue);
  box-shadow: 0 0 18px rgba(34, 201, 242, 0.7);
}

.wall-counter {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.wall-counter span {
  color: var(--muted);
  font-size: 12px;
}

.wall-counter strong {
  color: var(--red-soft);
  font-size: 40px;
  line-height: 1;
}

.blue-player .wall-counter strong {
  color: var(--blue-soft);
}

.wall-bank {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 16px;
}

.wall-token {
  height: 7px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 9px rgba(255, 62, 105, 0.42);
  transition: opacity 260ms ease, transform 260ms ease;
}

.blue-player .wall-token {
  background: var(--blue);
  box-shadow: 0 0 9px rgba(34, 201, 242, 0.42);
}

.wall-token.spent {
  opacity: 0.14;
  transform: scaleX(0.55);
}

.board-stage {
  grid-area: board;
  width: min(calc(100dvh - 280px), calc(100vw - 560px), 680px);
  min-width: 420px;
}

.board-frame {
  position: relative;
  padding: clamp(8px, 1vw, 13px);
  border: 1px solid rgba(139, 188, 255, 0.26);
  border-radius: 8px;
  background: rgba(3, 10, 23, 0.86);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(130, 183, 245, 0.3);
  background: #071126;
  isolation: isolate;
}

.board-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
}

.cell {
  position: relative;
  min-width: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(115, 160, 218, 0.13);
  border-bottom: 1px solid rgba(115, 160, 218, 0.13);
  background: rgba(5, 16, 38, 0.54);
  transition: background 100ms ease, transform 100ms ease, box-shadow 100ms ease;
}

.cell:nth-child(9n) {
  border-right: 0;
}

.cell:nth-last-child(-n + 9) {
  border-bottom: 0;
}

.cell.legal {
  cursor: pointer;
}

.cell.legal::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18%;
  aspect-ratio: 1;
  border: 2px solid rgba(142, 238, 255, 0.8);
  border-radius: 50%;
  background: rgba(34, 201, 242, 0.16);
  box-shadow: 0 0 12px rgba(34, 201, 242, 0.38);
  transform: translate(-50%, -50%) scale(0.75);
  transition: transform 150ms var(--overshoot), background 120ms ease;
  animation: legalPulse 1.8s ease-in-out infinite;
}

.cell.legal:hover {
  background: rgba(34, 201, 242, 0.16);
}

.cell.legal:hover::after {
  background: rgba(34, 201, 242, 0.34);
  transform: translate(-50%, -50%) scale(1);
}

.goal-band {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  height: 11.111%;
  pointer-events: none;
}

.goal-band span {
  position: absolute;
  right: 9px;
  color: rgba(233, 244, 255, 0.56);
  font-size: clamp(8px, 1vw, 11px);
}

.top-goal {
  top: 0;
  border-top: 3px solid rgba(255, 62, 105, 0.72);
  background: linear-gradient(180deg, rgba(255, 62, 105, 0.16), transparent 78%);
}

.top-goal span {
  top: 7px;
}

.bottom-goal {
  bottom: 0;
  border-bottom: 3px solid rgba(34, 201, 242, 0.74);
  background: linear-gradient(0deg, rgba(34, 201, 242, 0.17), transparent 78%);
}

.bottom-goal span {
  bottom: 7px;
}

.wall-layer,
.wall-slots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.wall-layer {
  z-index: 4;
  overflow: visible;
  pointer-events: none;
}

.wall-segment {
  stroke-width: 0.18;
  stroke-linecap: round;
  animation: wallPlace 360ms var(--overshoot) both;
}

.wall-segment.red {
  stroke: var(--red);
  filter: drop-shadow(0 0 7px rgba(255, 62, 105, 0.72));
}

.wall-segment.blue {
  stroke: var(--blue);
  filter: drop-shadow(0 0 7px rgba(34, 201, 242, 0.72));
}

.wall-slots {
  z-index: 6;
  pointer-events: none;
}

.wall-slot {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  transform-origin: center;
}

.wall-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(95, 226, 180, 0.62);
  border-radius: 999px;
  background: rgba(95, 226, 180, 0.08);
  opacity: 0;
  transition: opacity 100ms ease, transform 140ms var(--overshoot), background 100ms ease;
}

.wall-slot.legal::after {
  opacity: 0.2;
}

.wall-slot.legal:hover::after,
.wall-slot.legal:focus-visible::after {
  opacity: 1;
  transform: scale(1.18);
}

.wall-slot.illegal::after {
  border-color: rgba(255, 133, 150, 0.48);
  background: rgba(255, 62, 105, 0.08);
}

.wall-slot.illegal:hover::after,
.wall-slot.illegal:focus-visible::after {
  opacity: 0.72;
}

.wall-slot.occupied {
  pointer-events: none;
}

.wall-slot.dimmed {
  pointer-events: none;
}

.wall-slots:not(.active) .wall-slot {
  pointer-events: none;
}

.wall-slots:not(.active) .wall-slot::after {
  display: none;
}

.wall-slot.horizontal {
  height: 4.2%;
  transform: translateY(-50%);
}

.wall-slot.vertical {
  width: 4.2%;
  transform: translateX(-50%);
}

.wall-slot.drop-target::after {
  opacity: 1;
  transform: scale(1.22);
}

.wall-slot.drop-valid::after {
  border-color: rgba(95, 226, 180, 0.95);
  background: rgba(95, 226, 180, 0.24);
  box-shadow: 0 0 18px rgba(95, 226, 180, 0.4);
}

.wall-slot.drop-invalid::after {
  border-color: rgba(255, 102, 132, 0.9);
  background: rgba(255, 62, 105, 0.2);
  box-shadow: 0 0 18px rgba(255, 62, 105, 0.3);
}

.pawn {
  position: absolute;
  z-index: 8;
  width: 10.5%;
  height: 10.5%;
  object-fit: contain;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: left 370ms var(--overshoot), top 370ms var(--overshoot), transform 150ms ease;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.44));
}

.red-pawn {
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.44)) drop-shadow(0 0 11px rgba(255, 62, 105, 0.36));
}

.blue-pawn {
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.44)) drop-shadow(0 0 11px rgba(34, 201, 242, 0.36));
}

.board-flash {
  position: absolute;
  inset: 0;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 62, 105, 0.19);
}

.board-flash.show {
  animation: boardError 420ms ease-out both;
}

.action-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 13px;
}

.mode-button,
.rematch-button {
  min-height: 48px;
  border-color: var(--line);
  color: #b6c9df;
  background: rgba(8, 20, 40, 0.86);
}

.mode-button.active {
  border-color: rgba(95, 226, 180, 0.55);
  color: #eafff8;
  background: rgba(28, 99, 82, 0.42);
  box-shadow: inset 0 0 18px rgba(95, 226, 180, 0.07);
}

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

.wall-drag-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 14px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.wall-drag-preview {
  display: block;
  flex: 0 0 auto;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.wall-drag-preview.horizontal {
  width: 38px;
  height: 6px;
}

.wall-drag-preview.vertical {
  width: 6px;
  height: 32px;
}

.wall-drag-ghost {
  position: fixed;
  z-index: 1000;
  border-radius: 999px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08);
  background: #5fe2b4;
  box-shadow:
    0 0 0 1px rgba(234, 255, 248, 0.72),
    0 0 20px rgba(95, 226, 180, 0.72),
    0 10px 26px rgba(0, 0, 0, 0.38);
}

.wall-drag-ghost.horizontal {
  width: 46px;
  height: 10px;
}

.wall-drag-ghost.vertical {
  width: 10px;
  height: 46px;
}

body.wall-dragging {
  cursor: grabbing;
  user-select: none;
}

.rematch-button {
  grid-column: 1 / -1;
  color: #06131e;
  background: linear-gradient(135deg, #8eeeff, #5fe2b4);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(1, 5, 13, 0.78);
  backdrop-filter: blur(12px);
  animation: overlayIn 220ms ease both;
}

.modal-card {
  width: min(470px, 100%);
  padding: 34px;
  text-align: center;
  animation: modalIn 420ms var(--overshoot) both;
}

.waiting-code {
  width: 100%;
  margin: 10px 0 12px;
  padding: 16px 8px;
  border: 1px solid rgba(95, 226, 180, 0.32);
  border-radius: 8px;
  color: #eeffff;
  background: rgba(19, 66, 65, 0.34);
  cursor: pointer;
  font-size: clamp(42px, 9vw, 68px);
  font-weight: 850;
  text-shadow: 0 0 22px rgba(95, 226, 180, 0.28);
}

.modal-copy {
  margin: 10px auto 24px;
  color: #a7bad2;
  line-height: 1.6;
}

.result-card h2 {
  margin: 8px 0 6px;
  font-size: clamp(34px, 7vw, 58px);
}

.result-card.red-win h2 {
  color: #ff7891;
  text-shadow: 0 0 30px rgba(255, 62, 105, 0.28);
}

.result-card.blue-win h2 {
  color: #74e9ff;
  text-shadow: 0 0 30px rgba(34, 201, 242, 0.28);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border: 1px solid rgba(139, 188, 255, 0.22);
  border-radius: 8px;
  color: #edf6ff;
  background: rgba(7, 18, 36, 0.96);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: toastIn 240ms var(--overshoot) both;
}

.toast.error {
  border-color: rgba(255, 102, 132, 0.46);
}

.confetti {
  position: fixed;
  top: -8px;
  z-index: 70;
  width: 7px;
  height: 14px;
  pointer-events: none;
  animation: confettiFall var(--duration) linear var(--delay) forwards;
}

@keyframes legalPulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes wallPlace {
  from { opacity: 0; stroke-width: 0.03; }
  to { opacity: 1; stroke-width: 0.16; }
}

@keyframes boardError {
  0% { opacity: 0.72; }
  100% { opacity: 0; }
}

@keyframes overlayIn {
  from { opacity: 0; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes confettiFall {
  from { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  to { transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin)); opacity: 0; }
}

@media (max-width: 1060px) {
  .lobby-screen {
    grid-template-columns: 1fr;
    gap: 30px;
    width: min(660px, calc(100% - 32px));
    padding-top: 42px;
  }

  .rules-strip {
    grid-column: auto;
  }

  .game-screen {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "red blue"
      "board board";
    align-content: start;
    padding-top: 14px;
  }

  .board-stage {
    width: min(78vh, 100%);
    min-width: 0;
    justify-self: center;
  }

  .player-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 16px;
    padding: 14px 16px;
  }

  .reaction-bubble { grid-column: 1 / -1; min-width: 0; margin-top: 0; }

  .wall-counter {
    grid-row: 1 / span 2;
    grid-column: 2;
    min-width: 90px;
    margin: 0;
    padding: 0 0 0 16px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .wall-counter strong {
    font-size: 30px;
  }

  .wall-bank {
    grid-column: 1;
    margin-top: 2px;
  }
}

@media (max-width: 650px) {
  .session-toolbar { align-items: flex-start; font-size: 11px; }
  .session-toolbar > span { padding-top: 8px; }
  .social-bar { gap: 4px; }
  .social-bar .icon-button { padding: 8px; font-size: 12px; }
  .social-panel { padding: 12px; }
  .emoji-choices { gap: 5px; }
  .topbar {
    grid-template-columns: 1fr auto;
    min-height: 62px;
    padding: 8px 10px;
  }

  .mini-brand strong {
    display: none;
  }

  .room-chip {
    justify-self: center;
  }

  .room-chip > span {
    display: none;
  }

  .room-chip strong {
    min-width: 52px;
    font-size: 15px;
  }

  .turn-pill {
    grid-column: 1 / -1;
    justify-self: stretch;
    min-width: 0;
    padding: 7px 12px;
  }

  .game-layout {
    gap: 10px;
    padding: 10px;
  }

  .player-card {
    padding: 11px 12px;
    grid-template-columns: minmax(0, 1fr) 34px;
    column-gap: 8px;
  }

  .player-heading { gap: 6px; }
  .player-dot { width: 10px; height: 10px; }
  .player-heading strong { white-space: nowrap; }

  .player-card.self::after {
    top: 8px;
    right: 8px;
  }

  .player-heading strong {
    font-size: 15px;
  }

  .wall-counter {
    min-width: 0;
    padding-left: 8px;
  }

  .wall-counter span {
    display: none;
  }

  .wall-counter strong {
    font-size: 24px;
  }

  .wall-bank {
    gap: 4px;
  }

  .wall-token {
    height: 5px;
  }

  .board-frame {
    padding: 7px;
  }

  .goal-band span {
    display: none;
  }

  .action-bar {
    margin-top: 9px;
  }

  .mode-button,
  .wall-drag-button,
  .rematch-button {
    min-height: 46px;
  }

  .wall-drag-button {
    gap: 8px;
    padding: 0 10px;
  }

  .wall-drag-preview.horizontal {
    width: 30px;
  }

  .wall-drag-preview.vertical {
    height: 28px;
  }

  .modal-card {
    padding: 26px 20px;
  }
}

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