@font-face {
  font-family: "Orbitron";
  src: url("font/Orbitron-VariableFont_wght.ttf") format("truetype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #02050f;
  --bg-2: #0a1734;
  --panel: rgba(10, 18, 42, 0.78);
  --line: rgba(140, 126, 255, 0.28);
  --text: #f4fbff;
  --muted: #a9bedc;
  --cyan: #8c7eff;
  --magenta: #ff3cae;
  --violet: #6f7bff;
  --gold: #ffd85a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
  --radius-lg: 28px;
  --radius-md: 18px;
  --app-height: 100vh;
  --board-vertical-gap: 196px;
  --board-size: min(calc(100vw - 64px), calc(var(--app-height) - var(--board-vertical-gap)));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: var(--app-height);
  background:
    radial-gradient(circle at 18% 16%, rgba(140, 126, 255, 0.2), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(255, 60, 174, 0.22), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(111, 123, 255, 0.14), transparent 36%),
    linear-gradient(180deg, #06101f 0%, #020610 58%, #010309 100%);
  color: var(--text);
  font-family: "Orbitron", "Segoe UI", sans-serif;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body {
  position: relative;
  letter-spacing: 0.01em;
}

body.modal-open {
  overflow: hidden;
}

body.perf-lite {
  scroll-behavior: auto;
}

body.perf-lite .bg-orb,
body.perf-lite .grid-noise {
  display: none;
}

body.perf-lite .topbar,
body.perf-lite .board-panel,
body.perf-lite .board-frame,
body.perf-lite .modal,
body.perf-lite .modal-card,
body.perf-lite .turn-modal-card,
body.perf-lite .setup-player-card,
body.perf-lite .ghost-button,
body.perf-lite .primary-button,
body.perf-lite .choice-chip,
body.perf-lite .dice {
  backdrop-filter: none !important;
}

body.perf-lite .board-frame,
body.perf-lite .board-panel,
body.perf-lite .topbar,
body.perf-lite .modal-card,
body.perf-lite .turn-modal-card,
body.perf-lite .setup-player-card {
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
}

body.perf-lite .board-roll-display,
body.perf-lite .turn-avatar,
body.perf-lite .board-player-label,
body.perf-lite .board-track-cell,
body.perf-lite .board-goal-cell,
body.perf-lite .board-home-slot,
body.perf-lite .board-start-ring,
body.perf-lite .board-start-halo,
body.perf-lite .move-highlight,
body.perf-lite .piece-shadow,
body.perf-lite .piece-aura,
body.perf-lite .piece-select-ring,
body.perf-lite .piece-image,
body.perf-lite .setup-avatar,
body.perf-lite .setup-color-avatar {
  filter: none !important;
}

body.perf-lite .piece,
body.perf-lite .piece-image,
body.perf-lite .piece-select-ring,
body.perf-lite .board-frame,
body.perf-lite .turn-roll-result,
body.perf-lite .ghost-button,
body.perf-lite .primary-button,
body.perf-lite .choice-chip,
body.perf-lite .setup-player-card,
body.perf-lite .setup-player-card input[type="text"] {
  transition: none !important;
}

body.perf-lite .bg-orb-a,
body.perf-lite .bg-orb-b,
body.perf-lite .primary-button::before,
body.perf-lite .primary-button::after,
body.perf-lite .dice.pulse {
  animation: none !important;
}

body.perf-lite .board-start-halo,
body.perf-lite .piece-aura,
body.perf-lite .move-highlight {
  opacity: 0.82;
}

button {
  font: inherit;
}

.bg-orb,
.grid-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-orb {
  filter: blur(80px);
  opacity: 0.56;
}

.bg-orb-a {
  background: radial-gradient(circle at 25% 20%, rgba(140, 126, 255, 0.72), transparent 25%);
  animation: driftA 20s ease-in-out infinite alternate;
}

.bg-orb-b {
  background: radial-gradient(circle at 78% 68%, rgba(255, 60, 174, 0.54), transparent 26%);
  animation: driftB 24s ease-in-out infinite alternate;
}

.grid-noise {
  background-image:
    linear-gradient(rgba(140, 126, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 126, 255, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 34%, transparent 100%);
  opacity: 0.22;
}

.app-shell {
  position: relative;
  min-height: var(--app-height);
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(16, 30, 67, 0.82), rgba(5, 10, 26, 0.95)),
    rgba(10, 15, 36, 0.62);
  backdrop-filter: blur(18px);
  box-shadow: 0 0 34px rgba(140, 126, 255, 0.12), var(--shadow);
}

.eyebrow,
.section-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.74rem;
  color: var(--cyan);
}

h1,
h2 {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 2.3vw, 1.75rem);
  text-shadow: 0 0 18px rgba(140, 126, 255, 0.28), 0 0 42px rgba(255, 60, 174, 0.12);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
}

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
}

.app-footer {
  margin-top: 2px;
  padding: 2px 10px 0;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
  color: rgba(169, 190, 220, 0.62);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.24);
}

.app-footer a {
  color: rgba(255, 216, 90, 0.84);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 160ms ease, border-color 160ms ease;
}

.app-footer a:hover {
  color: rgba(255, 216, 90, 0.98);
  border-color: rgba(255, 216, 90, 0.5);
}

