:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #6f7787;
  --line: #d8deea;
  --line-strong: #6f7787;
  --x: #e23f5b;
  --x-soft: #ffe8ed;
  --o: #168a78;
  --o-soft: #dff7f1;
  --tie: #687081;
  --active: #2f66d0;
  --shadow: 0 18px 45px rgba(40, 50, 75, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(226, 63, 91, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(22, 138, 120, 0.09), transparent 34%),
    var(--bg);
}

button {
  font: inherit;
}

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

.app-shell[hidden],
.setup-screen[hidden] {
  display: none;
}

.setup-screen {
  min-height: 100svh;
  padding: 48px 20px;
  display: grid;
  place-items: center;
  background: #f5f7fb;
}

.setup-shell {
  width: min(760px, 100%);
}

.setup-view[hidden] {
  display: none;
}

.setup-home {
  min-height: min(680px, calc(100svh - 96px));
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.setup-home .setup-header {
  margin-bottom: 20px;
}

.setup-app-icon {
  width: clamp(138px, 24vw, 184px);
  aspect-ratio: 1;
  display: block;
  border-radius: 28px;
  box-shadow: 0 18px 44px rgba(29, 36, 51, 0.18);
}

.setup-primary-button.setup-play-button {
  width: min(260px, 100%);
  margin-top: 28px;
}

.setup-choice-heading {
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.setup-choice-heading h2 {
  font-size: 1.5rem;
}

.setup-header {
  margin-bottom: 42px;
  text-align: center;
}

.setup-header h1 {
  font-size: clamp(2.15rem, 5vw, 3.75rem);
}

.setup-tagline {
  max-width: 520px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.setup-progress {
  width: 150px;
  margin: 24px auto 0;
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
}

.setup-progress span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.setup-progress span.active {
  border-color: var(--active);
  background: var(--active);
  color: #fff;
}

.setup-progress i {
  height: 1px;
  background: var(--line);
}

.setup-step-heading {
  margin-bottom: 22px;
  text-align: center;
}

.setup-step-heading > span,
.setup-step-heading div > span {
  display: block;
  margin-bottom: 5px;
  color: var(--active);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.setup-step-heading h2 {
  font-size: 1.45rem;
}

.opponent-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.opponent-option {
  min-height: 170px;
  padding: 22px 14px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.opponent-option:hover,
.opponent-option.active {
  border-color: var(--active);
  box-shadow: 0 10px 26px rgba(47, 102, 208, 0.13);
  transform: translateY(-2px);
}

.opponent-option.active {
  box-shadow: inset 0 0 0 1px var(--active), 0 10px 26px rgba(47, 102, 208, 0.13);
}

.opponent-option strong {
  font-size: 0.96rem;
}

.opponent-option small {
  color: var(--muted);
  font-size: 0.75rem;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.difficulty-option {
  min-height: 150px;
  padding: 18px 12px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.difficulty-option:hover,
.difficulty-option:focus-visible {
  border-color: var(--active);
  outline: none;
  box-shadow: 0 10px 26px rgba(47, 102, 208, 0.13);
  transform: translateY(-2px);
}

.difficulty-option strong {
  font-size: 1rem;
}

.difficulty-option small {
  color: var(--muted);
  font-size: 0.72rem;
}

.setup-rule-picker {
  margin-bottom: 24px;
}

.setup-choice-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.setup-opponent-label {
  margin-top: 0;
}

.setup-rule-options {
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e9edf4;
}

.setup-rule-option {
  position: relative;
  min-width: 0;
  min-height: 88px;
  padding: 10px 48px 10px 12px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto auto;
  justify-items: start;
  align-content: center;
  column-gap: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.setup-rule-option:hover,
.setup-rule-option:focus-visible {
  background: rgba(255, 255, 255, 0.7);
  outline: none;
}

.setup-rule-option.active {
  border-color: var(--active);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--active), 0 3px 10px rgba(40, 50, 75, 0.11);
}

.setup-rule-icon {
  width: 40px;
  height: 40px;
  grid-row: 1 / 3;
  align-self: center;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #e5edff;
  color: var(--active);
  font-size: 0.78rem;
  font-weight: 900;
}

.setup-rule-option[data-setup-rule="wild"] .setup-rule-icon {
  background: #fff1c7;
  color: #946600;
}

.setup-rule-option strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  align-self: end;
  font-size: 0.86rem;
}

.setup-rule-option small {
  color: var(--muted);
  align-self: start;
  font-size: 0.67rem;
}

.setup-rule-state {
  position: absolute;
  top: 50%;
  right: 12px;
  min-width: 30px;
  padding: 4px 5px;
  border-radius: 6px;
  background: #dce2ec;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
  text-align: center;
  transform: translateY(-50%);
}

.setup-rule-option.active .setup-rule-state {
  background: var(--active);
  color: #fff;
}

.opponent-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--x-soft);
  color: var(--x);
  font-size: 0.75rem;
  font-weight: 900;
}

.opponent-icon.machine {
  background: #eef2f8;
  color: #4c5870;
}

.opponent-icon.online {
  background: var(--o-soft);
  color: var(--o);
}

.setup-primary-button {
  width: min(320px, 100%);
  min-height: 48px;
  margin: 24px auto 0;
  display: block;
  border: 0;
  border-radius: 7px;
  background: var(--active);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
}

.setup-primary-button:hover {
  background: #2558b8;
}

.public-links {
  position: fixed;
  right: 18px;
  bottom: 16px;
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  font-weight: 800;
}

.public-links a,
.document-nav a,
.marketing-nav a {
  color: var(--active);
  text-decoration: none;
}

.public-links a:hover,
.document-nav a:hover,
.marketing-nav a:hover {
  text-decoration: underline;
}

.setup-step-heading.with-back {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
}

.setup-back-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.15rem;
}

.setup-mode-summary {
  padding: 7px 10px;
  border-radius: 6px;
  background: #eef2f8;
  color: #4c5870;
  font-size: 0.72rem;
}

.setup-settings {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.setup-setting-group {
  min-height: 70px;
  padding: 12px 4px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 320px);
  gap: 20px;
  align-items: center;
}

.setup-setting-group + .setup-setting-group {
  border-top: 1px solid var(--line);
}

.setup-setting-title strong,
.setup-setting-title small {
  display: block;
}

.setup-setting-title strong {
  font-size: 0.88rem;
}

.setup-setting-title small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.setup-setting-group select,
.setup-segmented {
  width: 100%;
}

.setup-setting-group select {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.setup-segmented {
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef2f8;
}

.setup-segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.setup-segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.setup-segmented button.active {
  background: #fff;
  color: var(--active);
  box-shadow: 0 2px 8px rgba(40, 50, 75, 0.1);
}

.setup-toggle-row {
  grid-template-columns: 1fr auto;
}

.setup-switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: block;
}

.setup-switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: #aab3c2;
  cursor: pointer;
  transition: background 140ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(29, 36, 51, 0.24);
  transition: transform 140ms ease;
}

.setup-switch input:checked + .switch-track {
  background: var(--o);
}

.setup-switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.setup-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--active);
  outline-offset: 2px;
}

