:root {
  --page-bg: #0b3d91;
  --stage-bg: #ffffff;
  --ink: #263238;
  --panel-blue: #0877dc;
  --panel-blue-dark: #064f9e;
  --banner-yellow: #ffd21f;
  --banner-border: #14213d;
  --board-line: #192a56;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.24) 0 7px, transparent 8px),
    radial-gradient(circle at 82% 22%, rgba(255, 210, 31, 0.24) 0 9px, transparent 10px),
    radial-gradient(circle at 72% 78%, rgba(255, 255, 255, 0.16) 0 8px, transparent 9px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0 18%, transparent 18% 38%, rgba(255, 255, 255, 0.11) 38% 52%, transparent 52%),
    var(--page-bg);
  background-size: 96px 96px, 130px 130px, 118px 118px, 100% 100%;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  place-items: center;
  padding-inline: 16px;
  min-height: 100dvh;
}

.screen {
  display: none;
  width: min(94vw, 760px);
}

.screen-active {
  display: grid;
}

.home-screen {
  min-height: calc(100vh - 32px);
  align-content: center;
  gap: 24px;
}

.top-status-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.profile-pill,
.coin-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  background: linear-gradient(180deg, #0a8de8, #064f9e);
  border: 3px solid #ffd21f;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
  padding: 6px 12px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: #102a43;
  border: 2px solid #ffffff;
  border-radius: 8px;
  font-size: 0.8rem;
}