.board-panel {
  width: 100%;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03), transparent 58%),
    linear-gradient(180deg, rgba(7, 15, 34, 0.99), rgba(2, 5, 14, 1));
  border: 1px solid rgba(120, 239, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 44px rgba(140, 126, 255, 0.1),
    0 34px 100px rgba(0, 0, 0, 0.54),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

.board-stage {
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 1.8vw, 22px);
}

.board-frame {
  width: max(260px, var(--board-size));
  max-width: 100%;
  max-height: calc(var(--app-height) - var(--board-vertical-gap));
  aspect-ratio: 1 / 1;
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03), rgba(4, 7, 18, 0.94) 60%, rgba(2, 3, 8, 1)),
    #020304;
  border: 1px solid rgba(140, 126, 255, 0.16);
  box-shadow:
    inset 0 0 40px rgba(255, 255, 255, 0.03),
    0 0 24px rgba(140, 126, 255, 0.12),
    0 0 56px rgba(255, 60, 174, 0.05);
  overflow: hidden;
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.board-frame.active-player-focus {
  border-color: color-mix(in srgb, var(--active-player-accent, var(--cyan)) 92%, rgba(255, 255, 255, 0.34));
  box-shadow:
    inset 0 0 92px color-mix(in srgb, var(--active-player-accent, var(--cyan)) 18%, transparent),
    0 0 0 3px color-mix(in srgb, var(--active-player-accent, var(--cyan)) 88%, transparent),
    0 0 44px color-mix(in srgb, var(--active-player-accent, var(--cyan)) 96%, transparent),
    0 0 96px color-mix(in srgb, var(--active-player-accent, var(--cyan)) 78%, transparent),
    0 0 168px color-mix(in srgb, var(--active-player-accent, var(--cyan)) 54%, transparent),
    0 0 240px color-mix(in srgb, var(--active-player-accent, var(--cyan)) 30%, transparent);
}

.board-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.board-roll-display {
  font-family: "Arial Black", "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  font-size: 82px;
  font-weight: 900;
  letter-spacing: 0.02em;
  dominant-baseline: middle;
  pointer-events: none;
  opacity: 0;
  paint-order: stroke fill;
  stroke: rgba(4, 8, 20, 0.92);
  stroke-width: 10;
  filter:
    drop-shadow(0 0 20px currentColor)
    drop-shadow(0 0 44px currentColor)
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.48));
  transition: opacity 140ms ease;
}

.board-roll-display.visible {
  opacity: 0.96;
}

.status-card {
  background:
    linear-gradient(180deg, rgba(15, 23, 52, 0.9), rgba(7, 12, 30, 0.82)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.active-turn-card {
  background:
    linear-gradient(160deg, rgba(17, 29, 66, 0.98), rgba(9, 14, 35, 0.9)),
    linear-gradient(180deg, rgba(11, 18, 42, 0.95), rgba(7, 12, 30, 0.82));
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 1rem;
  margin: 0 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.turn-badge::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
}

.status-text,
.attempt-text,
.dice-text,
.rule-copy,
.modal-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 1.02rem;
}

.attempt-text {
  margin-top: 8px;
  color: var(--gold);
}

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

.primary-button,
.ghost-button,
.choice-chip {
  border: none;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-button {
  padding: 11px 18px;
  color: #03111d;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.02) 40%, transparent 42%),
    linear-gradient(135deg, color-mix(in srgb, var(--turn-accent, var(--cyan)) 76%, white), var(--turn-accent, var(--cyan)) 48%, color-mix(in srgb, var(--turn-accent, var(--cyan)) 68%, #041019));
  border: 1px solid color-mix(in srgb, var(--turn-accent, var(--cyan)) 58%, rgba(255,255,255,0.22));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.34),
    inset 0 -10px 20px rgba(0,0,0,0.14),
    0 0 24px color-mix(in srgb, var(--turn-accent, var(--cyan)) 32%, transparent),
    0 16px 34px color-mix(in srgb, var(--turn-accent, var(--cyan)) 26%, transparent);
}

.primary-button::before,
.ghost-button::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.9;
}

.primary-button::before {
  background:
    linear-gradient(120deg, rgba(255,255,255,0.24), transparent 24%, transparent 72%, rgba(255,255,255,0.12)),
    radial-gradient(circle at 18% 18%, rgba(255,255,255,0.32), transparent 22%);
  animation: saucerCorePulse 2.8s ease-in-out infinite;
}

.primary-button::after,
.ghost-button::after {
  content: "";
  position: absolute;
  top: -24%;
  left: -38%;
  width: 48%;
  height: 160%;
  transform: rotate(18deg);
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,0.2), rgba(255,255,255,0));
  opacity: 0.42;
  pointer-events: none;
  transition: opacity 160ms ease, transform 260ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.choice-chip:hover {
  transform: translateY(-2px);
}

.primary-button:hover::after,
.ghost-button:hover::after {
  opacity: 0.95;
  transform: translateX(190%) rotate(18deg);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.ghost-button {
  padding: 10px 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02)),
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 10px 22px rgba(0,0,0,0.16);
}

.wide-button {
  width: 100%;
  justify-content: center;
  min-height: 44px;
}

.choice-row {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  flex-wrap: nowrap;
  margin: 4px 0 22px;
}

.choice-row > * {
  flex: 1 1 0;
  min-width: 0;
}

.setup-player-forms {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.setup-modal-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}

.setup-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-right: 2px;
}

.setup-modal-header .choice-row {
  margin-bottom: 12px;
}