.setup-return-button {
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.legacy-game-controls {
  display: none !important;
}

.match-rule-summary {
  display: grid;
  gap: 8px;
}

.match-rule-summary span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.match-rule-summary strong {
  color: var(--ink);
}

.machine-setup-fields[hidden] {
  display: none;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

.game-panel,
.side-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(216, 222, 234, 0.9);
  box-shadow: var(--shadow);
}

.game-panel {
  border-radius: 8px;
  padding: 22px;
}

.side-panel {
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.detail-section {
  display: grid;
  gap: 16px;
}

.detail-section > section + section {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--active);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1;
}

h2 {
  font-size: 0.98rem;
}

.actions {
  display: flex;
  gap: 8px;
}

.settings-menu {
  position: relative;
}

.settings-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 80;
  width: 210px;
  padding: 6px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(29, 36, 51, 0.18);
}

.settings-dropdown[hidden] {
  display: none;
}

.settings-menu-item {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  text-decoration: none;
}

.settings-menu-item:hover,
.settings-menu-item:focus-visible {
  background: #eef3ff;
  outline: none;
}

.settings-menu-item > span {
  color: var(--active);
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
}

.settings-menu-item strong {
  font-weight: 850;
}

.text-link-button {
  min-height: 42px;
  padding: 0 12px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: none;
}

.install-button,
.icon-button,
.rewards-launch-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.rewards-launch-button {
  width: auto;
  min-width: 104px;
  padding: 0 10px;
  grid-auto-flow: column;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 850;
}

.rewards-launch-button > span:first-child {
  color: #c89300;
  font-size: 1.05rem;
}

.rewards-launch-button small {
  color: var(--active);
  font-size: 0.65rem;
}

.install-button {
  width: auto;
  min-width: 76px;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 850;
}

.install-button[hidden] {
  display: none;
}

.install-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.text-link-button:hover,
.rewards-launch-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--active);
  box-shadow: 0 8px 20px rgba(47, 102, 208, 0.16);
}

.install-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.status-row {
  margin: 20px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.game-hud {
  position: relative;
}

.countdown-banner {
  position: sticky;
  top: 8px;
  z-index: 30;
  width: 142px;
  min-height: 58px;
  margin-top: 16px;
  margin-left: auto;
  padding: 8px 11px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #e4bd43;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(40, 50, 75, 0.13);
}

.countdown-banner[hidden] {
  display: none;
}

.countdown-banner .label {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.25;
}

.countdown-banner div {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.countdown-banner strong {
  min-width: 2ch;
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  text-align: right;
}

.countdown-banner small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
}

.countdown-banner.timer-warning {
  border-color: var(--x);
  background: #fff4f6;
  box-shadow: 0 8px 22px rgba(226, 63, 91, 0.18);
}

.countdown-banner.timer-warning strong {
  color: var(--x);
  animation: timer-pulse 700ms ease-in-out infinite alternate;
}

.mode-switch,
.order-buttons,
.difficulty-buttons {
  width: min(100%, 420px);
  padding: 4px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f8;
}

.mode-switch,
.order-buttons {
  grid-template-columns: repeat(2, 1fr);
}

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

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

.mode-switch {
  margin: 0 0 12px;
}

.order-switch {
  width: min(100%, 420px);
  margin: 0 0 18px;
  display: none;
  gap: 8px;
}

.order-switch.visible {
  display: grid;
}

.online-room {
  width: min(100%, 620px);
  margin: 0 0 18px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.online-room-copy,
.online-room-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.online-room-copy strong,
.online-room-copy small {
  display: block;
}

.online-room-copy strong {
  color: var(--ink);
  font-size: 0.88rem;
}

.online-room-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.online-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #9aa5b5;
}

.online-dot[data-state="connecting"],
.online-dot[data-state="waiting"] {
  background: #d59d14;
}

.online-dot[data-state="connected"] {
  background: #168a78;
  box-shadow: 0 0 0 4px rgba(22, 138, 120, 0.12);
}

.online-dot[data-state="error"] {
  background: var(--x);
}

.online-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.online-button.primary {
  border-color: #168a78;
  background: #168a78;
  color: #fff;
}

.online-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.mode-button,
.order-button,
.difficulty-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
  transition:
    background 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.mode-button:hover,
.order-button:hover,
.difficulty-button:hover {
  color: var(--ink);
}

.mode-button.active,
.order-button.active,
.difficulty-button.active {
  background: #fff;
  color: var(--active);
  box-shadow: 0 5px 16px rgba(47, 102, 208, 0.14);
}

.turn-card {
  min-height: 64px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  align-content: center;
  gap: 4px;
}

.label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.turn-card strong {
  font-size: 0.96rem;
}

.combined-status-card {
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-left: 4px solid var(--active);
}

.status-player-piece {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  color: var(--active);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1;
}

.status-row.player-x .combined-status-card {
  border-left-color: var(--x);
}

.status-row.player-o .combined-status-card {
  border-left-color: var(--o);
}

.status-row.player-x .status-player-piece {
  background: var(--x-soft);
  color: var(--x);
  box-shadow: 0 0 0 4px var(--x-soft);
}

.status-row.player-o .status-player-piece {
  background: var(--o-soft);
  color: var(--o);
  box-shadow: 0 0 0 4px var(--o-soft);
}

.status-player-piece .piece-token {
  width: 27px;
  height: 27px;
}

.status-player-piece .emoji-piece {
  font-size: 1.05rem;
}

.combined-status-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.combined-status-copy strong {
  font-size: 0.96rem;
}

.combined-status-copy span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.3;
}

.board-wrap {
  display: grid;
  justify-items: center;
}

.mega-board {
  width: min(100%, 720px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
}

.small-board {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: #ecf0f7;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.small-board.playable {
  border-color: var(--active);
  background: #e9f0ff;
}

.power-button.armed ~ .power-hint {
  color: var(--active);
}

.small-board.locked {
  opacity: 0.55;
}

.small-board.won-x {
  background: var(--x-soft);
}

.small-board.won-o {
  background: var(--o-soft);
}

.small-board.tied {
  background: #eef0f4;
}

.cell {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: clamp(1rem, 3vw, 2.4rem);
  font-weight: 900;
  line-height: 1;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.cell:hover:not(:disabled) {
  border-color: var(--active);
  background: #fff;
  transform: scale(0.97);
}

.cell:disabled {
  cursor: default;
}

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

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

.piece-token {
  width: 82%;
  height: 82%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 2px rgba(29, 36, 51, 0.22));
}

.emoji-piece {
  display: block;
  font-size: 0.92em;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(29, 36, 51, 0.18));
}

.cell.last-move {
  border-color: #f0c340;
  box-shadow: inset 0 0 0 2px rgba(240, 195, 64, 0.7);
  animation: mark-bounce 260ms ease-out;
}

.cell.move-celebration {
  position: relative;
  isolation: isolate;
}

.cell.move-celebration::before,
.cell.move-celebration::after {
  content: "";
  position: absolute;
  inset: 12%;
  z-index: -1;
  border: 2px solid #f0c340;
  border-radius: 50%;
  pointer-events: none;
  animation: move-ring 620ms ease-out both;
}

.cell.move-celebration::after {
  border-color: var(--active);
  animation-delay: 90ms;
}

.claim-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: clamp(3.2rem, 10vw, 8.8rem);
  font-weight: 950;
  line-height: 1;
  opacity: 0.2;
}

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

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

.claim-mark.tie {
  color: var(--tie);
  font-size: clamp(2.2rem, 6vw, 5rem);
}

.claim-mark .piece-token {
  width: 86%;
  height: 86%;
  opacity: 0.72;
}

.claim-mark .emoji-piece {
  font-size: 0.82em;
  opacity: 0.72;
}