.coin-dot {
  width: 22px;
  height: 22px;
  background: radial-gradient(circle at 35% 30%, #fff59d, #ffb300 62%, #d86b00);
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.game-logo {
  display: grid;
  justify-items: center;
  color: #ffffff;
  font-weight: 900;
  text-align: center;
  text-shadow: 4px 4px 0 #071833, 0 8px 18px rgba(0, 0, 0, 0.28);
}

.game-logo span {
  color: #ffd21f;
  font-size: 3rem;
  line-height: 0.9;
}

.game-logo strong {
  color: #ffffff;
  font-size: 5rem;
  line-height: 0.9;
}

.menu-hero {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
}

.menu-dice {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  background: #ffffff;
  border: 5px solid #102a43;
  border-radius: 16px;
  color: #102a43;
  font-size: 3rem;
  font-weight: 900;
  box-shadow: 0 16px 22px rgba(0, 0, 0, 0.32);
  transform: rotate(-10deg);
}

.menu-piece {
  position: absolute;
  width: 58px;
  height: 86px;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 50% 50% 42% 42%;
  box-shadow: 0 14px 18px rgba(0, 0, 0, 0.32);
}

.menu-piece::before {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 28px;
  height: 28px;
  content: "";
  background: rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  transform: translateX(-50%);
}

.menu-piece-blue {
  left: 14%;
  bottom: 18px;
  background: #19a9f5;
}

.menu-piece-red {
  left: 34%;
  top: 8px;
  background: #e41f26;
  transform: scale(0.78);
}

.menu-piece-green {
  right: 34%;
  top: 8px;
  background: #0aa558;
  transform: scale(0.78);
}

.menu-piece-yellow {
  right: 14%;
  bottom: 18px;
  background: #f7cd18;
}

.mode-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  width: min(100%, 430px);
  margin-inline: auto;
  background: linear-gradient(180deg, #ffd23f, #f5a400);
  border: 5px solid #ffd94f;
  border-radius: 14px;
  color: #102a43;
  padding: 16px;
  text-align: left;
  box-shadow: 0 8px 0 #8a4b00, 0 18px 28px rgba(0, 0, 0, 0.32);
}

.mode-card strong,
.mode-card small {
  display: block;
}

.mode-card strong {
  color: #ffffff;
  font-size: 1.45rem;
  font-weight: 900;
  text-shadow: 2px 2px 0 #102a43;
  text-transform: uppercase;
}

.mode-card small {
  color: #102a43;
  font-size: 0.95rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mode-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  background: linear-gradient(180deg, #0a8de8, #064f9e);
  border: 3px solid #102a43;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.22);
}

.mode-icon-default {
  transition: opacity 150ms ease;
}

.mode-icon-spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 150ms ease;
}

.mode-icon-spinner::after {
  content: "";
  width: 28px;
  height: 28px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: mode-spin 0.7s linear infinite;
}

/* Loading state — swap icon for spinner */
.mode-card.loading {
  cursor: wait;
  opacity: 0.85;
  pointer-events: none;
}

.mode-card.loading .mode-icon-default {
  opacity: 0;
}

.mode-card.loading .mode-icon-spinner {
  opacity: 1;
}

@keyframes mode-spin {
  to { transform: rotate(360deg); }
}

.join-room-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: min(100%, 430px);
  margin-inline: auto;
}

.room-code-input,
.join-room-button {
  min-height: 48px;
  border: 3px solid #ffd21f;
  border-radius: 8px;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
}

.room-code-input {
  width: 100%;
  background: #ffffff;
  color: #102a43;
  padding: 0 12px;
}

.join-room-button {
  background: linear-gradient(180deg, #0a8de8, #064f9e);
  color: #ffffff;
  padding: 0 18px;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  width: min(100%, 430px);
  margin-inline: auto;
}

.legal-nav a {
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.legal-nav a:hover,
.legal-nav a:focus-visible {
  color: #ffd21f;
  text-decoration: underline;
}

.home-legal-nav {
  margin-top: 2px;
}

.player-select-screen {
  min-height: calc(100vh - 32px);
  place-items: center;
}

.selection-panel {
  width: min(92vw, 560px);
  background: linear-gradient(180deg, #0b86df, #064f9e);
  border: 4px solid #ffd21f;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.48), 0 28px 40px rgba(0, 0, 0, 0.45);
}

.lobby-screen {
  min-height: calc(100vh - 32px);
  place-items: center;
}

.lobby-panel {
  display: grid;
  gap: 18px;
  width: min(92vw, 560px);
  background: linear-gradient(180deg, #0b86df, #064f9e);
  border: 4px solid #ffd21f;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.48), 0 28px 40px rgba(0, 0, 0, 0.45);
}

.lobby-header {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.lobby-kicker,
.lobby-header p {
  color: #ffffff;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.32);
}

.lobby-header h1 {
  margin: 0;
  color: #ffd21f;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 3px 3px 0 #102a43;
}

.lobby-header p {
  margin: 0;
}

.lobby-slots {
  display: grid;
  gap: 10px;
}

.lobby-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  background: #ffffff;
  border: 3px solid #ffd21f;
  border-radius: 8px;
  padding: 10px 12px;
  color: #102a43;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
}

.lobby-slot-player {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lobby-slot-dot {
  width: 24px;
  height: 24px;
  border: 3px solid #102a43;
  border-radius: 50%;
}

.lobby-slot-state {
  color: #087f45;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.lobby-slot-empty .lobby-slot-state {
  color: #6b7280;
}

.lobby-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.selection-panel h1 {
  margin: 0 0 24px;
  color: #ffd21f;
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 3px 3px 0 #071833;
  text-transform: uppercase;
}

.player-options {
  display: grid;
  gap: 16px;
  margin-bottom: 28px;
}

.player-option {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 14px;
  background: transparent;
  border: 0;
  color: #ffffff;
  font-size: 1.7rem;
  font-weight: 900;
  text-align: left;
  text-shadow: 3px 3px 0 #071833;
  text-transform: uppercase;
}

.option-check {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 5px solid #ffd21f;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 210, 31, 0.55);
}

.player-option.active .option-check::after {
  width: 24px;
  height: 13px;
  content: "";
  border-bottom: 6px solid #ffd21f;
  border-left: 6px solid #ffd21f;
  transform: rotate(-45deg) translate(1px, -2px);
}

.selection-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.circle-action,
.next-action {
  border: 4px solid #ffd21f;
  color: #ffffff;
  font-weight: 900;
  text-shadow: 2px 2px 0 #071833;
  text-transform: uppercase;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.36);
}

.circle-action {
  width: 76px;
  height: 64px;
  background: linear-gradient(180deg, #0a8de8, #064f9e);
  border-radius: 50%;
}

.next-action {
  min-width: 170px;
  min-height: 58px;
  background: linear-gradient(180deg, #0a8de8, #064f9e);
  border-radius: 10px;
  font-size: 1.15rem;
}

.game-screen {
  align-content: center;
  justify-items: center;
  min-height: calc(100vh - 32px);
  gap: 14px;
}

.hero-banner {
  width: min(94vw, 760px);
  background: var(--banner-yellow);
  border: 5px solid var(--banner-border);
  border-left-width: 12px;
  border-right-width: 12px;
  border-radius: 8px;
  box-shadow: 0 8px 0 #071833, 0 16px 28px rgba(0, 0, 0, 0.28);
  padding: 8px 20px;
  text-align: center;
  transform: rotate(-2deg);
}

.hero-banner h1 {
  margin: 0;
  color: #ffed4a;
  font-size: 4rem;
  font-weight: 900;
  line-height: 0.95;
  text-shadow:
    3px 3px 0 #102a43,
    -2px -2px 0 #102a43,
    0 5px 0 #e57d00;
}

.dice-panel {
  display: grid;
  gap: 8px;
  justify-items: center;
  width: min(92vw, 720px);
  background: rgba(5, 43, 91, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.room-status {
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.roll-panel {
  display: grid;
  justify-items: center;
  width: min(92vw, 720px);
}

.dice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.dice-button {
  min-width: 136px;
  border: 2px solid #ffffff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  font-weight: 800;
  text-transform: uppercase;
}

.dice-roll-control {
  --dice-face-start: #ffffff;
  --dice-face-end: #e8f2ff;
  --dice-border: #071833;
  --dice-pip: #102a43;
  --dice-glow: rgba(0, 0, 0, 0.3);
  display: grid;
  gap: 8px;
  place-items: center;
  min-width: 96px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-weight: 900;
  text-transform: uppercase;
}

.dice-roll-control[data-dice-tone="yellow"] {
  --dice-face-start: #fff9d7;
  --dice-face-end: #ffe172;
  --dice-border: #b87900;
  --dice-pip: #7a4300;
  --dice-glow: rgba(247, 205, 24, 0.52);
}

.dice-roll-control[data-dice-tone="red"] {
  --dice-face-start: #fff1f1;
  --dice-face-end: #ffb6b6;
  --dice-border: #b81218;
  --dice-pip: #8f1015;
  --dice-glow: rgba(228, 31, 38, 0.45);
}

.dice-roll-control[data-dice-tone="blue"] {
  --dice-face-start: #f0fbff;
  --dice-face-end: #98dbff;
  --dice-border: #0874c7;
  --dice-pip: #064f9e;
  --dice-glow: rgba(25, 169, 245, 0.48);
}

.dice-roll-control[data-dice-tone="green"] {
  --dice-face-start: #effff6;
  --dice-face-end: #a9efc5;
  --dice-border: #087f45;
  --dice-pip: #075c34;
  --dice-glow: rgba(10, 165, 88, 0.48);
}

.dice-roll-control:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.dice-face {
  position: relative;
  display: block;
  width: 72px;
  height: 72px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.96) 0 12%, transparent 13%),
    linear-gradient(145deg, var(--dice-face-start), var(--dice-face-end));
  border: 5px solid var(--dice-border);
  border-radius: 14px;
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.28),
    0 16px 22px var(--dice-glow),
    inset 0 4px 0 rgba(255, 255, 255, 0.9);
  transition: background 180ms ease, border-color 180ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.dice-roll-control:not(:disabled):hover .dice-face {
  transform: translateY(-2px) rotate(-3deg);
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.28),
    0 18px 24px var(--dice-glow),
    inset 0 4px 0 rgba(255, 255, 255, 0.9);
}

.dice-roll-control.rolling .dice-face {
  animation: dice-roll-spin 520ms ease-in-out infinite;
}

.dice-pip {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--dice-pip);
  border-radius: 50%;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22);
  opacity: 0;
  transform: translate(-50%, -50%);
}

.dice-pip-top-left {
  top: 26%;
  left: 26%;
}

.dice-pip-top-right {
  top: 26%;
  left: 74%;
}

.dice-pip-middle-left {
  top: 50%;
  left: 26%;
}

.dice-pip-center {
  top: 50%;
  left: 50%;
}

.dice-pip-middle-right {
  top: 50%;
  left: 74%;
}

.dice-pip-bottom-left {
  top: 74%;
  left: 26%;
}

.dice-pip-bottom-right {
  top: 74%;
  left: 74%;
}

.dice-roll-control[data-dice-value="1"] .dice-pip-center,
.dice-roll-control[data-dice-value="2"] .dice-pip-top-left,
.dice-roll-control[data-dice-value="2"] .dice-pip-bottom-right,
.dice-roll-control[data-dice-value="3"] .dice-pip-top-left,
.dice-roll-control[data-dice-value="3"] .dice-pip-center,
.dice-roll-control[data-dice-value="3"] .dice-pip-bottom-right,
.dice-roll-control[data-dice-value="4"] .dice-pip-top-left,
.dice-roll-control[data-dice-value="4"] .dice-pip-top-right,
.dice-roll-control[data-dice-value="4"] .dice-pip-bottom-left,
.dice-roll-control[data-dice-value="4"] .dice-pip-bottom-right,
.dice-roll-control[data-dice-value="5"] .dice-pip-top-left,
.dice-roll-control[data-dice-value="5"] .dice-pip-top-right,
.dice-roll-control[data-dice-value="5"] .dice-pip-center,
.dice-roll-control[data-dice-value="5"] .dice-pip-bottom-left,
.dice-roll-control[data-dice-value="5"] .dice-pip-bottom-right,
.dice-roll-control[data-dice-value="6"] .dice-pip-top-left,
.dice-roll-control[data-dice-value="6"] .dice-pip-top-right,
.dice-roll-control[data-dice-value="6"] .dice-pip-middle-left,
.dice-roll-control[data-dice-value="6"] .dice-pip-middle-right,
.dice-roll-control[data-dice-value="6"] .dice-pip-bottom-left,
.dice-roll-control[data-dice-value="6"] .dice-pip-bottom-right {
  opacity: 1;
}

.dice-roll-label {
  color: #ffffff;
  font-size: 0.86rem;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.34);
}

@keyframes dice-roll-spin {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
  }

  35% {
    transform: translateY(-8px) rotate(14deg) scale(1.04);
  }

  70% {
    transform: translateY(2px) rotate(-12deg) scale(0.98);
  }

  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

@keyframes active-player-pulse {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-1px);
  }
}

@keyframes active-player-sparkle {
  0% {
    left: -45%;
    opacity: 0;
  }

  35% {
    opacity: 0.95;
  }

  75% {
    left: 108%;
    opacity: 0;
  }

  100% {
    left: 108%;
    opacity: 0;
  }
}

.movement-status {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.5em;
  margin: 0;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.32);
}

.game-table {
  display: grid;
  gap: 10px;
  width: min(94vw, 66vh, 650px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.12), transparent 36%),
    linear-gradient(180deg, var(--panel-blue), var(--panel-blue-dark));
  border: 5px solid #071833;
  border-radius: 8px;
  box-shadow:
    0 16px 0 rgba(0, 0, 0, 0.2),
    0 28px 42px rgba(0, 0, 0, 0.36);
  padding: clamp(10px, 2vw, 16px);
}

