:root {
  color-scheme: light;
  --paper: #f8f5ef;
  --paper-deep: #eee9e0;
  --paper-soft: #fffdf9;
  --ink: #190d32;
  --ink-soft: #3d2f52;
  --violet: #59368c;
  --violet-dark: #402567;
  --violet-wash: #e6ddf0;
  --lavender: #dcd4e9;
  --lavender-dark: #76678d;
  --pink: #f3d7d2;
  --pink-dark: #a35d65;
  --sage: #b6d5ca;
  --sage-dark: #3f746f;
  --turquoise: #9ddbd4;
  --line: rgba(25, 13, 50, 0.14);
  --line-strong: rgba(25, 13, 50, 0.26);
  --shadow: 0 20px 48px rgba(25, 13, 50, 0.1);
  --shadow-soft: 0 8px 24px rgba(25, 13, 50, 0.08);
  --radius-lg: 26px;
  --radius-md: 17px;
  --radius-sm: 11px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Avenir Next", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 77% -12%, rgba(182, 213, 202, 0.23), transparent 33rem),
    var(--paper);
  font-size: 15px;
  line-height: 1.45;
}

body[data-theme="garden"] {
  --paper: #f2f5ee;
  --paper-deep: #e5ede2;
}

body[data-theme="sunset"] {
  --paper: #fbf1ec;
  --paper-deep: #f2e0d7;
}

body[data-theme="midnight"] {
  color-scheme: dark;
  --paper: #1c1530;
  --paper-deep: #292044;
  --paper-soft: #261c3c;
  --ink: #f8f5ef;
  --ink-soft: #d8d0df;
  --line: rgba(248, 245, 239, 0.15);
  --line-strong: rgba(248, 245, 239, 0.27);
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.2);
  background: #1c1530;
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--turquoise);
  outline-offset: 3px;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  letter-spacing: -0.045em;
  line-height: 1.02;
}

h1 {
  max-width: 10ch;
  font-size: clamp(3rem, 5vw, 5.25rem);
  font-weight: 750;
}

h2 {
  font-size: clamp(1.45rem, 2.2vw, 2.05rem);
  font-weight: 720;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 9px 14px;
  border-radius: 9px;
  color: var(--paper);
  background: var(--violet);
  transform: translateY(-140%);
  transition: transform 180ms var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

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

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 244px;
  height: 100svh;
  padding: 29px 18px 22px;
  color: var(--paper);
  background: var(--ink);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: block;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
}

.brand-name {
  overflow: hidden;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-note {
  margin: 10px 0 31px 45px;
  color: rgba(248, 245, 239, 0.52);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.primary-nav,
.mobile-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 13px;
  min-height: 45px;
  padding: 10px 13px;
  border: 0;
  border-radius: 12px;
  color: rgba(248, 245, 239, 0.66);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}

.nav-item svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.nav-item:hover {
  color: var(--paper);
  background: rgba(248, 245, 239, 0.1);
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.is-active {
  color: var(--ink);
  background: var(--turquoise);
  box-shadow: 0 8px 20px rgba(157, 219, 212, 0.16);
}

/* The runtime uses the shorter .active hook when switching views. */
.nav-item.active {
  color: var(--ink);
  background: var(--turquoise);
  box-shadow: 0 8px 20px rgba(157, 219, 212, 0.16);
}

.sidebar-spacer {
  flex: 1;
}

.account-button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 12px 10px;
  border: 1px solid rgba(248, 245, 239, 0.14);
  border-radius: 15px;
  color: var(--paper);
  background: rgba(248, 245, 239, 0.06);
  text-align: left;
  transition: background 180ms var(--ease), border-color 180ms var(--ease);
}

.account-button:hover {
  border-color: rgba(157, 219, 212, 0.4);
  background: rgba(157, 219, 212, 0.12);
}

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

.account-copy strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy small {
  color: rgba(248, 245, 239, 0.48);
  font-size: 10px;
}

.account-chevron {
  width: 15px;
  height: 15px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  opacity: 0.58;
}

.avatar {
  display: inline-grid;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--turquoise);
  font-family: Georgia, serif;
  font-size: 17px;
}