.setup-global-options {
  margin-bottom: 14px;
}

.setup-global-card {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    rgba(7, 12, 28, 0.78);
}

.setup-option-group {
  display: grid;
  gap: 8px;
}

.setup-option-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(234, 247, 255, 0.72);
}

.setup-dot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setup-dot-button,
.setup-start-avatar,
.setup-seat-dot {
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
}

.setup-dot-button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.03)),
    rgba(5, 10, 22, 0.9);
  color: var(--text);
  font-weight: 800;
}

.setup-dot-button.selected {
  border-color: rgba(140, 126, 255, 0.84);
  box-shadow: 0 0 18px rgba(140, 126, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.05)),
    rgba(38, 56, 124, 0.92);
}

.start-player-row {
  gap: 10px;
}

.setup-start-avatar {
  width: 44px;
  height: 44px;
  padding: 2px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.03)),
    color-mix(in srgb, var(--start-accent, var(--cyan)) 20%, rgba(5, 10, 22, 0.94));
  box-shadow: 0 0 14px color-mix(in srgb, var(--start-accent, var(--cyan)) 24%, transparent);
}

.setup-start-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.setup-start-avatar.selected {
  border-color: color-mix(in srgb, var(--start-accent, var(--cyan)) 88%, white);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--start-accent, var(--cyan)) 30%, transparent),
    0 0 24px color-mix(in srgb, var(--start-accent, var(--cyan)) 44%, transparent);
}

.setup-modal-card .wide-button {
  flex: 0 0 auto;
}

.setup-player-card {
  position: relative;
  padding: 6px 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--setup-card-accent, var(--cyan)) 26%, rgba(255,255,255,0.16)), transparent 36%),
    linear-gradient(135deg, color-mix(in srgb, var(--setup-card-accent, var(--cyan)) 22%, rgba(9, 15, 35, 0.96)), rgba(9, 15, 35, 0.9) 62%),
    rgba(9, 15, 35, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 26px color-mix(in srgb, var(--setup-card-accent, var(--cyan)) 18%, transparent),
    0 18px 40px rgba(0, 0, 0, 0.28);
}

.setup-player-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-avatar-select {
  position: relative;
  flex: 0 0 auto;
  z-index: 4;
}

.setup-avatar-button {
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  padding: 2px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--chip-accent, var(--cyan)) 54%, rgba(255, 255, 255, 0.16));
  background:
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.03)),
    color-mix(in srgb, var(--chip-accent, var(--cyan)) 18%, rgba(5, 10, 22, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 24px color-mix(in srgb, var(--chip-accent, var(--cyan)) 24%, transparent),
    0 14px 28px rgba(0, 0, 0, 0.24);
}

.setup-avatar-button.open {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 30px color-mix(in srgb, var(--chip-accent, var(--cyan)) 34%, transparent),
    0 16px 34px rgba(0, 0, 0, 0.28);
}

.setup-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter:
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.28))
    drop-shadow(0 0 14px rgba(255, 255, 255, 0.1));
}

.setup-avatar-caret {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.04)),
    rgba(4, 8, 20, 0.86);
  box-shadow:
    0 0 12px color-mix(in srgb, var(--chip-accent, var(--cyan)) 24%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.12);
}

.setup-avatar-caret::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -30%);
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 5px solid rgba(255, 255, 255, 0.92);
}

.setup-name-stack {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
}

.setup-input-seat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.setup-seat-row {
  display: grid;
  grid-template-columns: repeat(2, 24px);
  gap: 4px;
  flex: 0 0 auto;
  width: max-content;
  height: 58px;
  align-content: center;
  padding: 3px 4px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(4, 8, 20, 0.58);
}

.setup-seat-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 32%, rgba(255,255,255,0.22), transparent 34%),
    color-mix(in srgb, var(--seat-accent, var(--cyan)) 30%, rgba(5, 10, 22, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 0 10px color-mix(in srgb, var(--seat-accent, var(--cyan)) 26%, transparent);
}

.setup-seat-dot.selected {
  border-color: color-mix(in srgb, var(--seat-active, var(--gold)) 88%, white);
  background:
    radial-gradient(circle at 35% 32%, rgba(255,255,255,0.28), transparent 34%),
    color-mix(in srgb, var(--seat-active, var(--gold)) 74%, rgba(5, 10, 22, 0.14));
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--seat-active, var(--gold)) 24%, transparent),
    0 0 16px color-mix(in srgb, var(--seat-active, var(--gold)) 36%, transparent);
}

.setup-player-card input[type="text"] {
  flex: 1 1 auto;
  width: auto;
  min-height: 58px;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(2, 6, 18, 0.8);
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.setup-player-card input[type="text"]:focus {
  outline: none;
  border-color: rgba(140, 126, 255, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(140, 126, 255, 0.28),
    0 0 24px rgba(140, 126, 255, 0.18);
}

.setup-player-card input[type="text"].invalid {
  border-color: rgba(255, 86, 86, 0.88);
  background: rgba(44, 8, 14, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(255, 86, 86, 0.18),
    0 0 18px rgba(255, 86, 86, 0.18);
}

.setup-player-card input[type="text"]::placeholder {
  color: rgba(236, 247, 255, 0.46);
}

.setup-color-picker {
  position: absolute;
  top: 50%;
  left: calc(100% + 6px);
  z-index: 20;
  width: 172px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03)),
    rgba(5, 10, 22, 0.96);
  box-shadow:
    0 0 32px rgba(0, 0, 0, 0.34),
    0 0 24px color-mix(in srgb, var(--setup-card-accent, var(--cyan)) 18%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.97);
  transition: opacity 140ms ease, transform 140ms ease;
}

.setup-color-picker.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.setup-color-chip {
  width: 36px;
  height: 36px;
  padding: 1px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--chip-accent) 54%, rgba(255, 255, 255, 0.14));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)),
    color-mix(in srgb, var(--chip-accent) 24%, rgba(5, 10, 22, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 24px rgba(0, 0, 0, 0.22);
}

.setup-color-chip:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 26px color-mix(in srgb, var(--chip-accent) 30%, transparent),
    0 12px 28px rgba(0, 0, 0, 0.26);
}