.claim-pop {
  animation: claim-pop 520ms cubic-bezier(0.2, 1.4, 0.32, 1);
}

.piece-customizer {
  display: grid;
  gap: 12px;
}

.piece-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
}

.piece-label {
  font-size: 1.1rem;
  font-weight: 950;
  text-align: center;
}

.piece-select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 36px 0 12px;
  font-weight: 850;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 17px,
    calc(100% - 12px) 17px;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}

.piece-select:hover:not(:disabled),
.piece-select:focus {
  border-color: var(--active);
  outline: 0;
}

.piece-picker {
  position: relative;
  min-width: 0;
}

.mobile-piece-control {
  display: none;
}

.mobile-pieces-button {
  width: 100%;
  min-height: 54px;
  padding: 4px 7px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.mobile-pieces-button:hover:not(:disabled),
.mobile-pieces-button:focus-visible,
.mobile-pieces-button[aria-expanded="true"] {
  border-color: var(--active);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(47, 102, 208, 0.12);
}

.mobile-pieces-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.mobile-piece-token,
.mobile-pieces-copy {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 1px;
}

.mobile-piece-token small,
.mobile-pieces-copy small {
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 850;
  line-height: 1;
}

.mobile-pieces-copy strong {
  font-size: 0.7rem;
  line-height: 1.1;
}

.mobile-piece-token .piece-picker-preview {
  width: 32px;
  height: 32px;
}

.mobile-piece-token.player-x .piece-picker-preview {
  color: var(--x);
  background: var(--x-soft);
}

.mobile-piece-token.player-o .piece-picker-preview {
  color: var(--o);
  background: var(--o-soft);
}

.mobile-piece-sheet {
  position: fixed;
  right: 8px;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px) + 8px);
  left: 8px;
  z-index: 85;
  max-height: min(420px, 62svh);
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(29, 36, 51, 0.24);
}

.mobile-piece-sheet[hidden] {
  display: none;
}

.mobile-piece-sheet-header {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mobile-piece-sheet-header > strong {
  font-size: 0.85rem;
}

.mobile-piece-sheet-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: #eef2f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.mobile-piece-tabs {
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f3f7;
}

.mobile-piece-tab {
  min-height: 40px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.mobile-piece-tab strong {
  font-size: 0.88rem;
}

.mobile-piece-tab small {
  font-size: 0.68rem;
  font-weight: 800;
}

.mobile-piece-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(29, 36, 51, 0.1);
}

.mobile-piece-tab[data-mobile-piece-player="X"].active strong {
  color: var(--x);
}

.mobile-piece-tab[data-mobile-piece-player="O"].active strong {
  color: var(--o);
}

.mobile-piece-tab:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mobile-piece-grid {
  min-height: 0;
  padding-right: 2px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 2px;
  overflow-y: auto;
}

.piece-picker-trigger {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 18px;
  gap: 9px;
  align-items: center;
  min-height: 46px;
  width: 100%;
  padding: 5px 10px 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.piece-picker-trigger:hover:not(:disabled),
.piece-picker-trigger:focus-visible,
.piece-picker-trigger[aria-expanded="true"] {
  border-color: var(--active);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(47, 102, 208, 0.12);
}

.piece-picker-preview {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border: 1px solid #e2e6ee;
  border-radius: 7px;
  background: #f7f8fb;
  font-size: 1.15rem;
  font-weight: 950;
  line-height: 1;
}

.piece-picker-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.piece-picker-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.piece-picker-chevron {
  color: var(--muted);
  font-size: 1.1rem;
  text-align: center;
  transition: transform 160ms ease;
}

.piece-picker-trigger[aria-expanded="true"] .piece-picker-chevron {
  transform: rotate(180deg);
}

.piece-picker-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: grid;
  max-height: min(340px, 52vh);
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(29, 36, 51, 0.18);
}

.piece-picker-menu[hidden] {
  display: none;
}

.piece-picker-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  width: 100%;
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.piece-picker-option:hover:not(:disabled),
.piece-picker-option:focus-visible,
.piece-picker-option[aria-selected="true"] {
  outline: 0;
  background: #edf3ff;
}

.piece-picker-option:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.piece-picker-option-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.piece-picker-option-copy strong,
.piece-picker-option-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.piece-picker-option-copy strong {
  font-size: 0.88rem;
}

.piece-picker-option-copy small {
  color: var(--muted);
  font-size: 0.69rem;
}

.piece-row.disabled {
  opacity: 0.55;
}

.piece-row.disabled .piece-select,
.piece-row.disabled .piece-picker-trigger {
  cursor: not-allowed;
  background-color: #f3f5f9;
}

.game-options,
.achievements-panel,
.rewards-panel {
  display: grid;
  gap: 10px;
}

.reward-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.reward-stats > div {
  min-height: 58px;
  padding: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.reward-stats span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.reward-stats strong {
  color: var(--active);
  font-size: 1.35rem;
}

.check-in-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--active);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(47, 102, 208, 0.18);
}

.check-in-button:hover:not(:disabled) {
  background: #2558b8;
  transform: translateY(-1px);
}

.check-in-button:disabled {
  border: 1px solid #87cdbf;
  background: var(--o-soft);
  color: #116b5d;
  cursor: default;
  box-shadow: none;
  opacity: 1;
}

.check-in-status {
  min-height: 1rem;
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
}

.reward-list {
  display: grid;
  gap: 6px;
}

.reward-item {
  min-height: 54px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border-left: 3px solid var(--line);
  background: #f5f7fb;
  color: var(--muted);
}

.reward-icon {
  filter: grayscale(1);
  font-size: 1.35rem;
  opacity: 0.45;
  text-align: center;
}

.reward-item strong,
.reward-item small {
  display: block;
}

.reward-item strong {
  font-size: 0.78rem;
}

.reward-item small {
  margin: 1px 0 4px;
  font-size: 0.68rem;
}

.reward-item progress {
  width: 100%;
  height: 5px;
  display: block;
  border: 0;
  accent-color: var(--active);
}

.reward-item.unlocked {
  border-left-color: #f0c340;
  background: #fff9df;
  color: var(--ink);
}

.reward-item.unlocked .reward-icon {
  filter: none;
  opacity: 1;
}

.reward-item.unlocked progress {
  accent-color: #c89300;
}

.option-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.compact-select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 30px 0 10px;
  font: inherit;
  font-weight: 800;
}

.option-row input[type="checkbox"] {
  width: 42px;
  height: 24px;
  margin: 0;
  accent-color: var(--active);
  cursor: pointer;
}

.power-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.power-button.armed {
  border-color: var(--active);
  background: #e9f0ff;
  color: var(--active);
  box-shadow: inset 0 0 0 2px rgba(47, 102, 208, 0.14);
}

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