.avatar--account {
  color: var(--ink);
  background: var(--paper);
}

.avatar--small {
  width: 27px;
  height: 27px;
  color: var(--paper);
  background: var(--violet);
  font-size: 15px;
}

.avatar--light {
  color: var(--ink);
  background: var(--turquoise);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 17px 5px 0;
  color: rgba(248, 245, 239, 0.4);
  font-size: 10px;
}

.sidebar-footer .legal {
  text-decoration: none;
}

.sidebar-footer .legal:hover {
  color: var(--paper);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mobile-topbar,
.mobile-nav {
  display: none;
}

.main-content {
  min-width: 0;
  min-height: 100svh;
  overflow: clip;
}

.global-status {
  width: min(100%, 1610px);
  min-height: 0;
  padding: 0 clamp(24px, 5vw, 76px);
  margin: 0 auto;
}

.global-status:not(:empty) {
  padding-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--violet);
  background: color-mix(in srgb, var(--violet-wash) 44%, transparent);
  font-weight: 650;
}

.view-play {
  min-height: 100svh;
}

.lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  max-width: 1180px;
  gap: clamp(28px, 4vw, 72px);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 72px) clamp(24px, 5vw, 76px) 42px;
}

.lobby-column {
  min-width: 0;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 18px;
}

.eyebrow {
  color: var(--violet);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
}

.sidebar .eyebrow,
.mode-card--dice .eyebrow {
  color: var(--turquoise);
}

.eyebrow-rule {
  display: inline-block;
  width: 30px;
  height: 1px;
  background: var(--line-strong);
}

.eyebrow-hint {
  color: var(--ink-soft);
  font-size: 11px;
  opacity: 0.68;
}

.hero-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 24px 0 39px;
}

.hero-heading h1 {
  margin-top: 13px;
}

.hero-copy {
  max-width: 43ch;
  margin-top: 17px;
  color: var(--ink-soft);
  font-size: 14px;
}

.hero-glyph {
  display: grid;
  flex: 0 0 auto;
  width: 49px;
  height: 49px;
  place-items: center;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--violet);
  font-size: 23px;
  transform: rotate(-8deg);
}

.cards {
  display: grid;
}

.mode-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: var(--paper-soft);
  box-shadow: var(--shadow-soft);
  text-align: left;
  transition: border-color 220ms var(--ease), box-shadow 220ms var(--ease), transform 220ms var(--ease);
}

.mode-card:hover {
  border-color: rgba(89, 54, 140, 0.3);
  box-shadow: var(--shadow);
  transform: translateY(-4px);
}

.mode-card:active {
  transform: translateY(-1px) scale(0.995);
}

.mode-card.is-selected {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(89, 54, 140, 0.1), var(--shadow-soft);
}

/* The runtime uses .selected-mode when a mode is chosen. */
.mode-card.selected-mode {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(89, 54, 140, 0.1), var(--shadow-soft);
}

.mode-card-art {
  position: relative;
  display: grid;
  height: clamp(160px, 17vw, 225px);
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.mode-card-art::after {
  position: absolute;
  right: 17px;
  bottom: 14px;
  left: 17px;
  height: 1px;
  content: "";
  background: currentColor;
  opacity: 0.14;
}

.mode-card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 500ms var(--ease);
}

.mode-card:hover .mode-card-art img,
.mode-card.is-selected .mode-card-art img,
.mode-card.selected-mode .mode-card-art img {
  transform: scale(1.06) rotate(-1.2deg);
}

.mode-card--dice {
  --card-ink: #f8f5ef;
  color: var(--card-ink);
  background: var(--violet-dark);
}

.mode-card--dice .mode-card-art {
  background: #4b2c7d;
}

.mode-card--cards {
  --card-ink: #2d193b;
  color: var(--card-ink);
  background: var(--pink);
}

.mode-card--cards .mode-card-art {
  background: #edc3c6;
}

.mode-card--classic {
  --card-ink: #29173b;
  color: var(--card-ink);
  background: var(--lavender);
}