.setup-color-chip:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  box-shadow: none;
}

.setup-color-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.22))
    drop-shadow(0 0 10px color-mix(in srgb, var(--chip-accent) 24%, transparent));
}

.setup-player-error {
  margin: 2px 2px 0 72px;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  font-size: 0.76rem;
  color: #ff7d7d;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 120ms ease, max-height 120ms ease;
}

.setup-player-error.visible {
  opacity: 1;
  max-height: 18px;
}

.choice-chip {
  padding: 12px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px rgba(0, 0, 0, 0.18);
}

.choice-chip.selected {
  background:
    linear-gradient(135deg, rgba(255, 60, 174, 0.34), rgba(140, 126, 255, 0.28)),
    rgba(255, 255, 255, 0.04);
  border-color: rgba(140, 126, 255, 0.54);
  box-shadow:
    0 0 26px rgba(255, 60, 174, 0.22),
    0 0 42px rgba(140, 126, 255, 0.14);
}

.modal-card .primary-button {
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.34),
    inset 0 -10px 20px rgba(0,0,0,0.14),
    0 0 34px color-mix(in srgb, var(--turn-accent, var(--cyan)) 34%, transparent),
    0 18px 36px color-mix(in srgb, var(--turn-accent, var(--cyan)) 28%, transparent);
  animation: saucerHover 3.4s ease-in-out infinite;
}

.modal-card .ghost-button {
  border-radius: 18px;
  backdrop-filter: blur(10px);
}

.modal-card .primary-button::after {
  top: -34%;
  left: -44%;
  width: 52%;
  height: 186%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,0.28), rgba(255,255,255,0)),
    linear-gradient(90deg, rgba(255,255,255,0), color-mix(in srgb, var(--turn-accent, var(--cyan)) 40%, white), rgba(255,255,255,0));
  animation: saucerSweep 3.4s linear infinite;
}

.modal-card .primary-button:disabled,
.modal-card .primary-button:disabled::before,
.modal-card .primary-button:disabled::after {
  animation: none;
}

.dice {
  position: relative;
  width: min(160px, 42vw);
  aspect-ratio: 1 / 1;
  margin: 18px auto 14px;
  border-radius: 30px;
  border: 1px solid color-mix(in srgb, var(--turn-accent, var(--cyan)) 52%, transparent);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.28), transparent 24%),
    linear-gradient(145deg, color-mix(in srgb, var(--turn-accent, var(--cyan)) 34%, white), color-mix(in srgb, var(--turn-accent, var(--cyan)) 16%, #161e48)),
    rgba(8, 13, 34, 0.98);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    inset 0 -12px 28px rgba(0, 0, 0, 0.24),
    inset 0 0 30px color-mix(in srgb, var(--turn-accent, var(--cyan)) 22%, transparent),
    0 0 26px color-mix(in srgb, var(--turn-accent, var(--cyan)) 24%, transparent),
    0 20px 40px rgba(0, 0, 0, 0.44);
  transition: transform 180ms ease, box-shadow 180ms ease;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.dice.pulse {
  animation: dicePulse 180ms ease-out;
}

.pip {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.28),
    0 0 20px rgba(255, 255, 255, 0.72),
    0 4px 10px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 85ms linear;
  backface-visibility: hidden;
}

.dice[data-value="1"] .pip-4,
.dice[data-value="2"] .pip-1,
.dice[data-value="2"] .pip-7,
.dice[data-value="3"] .pip-1,
.dice[data-value="3"] .pip-4,
.dice[data-value="3"] .pip-7,
.dice[data-value="4"] .pip-1,
.dice[data-value="4"] .pip-3,
.dice[data-value="4"] .pip-5,
.dice[data-value="4"] .pip-7,
.dice[data-value="5"] .pip-1,
.dice[data-value="5"] .pip-3,
.dice[data-value="5"] .pip-4,
.dice[data-value="5"] .pip-5,
.dice[data-value="5"] .pip-7,
.dice[data-value="6"] .pip-1,
.dice[data-value="6"] .pip-2,
.dice[data-value="6"] .pip-3,
.dice[data-value="6"] .pip-5,
.dice[data-value="6"] .pip-6,
.dice[data-value="6"] .pip-7 {
  opacity: 1;
}

.pip-1 { top: 20%; left: 22%; }
.pip-2 { top: 20%; left: 50%; transform: translateX(-50%); }
.pip-3 { top: 20%; right: 22%; }
.pip-4 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.pip-5 { bottom: 20%; left: 22%; }
.pip-6 { bottom: 20%; left: 50%; transform: translateX(-50%); }
.pip-7 { bottom: 20%; right: 22%; }

.player-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.modal-player-list {
  margin-top: 14px;
}

.player-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease, transform 180ms ease;
}

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