.power-hint {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading > strong {
  color: var(--active);
  font-size: 0.78rem;
}

.achievement-list {
  display: grid;
  gap: 6px;
}

.achievement-item {
  min-height: 44px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 7px;
  align-items: center;
  border-left: 3px solid var(--line);
  background: #f5f7fb;
  color: var(--muted);
}

.achievement-item > span {
  font-size: 1.15rem;
  text-align: center;
}

.achievement-item strong,
.achievement-item small {
  display: block;
}

.achievement-item strong {
  font-size: 0.78rem;
}

.achievement-item small {
  margin-top: 2px;
  font-size: 0.68rem;
  line-height: 1.25;
}

.achievement-item.unlocked {
  border-left-color: #f0c340;
  background: #fff9df;
  color: var(--ink);
}

.achievement-item.unlocked > span {
  color: #c89300;
}

.achievement-surprise {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  z-index: 60;
  width: min(430px, calc(100vw - 28px));
  min-height: 82px;
  padding: 11px 13px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  border: 2px solid #d8aa20;
  border-radius: 8px;
  background: #fff9df;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-shadow: 0 18px 42px rgba(29, 36, 51, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -14px) scale(0.97);
  transition: opacity 180ms ease, transform 180ms ease;
}

.achievement-surprise[hidden] {
  display: none;
}

.achievement-surprise.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.achievement-surprise-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f0c340;
  color: #5b4300;
  font-size: 1.45rem;
  box-shadow: 0 0 0 4px rgba(240, 195, 64, 0.2);
}

.achievement-surprise-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.achievement-surprise-copy small {
  color: #8a6500;
  font-size: 0.64rem;
  font-weight: 950;
  text-transform: uppercase;
}

.achievement-surprise-copy strong {
  font-size: 0.96rem;
}

.achievement-surprise-copy > span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.3;
}

.game-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 28px));
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 14px 35px rgba(29, 36, 51, 0.28);
  font-size: 0.86rem;
  font-weight: 850;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.game-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.modal-open {
  overflow: hidden;
}

.coach-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
}

.coach-overlay[hidden] {
  display: none;
}

.coach-focus {
  position: fixed;
  border: 3px solid #f0c340;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(22, 27, 39, 0.68), 0 0 0 5px rgba(240, 195, 64, 0.26);
  pointer-events: none;
  opacity: 0;
  transition: left 180ms ease, top 180ms ease, width 180ms ease, height 180ms ease, opacity 120ms ease;
}