.player-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.player-badge {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.14);
}

.player-badge::before {
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 255, 255, 0);
  border-radius: 5px;
  content: "";
  pointer-events: none;
}

.player-badge::after {
  position: absolute;
  top: -35%;
  left: -45%;
  width: 42%;
  height: 170%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: rotate(18deg);
}

.player-badge-active {
  box-shadow:
    inset 0 -8px 0 rgba(0, 0, 0, 0.14),
    0 0 0 3px rgba(255, 255, 255, 0.82),
    0 0 18px rgba(255, 237, 74, 0.9);
  animation: active-player-pulse 1200ms ease-in-out infinite;
}

.player-badge-active::before {
  border-color: rgba(255, 255, 255, 0.86);
}

.player-badge-active::after {
  animation: active-player-sparkle 1300ms ease-in-out infinite;
}

.player-badge-red {
  background: #e41f26;
  --pin-color: #e41f26;
}

.player-badge-blue {
  background: #19a9f5;
  --pin-color: #19a9f5;
}

.player-badge-green {
  background: #0aa558;
  --pin-color: #0aa558;
}

.player-badge-yellow {
  background: #f7cd18;
  --pin-color: #f7cd18;
}

.player-pin {
  position: relative;
  width: 18px;
  height: 24px;
  flex: 0 0 auto;
  background: var(--pin-color);
  border: 4px solid var(--pin-color);
  border-radius: 50% 50% 50% 0;
  box-shadow:
    inset 4px 3px 0 rgba(255, 255, 255, 0.72),
    0 3px 0 rgba(0, 0, 0, 0.28);
  transform: rotate(-45deg);
}