.player-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 0 16px var(--player-color);
}

.player-name {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.08rem;
}

.player-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(140, 126, 255, 0.1), transparent 30%),
    radial-gradient(circle at 50% 82%, rgba(255, 60, 174, 0.08), transparent 32%),
    rgba(1, 4, 11, 0.82);
  backdrop-filter: blur(18px) saturate(1.12);
  z-index: 10;
}

.modal.visible {
  display: flex;
}

.board-bound-modal {
  pointer-events: none;
  padding: 0;
  background: none;
  backdrop-filter: none;
}

.board-bound-modal.visible {
  display: block;
}

.board-bound-modal .modal-card {
  position: fixed;
  left: var(--board-modal-left, 0px);
  top: var(--board-modal-top, 0px);
  width: var(--board-modal-width, 320px);
  height: var(--board-modal-height, 320px);
  max-width: none;
  max-height: none;
  margin: 0;
  pointer-events: auto;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.modal-card {
  width: min(100%, 500px);
  max-height: min(calc(var(--app-height) - 36px), 860px);
  overflow: auto;
  padding: 30px;
  border-radius: 36px;
  border: 1px solid rgba(140, 126, 255, 0.3);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.08), transparent 28%),
    radial-gradient(circle at top left, rgba(140, 126, 255, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(255, 60, 174, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(11, 18, 43, 0.985), rgba(6, 10, 26, 0.975));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 56px rgba(140, 126, 255, 0.24),
    0 0 90px rgba(255, 60, 174, 0.12),
    0 24px 72px rgba(0, 0, 0, 0.56);
}

.setup-modal-card {
  width: min(100%, 620px);
  padding-top: 24px;
  padding-bottom: 24px;
  max-height: min(calc(var(--app-height) - 36px), 980px);
}

.board-bound-modal .setup-modal-card,
.board-bound-modal .modal-card:not(.turn-modal-card) {
  width: var(--board-modal-width, 320px);
  height: var(--board-modal-height, 320px);
  padding: clamp(16px, 3vw, 28px);
  border-radius: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.board-bound-modal .setup-modal-card {
  justify-content: flex-start;
  overflow: hidden;
}

.modal-hero {
  margin-bottom: 14px;
  padding: 16px 18px 14px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(140, 126, 255, 0.18), rgba(255, 60, 174, 0.12)),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.turn-modal-shell {
  pointer-events: none;
  padding: 0;
  background: none;
  backdrop-filter: none;
  z-index: 8;
}

.turn-modal-shell:not(.visible) {
  display: none;
}

.turn-modal-card {
  position: fixed;
  left: var(--turn-modal-left, 0px);
  top: var(--turn-modal-top, 0px);
  width: var(--turn-modal-width, 320px);
  height: var(--turn-modal-height, 320px);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(16px, 3.2vw, 28px);
  border-radius: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  pointer-events: auto;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 26%),
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--turn-accent, var(--cyan)) 56%, transparent), transparent 44%),
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--turn-accent, var(--cyan)) 32%, transparent), transparent 30%),
    linear-gradient(180deg, color-mix(in srgb, var(--turn-accent, var(--cyan)) 48%, rgba(10, 16, 38, 0.98)), color-mix(in srgb, var(--turn-accent, var(--cyan)) 24%, rgba(3, 7, 20, 0.98)));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 84px color-mix(in srgb, var(--turn-accent, var(--cyan)) 52%, transparent),
    inset 0 0 52px color-mix(in srgb, var(--turn-accent, var(--cyan)) 18%, transparent),
    0 24px 70px rgba(0, 0, 0, 0.52);
  border: 1px solid color-mix(in srgb, var(--turn-accent, var(--cyan)) 82%, rgba(255, 255, 255, 0.18));
  transform: rotate(var(--turn-rotation, 0deg));
  transform-origin: center center;
}

.turn-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.turn-player-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.turn-avatar {
  width: clamp(70px, 10vw, 96px);
  height: clamp(70px, 10vw, 96px);
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  filter:
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.3))
    drop-shadow(0 0 14px color-mix(in srgb, var(--turn-accent, var(--cyan)) 22%, transparent));
}

.turn-title {
  font-size: clamp(1.3rem, 3vw, 2rem);
  letter-spacing: 0.05em;
  line-height: 1;
  text-shadow: 0 0 18px color-mix(in srgb, var(--turn-accent, var(--cyan)) 36%, transparent);
}

.compact-button {
  padding: 8px 12px;
  border-radius: 12px;
}

.turn-modal-card .ghost-button {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--turn-accent, var(--cyan)) 42%, transparent), rgba(255, 255, 255, 0.05)),
    rgba(255, 255, 255, 0.04);
  border-color: color-mix(in srgb, var(--turn-accent, var(--cyan)) 72%, rgba(255, 255, 255, 0.12));
  box-shadow: 0 0 24px color-mix(in srgb, var(--turn-accent, var(--cyan)) 24%, transparent);
}

.turn-dice-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}