.coach-card {
  position: fixed;
  z-index: 1;
  width: min(320px, calc(100vw - 24px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 46px rgba(10, 15, 28, 0.3);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.coach-overlay.ready .coach-focus,
.coach-overlay.ready .coach-card {
  opacity: 1;
}

.coach-overlay.ready .coach-card {
  transform: translateY(0);
}

.coach-kicker {
  margin: 0 0 5px;
  color: var(--active);
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
}

.coach-card h2 {
  font-size: 1.05rem;
}

.coach-card > p:not(.coach-kicker) {
  margin: 7px 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.coach-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.coach-skip,
.coach-next {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 850;
}

.coach-next {
  border-color: var(--active);
  background: var(--active);
  color: #fff;
}

.coach-skip:focus-visible,
.coach-next:focus-visible {
  outline: 3px solid rgba(240, 195, 64, 0.58);
  outline-offset: 2px;
}

.document-page,
.marketing-page {
  min-height: 100vh;
}

.document-shell {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.document-nav,
.marketing-nav {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-bottom: 18px;
  font-size: 0.82rem;
  font-weight: 850;
}

.document-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.document-card h1 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.document-updated {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.document-card section {
  padding-top: 22px;
}

.document-card h2 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.document-card p {
  color: #3f4859;
  line-height: 1.7;
}

.marketing-hero {
  width: min(1180px, calc(100% - 32px));
  min-height: min(760px, 100svh);
  margin: 0 auto;
  padding: 26px 0 36px;
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(340px, 1.08fr);
  gap: clamp(28px, 6vw, 76px);
  align-items: center;
}

.marketing-nav {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.marketing-copy {
  display: grid;
  gap: 16px;
}

.marketing-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: 0 18px 38px rgba(29, 36, 51, 0.2);
}

.marketing-copy h1 {
  max-width: 10ch;
  font-size: clamp(3rem, 9vw, 6.8rem);
  line-height: 0.92;
}

.marketing-copy p:not(.eyebrow) {
  max-width: 560px;
  margin: 0;
  color: #3f4859;
  font-size: 1.1rem;
  line-height: 1.65;
}

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

.marketing-primary,
.marketing-secondary {
  min-height: 46px;
  padding: 0 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 850;
  text-decoration: none;
}

.marketing-primary {
  background: var(--active);
  color: #fff;
}

.marketing-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.marketing-board {
  aspect-ratio: 1;
  padding: clamp(8px, 1.8vw, 14px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.2vw, 10px);
  border: 3px solid #1d2433;
  border-radius: 8px;
  background: #1d2433;
  box-shadow: 0 24px 60px rgba(29, 36, 51, 0.22);
}

.preview-board {
  min-width: 0;
  min-height: 0;
  padding: clamp(4px, 1vw, 8px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(2px, 0.5vw, 4px);
  border: 1px solid rgba(216, 222, 234, 0.9);
  border-radius: 5px;
  background: #ffffff;
}

.preview-board.active {
  outline: 3px solid var(--active);
  outline-offset: -3px;
}

.preview-board span,
.preview-board strong {
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: #f5f7fb;
  color: var(--muted);
  font-weight: 950;
}

.preview-board .x,
.preview-board.claimed-x strong {
  color: var(--x);
}

.preview-board .o,
.preview-board.claimed-o strong {
  color: var(--o);
}

.preview-board.claimed-x,
.preview-board.claimed-o {
  grid-template-columns: 1fr;
}

.preview-board.claimed-x strong,
.preview-board.claimed-o strong {
  font-size: clamp(3rem, 10vw, 7rem);
}

.marketing-section {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 48px;
}

.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.feature-strip div {
  min-height: 116px;
  padding: 20px;
  display: grid;
  gap: 8px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.feature-strip strong,
.feature-strip span {
  display: block;
}

.feature-strip span {
  color: var(--muted);
  line-height: 1.45;
}

.rewards-overlay,
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(29, 36, 51, 0.46);
  backdrop-filter: blur(3px);
}

.rewards-overlay[hidden],
.tutorial-overlay[hidden] {
  display: none;
}

.tutorial-overlay.first-launch {
  background: var(--bg);
  backdrop-filter: none;
}

.tutorial-overlay.first-launch .tutorial-dialog {
  box-shadow: 0 18px 55px rgba(29, 36, 51, 0.16);
}

.tutorial-dialog {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(29, 36, 51, 0.3);
  animation: rewards-open 220ms cubic-bezier(0.2, 1.4, 0.32, 1);
}

.tutorial-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.tutorial-header h2 {
  font-size: 1.15rem;
}

.tutorial-header .tutorial-skip-button {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  font-size: 0.68rem;
  font-weight: 750;
}

.tutorial-header .tutorial-skip-button:hover,
.tutorial-header .tutorial-skip-button:focus-visible {
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: none;
}

.tutorial-slides {
  min-height: 475px;
}

.tutorial-slide {
  text-align: center;
}

.tutorial-slide[hidden] {
  display: none;
}

.tutorial-slide.active {
  animation: tutorial-step-in 180ms ease-out;
}

.tutorial-slide h3 {
  margin: 5px 0;
  font-size: 1.05rem;
}

.tutorial-slide > p:last-child {
  max-width: 470px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.5;
}

.tutorial-step-label {
  margin: 0;
  color: var(--active);
  font-size: 0.62rem;
  font-weight: 850;
  text-transform: uppercase;
}

.tutorial-visual {
  min-height: 205px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.tutorial-visual.live-route-demo {
  min-height: 402px;
  padding: 8px 0 4px;
  flex-direction: column;
  gap: 10px;
}

.tutorial-demo-players {
  width: min(350px, 100%);
  margin-bottom: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tutorial-demo-players > span {
  min-height: 34px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8f9fc;
  opacity: 0.5;
  transition: opacity 180ms ease, border-color 180ms ease, background 180ms ease;
}

.tutorial-demo-players > span.active {
  border-color: var(--active);
  background: #eef4ff;
  opacity: 1;
}

.tutorial-demo-players b {
  font-size: 0.92rem;
}

.tutorial-demo-players [data-tutorial-demo-player="X"] b {
  color: var(--x);
}

.tutorial-demo-players [data-tutorial-demo-player="O"] b {
  color: var(--o);
}

.tutorial-demo-players small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
}

.tutorial-mega-demo {
  width: min(340px, calc(100vw - 74px));
  aspect-ratio: 1;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
}

.tutorial-mini-demo {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  border-radius: 4px;
  background: #e9edf4;
  box-shadow: 0 0 0 0 transparent;
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.tutorial-mega-demo.restricted .tutorial-mini-demo.locked {
  opacity: 0.18;
  filter: grayscale(0.8);
  transform: scale(0.92);
}

.tutorial-mega-demo.restricted .tutorial-mini-demo.route-source-board {
  opacity: 0.62;
  filter: grayscale(0.25);
  transform: scale(0.97);
}

.tutorial-mini-demo.open-choice {
  background: #dfe9fb;
}

.tutorial-mini-demo.allowed {
  --route-color: var(--o);
  --route-surface: #bcefe2;
  --route-cell: #d0f6ed;
  --route-cell-muted: #ecfbf7;
  --route-cell-line: rgba(22, 138, 120, 0.25);
  --route-ring-strong: rgba(22, 138, 120, 0.88);
  --route-ring-soft: rgba(22, 138, 120, 0.28);
  z-index: 4;
  opacity: 1;
  filter: none;
  background: var(--route-surface);
  box-shadow: 0 0 0 4px #fff, 0 0 0 9px var(--route-color);
  animation: tutorial-allowed-pulse 700ms ease-in-out infinite alternate;
  transform: scale(1.12);
}

.tutorial-mini-demo.allowed-x {
  --route-color: var(--x);
  --route-surface: #ffcbd6;
  --route-cell: #ffe0e7;
  --route-cell-muted: #fff0f3;
  --route-cell-line: rgba(226, 63, 91, 0.28);
  --route-ring-strong: rgba(226, 63, 91, 0.88);
  --route-ring-soft: rgba(226, 63, 91, 0.28);
}

.tutorial-mini-demo.allowed::after {
  content: attr(data-play-label);
  position: absolute;
  top: -17px;
  left: 50%;
  z-index: 6;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--route-color);
  color: #fff;
  font-size: 0.44rem;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.tutorial-mini-demo.allowed > button {
  background: var(--route-cell-muted);
  box-shadow: inset 0 0 0 1px var(--route-cell-line);
}

.tutorial-mini-demo.allowed > button.playable {
  background: var(--route-cell);
}

.tutorial-mini-demo > button {
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 2px;
  background: #fff;
  color: var(--muted);
  cursor: default;
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
}

.tutorial-mini-demo > button.playable,
.tutorial-mini-demo > button.suggested {
  cursor: pointer;
}

.tutorial-mini-demo > button.suggested {
  background: var(--x-soft);
  box-shadow: inset 0 0 0 2px var(--x);
  animation: tutorial-practice-pulse 680ms ease-in-out infinite alternate;
}

.tutorial-mini-demo > button.x {
  background: var(--x-soft);
  color: var(--x);
}

.tutorial-mini-demo > button.o {
  background: var(--o-soft);
  color: var(--o);
}

.tutorial-mini-demo > button.last-move {
  animation: tutorial-piece-pop 360ms cubic-bezier(0.2, 1.5, 0.4, 1);
  box-shadow: inset 0 0 0 2px currentColor;
}

.tutorial-demo-caption {
  width: min(440px, 100%);
  min-height: 58px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 9px;
  border: 2px solid #d8aa20;
  border-radius: 8px;
  background: #fff7d2;
  box-shadow: 0 4px 0 rgba(216, 170, 32, 0.2);
  text-align: left;
}

.tutorial-demo-caption strong {
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.22;
}

.tutorial-demo-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.tutorial-route-kicker {
  color: #775900;
  font-size: 0.52rem;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.tutorial-demo-copy small {
  width: max-content;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--o);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
}

.tutorial-demo-caption.player-x .tutorial-demo-copy small {
  background: var(--x);
}

.tutorial-demo-caption.player-o .tutorial-demo-copy small {
  background: var(--o);
}

.tutorial-demo-piece {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: #fff;
  font-size: 1rem;
  font-weight: 950;
  text-align: center;
}

.tutorial-demo-piece.x {
  color: var(--x);
}

.tutorial-demo-piece.o {
  color: var(--o);
}

.tutorial-replay-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 900;
}

.tutorial-route-flight {
  position: fixed;
  z-index: 35;
  display: grid;
  place-items: center;
  border-radius: 4px;
  pointer-events: none;
  font-weight: 950;
  opacity: 1;
  transform: translate(0, 0) scale(1);
  transition: transform 620ms cubic-bezier(0.2, 0.85, 0.3, 1), opacity 620ms ease;
}

.tutorial-route-flight.x {
  background: var(--x-soft);
  color: var(--x);
}

.tutorial-route-flight.o {
  background: var(--o-soft);
  color: var(--o);
}

.tutorial-route-flight.moving {
  opacity: 0.2;
  transform: translate(var(--route-x), var(--route-y)) scale(1.8);
}

.tutorial-action-visual {
  min-height: 320px;
}

.tutorial-wild-visual {
  min-height: 350px;
}

.tutorial-wild-demo {
  width: min(320px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
}

.tutorial-wild-board {
  width: min(280px, calc(100vw - 96px));
  aspect-ratio: 1;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
}

.tutorial-wild-board-choice {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  border: 0;
  border-radius: 4px;
  background: #e9edf4;
  cursor: default;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.tutorial-wild-board-choice > span {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: #fff;
  color: var(--o);
  font-size: 0.72rem;
  font-weight: 950;
}

.tutorial-wild-board-choice.locked {
  opacity: 0.2;
  transform: scale(0.94);
}

.tutorial-wild-board-choice.forced,
.tutorial-wild-board-choice.route-origin {
  z-index: 2;
  background: var(--o-soft);
  box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--o);
  transform: scale(1.08);
}

.tutorial-wild-board-choice.forced::after {
  content: "ROUTED HERE";
  position: absolute;
  top: -17px;
  left: 50%;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--o);
  color: #fff;
  font-size: 0.44rem;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.tutorial-wild-board-choice.available {
  background: #dce8ff;
  box-shadow: inset 0 0 0 2px #2f66d0;
  cursor: pointer;
  animation: tutorial-practice-pulse 680ms ease-in-out infinite alternate;
}

.tutorial-wild-board-choice.available > span {
  background: #f2f6ff;
}

.tutorial-wild-board-choice.chosen {
  z-index: 3;
  background: var(--o-soft);
  box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--o);
  transform: scale(1.08);
}

.tutorial-wild-board-choice > span.o {
  background: #d0f6ed;
  color: var(--o);
  box-shadow: inset 0 0 0 2px var(--o);
}

.tutorial-wild-button {
  min-width: 210px;
  min-height: 50px;
  padding: 5px 12px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 2px solid #d8aa20;
  border-radius: 8px;
  background: #fff7d2;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-shadow: 0 4px 0 rgba(216, 170, 32, 0.2);
  animation: tutorial-practice-pulse 680ms ease-in-out infinite alternate;
}

.tutorial-wild-button > span {
  color: #b47d00;
  font-size: 1.25rem;
  text-align: center;
}

.tutorial-wild-button strong {
  font-size: 0.78rem;
}

.tutorial-wild-button small {
  color: #775900;
  font-size: 0.58rem;
  font-weight: 900;
}

.tutorial-wild-button.active,
.tutorial-wild-button.used {
  animation: none;
}

.tutorial-wild-button.active {
  border-color: var(--active);
  background: #eef4ff;
  box-shadow: none;
}

.tutorial-wild-button.used {
  opacity: 0.65;
  box-shadow: none;
}

.tutorial-wild-message {
  gap: 2px;
}

.tutorial-wild-message small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 750;
}

.tutorial-practice-wrap {
  position: relative;
}

.tutorial-grid .tutorial-practice-cell {
  padding: 0;
  border: 0;
  background: #fff;
  color: var(--x);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 950;
}

.tutorial-grid .tutorial-practice-cell.suggested {
  background: var(--x-soft);
  box-shadow: inset 0 0 0 3px var(--x);
  animation: tutorial-practice-pulse 680ms ease-in-out infinite alternate;
}

.tutorial-grid .tutorial-practice-cell.x {
  background: var(--x-soft);
  color: var(--x);
}

.tutorial-claim-result,
.tutorial-win-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 3px solid var(--x);
  border-radius: 8px;
  background: rgba(255, 232, 237, 0.94);
  color: var(--x);
  font-size: 5.4rem;
  font-weight: 950;
  animation: tutorial-claim-reveal 520ms 180ms cubic-bezier(0.2, 1.35, 0.3, 1) both;
}

.tutorial-win-result {
  border-color: var(--active);
  background: rgba(238, 244, 255, 0.95);
  color: var(--active);
}

.tutorial-claim-result[hidden],
.tutorial-win-result[hidden] {
  display: none;
}

.tutorial-action-message {
  min-height: 42px;
  margin: -6px auto 2px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
}

.tutorial-win-grid.complete > :nth-child(-n + 3) {
  animation: winner-flash 420ms ease-in-out 2 alternate;
}

.tutorial-grid {
  width: min(240px, calc(100vw - 96px));
  aspect-ratio: 1;
  padding: 7px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
}

.tutorial-grid span,
.tutorial-grid .tutorial-practice-cell {
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 950;
}

.tutorial-grid span.x,
.tutorial-grid span.claimed,
.tutorial-grid .tutorial-practice-cell.x {
  background: var(--x-soft);
  color: var(--x);
}

.tutorial-grid span.o {
  background: var(--o-soft);
  color: var(--o);
}

.tutorial-grid span.target {
  background: #fff2bb;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px #e4bd43;
}

.tutorial-grid.meta-demo {
  width: min(240px, calc(100vw - 96px));
}

.tutorial-grid.free-demo span:not(.claimed) {
  background: #eef4ff;
  box-shadow: inset 0 0 0 1px #91afe8;
}

.tutorial-grid.win-demo span.x {
  animation: winner-flash 620ms ease-in-out infinite alternate;
}

.tutorial-arrow {
  color: var(--active);
  font-size: 2rem;
  font-weight: 900;
}

.tutorial-footer {
  padding-top: 14px;
  display: grid;
  grid-template-columns: 112px 1fr 112px;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.tutorial-nav-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 850;
}

.tutorial-nav-button.primary {
  border-color: var(--active);
  background: var(--active);
  color: #fff;
}

.tutorial-nav-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.tutorial-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9ced9;
}

.tutorial-dots span.active {
  background: var(--active);
  box-shadow: 0 0 0 3px rgba(47, 102, 208, 0.14);
}

.rewards-dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  padding: 20px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(29, 36, 51, 0.3);
  animation: rewards-open 220ms cubic-bezier(0.2, 1.4, 0.32, 1);
}

.rewards-dialog-header {
  margin-bottom: 12px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.progress-tabs {
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f9;
}

.progress-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 900;
}

.progress-tab.active {
  background: #fff;
  color: var(--active);
  box-shadow: 0 4px 12px rgba(47, 102, 208, 0.13);
}

.progress-tab-panel {
  margin-top: 16px;
}

.progress-tab-panel[hidden] {
  display: none;
}

.progress-tab-panel .section-heading > div {
  display: grid;
  gap: 3px;
}

.rewards-dialog .achievement-list {
  margin-top: 2px;
}

.reward-summary {
  max-width: 380px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.rewards-dialog .reward-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sound-icon-button {
  font-size: 1rem;
}

.match-scorebar {
  min-height: 64px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.score-rules-caption {
  margin: 5px 4px 16px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
}

.match-score-item {
  position: relative;
  min-width: 0;
  padding: 8px 10px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  text-align: center;
}

.score-gain {
  position: absolute;
  right: 3px;
  bottom: 2px;
  left: 3px;
  color: var(--active);
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.score-gain.visible {
  opacity: 1;
  transform: translateY(0);
}

.match-score-item strong.score-pulse {
  animation: live-score-pulse 420ms ease;
}

@keyframes live-score-pulse {
  50% {
    transform: scale(1.18);
  }
}

.match-score-item + .match-score-item {
  border-left: 1px solid var(--line);
}

.match-score-item.best {
  background: #eef3ff;
}

.match-score-item span {
  max-width: 100%;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.67rem;
  font-weight: 850;
  text-transform: uppercase;
}

.match-score-item strong {
  font-size: 1.45rem;
  line-height: 1;
}

.match-score-item.player-x strong {
  color: var(--x);
}

.match-score-item.player-o strong {
  color: var(--o);
}

.match-score-item.best strong {
  color: var(--active);
}

.mini-meta {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
}

.meta-cell {
  border-radius: 5px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 2rem;
  font-weight: 950;
}

.meta-cell.x {
  color: var(--x);
  background: var(--x-soft);
}

.meta-cell.o {
  color: var(--o);
  background: var(--o-soft);
}

.meta-cell.tie {
  color: var(--tie);
  background: #eef0f4;
  font-size: 1.4rem;
}

.meta-cell .piece-token {
  width: 78%;
  height: 78%;
}

.winning-board {
  z-index: 1;
  outline: 5px solid #f0c340;
  outline-offset: -6px;
  animation: winner-flash 620ms ease-in-out infinite alternate;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(245, 247, 251, 0.78);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
}

.celebration.visible {
  opacity: 1;
  visibility: visible;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -28px;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 1.55);
  border-radius: 3px;
  background: var(--confetti-color);
  opacity: 0.9;
  animation: confetti-fall var(--duration) linear var(--delay) infinite;
  transform: translate3d(0, 0, 0) rotate(var(--spin));
}

.celebration-card {
  position: relative;
  width: min(100%, 340px);
  padding: 24px;
  border: 1px solid rgba(216, 222, 234, 0.95);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(29, 36, 51, 0.24);
  display: grid;
  justify-items: center;
  gap: 12px;
  pointer-events: auto;
  text-align: center;
  transform: translateY(12px) scale(0.96);
  transition: transform 220ms cubic-bezier(0.2, 1.4, 0.32, 1);
}

.celebration.visible .celebration-card {
  transform: translateY(0) scale(1);
}

.celebration-piece {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  font-size: 7rem;
  font-weight: 950;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(29, 36, 51, 0.24));
  animation: piece-victory 900ms ease-in-out infinite alternate;
}

.celebration-piece.winner-x {
  color: var(--x);
}

.celebration-piece.winner-o {
  color: var(--o);
}

.celebration-piece.tie {
  color: var(--tie);
}

.celebration-piece .piece-token {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.celebration-piece .emoji-piece {
  font-size: 0.78em;
  line-height: 1;
}

.celebration-kicker {
  margin: 0;
  color: var(--active);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.celebration-card h2 {
  font-size: 1.65rem;
}

.celebration-result-reason {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
}

.celebration-result-reason[hidden] {
  display: none;
}

.celebration-score {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.celebration-score > span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.celebration-score > strong {
  color: var(--active);
  font-size: 2.35rem;
  line-height: 1;
}

.celebration-score > small {
  margin-top: 4px;
  padding: 4px 7px;
  border-radius: 6px;
  background: #fff1c7;
  color: #805800;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
}

.celebration-breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 12px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.celebration-breakdown span[hidden] {
  display: none;
}

.play-again-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(29, 36, 51, 0.22);
  transition:
    transform 150ms ease,
    background 150ms ease;
}

.play-again-button:hover {
  transform: translateY(-1px);
  background: var(--active);
}

@keyframes mark-bounce {
  0% {
    transform: scale(0.72);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes move-ring {
  0% {
    opacity: 0.9;
    transform: scale(0.3);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

@keyframes timer-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

@keyframes rewards-open {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes claim-pop {
  0% {
    opacity: 0;
    transform: scale(0.35) rotate(-8deg);
  }
  70% {
    opacity: 0.28;
    transform: scale(1.12) rotate(3deg);
  }
  100% {
    opacity: 0.2;
    transform: scale(1) rotate(0);
  }
}

@keyframes winner-flash {
  from {
    background: #fff7d7;
    outline-color: #f0c340;
    box-shadow:
      inset 0 0 10px rgba(240, 195, 64, 0.3),
      0 0 0 rgba(240, 195, 64, 0);
    transform: scale(1);
  }
  to {
    background: #ffe27a;
    outline-color: #ffe27a;
    box-shadow:
      inset 0 0 28px rgba(240, 195, 64, 0.62),
      0 0 18px rgba(240, 195, 64, 0.52);
    transform: scale(1.015);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(var(--spin));
  }
  100% {
    transform: translate3d(var(--drift), calc(100vh + 80px), 0)
      rotate(calc(var(--spin) + 760deg));
  }
}

@keyframes piece-victory {
  from {
    transform: translateY(0) rotate(-2deg) scale(1);
  }
  to {
    transform: translateY(-5px) rotate(2deg) scale(1.04);
  }
}

@keyframes tutorial-step-in {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tutorial-allowed-pulse {
  from {
    box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--route-ring-strong);
  }
  to {
    box-shadow: 0 0 0 4px #fff, 0 0 0 12px var(--route-ring-soft);
  }
}

@keyframes tutorial-piece-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes tutorial-practice-pulse {
  from {
    transform: scale(0.9);
  }
  to {
    transform: scale(1);
  }
}

@keyframes tutorial-claim-reveal {
  from {
    opacity: 0;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .detail-section {
    grid-column: 1;
  }

  .marketing-hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .marketing-board {
    width: min(100%, 620px);
    justify-self: center;
  }

  .feature-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body {
    min-height: 100svh;
  }

  body:not(.setup-active) {
    height: 100svh;
    overflow: hidden;
  }

  .setup-screen {
    padding: 26px 14px;
    place-items: start center;
  }

  .setup-home {
    min-height: calc(100svh - 52px);
  }

  .setup-header {
    margin-bottom: 28px;
  }

  .setup-home .setup-header {
    margin-bottom: 18px;
  }

  .setup-header h1 {
    font-size: 2rem;
  }

  .setup-tagline {
    font-size: 0.9rem;
  }

  .setup-app-icon {
    width: 138px;
    border-radius: 24px;
  }

  .setup-primary-button.setup-play-button {
    margin-top: 24px;
  }

  .setup-choice-heading {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    margin-bottom: 18px;
  }

  .setup-choice-heading h2 {
    font-size: 1.3rem;
  }

  .setup-progress {
    margin-top: 18px;
  }

  .setup-rule-picker {
    margin-bottom: 18px;
  }

  .setup-choice-label {
    margin-bottom: 8px;
  }

  .setup-rule-options {
    padding: 4px;
    gap: 4px;
  }

  .setup-rule-option {
    min-height: 78px;
    padding: 8px 38px 8px 8px;
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 7px;
  }

  .setup-rule-icon {
    width: 32px;
    height: 32px;
    font-size: 0.72rem;
  }

  .setup-rule-option strong {
    font-size: 0.76rem;
  }

  .setup-rule-option small {
    font-size: 0.62rem;
  }

  .setup-rule-state {
    right: 7px;
    min-width: 27px;
    padding: 3px;
    font-size: 0.58rem;
  }

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

  .opponent-option {
    min-height: 82px;
    padding: 12px 14px;
    grid-template-columns: 46px 1fr;
    grid-template-rows: auto auto;
    justify-items: start;
    align-content: center;
    column-gap: 12px;
    text-align: left;
  }

  .opponent-icon {
    width: 46px;
    height: 46px;
    grid-row: 1 / 3;
  }

  .opponent-option strong {
    align-self: end;
  }

  .opponent-option small {
    align-self: start;
  }

  .difficulty-options {
    gap: 8px;
  }

  .difficulty-option {
    min-height: 118px;
    padding: 12px 6px;
  }

  .setup-step-heading.with-back {
    grid-template-columns: 38px 1fr;
  }

  .setup-back-button {
    width: 38px;
    height: 38px;
  }

  .setup-mode-summary {
    grid-column: 2;
    width: fit-content;
  }

  .setup-setting-group {
    padding: 12px 2px;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .setup-toggle-row {
    grid-template-columns: 1fr auto;
  }

  .app-shell {
    width: 100%;
    height: 100svh;
    min-width: 0;
    padding: 0;
    grid-template-rows: auto minmax(68px, 1fr);
    gap: 0;
    overflow: hidden;
  }

  .game-panel,
  .side-panel {
    border-radius: 0;
    box-shadow: none;
  }

  .game-panel {
    height: auto;
    width: 100%;
    min-width: 0;
    padding: 6px 8px 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 0;
    border-right: 0;
  }

  .side-panel {
    position: static;
    z-index: 70;
    width: 100%;
    min-width: 0;
    min-height: calc(68px + env(safe-area-inset-bottom, 0px));
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    overflow: visible;
    border: 0;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -8px 22px rgba(29, 36, 51, 0.12);
    align-content: start;
  }

  .detail-section {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(112px, 0.7fr);
    align-items: center;
    gap: 6px;
  }

  .detail-section > section + section {
    padding-top: 0;
    border-top: 0;
  }

  .mobile-piece-control {
    display: block;
    grid-column: 1;
    grid-row: 1;
  }

  .mobile-piece-sheet {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    left: 0;
  }

  .piece-customizer,
  .piece-customizer > h2,
  .game-options > h2,
  .power-hint {
    display: none;
  }

  .game-options {
    grid-column: 2;
    grid-row: 1;
    align-content: center;
    gap: 3px;
  }

  .match-rule-summary {
    gap: 0;
  }

  .match-rule-summary span {
    justify-content: center;
    gap: 3px;
    font-size: 0.52rem;
    line-height: 1.2;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
  }

  h1 {
    max-width: 100%;
    font-size: 1rem;
    line-height: 1.05;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 0.52rem;
  }

  .actions {
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 3px;
    justify-content: flex-end;
  }

  .install-button,
  .icon-button,
  .text-link-button,
  .rewards-launch-button,
  .setup-return-button {
    height: 34px;
  }

  .text-link-button {
    display: none;
  }

  .setup-return-button {
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .icon-button {
    width: 34px;
  }

  .rewards-launch-button {
    position: relative;
    width: 34px;
    min-width: 34px;
    padding: 0;
  }

  .rewards-launch-button .rewards-label {
    display: none;
  }

  .rewards-launch-button small {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    padding: 2px 3px;
    border-radius: 6px;
    background: var(--active);
    color: #fff;
    font-size: 0.55rem;
  }

  .install-button {
    min-width: 66px;
    padding: 0 10px;
  }

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

  .game-hud {
    position: static;
    z-index: auto;
    margin: 5px 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 5px;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .game-hud .status-row {
    grid-column: 1;
    grid-row: 1;
  }

  .countdown-banner {
    position: static;
    grid-column: 2;
    grid-row: 1;
    width: 68px;
    min-height: 44px;
    margin: 0;
    padding: 3px 5px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 1px;
  }

  .countdown-banner strong {
    font-size: 1rem;
  }

  .countdown-banner .label {
    font-size: 0.48rem;
  }

  .countdown-banner small {
    font-size: 0.5rem;
  }

  .turn-card {
    min-height: 44px;
    padding: 5px 7px;
  }

  .turn-card strong {
    font-size: 0.82rem;
  }

  .combined-status-card {
    min-height: 44px;
    padding: 5px 7px;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 7px;
  }

  .status-player-piece {
    width: 26px;
    height: 26px;
  }

  .combined-status-copy strong,
  .combined-status-copy span {
    font-size: 0.7rem;
  }

  .mode-switch,
  .order-switch,
  .order-buttons,
  .difficulty-buttons {
    width: 100%;
  }

  .mode-switch {
    margin-bottom: 8px;
  }

  .online-room {
    min-height: 42px;
    margin: 0 0 4px;
    padding: 5px 7px;
    align-items: center;
    flex-direction: row;
    gap: 6px;
  }

  .online-room-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 3px;
  }

  .online-room-actions #create-room-button {
    grid-column: auto;
  }

  .online-room-copy strong {
    font-size: 0.68rem;
  }

  .online-room-copy small,
  .online-button {
    font-size: 0.58rem;
  }

  .online-button {
    min-height: 32px;
    padding: 0 7px;
  }

  .mode-button {
    padding-inline: 4px;
    font-size: 0.72rem;
  }

  .order-switch {
    margin-bottom: 10px;
  }

  .mode-button,
  .order-button,
  .difficulty-button,
  .piece-select,
  .power-button {
    min-height: 36px;
    font-size: 0.86rem;
  }

  .game-options .power-button {
    min-height: 32px;
    padding: 0 4px;
    font-size: 0.62rem;
    line-height: 1.1;
  }

  .check-in-button {
    min-height: 38px;
    font-size: 0.86rem;
  }

  .achievement-list {
    grid-template-columns: 1fr;
  }

  .achievement-item {
    min-width: 0;
  }

  .piece-customizer {
    gap: 0;
  }

  .detail-section,
  .piece-row,
  .piece-select {
    min-width: 0;
    max-width: 100%;
  }

  .mega-board {
    width: min(100%, calc(100vw - 16px));
    height: auto;
    max-width: 100%;
    gap: 4px;
    padding: 4px;
    border-width: 2px;
  }

  .small-board {
    gap: 2px;
    padding: 3px;
  }

  .cell {
    border-radius: 3px;
    font-size: clamp(0.78rem, 5vw, 1.45rem);
  }

  .claim-mark {
    font-size: clamp(2.6rem, 15vw, 6rem);
  }

  .match-scorebar {
    min-height: 46px;
    margin-bottom: 0;
  }

  .match-score-item {
    padding: 4px 5px;
  }

  .match-score-item span {
    font-size: 0.59rem;
  }

  .match-score-item strong {
    font-size: 1.05rem;
  }

  .score-rules-caption {
    margin: 2px 2px 4px;
    font-size: 0.54rem;
    line-height: 1.2;
  }

  .board-wrap {
    flex: 0 0 auto;
    min-height: 0;
    align-items: start;
  }

  .celebration {
    padding: 14px;
  }

  .rewards-overlay,
  .tutorial-overlay {
    padding: 10px;
  }

  .rewards-dialog {
    max-height: calc(100svh - 20px);
    padding: 16px;
  }

  .tutorial-dialog {
    max-height: calc(100svh - 20px);
    padding: 16px;
  }

  .tutorial-slides {
    min-height: 468px;
  }

  .tutorial-visual {
    min-height: 230px;
    gap: 10px;
  }

  .tutorial-visual.live-route-demo {
    min-height: 398px;
  }

  .tutorial-mega-demo {
    width: min(316px, calc(100vw - 74px));
  }

  .tutorial-demo-players {
    width: min(320px, 100%);
  }

  .tutorial-demo-caption strong {
    font-size: 0.74rem;
  }

  .tutorial-grid,
  .tutorial-grid.meta-demo {
    width: min(230px, calc(100vw - 96px));
    padding: 5px;
    gap: 4px;
  }

  .routing-demo .tutorial-grid,
  .routing-demo .tutorial-grid.meta-demo {
    width: 108px;
  }

  .tutorial-grid span {
    font-size: 1.05rem;
  }

  .tutorial-arrow {
    font-size: 1.35rem;
  }

  .tutorial-footer {
    grid-template-columns: 92px 1fr 108px;
    gap: 8px;
  }

  .rewards-dialog .reward-list {
    grid-template-columns: 1fr;
  }

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

  .celebration-piece {
    width: 108px;
    height: 108px;
    font-size: 5.8rem;
  }

  .celebration-card h2 {
    font-size: 1.35rem;
  }

  .celebration-score > strong {
    font-size: 2rem;
  }

  .public-links {
    position: static;
    justify-content: center;
    margin-top: 26px;
  }

  .document-shell {
    width: min(100% - 24px, 860px);
    padding: 18px 0 32px;
  }

  .document-card {
    padding: 22px;
  }

  .marketing-hero {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
    gap: 28px;
  }

  .marketing-nav {
    justify-content: flex-start;
  }

  .marketing-icon {
    width: 76px;
    height: 76px;
    border-radius: 18px;
  }

  .marketing-copy h1 {
    font-size: 3.35rem;
  }

  .marketing-copy p:not(.eyebrow) {
    font-size: 1rem;
  }

  .marketing-section {
    width: min(100% - 24px, 1180px);
  }
}

@media (max-width: 680px) and (max-height: 650px) {
  .app-shell {
    grid-template-rows: 1fr;
  }

  .game-panel {
    height: calc(100svh - 68px - env(safe-area-inset-bottom, 0px));
  }

  .side-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .mobile-piece-sheet {
    position: fixed;
    right: 8px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px) + 8px);
    left: 8px;
  }

  .mega-board {
    width: auto;
    height: min(100%, calc(100vw - 16px));
  }

  .board-wrap {
    flex: 1 1 0;
  }
}