.player-pin::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.board-stage {
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(238, 246, 255, 0.92)),
    var(--stage-bg);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.24);
  padding: clamp(8px, 1.5vw, 14px);
}

#gameBoard {
  display: block;
  width: 100%;
  height: 100%;
}

.game-over-modal,
.resume-modal {  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(3, 10, 24, 0.62);
  padding: 20px;
}

.game-over-modal[hidden],
.resume-modal[hidden] {
  display: none;
}

.game-over-dialog,
.resume-dialog {
  display: grid;
  gap: 16px;
  width: min(92vw, 420px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(234, 244, 255, 0.98));
  border: 5px solid #071833;
  border-radius: 8px;
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.22),
    0 24px 40px rgba(0, 0, 0, 0.36);
  padding: clamp(20px, 5vw, 28px);
  text-align: center;
}

.game-over-dialog h2,
.resume-dialog h2 {
  margin: 0;
  color: #102a43;
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  line-height: 0.95;
  text-shadow: 0 3px 0 rgba(255, 211, 42, 0.75);
}

.game-over-dialog p,
.resume-dialog p {
  margin: 0;
  color: #243b53;
  font-size: 1rem;
  font-weight: 700;
}

.leaderboard-table {
  display: grid;
  overflow: hidden;
  border: 3px solid #071833;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.14);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: minmax(82px, 0.7fr) minmax(0, 1.3fr);
  align-items: center;
  min-height: 44px;
}