.mode-card--classic .mode-card-art {
  background: #c7bddc;
}

.mode-card--evolution {
  --card-ink: #173a39;
  color: var(--card-ink);
  background: var(--sage);
}

.mode-card--evolution .mode-card-art {
  background: #90ccc2;
}

.mode-card-body {
  display: grid;
  min-height: 145px;
  gap: 7px;
  padding: 17px 18px 19px;
}

.mode-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 19px;
  padding: 3px 7px;
  border-radius: 99px;
  color: currentColor;
  background: rgba(25, 13, 50, 0.08);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1;
  white-space: nowrap;
}

.mode-card--dice .badge {
  background: rgba(248, 245, 239, 0.16);
}

.mode-arrow {
  font-size: 20px;
  font-weight: 350;
  line-height: 1;
  opacity: 0.72;
}

.mode-card-title {
  font-size: 24px;
  font-weight: 740;
  letter-spacing: -0.05em;
}

.mode-card-description {
  max-width: 29ch;
  color: currentColor;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.72;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--paper-soft) 84%, transparent);
  box-shadow: var(--shadow-soft);
}

.setup-panel {
  position: sticky;
  top: 32px;
  padding: 25px 23px 23px;
}

.setup-heading,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.setup-heading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.setup-heading h2 {
  margin-top: 8px;
}

.setup-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 10px;
  color: var(--violet);
  background: var(--violet-wash);
  font-size: 16px;
}

.setup-form {
  display: grid;
  gap: 14px;
  padding-top: 20px;
}

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

.field label,
.field > span:first-child,
.card-choice-group legend {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.field > .select-wrap {
  display: block;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--violet);
  content: "⌄";
  font-size: 16px;
  pointer-events: none;
  transform: translateY(-58%);
}

select {
  width: 100%;
  min-height: 43px;
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--ink);
  background: var(--paper);
  appearance: none;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease);
}

select:hover {
  border-color: var(--line-strong);
}

select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(89, 54, 140, 0.12);
}

.field-row,
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-row {
  align-items: flex-start;
}

.field--half {
  flex: 1 1 0;
  min-width: 0;
}

.setup-divider {
  width: 100%;
  height: 1px;
  margin: 3px 0 0;
  background: var(--line);
}

.card-choice-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px 0 0;
  margin: 0;
  border: 0;
}

.field-help {
  margin-top: -2px;
  color: var(--ink-soft);
  font-size: 11px;
  opacity: 0.72;
}

.card-choice-group .field label,
.card-choice-group .field > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-chip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.color-chip--white {
  background: var(--paper-soft);
}

.color-chip--black {
  background: var(--ink);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  gap: 9px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--paper-soft);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.1;
  text-decoration: none;
  transition: border-color 180ms var(--ease), background 180ms var(--ease), color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0) scale(0.985);
}

.button--primary {
  width: 100%;
  min-height: 52px;
  border-color: var(--violet);
  color: var(--paper);
  background: var(--violet);
  box-shadow: 0 10px 24px rgba(89, 54, 140, 0.2);
}

.button--primary:hover {
  border-color: var(--violet-dark);
  background: var(--violet-dark);
  box-shadow: 0 12px 28px rgba(89, 54, 140, 0.26);
}

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

.button.secondary:hover {
  border-color: var(--violet);
  color: var(--violet);
  background: var(--violet-wash);
}

.button-arrow {
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}

.form-status {
  min-height: 16px;
  margin: -4px 2px 0;
  color: var(--violet);
  font-size: 11px;
}

.form-status:empty {
  display: none;
}

.text-button {
  display: inline-flex;
  width: fit-content;
  padding: 2px 0;
  border: 0;
  color: var(--violet);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
}

.text-button:hover {
  text-decoration-color: currentColor;
}

.error {
  color: #a33f4d !important;
}

.resume-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 19px 20px;
}

.resume-panel h2 {
  margin-top: 6px;
  font-size: 20px;
}

.resume-panel .muted {
  margin-top: 5px;
}

.muted {
  color: var(--ink-soft);
  opacity: 0.72;
}