.turn-roll-result {
  min-height: 1.2em;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: clamp(1rem, 2vw, 1.4rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(4px);
  text-shadow:
    0 0 14px currentColor,
    0 0 28px color-mix(in srgb, currentColor 42%, transparent);
  transition: opacity 120ms ease, transform 120ms ease;
}

.turn-roll-result.visible {
  opacity: 1;
  transform: translateY(0);
}

.turn-modal-shell .dice {
  margin: 0;
  width: min(62%, 340px);
  min-width: 180px;
  cursor: pointer;
  outline: none;
  opacity: 1;
}

.turn-modal-shell .dice:hover:not(.disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    inset 0 -12px 28px rgba(0, 0, 0, 0.24),
    inset 0 0 30px color-mix(in srgb, var(--turn-accent, var(--cyan)) 22%, transparent),
    0 0 34px color-mix(in srgb, var(--turn-accent, var(--cyan)) 28%, transparent),
    0 22px 42px rgba(0, 0, 0, 0.46);
}

.turn-modal-shell .dice:not(.disabled) {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.24),
    inset 0 -12px 28px rgba(0, 0, 0, 0.24),
    inset 0 0 34px color-mix(in srgb, var(--turn-accent, var(--cyan)) 26%, transparent),
    0 0 34px color-mix(in srgb, var(--turn-accent, var(--cyan)) 32%, transparent),
    0 22px 42px rgba(0, 0, 0, 0.46);
}

.turn-modal-shell .dice:focus-visible:not(.disabled) {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    inset 0 -12px 28px rgba(0, 0, 0, 0.24),
    inset 0 0 30px color-mix(in srgb, var(--turn-accent, var(--cyan)) 22%, transparent),
    0 0 0 2px rgba(255, 255, 255, 0.22),
    0 0 38px color-mix(in srgb, var(--turn-accent, var(--cyan)) 30%, transparent),
    0 22px 42px rgba(0, 0, 0, 0.46);
}

.turn-modal-shell .dice.disabled {
  cursor: default;
  opacity: 0.34;
  transform: none;
  filter: grayscale(0.35) saturate(0.55) brightness(0.72);
  border-color: rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.1), transparent 24%),
    linear-gradient(145deg, rgba(120, 126, 148, 0.22), rgba(28, 34, 54, 0.94)),
    rgba(8, 13, 34, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -6px 14px rgba(0, 0, 0, 0.18),
    0 6px 14px rgba(0, 0, 0, 0.16);
}

.turn-modal-shell .dice.disabled .pip {
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.16),
    0 0 6px rgba(255, 255, 255, 0.16),
    0 2px 6px rgba(0, 0, 0, 0.18);
}

.board-player-label {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 33px;
  letter-spacing: 0.03em;
  font-weight: 900;
  opacity: 1;
  pointer-events: none;
  dominant-baseline: middle;
  text-anchor: middle;
}

.board-player-label-outline {
  fill: none;
  stroke: currentColor;
  stroke-width: 12;
  stroke-linejoin: round;
  paint-order: stroke;
  filter:
    drop-shadow(0 0 8px currentColor)
    drop-shadow(0 0 18px currentColor)
    drop-shadow(0 0 32px color-mix(in srgb, currentColor 62%, transparent))
    drop-shadow(0 0 50px color-mix(in srgb, currentColor 44%, transparent));
}

.board-player-label-fill {
  fill: #fffdfd;
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 1.6;
  paint-order: stroke fill;
  filter:
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.72))
    drop-shadow(0 0 18px color-mix(in srgb, currentColor 20%, transparent));
}

.board-player-label-outline.board-player-label-white {
  stroke: rgba(0, 0, 0, 0.94);
  filter:
    drop-shadow(0 0 6px rgba(255, 255, 255, 0.52))
    drop-shadow(0 0 14px rgba(255, 255, 255, 0.34))
    drop-shadow(0 0 24px rgba(255, 255, 255, 0.18));
}

.board-player-label-fill.board-player-label-white {
  fill: #05070d;
  stroke: rgba(255, 255, 255, 0.92);
  filter:
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.42))
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.16));
}

.board-track-cell,
.board-home-slot,
.board-goal-cell,
.board-start-ring,
.board-start-halo {
  transition: opacity 160ms ease;
}

.board-track-cell {
  fill: rgba(0, 0, 0, 0.92);
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 7;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.92));
}

.board-track-cell.safe {
  fill: rgba(0, 0, 0, 0.94);
  stroke: rgba(255, 255, 255, 0.98);
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.94));
}

.board-goal-cell {
  fill: color-mix(in srgb, currentColor 34%, rgba(255, 255, 255, 0.04));
  stroke: color-mix(in srgb, currentColor 86%, white);
  stroke-width: 7.5;
  filter:
    drop-shadow(0 0 20px currentColor)
    drop-shadow(0 0 42px color-mix(in srgb, currentColor 48%, transparent));
}

.board-home-slot {
  fill: color-mix(in srgb, currentColor 28%, rgba(0, 0, 0, 0.18));
  stroke: color-mix(in srgb, currentColor 84%, white);
  stroke-width: 8.5;
  filter:
    drop-shadow(0 0 18px currentColor)
    drop-shadow(0 0 34px color-mix(in srgb, currentColor 42%, transparent))
    drop-shadow(0 0 24px rgba(255, 255, 255, 0.86));
}

.board-start-ring {
  fill: none;
  stroke-width: 11;
  opacity: 1;
  filter:
    drop-shadow(0 0 30px currentColor)
    drop-shadow(0 0 58px color-mix(in srgb, currentColor 50%, transparent));
}