.leaderboard-row + .leaderboard-row {
  border-top: 2px solid rgba(7, 24, 51, 0.18);
}

.leaderboard-rank,
.leaderboard-player {
  padding: 10px 12px;
  font-weight: 900;
}

.leaderboard-rank {
  height: 100%;
  background: #ffd32a;
  color: #102a43;
  text-transform: uppercase;
}

.leaderboard-player {
  color: #243b53;
  text-align: left;
}

.leaderboard-player-lost {
  color: #9f1239;
}

.game-over-actions,
.resume-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.game-over-button,
.resume-button {
  min-height: 46px;
  border: 2px solid #ffffff;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
}

@media (max-width: 560px) {
  .app-shell {
    place-items: start center;
  }

  .home-screen,
  .game-screen,
  .player-select-screen {
    min-height: calc(100vh - 32px);
  }

  .game-logo span {
    font-size: 2.4rem;
  }

  .game-logo strong {
    font-size: 3.7rem;
  }

  .hero-banner {
    border-width: 4px 8px;
    padding-inline: 10px;
  }

  .hero-banner h1 {
    font-size: 2.4rem;
  }

  .selection-panel h1 {
    font-size: 2.3rem;
  }

  .player-option {
    font-size: 1.25rem;
  }

  .player-badge {
    font-size: 0.85rem;
  }

  .game-table {
    width: min(96vw, 620px);
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding-block: 8px !important;
    padding-inline: 10px;
  }

  .screen {
    width: min(96vw, 680px);
  }

  .home-screen,
  .player-select-screen,
  .game-screen {
    min-height: calc(100dvh - 16px);
  }

  .game-screen {
    align-content: start;
    gap: 8px;
  }

  .hero-banner {
    width: min(96vw, 620px);
    border-width: 4px 8px;
    padding: 6px 12px;
    box-shadow: 0 5px 0 #071833, 0 10px 20px rgba(0, 0, 0, 0.24);
    transform: rotate(-1deg);
  }

  .hero-banner h1 {
    font-size: 2.35rem;
    text-shadow:
      2px 2px 0 #102a43,
      -1px -1px 0 #102a43,
      0 3px 0 #e57d00;
  }

  .dice-panel {
    width: min(96vw, 620px);
    gap: 6px;
    padding: 8px;
  }

  .roll-panel {
    width: min(96vw, 620px);
  }

  .dice-actions {
    gap: 6px;
  }

  .dice-button {
    min-width: 104px;
    min-height: 36px;
    padding: 5px 10px;
    font-size: 0.82rem;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  }

  .dice-face {
    width: 60px;
    height: 60px;
    border-width: 4px;
    border-radius: 12px;
  }

  .dice-pip {
    width: 10px;
    height: 10px;
  }

  .movement-status {
    font-size: 0.82rem;
  }

  .game-table {
    width: min(96vw, calc(100dvh - 285px), 560px);
    gap: 6px;
    border-width: 4px;
    padding: 8px;
    box-shadow:
      0 8px 0 rgba(0, 0, 0, 0.2),
      0 16px 26px rgba(0, 0, 0, 0.32);
  }

  .player-strip {
    gap: 6px;
  }

  .player-badge {
    min-height: 32px;
    border-width: 2px;
    border-radius: 6px;
    font-size: 0.78rem;
    gap: 5px;
  }

  .player-pin {
    width: 14px;
    height: 14px;
    border-width: 3px;
  }

  .board-stage {
    border-width: 4px;
    padding: 6px;
  }
}