.lobby-footnote {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 26px;
  color: var(--ink-soft);
  font-size: 11px;
  opacity: 0.76;
}

.footnote-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage-dark);
}

.app-store-link {
  color: var(--violet);
  font-weight: 700;
  text-decoration: none;
}

.app-store-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Game view */
.view-game,
.content-view {
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 70px) clamp(24px, 5vw, 76px) 54px;
}

.game-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 26px;
}

.game-header h1 {
  margin-top: 11px;
  font-size: clamp(2.4rem, 4vw, 4.4rem);
}

.game-header .muted {
  margin-top: 9px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  color: var(--violet);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.game-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, min(72vh, 720px)) minmax(245px, 310px);
  align-items: start;
  justify-content: center;
  gap: clamp(20px, 4vw, 54px);
}

.board-column {
  min-width: 0;
}

.player-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 47px;
  padding: 7px 4px;
}

.player-name {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
}

.clock {
  min-width: 67px;
  padding: 6px 10px;
  border-radius: 9px;
  color: var(--paper);
  background: var(--ink);
  font-size: 14px;
  letter-spacing: 0.03em;
  text-align: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #39284e;
  border-radius: 12px;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.board-square {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: #e9ddca;
}

.coordinate {
  position: absolute;
  z-index: 2;
  color: currentColor;
  font-size: clamp(7px, 1.2vw, 11px);
  font-weight: 760;
  line-height: 1;
  opacity: 0.68;
  pointer-events: none;
  text-transform: lowercase;
}

.coordinate.rank {
  top: 4px;
  left: 5px;
}

.coordinate.file {
  right: 5px;
  bottom: 4px;
}

.board-square.dark {
  color: var(--paper);
  background: #7c6b96;
}

.board-square.light {
  background: #e9ddca;
}

.board-square.last-move::before,
.board-square.selected::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: rgba(230, 205, 116, 0.28);
}

.board-square.selected::before {
  background: rgba(157, 219, 212, 0.32);
  box-shadow: inset 0 0 0 2px rgba(64, 37, 103, 0.65);
}

.board-square.legal::after {
  position: absolute;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  content: "";
  background: #27183d;
  opacity: 0.26;
  pointer-events: none;
}

.board-square.legal:has(.piece)::after {
  width: 88%;
  border: 3px solid #27183d;
  background: transparent;
}

.piece {
  /* Keep artwork out of grid sizing: occupied rows must never grow taller. */
  position: absolute;
  inset: 5%;
  z-index: 1;
  display: block;
  width: 90%;
  height: 90%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(25, 13, 50, 0.16));
  pointer-events: none;
}

.resource-controls {
  justify-content: center;
  flex-wrap: wrap;
  min-height: 46px;
  margin-top: 10px;
}

.resource-value {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--violet);
  background: var(--violet-wash);
  font-size: 12px;
  font-weight: 700;
}

.game-sidebar {
  display: grid;
  gap: 14px;
}

.game-panel {
  padding: 18px;
}