.board-start-halo {
  filter: blur(24px);
  opacity: 1;
}

.move-highlight {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 5;
  fill-opacity: 0.14;
  stroke-opacity: 0.78;
  filter:
    drop-shadow(0 0 6px currentColor)
    drop-shadow(0 0 12px color-mix(in srgb, currentColor 42%, transparent));
  pointer-events: none;
  animation: none;
}

.capture-burst {
  fill: currentColor;
  fill-opacity: 0.56;
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 6;
  stroke-opacity: 1;
  filter:
    drop-shadow(0 0 18px currentColor)
    drop-shadow(0 0 34px currentColor)
    drop-shadow(0 0 64px color-mix(in srgb, currentColor 72%, transparent));
  pointer-events: none;
}

.capture-burst.reduced {
  filter:
    drop-shadow(0 0 10px currentColor)
    drop-shadow(0 0 18px color-mix(in srgb, currentColor 46%, transparent));
}

.piece {
  cursor: pointer;
  transition: opacity 160ms ease, filter 160ms ease;
}

.piece.capture-active,
.piece.capture-active .piece-image,
.piece.capture-active .piece-aura,
.piece.capture-active .piece-select-ring,
.piece.capture-active .piece-shadow {
  transition: none !important;
  will-change: transform, opacity;
}

.piece.capture-active .piece-image,
.piece.capture-active .piece-aura,
.piece.capture-active .piece-select-ring,
.piece.capture-active .piece-shadow {
  filter: none !important;
}

.piece-hidden {
  display: none;
}

.piece.active-turn {
  opacity: 1;
}

.piece.inactive {
  opacity: 1;
}

.piece.inactive .piece-image,
.piece.inactive .piece-aura,
.piece.inactive .piece-select-ring,
.piece.inactive .piece-shadow {
  filter: none;
}

.piece.inactive.selectable {
  opacity: 1;
}

.piece-shadow {
  fill: rgba(0, 0, 0, 0.42);
  filter: blur(4px);
}

.piece-aura {
  filter: blur(9px);
  opacity: 0.88;
}

.piece-select-ring {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 4;
  opacity: 0;
  transition: opacity 160ms ease, stroke 160ms ease, filter 160ms ease;
}

.piece-image {
  overflow: visible;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.16));
  transition: transform 160ms ease, filter 160ms ease;
}

.piece:hover .piece-image {
  transform: scale(1.04);
}

.piece.selectable .piece-aura {
  filter: blur(12px);
  opacity: 1;
}

.piece.selectable .piece-select-ring {
  opacity: 1;
  stroke: rgba(255, 255, 255, 0.94);
  filter: drop-shadow(0 0 14px currentColor) drop-shadow(0 0 24px rgba(255, 255, 255, 0.74));
}

.piece.selectable .piece-image {
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.34)) drop-shadow(0 0 16px currentColor);
  transform: scale(1.06);
}

@media (max-width: 980px) {
  :root {
    --board-vertical-gap: 212px;
    --board-size: min(calc(100vw - 44px), calc(var(--app-height) - var(--board-vertical-gap)));
  }
}