@media (max-width: 420px) {
  .game-screen {
    gap: 6px;
  }

  .hero-banner h1 {
    font-size: 1.85rem;
  }

  .dice-button {
    min-width: 94px;
    min-height: 34px;
    font-size: 0.76rem;
  }

  .dice-roll-control {
    gap: 5px;
  }

  .dice-face {
    width: 54px;
    height: 54px;
  }

  .movement-status {
    font-size: 0.76rem;
  }

  .game-table {
    width: min(96vw, calc(100dvh - 260px), 420px);
    padding: 6px;
  }

  .player-badge {
    min-height: 28px;
    font-size: 0.72rem;
  }

  .board-stage {
    padding: 5px;
  }
}

@media (max-height: 700px) {
  .game-screen {
    align-content: start;
    gap: 6px;
  }

  .hero-banner {
    padding-block: 4px;
  }

  .hero-banner h1 {
    font-size: 1.9rem;
  }

  .dice-panel {
    padding: 6px;
  }

  .movement-status {
    font-size: 0.76rem;
  }

  .game-table {
    width: min(96vw, calc(100dvh - 255px), 520px);
    gap: 5px;
    padding: 6px;
  }

  .player-badge {
    min-height: 28px;
    font-size: 0.72rem;
  }
}

@media (max-height: 580px) {
  .hero-banner {
    display: none;
  }

  .game-table {
    width: min(94vw, calc(100dvh - 185px), 460px);
  }
}