.panel-heading {
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.move-list {
  display: grid;
  max-height: 360px;
  gap: 2px;
  overflow: auto;
  padding: 10px 0 0 26px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.move-list:empty + .empty {
  display: block;
}

.move-list:not(:empty) + .empty {
  display: none;
}

.move-list li {
  padding: 7px 8px;
  border-radius: 8px;
}

.move-list li:last-child {
  color: var(--violet);
  background: var(--violet-wash);
  font-weight: 700;
}

.empty {
  padding: 16px 0 2px;
  color: var(--ink-soft);
  font-size: 12px;
  opacity: 0.7;
}

.game-panel--actions {
  display: grid;
  gap: 9px;
}

.game-panel--actions .button--primary {
  min-height: 46px;
}

.action-row {
  align-items: stretch;
}

.action-row .button {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 8px;
  font-size: 11px;
}

.game-result {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

/* Content and profile views */
.view-heading {
  max-width: 670px;
  margin-bottom: 28px;
}

.view-heading h1 {
  margin-top: 14px;
}

.view-heading .muted {
  margin-top: 14px;
}

.view-slot {
  min-height: 170px;
  padding: 21px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  align-items: start;
  gap: 18px;
}

.profile-grid,
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.profile-grid > .panel,
.lesson-grid > .panel {
  display: grid;
  gap: 12px;
  padding: 21px;
}

.profile-grid h2,
.lesson-grid h2 {
  font-size: 21px;
}

.profile-grid p,
.lesson-grid p {
  color: var(--ink-soft);
  font-size: 13px;
}

.profile-grid .button,
.lesson-grid .button {
  width: fit-content;
}

.preferences-panel {
  display: grid;
  gap: 16px;
  padding: 21px;
}

.preferences-panel .field {
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.toggle-row > span:first-child {
  display: grid;
  gap: 2px;
}

.toggle-row strong {
  font-size: 12px;
}

.toggle-row small {
  color: var(--ink-soft);
  font-size: 10px;
  opacity: 0.72;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: var(--line-strong);
  transition: background 180ms var(--ease);
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  content: "";
  background: var(--paper-soft);
  box-shadow: 0 2px 5px rgba(25, 13, 50, 0.2);
  transition: transform 180ms var(--ease);
}

.toggle-row input:checked + .toggle {
  background: var(--violet);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(18px);
}

.icon-button {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  font-size: 21px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--violet);
  color: var(--violet);
  background: var(--violet-wash);
}

dialog {
  width: min(92vw, 520px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: var(--paper-soft);
  box-shadow: 0 30px 90px rgba(25, 13, 50, 0.28);
}

dialog::backdrop {
  background: rgba(25, 13, 50, 0.58);
  backdrop-filter: blur(5px);
}

.modal-card {
  padding: 21px;
}

.modal-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
}

.noscript-note {
  position: fixed;
  z-index: 80;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--paper);
  background: var(--ink);
  text-align: center;
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
  animation-duration: 0.001ms !important;
}

/* Keep the board legible when a player changes the profile theme. */
#board[data-theme="garden"] .board-square.light {
  background: #dce8d8;
}

#board[data-theme="garden"] .board-square.dark {
  background: #5e8b80;
}

#board[data-theme="sunset"] .board-square.light {
  background: #f3dfd0;
}

#board[data-theme="sunset"] .board-square.dark {
  background: #a56e72;
}

#board[data-theme="midnight"] .board-square.light {
  background: #8c7da0;
}

#board[data-theme="midnight"] .board-square.dark {
  background: #4b3b64;
}

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

@media (max-width: 1150px) {
  .lobby-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding-inline: 38px;
  }

  .mode-card-body {
    min-height: 136px;
    padding-inline: 15px;
  }

  .mode-card-title {
    font-size: 22px;
  }

  .game-layout {
    grid-template-columns: minmax(0, min(68vh, 620px)) minmax(230px, 280px);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .sidebar {
    width: 200px;
    padding-inline: 14px;
  }

  .brand-note {
    margin-left: 42px;
  }

  .lobby-layout {
    grid-template-columns: 1fr;
    max-width: 730px;
    padding: 38px 30px 45px;
  }

  .setup-panel {
    position: static;
    max-width: none;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 690px;
    margin-inline: auto;
  }

  .game-sidebar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .game-result {
    grid-column: 1 / -1;
  }

  .move-list {
    max-height: 230px;
  }
}