@media (max-width: 720px) {
  :root {
    --board-vertical-gap: 252px;
    --board-size: min(calc(100vw - 28px), calc(var(--app-height) - var(--board-vertical-gap)));
  }

  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
    gap: 10px;
  }

  .topbar {
    padding: 8px 10px;
    border-radius: 16px;
    gap: 8px;
  }

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

  .topbar h1 {
    font-size: 0.88rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 6px;
  }

  .header-actions .ghost-button {
    min-height: 30px;
    padding: 6px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.08),
      0 6px 14px rgba(0,0,0,0.12);
  }

  .header-actions .ghost-button::before,
  .header-actions .ghost-button::after {
    display: none;
  }

  .status-card {
    padding: 14px;
  }

  .board-stage {
    padding: 8px;
  }

  .board-frame {
    min-width: 0;
    max-height: calc(var(--app-height) - var(--board-vertical-gap));
  }

  .choice-row {
    flex-direction: row;
  }

  .choice-chip {
    width: auto;
    padding: 11px 10px;
    font-size: 0.94rem;
  }

  .setup-modal-card {
    width: 100%;
    max-height: calc(var(--app-height) - 20px);
  }

  .setup-player-row {
    gap: 12px;
  }

  .setup-avatar-button {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .setup-color-picker {
    width: 204px;
    gap: 8px;
  }

  .setup-color-chip {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .turn-modal-shell {
    padding: 0;
  }

  .turn-modal-card {
    padding: 16px 14px 16px;
    border-radius: 26px;
  }

  .turn-dice-row {
    gap: 16px;
  }

  .turn-avatar {
    width: clamp(60px, 14vw, 78px);
    height: clamp(60px, 14vw, 78px);
  }
}

@media (max-width: 560px) {
  .setup-player-row {
    align-items: center;
  }

  .setup-avatar-button {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }

  .setup-player-card input[type="text"] {
    min-height: 54px;
    padding: 6px 10px;
    font-size: 0.95rem;
  }

  .setup-seat-row {
    height: 54px;
    grid-template-columns: repeat(2, 21px);
    gap: 4px;
    padding: 3px;
  }

  .setup-seat-dot {
    width: 21px;
    height: 21px;
  }
}

@media (max-width: 500px) {
  :root {
    --board-vertical-gap: 274px;
    --board-size: min(calc(100vw - 20px), calc(var(--app-height) - var(--board-vertical-gap)));
  }

  h1 {
    font-size: 1.55rem;
  }

  .board-roll-display {
    font-size: 62px;
    stroke-width: 6;
  }

  .dice {
    width: min(132px, 38vw);
  }

  .pip {
    width: 22px;
    height: 22px;
  }
}

@media (orientation: landscape) and (max-height: 820px) and (min-width: 700px) {
  .turn-modal-shell .dice {
    width: min(48%, 248px);
    min-width: 148px;
  }

  .turn-modal-shell .pip {
    width: 28px;
    height: 28px;
  }

  .turn-modal-shell .pip-1 { top: 19%; left: 21%; }
  .turn-modal-shell .pip-2 { top: 19%; left: 50%; transform: translateX(-50%); }
  .turn-modal-shell .pip-3 { top: 19%; right: 21%; }
  .turn-modal-shell .pip-4 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
  .turn-modal-shell .pip-5 { bottom: 19%; left: 21%; }
  .turn-modal-shell .pip-6 { bottom: 19%; left: 50%; transform: translateX(-50%); }
  .turn-modal-shell .pip-7 { bottom: 19%; right: 21%; }
}

@media (pointer: coarse) and (min-width: 768px) {
  body.modal-open {
    overflow-y: auto;
  }

  .bg-orb,
  .grid-noise {
    display: none;
  }

  .modal {
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
  }

  .topbar,
  .modal,
  .modal-card,
  .turn-modal-card,
  .setup-player-card,
  .modal-card .ghost-button {
    backdrop-filter: none !important;
  }

  .topbar,
  .board-panel,
  .board-frame,
  .modal-card,
  .turn-modal-card,
  .setup-player-card {
    box-shadow:
      0 10px 26px rgba(0, 0, 0, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  .setup-modal-card {
    margin: 0 auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .setup-player-card,
  .setup-avatar-button,
  .setup-color-picker,
  .setup-player-card input[type="text"] {
    transition: none !important;
  }

  .setup-player-card input[type="text"] {
    font-size: 16px;
  }

  .board-player-label,
  .board-goal-cell,
  .board-home-slot,
  .board-start-ring,
  .piece-image,
  .piece-aura,
  .piece-select-ring,
  .turn-avatar,
  .setup-avatar,
  .setup-color-avatar {
    filter: none !important;
  }
}

@keyframes diceSpin {
  0% { transform: rotate(0deg) scale(1); }
  30% { transform: rotate(96deg) scale(1.05); }
  65% { transform: rotate(218deg) scale(0.96); }
  100% { transform: rotate(300deg) scale(1); }
}

@keyframes dicePulse {
  0% { transform: translateZ(0) scale(1); }
  45% { transform: translateZ(0) scale(1.06); }
  100% { transform: translateZ(0) scale(1); }
}

@keyframes targetPulse {
  0% {
    fill-opacity: 0.14;
    stroke-opacity: 0.76;
    filter:
      drop-shadow(0 0 8px currentColor)
      drop-shadow(0 0 16px currentColor)
      drop-shadow(0 0 28px color-mix(in srgb, currentColor 42%, transparent));
  }
  50% {
    fill-opacity: 0.28;
    stroke-opacity: 1;
    filter:
      drop-shadow(0 0 12px currentColor)
      drop-shadow(0 0 24px currentColor)
      drop-shadow(0 0 40px color-mix(in srgb, currentColor 60%, transparent));
  }
  100% {
    fill-opacity: 0.14;
    stroke-opacity: 0.76;
    filter:
      drop-shadow(0 0 8px currentColor)
      drop-shadow(0 0 16px currentColor)
      drop-shadow(0 0 28px color-mix(in srgb, currentColor 42%, transparent));
  }
}

@keyframes saucerHover {
  0%, 100% {
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.34),
      inset 0 -10px 20px rgba(0,0,0,0.14),
      0 0 26px color-mix(in srgb, var(--turn-accent, var(--cyan)) 26%, transparent),
      0 14px 28px color-mix(in srgb, var(--turn-accent, var(--cyan)) 18%, transparent);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.38),
      inset 0 -12px 24px rgba(0,0,0,0.16),
      0 0 42px color-mix(in srgb, var(--turn-accent, var(--cyan)) 40%, transparent),
      0 22px 42px color-mix(in srgb, var(--turn-accent, var(--cyan)) 30%, transparent);
  }
}

@keyframes saucerCorePulse {
  0%, 100% {
    opacity: 0.82;
    transform: scaleY(1);
  }
  50% {
    opacity: 1;
    transform: scaleY(1.03);
  }
}

@keyframes saucerSweep {
  0% {
    opacity: 0;
    transform: translateX(0%) rotate(18deg);
  }
  18% {
    opacity: 0.58;
  }
  52% {
    opacity: 0.9;
  }
  88% {
    opacity: 0.22;
  }
  100% {
    opacity: 0;
    transform: translateX(245%) rotate(18deg);
  }
}

@keyframes driftA {
  from { transform: translate3d(-3%, -3%, 0) scale(1); }
  to { transform: translate3d(4%, 2%, 0) scale(1.05); }
}

@keyframes driftB {
  from { transform: translate3d(2%, -1%, 0) scale(1); }
  to { transform: translate3d(-4%, 3%, 0) scale(1.06); }
}