/* ==========================================================================
   Auth Screen
   ========================================================================== */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #030a18 0%, #071833 50%, #0a2040 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Decorative floating game pieces in the background */
.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-bg-piece {
  position: absolute;
  border-radius: 50%;
  opacity: 0.07;
  animation: auth-float 8s ease-in-out infinite;
}

.auth-bg-piece-1 {
  width: 180px;
  height: 180px;
  background: #f2c94c;
  top: -40px;
  left: -40px;
  animation-delay: 0s;
}

.auth-bg-piece-2 {
  width: 120px;
  height: 120px;
  background: #eb5757;
  top: 20%;
  right: -30px;
  animation-delay: 2s;
}

.auth-bg-piece-3 {
  width: 200px;
  height: 200px;
  background: #2f80ed;
  bottom: -60px;
  left: 10%;
  animation-delay: 4s;
}

.auth-bg-piece-4 {
  width: 100px;
  height: 100px;
  background: #27ae60;
  bottom: 15%;
  right: 5%;
  animation-delay: 6s;
}

@keyframes auth-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-20px) scale(1.05); }
}

/* Card */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 28px 28px;
  backdrop-filter: blur(12px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  position: relative;
  z-index: 1;
}

/* Logo inside card */
.auth-logo {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: #ffffff;
  text-align: center;
  line-height: 1;
}

.auth-logo span {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 400;
  margin-right: 6px;
}

.auth-logo strong {
  color: #f2c94c;
}

.auth-tagline {
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.82rem;
  margin: 6px 0 20px;
}

.auth-card-header {
  margin-bottom: 4px;
}

/* Tabs */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
  gap: 3px;
}

.auth-tab {
  padding: 9px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.auth-tab:hover {
  color: rgba(255, 255, 255, 0.75);
}

.auth-tab-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Google button */
.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: #ffffff;
  border: none;
  border-radius: 10px;
  color: #1a1a2e;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease, box-shadow 150ms ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.auth-google-btn:hover {
  background: #f5f5f5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.auth-google-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.auth-google-icon {
  flex-shrink: 0;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

/* Form fields */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.3px;
}

.auth-input {
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.auth-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.auth-input:focus {
  border-color: #f2c94c;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.15);
}

/* Error message */
.auth-error {
  margin: 0;
  padding: 9px 12px;
  background: rgba(235, 87, 87, 0.15);
  border: 1px solid rgba(235, 87, 87, 0.35);
  border-radius: 8px;
  color: #ff8080;
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Submit button */
.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  background: linear-gradient(135deg, #f2c94c, #e6b800);
  border: none;
  border-radius: 10px;
  color: #1a1a2e;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 150ms ease, transform 100ms ease, box-shadow 150ms ease;
  box-shadow: 0 4px 14px rgba(242, 201, 76, 0.35);
}

.auth-submit-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(242, 201, 76, 0.45);
}

.auth-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(242, 201, 76, 0.3);
}

.auth-submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.auth-legal-nav {
  width: 100%;
  margin-top: 18px;
}

.auth-legal-nav a {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.78rem;
  font-weight: 700;
  text-shadow: none;
}

.auth-legal-nav a:hover,
.auth-legal-nav a:focus-visible {
  color: #f2c94c;
}

/* Spinner inside submit button */
.auth-btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(26, 26, 46, 0.3);
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* Profile pill sign-out button */
.profile-signout-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 150ms ease;
}

.profile-signout-btn:hover {
  color: #ffffff;
}

/* ==========================================================================
   Sign Out Confirmation Modal
   ========================================================================== */

.signout-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(3, 10, 24, 0.75);
  padding: 20px;
  backdrop-filter: blur(4px);
}

.signout-modal[hidden] {
  display: none;
}

.signout-dialog {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(180deg, #0d2240, #071833);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 28px 24px 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: signout-in 180ms ease;
}

@keyframes signout-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.signout-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 8px;
}

.signout-message {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 0 22px;
  line-height: 1.5;
}

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