@media (max-width: 700px) {
  body {
    padding-bottom: calc(73px + env(safe-area-inset-bottom));
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: blur(16px);
  }

  .mobile-topbar .brand-mark {
    width: 36px;
    height: 36px;
  }

  .mobile-topbar .brand-name {
    font-size: 18px;
  }

  .mobile-account {
    display: grid;
    width: 35px;
    height: 35px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
  }

  .mobile-account .avatar {
    width: 30px;
    height: 30px;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 8px 7px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper-soft) 92%, transparent);
    box-shadow: 0 -8px 30px rgba(25, 13, 50, 0.08);
    backdrop-filter: blur(17px);
  }

  .mobile-nav .nav-item {
    color: var(--ink-soft);
    display: grid;
    min-height: 49px;
    gap: 3px;
    padding: 5px 2px;
    place-items: center;
    border-radius: 11px;
    font-size: 9px;
    text-align: center;
  }
  .mobile-nav .nav-item:hover { color: var(--violet); }

  .mobile-nav .nav-item svg {
    width: 18px;
    height: 18px;
  }

  .main-content {
    min-height: calc(100svh - 64px);
  }

  .global-status {
    padding-inline: 16px;
  }

  .lobby-layout {
    display: block;
    padding: 27px 16px 43px;
  }

  .eyebrow-hint {
    display: none;
  }

  .hero-heading {
    margin: 20px 0 27px;
  }

  h1 {
    font-size: clamp(2.8rem, 12vw, 4.1rem);
  }

  .hero-copy {
    max-width: 31ch;
    margin-top: 13px;
    font-size: 13px;
  }

  .hero-glyph {
    width: 40px;
    height: 40px;
    margin-bottom: 3px;
    font-size: 20px;
  }

  .mode-grid {
    gap: 12px;
  }

  .mode-card-art {
    height: 147px;
  }

  .mode-card-body {
    min-height: 131px;
    padding: 14px 14px 16px;
  }

  .mode-card-title {
    font-size: 20px;
  }

  .mode-card-description {
    font-size: 11px;
  }

  .setup-panel {
    margin-top: 26px;
    padding: 21px 16px 18px;
  }

  .view-game,
  .content-view {
    padding: 25px 16px 40px;
  }

  .game-header {
    display: grid;
    align-items: start;
    gap: 18px;
    margin-bottom: 18px;
  }

  .game-actions {
    justify-content: flex-start;
  }

  .game-layout {
    gap: 12px;
  }

  .board {
    border-width: 3px;
    border-radius: 9px;
  }

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

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

  .profile-grid,
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .view-heading h1 {
    font-size: clamp(2.7rem, 12vw, 4.1rem);
  }
}

@media (max-width: 460px) {
  .hero-heading {
    gap: 8px;
  }

  .hero-glyph {
    width: 35px;
    height: 35px;
    font-size: 17px;
  }

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

  .mode-card {
    display: grid;
    grid-template-columns: 42% minmax(0, 1fr);
    min-height: 147px;
    border-radius: 20px;
  }

  .mode-card-art {
    height: 100%;
    min-height: 147px;
  }

  .mode-card-body {
    min-height: 147px;
    padding: 14px;
  }

  .mode-card-description {
    max-width: 25ch;
  }

  .resume-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .resume-panel .button {
    width: 100%;
  }

  .field-row {
    gap: 8px;
  }

  .game-actions .button {
    flex: 1 1 auto;
  }

  .player-strip {
    min-height: 43px;
  }
}