.signout-cancel-btn {
  padding: 11px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}

.signout-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.13);
}

.signout-confirm-btn {
  padding: 11px;
  background: #eb5757;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease;
  box-shadow: 0 4px 12px rgba(235, 87, 87, 0.35);
}

.signout-confirm-btn:hover {
  background: #d94f4f;
  transform: translateY(-1px);
}

.signout-confirm-btn:active {
  transform: translateY(0);
}

/* ==========================================================================
   Public Information Pages
   ========================================================================== */

.legal-page-shell {
  display: grid;
  min-height: 100dvh;
  padding: clamp(18px, 4vw, 42px) 16px;
  place-items: start center;
}

.legal-page {
  display: grid;
  gap: 22px;
  width: min(100%, 860px);
  background: rgba(255, 255, 255, 0.96);
  border: 5px solid #071833;
  border-radius: 8px;
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.22),
    0 24px 40px rgba(0, 0, 0, 0.34);
  padding: clamp(22px, 5vw, 42px);
}

.legal-page-header {
  display: grid;
  gap: 6px;
}

.legal-page-nav {
  justify-content: flex-start;
  width: 100%;
  margin: 4px 0 10px;
}

.legal-page-nav a {
  color: #064f9e;
  font-size: 0.82rem;
  text-shadow: none;
}

.legal-page-nav a:hover,
.legal-page-nav a:focus-visible {
  color: #0877dc;
}

.legal-back-link {
  justify-self: start;
  color: #064f9e;
  font-weight: 900;
  text-decoration: none;
}

.legal-back-link:hover,
.legal-back-link:focus-visible {
  color: #0a8de8;
  text-decoration: underline;
}

.legal-kicker {
  margin: 6px 0 0;
  color: #0877dc;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.legal-page h1 {
  margin: 0;
  color: #102a43;
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(255, 210, 31, 0.82);
}

.legal-page h2 {
  margin: 0 0 8px;
  color: #102a43;
  font-size: clamp(1.24rem, 4vw, 1.55rem);
  font-weight: 900;
}

.legal-page p,
.legal-page li {
  color: #243b53;
  font-size: 1rem;
  line-height: 1.65;
}

.legal-page p {
  margin: 0;
}

.legal-page p + p {
  margin-top: 10px;
}

.legal-page ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.legal-page a {
  color: #064f9e;
  font-weight: 800;
}

.legal-page a:hover,
.legal-page a:focus-visible {
  color: #0877dc;
}

/* ==========================================================================
   Cookie Consent
   ========================================================================== */

.cookie-consent {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 120;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: min(100% - 32px, 860px);
  margin-inline: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 4px solid #071833;
  border-radius: 8px;
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.22),
    0 20px 36px rgba(0, 0, 0, 0.36);
  padding: 16px;
}

.cookie-consent[hidden] {
  display: none;
}

.cookie-consent-copy {
  display: grid;
  gap: 4px;
}

.cookie-consent-copy strong {
  color: #102a43;
  font-size: 1rem;
  font-weight: 900;
}

.cookie-consent-copy p {
  margin: 0;
  color: #243b53;
  font-size: 0.9rem;
  line-height: 1.45;
}

.cookie-consent-copy a {
  color: #064f9e;
  font-weight: 800;
}

.cookie-consent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.cookie-primary-button,
.cookie-secondary-button {
  min-height: 42px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 900;
  padding: 0 14px;
  text-transform: uppercase;
}

.cookie-primary-button {
  background: linear-gradient(180deg, #0a8de8, #064f9e);
  border: 3px solid #ffd21f;
  color: #ffffff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.cookie-secondary-button {
  background: #ffffff;
  border: 3px solid #102a43;
  color: #102a43;
}

@media (max-width: 680px) {
  .cookie-consent {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .cookie-consent-actions {
    justify-content: stretch;
  }

  .cookie-primary-button,
  .cookie-secondary-button {
    flex: 1 1 170px;
  }
}