/* Mode selection opens a focused setup sheet instead of a second lobby column. */
body.setup-open { overflow: hidden; }
.setup-sheet {
  width: min(520px, calc(100% - 40px));
  max-width: none;
  max-height: min(90dvh, 800px);
  overflow: hidden;
  margin: auto;
  border-radius: 28px;
}
.setup-sheet[open] { animation: setup-enter 260ms var(--ease) both; }
.setup-sheet.is-closing { animation: setup-exit 180ms ease-in both; }
.setup-sheet::backdrop { background: rgba(25, 13, 50, 0.38); backdrop-filter: blur(6px); }
.setup-sheet .setup-panel {
  position: relative;
  top: auto;
  display: flex;
  flex-direction: column;
  max-height: min(90dvh, 800px);
  margin: 0;
  padding: 0;
}
.sheet-handle { display: none; }
.setup-sheet .setup-heading { flex-shrink: 0; padding: 26px 26px 20px; }
.setup-sheet .setup-heading h2 { margin: 7px 0 8px; font-size: 30px; outline: none; }
.setup-description { max-width: 34ch; margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.setup-sheet .icon-button { flex-shrink: 0; width: 40px; height: 40px; }
.setup-sheet .setup-form { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 26px 0; }
.setup-sheet .field > span:first-child { font-size: 12px; }
.setup-sheet .setup-submit {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 6px -26px 0;
  padding: 16px 26px max(22px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
}
.setup-submit .button { width: 100%; min-height: 52px; }
.setup-error { margin: 0 0 10px; color: #a33e49; font-size: 13px; }
.setup-error:empty { display: none; }
@keyframes setup-enter { from { opacity: 0; transform: translateY(32px); } to { opacity: 1; transform: translateY(0); } }
@keyframes setup-exit { to { opacity: 0; transform: translateY(32px); } }
@media (max-width: 700px) {
  .setup-sheet {
    width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 26px 26px 0 0;
  }
  .setup-sheet .setup-panel { max-height: 92dvh; }
  .sheet-handle { display: block; flex-shrink: 0; width: 38px; height: 4px; margin: 10px auto 0; border-radius: 8px; background: var(--line-strong); }
  .setup-sheet .setup-heading { padding: 18px 22px; }
  .setup-sheet .setup-form { padding: 20px 22px 0; }
  .setup-sheet .setup-submit { margin-inline: -22px; padding-inline: 22px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  @keyframes setup-enter { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes setup-exit { to { transform: translateY(100%); } }
}

/* Carry each mode's artwork and palette into the setup experience. */
.setup-sheet {
  --ink: #281936;
  --ink-soft: #71647d;
  --paper-soft: #fbf8f2;
  --line: rgba(64, 37, 103, 0.12);
  --setup-accent: #59368c;
  --setup-wash: #eee7f7;
  --setup-hero: #402567;
  --setup-hero-ink: #fff9ed;
  background: var(--paper-soft);
}
.setup-sheet[data-mode="cards"] { --setup-hero: #f3d7d2; --setup-hero-ink: #422534; --setup-accent: #8f4d64; --setup-wash: #f7e8eb; }
.setup-sheet[data-mode="classic"] { --setup-hero: #dcd4e9; --setup-hero-ink: #29173b; }
.setup-sheet[data-mode="evolution"] { --setup-hero: #b6d5ca; --setup-hero-ink: #173a39; --setup-accent: #356b62; --setup-wash: #e4f0e9; }
.setup-sheet .setup-heading {
  position: relative;
  overflow: hidden;
  min-height: 170px;
  padding: 30px 26px 24px;
  border: 0;
  color: var(--setup-hero-ink);
  background: var(--setup-hero);
}
.setup-heading-copy { position: relative; z-index: 1; width: 65%; }
.setup-sheet .setup-heading .eyebrow {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid currentColor;
  border-radius: 7px;
  color: inherit;
  font-size: 9px;
  letter-spacing: 0.14em;
  line-height: 1;
  opacity: 0.8;
}
.setup-sheet .setup-heading h2 { margin: 10px 0 8px; color: inherit; font-size: 30px; letter-spacing: -0.045em; }
.setup-sheet .setup-description { color: inherit; max-width: 27ch; font-size: 12px; line-height: 1.45; opacity: 0.8; }
.setup-art { position: absolute; right: -10px; bottom: -12px; width: 178px; height: 178px; object-fit: contain; pointer-events: none; mask-image: linear-gradient(to right, transparent, #000 24%); }
.setup-sheet #setup-close { position: absolute; top: 17px; right: 17px; z-index: 3; width: 32px; height: 32px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); border-radius: 50%; color: var(--setup-hero-ink); background: color-mix(in srgb, var(--setup-hero) 70%, transparent); backdrop-filter: blur(8px); font-size: 22px; }
.setup-sheet .setup-form { gap: 19px; padding-top: 22px; }
.setup-choice-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.setup-choice-field legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; color: var(--ink); font-size: 12px; font-weight: 750; }
.setup-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; clear: both; }
.setup-option { position: relative; min-width: 0; cursor: pointer; }
.setup-option input { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.setup-option-face { display: flex; align-items: center; gap: 10px; height: 100%; min-height: 70px; padding: 12px; border: 1.5px solid var(--line); border-radius: 16px; background: #fffdf9; transition: background 160ms, border-color 160ms, box-shadow 160ms; }
.setup-option-icon { display: grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; }
.setup-option-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.setup-option-copy { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.setup-option-copy strong { color: var(--ink); font-size: 13px; font-weight: 750; }
.setup-option-copy small { color: var(--ink-soft); font-size: 10px; font-weight: 500; line-height: 1.25; }
.setup-option-check { position: absolute; right: 7px; top: 6px; color: var(--setup-accent); font-size: 10px; font-weight: 800; opacity: 0; }
.setup-option input:checked + .setup-option-face { border-color: var(--setup-accent); background: var(--setup-wash); box-shadow: 0 2px 5px color-mix(in srgb, var(--setup-accent) 8%, transparent); }
.setup-option input:checked + .setup-option-face .setup-option-check { opacity: 1; }
.setup-option input:focus-visible + .setup-option-face { outline: 3px solid var(--turquoise); outline-offset: 2px; }
.setup-option:hover .setup-option-face { border-color: color-mix(in srgb, var(--setup-accent) 55%, transparent); }
#difficulty-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px; gap: 3px; background: #ede8e2; border-radius: 15px; }
#difficulty-choices .setup-option-face { flex-direction: column; min-height: 82px; justify-content: center; gap: 6px; padding: 8px 4px; border-color: transparent; background: transparent; border-radius: 11px; }
#difficulty-choices input:checked + .setup-option-face { background: #fffdf9; border-color: color-mix(in srgb, var(--setup-accent) 20%, transparent); box-shadow: 0 2px 5px #2819360e; }
#difficulty-choices .setup-option-copy strong { font-size: 12px; }
#difficulty-choices .setup-option-icon { width: 44px; height: 44px; flex-basis: 44px; }
#difficulty-choices .setup-option-check { display: none; }
#dice-rule-choices .setup-option-face { align-items: flex-start; min-height: 77px; gap: 8px; padding: 13px 10px; }
#dice-rule-choices .setup-option-icon { flex-basis: 30px; width: 30px; height: 30px; }
#dice-rule-choices .setup-option-copy strong { font-size: 12px; }
.setup-sheet .setup-submit { margin-top: 2px; padding-top: 14px; background: var(--paper-soft); border-color: var(--line); }
.setup-sheet #start-game { justify-content: space-between; min-height: 54px; padding: 10px 13px 10px 20px; border-radius: 17px; border-color: var(--setup-accent); background: var(--setup-accent); box-shadow: 0 6px 18px color-mix(in srgb, var(--setup-accent) 18%, transparent); color: #fffdf9; font-size: 14px; }
.setup-cta-arrow { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: #ffffff20; font-size: 21px; }
.setup-sheet .select-wrap select { border-radius: 14px; border-color: var(--line); background: #fffdf9; color: var(--ink); }
@media (max-width: 700px) {
  .setup-sheet .setup-heading { min-height: 166px; padding: 30px 22px 21px; }
  .setup-heading-copy { width: 64%; }
  .setup-sheet .setup-heading h2 { font-size: 28px; }
  .setup-art { width: 153px; height: 153px; right: -9px; bottom: -8px; }
  .setup-sheet .sheet-handle { position: absolute; top: 9px; z-index: 4; margin: 0; left: calc(50% - 19px); background: color-mix(in srgb, var(--setup-hero-ink) 35%, transparent); }
  .setup-sheet .setup-form { gap: 17px; padding-top: 19px; }
}
@media (max-width: 360px) {
  .setup-sheet .setup-heading { padding-inline: 16px; }
  .setup-sheet .setup-form { padding-inline: 16px; }
  .setup-sheet .setup-submit { margin-inline: -16px; padding-inline: 16px; }
  .setup-option-face { gap: 6px; padding: 10px 8px; }
  .setup-option-copy strong { font-size: 12px; }
  .setup-option-copy small { font-size: 9px; }
  .setup-heading-copy { width: 67%; }
  .setup-art { width: 132px; height: 132px; }
}

/* Original iOS artwork, with its colors and transparency preserved. */
.nav-item .nav-art { display: block; width: 32px; height: 32px; flex: 0 0 32px; object-fit: contain; }
.mobile-nav .nav-item .nav-art { width: 29px; height: 29px; flex-basis: 29px; }
