/* =================================================================
   1·4·24 — Dice Game
   ================================================================= */

:root {
  --bg: #0a0e1b;
  --bg-grad: radial-gradient(ellipse 80% 50% at 50% 0%, #141b30 0%, #0a0e1b 60%);

  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text: #eef1f8;
  --text-dim: #a7b0c4;
  --text-muted: #707a92;
  --text-faint: #4a5066;

  --gold: #f5b32b;
  --gold-hi: #ffd166;
  --gold-lo: #b88219;
  --gold-dim: rgba(245, 179, 43, 0.15);
  --gold-glow: 0 0 40px rgba(245, 179, 43, 0.35);

  --emerald: #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.15);

  --ruby: #ef4444;
  --ruby-dim: rgba(239, 68, 68, 0.15);

  --felt: radial-gradient(ellipse at center, #1e5a3f 0%, #0c2a1c 78%);
  --felt-shadow: inset 0 0 100px rgba(0, 0, 0, 0.55), 0 30px 60px -20px rgba(0, 0, 0, 0.8);

  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.hidden { display: none !important; }

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  font-family: var(--font-body);
  min-height: 48px;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.btn-large {
  padding: 18px 32px;
  font-size: 17px;
  min-height: 58px;
  border-radius: 14px;
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 100%);
  color: #1a1200;
  box-shadow:
    0 4px 0 0 var(--gold-lo),
    0 10px 22px -4px rgba(245, 179, 43, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow:
      0 6px 0 0 var(--gold-lo),
      0 14px 28px -4px rgba(245, 179, 43, 0.55),
      inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }
}

.btn-primary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 0 var(--gold-lo),
    0 4px 12px -4px rgba(245, 179, 43, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

@media (hover: hover) {
  .btn-ghost:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
  }
}

/* ============ SETUP SCREEN ============ */

.setup-header {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 48px;
}

.brand {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 20px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(56px, 11vw, 104px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 20px;
  background: linear-gradient(180deg, #ffeaa0 0%, var(--gold) 55%, var(--gold-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 30px rgba(245, 179, 43, 0.2));
}

.logo span { display: inline-block; }

.tagline {
  font-size: 17px;
  color: var(--text-dim);
  letter-spacing: -0.01em;
}

.tagline .g {
  color: var(--gold);
  font-weight: 600;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  align-items: start;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.count-selector {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.count-btn {
  padding: 14px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 16px;
  font-family: var(--font-display);
  transition: all 0.15s;
}

@media (hover: hover) {
  .count-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
  }
}

.count-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 4px 20px -6px var(--gold);
}

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

.player-input {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 16px 2px 18px;
  transition: border-color 0.15s, background 0.15s;
}

.player-input:focus-within {
  background: var(--surface-2);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.player-num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--gold);
  font-size: 13px;
  min-width: 18px;
}

.player-input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 0;
  font-weight: 500;
  min-width: 0;
}

.money-input {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 16px;
  transition: border-color 0.15s, background 0.15s;
}

.money-input:focus-within {
  background: var(--surface-2);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.money-input .currency {
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}

.money-input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 0;
  font-weight: 600;
  width: 100%;
  min-width: 0;
}

.money-input input::-webkit-outer-spin-button,
.money-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.money-input input[type="number"] {
  -moz-appearance: textfield;
}

.play-money-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ============ TOGGLE SWITCH ============ */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

@media (hover: hover) {
  .toggle-row:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
  }
}

.toggle-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.toggle-switch {
  width: 46px;
  height: 26px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.22s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-row input[type="checkbox"]:checked ~ .toggle-switch {
  background: var(--gold-dim);
  border-color: var(--gold);
}

.toggle-row input[type="checkbox"]:checked ~ .toggle-switch .toggle-thumb {
  transform: translateX(20px);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  box-shadow: 0 2px 6px rgba(245, 179, 43, 0.4);
}

.toggle-row:has(input:checked) {
  background: rgba(245, 179, 43, 0.08);
  border-color: rgba(245, 179, 43, 0.4);
}

.toggle-row input[type="checkbox"]:focus-visible ~ .toggle-switch {
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.rules-card {
  position: sticky;
  top: 24px;
}

.rules-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

.rules-list {
  list-style: none;
  counter-reset: rule;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.rules-list li {
  position: relative;
  padding-left: 30px;
  counter-increment: rule;
}

.rules-list li::before {
  content: counter(rule);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}

.rules-list .one { color: var(--gold); }
.rules-list .four { color: var(--gold); }

.rng-badge {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.rng-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), 0 0 10px var(--emerald);
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============ GAME SCREEN ============ */

.game-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 18px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.round-pill, .pot-pill {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 90px;
}

.pot-pill {
  background: var(--gold-dim);
  border-color: rgba(245, 179, 43, 0.35);
  box-shadow: 0 0 24px -10px var(--gold);
}

.pill-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1;
  margin-bottom: 4px;
}

.pot-pill .pill-label { color: var(--gold); }

.pill-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.pot-pill .pill-value { color: var(--gold); }

.header-right {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.players-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  justify-content: flex-end;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.players-strip::-webkit-scrollbar { height: 4px; }
.players-strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.player-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 96px;
  transition: all 0.2s;
  position: relative;
  flex-shrink: 0;
}

.player-chip.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 179, 43, 0.15), 0 0 24px -8px var(--gold);
}

.player-chip.done {
  opacity: 0.65;
}

.chip-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.player-chip.active .chip-name { color: var(--gold); }

.chip-balance {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.chip-score {
  position: absolute;
  top: -10px;
  right: -8px;
  background: var(--emerald);
  color: #052619;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  font-family: var(--font-display);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.chip-score.dq {
  background: var(--ruby);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* ============ TABLE ============ */

.table {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-felt {
  width: 100%;
  background: var(--felt);
  border-radius: var(--radius-lg);
  box-shadow: var(--felt-shadow);
  padding: 40px 32px 44px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.table-felt::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 15%, rgba(255, 255, 255, 0.06), transparent 55%);
  pointer-events: none;
}

.table-felt::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.turn-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

.current-player {
  text-align: center;
}

.current-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.current-name {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: #fff;
}

.current-balance {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.current-balance span {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
  font-family: var(--font-display);
}

/* ============ QUALIFICATION STRIP ============ */

.qual-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.qual-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: all 0.3s;
}

.qual-chip.met {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--emerald);
  box-shadow: 0 0 24px -8px var(--emerald);
}

.qual-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.qual-chip.met .qual-label { color: var(--emerald); }

.score-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 20px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  min-width: 84px;
  transition: all 0.3s;
}

.score-chip.qualified {
  background: rgba(245, 179, 43, 0.18);
  border-color: var(--gold);
  box-shadow: 0 0 24px -8px var(--gold);
}

.score-chip .qual-label { color: rgba(255, 255, 255, 0.5); }
.score-chip.qualified .qual-label { color: var(--gold); }

.score-chip .score-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  margin-top: 2px;
}

.score-chip.qualified .score-value { color: var(--gold-hi); }

/* ============ DICE AREA ============ */

.dice-area {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.dice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.dice-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 88px;
  align-items: center;
}

.dice-row--banked {
  min-height: 68px;
  gap: 10px;
}

/* ============ DICE ============ */

.die {
  --size: 72px;
  --pip-size: 11px;
  --pip-pad: 12px;
  --pip-gap: 4px;
  width: var(--size);
  height: var(--size);
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff 0%, #e4e7ef 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: var(--pip-pad);
  gap: var(--pip-gap);
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.12),
    inset 0 2px 2px rgba(255, 255, 255, 0.95),
    0 12px 24px -4px rgba(0, 0, 0, 0.55),
    0 4px 8px -2px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.die .pip {
  opacity: 0;
  background: radial-gradient(circle, #30364a 0%, #151928 70%);
  border-radius: 50%;
  width: var(--pip-size);
  height: var(--pip-size);
  align-self: center;
  justify-self: center;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.45), inset 0 -1px 1px rgba(255, 255, 255, 0.08);
}

/* Pip positions: grid is 1 2 3 / 4 5 6 / 7 8 9 */
.die[data-value="1"] .pip:nth-child(5),
.die[data-value="2"] .pip:nth-child(1),
.die[data-value="2"] .pip:nth-child(9),
.die[data-value="3"] .pip:nth-child(1),
.die[data-value="3"] .pip:nth-child(5),
.die[data-value="3"] .pip:nth-child(9),
.die[data-value="4"] .pip:nth-child(1),
.die[data-value="4"] .pip:nth-child(3),
.die[data-value="4"] .pip:nth-child(7),
.die[data-value="4"] .pip:nth-child(9),
.die[data-value="5"] .pip:nth-child(1),
.die[data-value="5"] .pip:nth-child(3),
.die[data-value="5"] .pip:nth-child(5),
.die[data-value="5"] .pip:nth-child(7),
.die[data-value="5"] .pip:nth-child(9),
.die[data-value="6"] .pip:nth-child(1),
.die[data-value="6"] .pip:nth-child(3),
.die[data-value="6"] .pip:nth-child(4),
.die[data-value="6"] .pip:nth-child(6),
.die[data-value="6"] .pip:nth-child(7),
.die[data-value="6"] .pip:nth-child(9) {
  opacity: 1;
}

.die--active {
  cursor: pointer;
}

@media (hover: hover) {
  .die--active:hover:not(.rolling) {
    transform: translateY(-5px);
    box-shadow:
      inset 0 -3px 6px rgba(0, 0, 0, 0.12),
      inset 0 2px 2px rgba(255, 255, 255, 0.95),
      0 18px 32px -6px rgba(0, 0, 0, 0.6),
      0 6px 12px -2px rgba(0, 0, 0, 0.5);
  }
}

.die--selected {
  cursor: pointer;
  transform: translateY(-12px);
  background: linear-gradient(145deg, #fff4c6 0%, #f5d882 100%);
  box-shadow:
    inset 0 -3px 6px rgba(180, 120, 0, 0.2),
    inset 0 2px 2px rgba(255, 255, 255, 0.9),
    0 22px 40px -6px rgba(0, 0, 0, 0.6),
    0 0 0 3px var(--gold),
    0 0 44px rgba(245, 179, 43, 0.55);
}

.die--selected .pip {
  background: radial-gradient(circle, #3a2e12 0%, #1a1405 70%);
}

.die--banked {
  --size: 52px;
  --pip-size: 8px;
  --pip-pad: 9px;
  --pip-gap: 3px;
  border-radius: 10px;
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.1),
    inset 0 2px 2px rgba(255, 255, 255, 0.9),
    0 6px 14px -2px rgba(0, 0, 0, 0.55),
    0 2px 4px -1px rgba(0, 0, 0, 0.4);
}

.die--placeholder {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.die--placeholder .pip { display: none; }

.die--mystery {
  background: linear-gradient(145deg, #2a3447 0%, #151928 100%);
  border: 2px solid var(--gold);
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.5),
    inset 0 2px 2px rgba(255, 255, 255, 0.06),
    0 12px 24px -4px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(245, 179, 43, 0.35);
  position: relative;
  animation: mystery-breathe 2.2s ease-in-out infinite;
  padding: 0;
}

.die--mystery .pip { display: none; }

.die--mystery::before {
  content: '?';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: calc(var(--size) * 0.55);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(245, 179, 43, 0.8), 0 2px 4px rgba(0, 0, 0, 0.4);
}

@keyframes mystery-breathe {
  0%, 100% {
    box-shadow:
      inset 0 -3px 6px rgba(0, 0, 0, 0.5),
      inset 0 2px 2px rgba(255, 255, 255, 0.06),
      0 12px 24px -4px rgba(0, 0, 0, 0.6),
      0 0 40px rgba(245, 179, 43, 0.35);
  }
  50% {
    box-shadow:
      inset 0 -3px 6px rgba(0, 0, 0, 0.5),
      inset 0 2px 2px rgba(255, 255, 255, 0.06),
      0 12px 24px -4px rgba(0, 0, 0, 0.6),
      0 0 56px rgba(245, 179, 43, 0.6);
  }
}

.die--revealed {
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.12),
    inset 0 2px 2px rgba(255, 255, 255, 0.95),
    0 22px 40px -6px rgba(0, 0, 0, 0.6),
    0 0 0 3px var(--gold),
    0 0 56px rgba(245, 179, 43, 0.7);
  animation: die-reveal 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  transform-origin: center;
}

/* The alternative die — the path not taken. Dimmed, desaturated, fades
   in slightly after the chosen die so the reveal feels sequenced. */
.die--ghost {
  opacity: 0.3;
  filter: grayscale(0.8);
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.1),
    inset 0 2px 2px rgba(255, 255, 255, 0.7),
    0 6px 14px -2px rgba(0, 0, 0, 0.4);
  animation: ghost-fade-in 0.5s 0.35s both ease-out;
}

@keyframes ghost-fade-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 0.3; transform: scale(1); }
}

@keyframes die-reveal {
  0%   { transform: scale(0.35) rotate(-14deg); opacity: 0; filter: brightness(1.8); }
  55%  { transform: scale(1.18) rotate(6deg);  opacity: 1; filter: brightness(1.3); }
  100% { transform: scale(1)    rotate(0deg);  opacity: 1; filter: brightness(1);   }
}

/* Dimmed not-chosen button shown next to the revealed choice */
.tb-choices .btn.not-chosen {
  opacity: 0.35;
  filter: grayscale(0.6);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.4);
}

.die.rolling {
  cursor: default;
  animation: shake 0.1s linear infinite;
}

.die.settling {
  animation: settle 0.4s ease-out;
}

.die.newly-banked {
  animation: bankFlash 0.6s ease-out;
}

.die-slot {
  --size: 52px;
  width: var(--size);
  height: var(--size);
  border-radius: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

/* Mini die for qualification chips */
.mini-die {
  --size: 22px;
  --pip-size: 3px;
  width: var(--size);
  height: var(--size);
  background: linear-gradient(145deg, #ffffff 0%, #e4e7ef 100%);
  border-radius: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 3px;
  gap: 1px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.mini-die .pip {
  opacity: 0;
  background: #1a1f30;
  border-radius: 50%;
  width: var(--pip-size);
  height: var(--pip-size);
  align-self: center;
  justify-self: center;
}

.mini-die[data-value="1"] .pip:nth-child(5),
.mini-die[data-value="4"] .pip:nth-child(1),
.mini-die[data-value="4"] .pip:nth-child(3),
.mini-die[data-value="4"] .pip:nth-child(7),
.mini-die[data-value="4"] .pip:nth-child(9) {
  opacity: 1;
}

/* ============ ACTIONS ============ */

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 6px;
}

.actions {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.actions > .btn {
  min-width: 240px;
  width: 100%;
}

.tb-choices {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.tb-choices .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 14px;
  padding-right: 14px;
}

.tb-choices .btn:first-child {
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 100%);
}

.tb-choices .btn:last-child {
  background: linear-gradient(180deg, #a5e3c8 0%, var(--emerald) 100%);
  color: #062917;
  box-shadow:
    0 4px 0 0 var(--emerald-dim),
    0 10px 22px -4px rgba(16, 185, 129, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

@media (hover: hover) {
  .tb-choices .btn:last-child:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow:
      0 6px 0 0 var(--emerald-dim),
      0 14px 28px -4px rgba(16, 185, 129, 0.55),
      inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }
}

.tb-choices .btn:last-child:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 0 var(--emerald-dim),
    0 4px 12px -4px rgba(16, 185, 129, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  min-height: 20px;
  font-weight: 500;
}

/* ============ OVERLAY / MODAL ============ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.25s ease-out;
}

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 44px 48px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  backdrop-filter: blur(20px);
  animation: slideUp 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.overlay-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.overlay-name {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(180deg, #ffeaa0 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}

.overlay-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ============ RESULTS SCREEN ============ */

.results-wrapper {
  max-width: 720px;
  margin: 40px auto;
  padding: 20px;
}

.results-header {
  text-align: center;
  margin-bottom: 32px;
}

.results-round {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.results-round span { color: var(--text-dim); font-weight: 700; }

.results-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffeaa0 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.15;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.result-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.2s;
}

.result-row.winner {
  background: var(--gold-dim);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 48px -14px var(--gold);
}

.result-rank {
  font-size: 22px;
  text-align: center;
  line-height: 1;
}

.result-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-row.winner .result-name { color: var(--gold-hi); }

.result-dice {
  display: flex;
  gap: 5px;
}

.result-dice .die {
  --size: 30px;
  --pip-size: 4px;
  --pip-pad: 4px;
  --pip-gap: 1px;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.result-score {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  min-width: 56px;
  text-align: right;
  color: var(--text);
}

.result-row.winner .result-score { color: var(--gold-hi); }

.result-score.dq {
  color: var(--ruby);
  font-size: 18px;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.results-actions .btn {
  min-width: 280px;
}

/* ============ ANIMATIONS ============ */

@keyframes shake {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  20% { transform: translate3d(-2px, -3px, 0) rotate(-5deg); }
  40% { transform: translate3d(3px, 1px, 0) rotate(4deg); }
  60% { transform: translate3d(-2px, 3px, 0) rotate(-3deg); }
  80% { transform: translate3d(2px, -1px, 0) rotate(4deg); }
}

@keyframes settle {
  0% { transform: translateY(-6px) scale(1.05); }
  50% { transform: translateY(0) scale(0.97); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes bankFlash {
  0% {
    transform: translateY(-56px) scale(1.25);
    filter: brightness(1.6) drop-shadow(0 12px 20px rgba(245, 179, 43, 0.4));
  }
  60% {
    transform: translateY(0) scale(1.08);
    filter: brightness(1.3);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .rules-card {
    position: static;
    order: -1;
  }

  .game-wrapper {
    padding: 14px;
    gap: 14px;
  }

  .game-header {
    gap: 10px;
  }

  .header-right {
    order: 2;
    width: 100%;
  }

  .players-strip {
    justify-content: flex-start;
  }

  .table-felt {
    padding: 28px 16px 32px;
  }

  .die {
    --size: 56px;
    --pip-size: 9px;
    --pip-pad: 9px;
    --pip-gap: 3px;
    border-radius: 11px;
  }

  .die--banked {
    --size: 44px;
    --pip-size: 7px;
    --pip-pad: 7px;
    --pip-gap: 2px;
    border-radius: 8px;
  }

  .die-slot {
    --size: 44px;
    border-radius: 8px;
  }

  .dice-row {
    gap: 10px;
    min-height: 70px;
  }

  .dice-row--banked {
    gap: 8px;
    min-height: 56px;
  }

  .current-name {
    font-size: 26px;
  }

  .qual-strip {
    gap: 8px;
  }

  .qual-chip, .score-chip {
    padding: 8px 12px;
  }

  .actions .btn {
    min-width: 200px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 20px 16px;
  }

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

  .card {
    padding: 20px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .count-selector {
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }

  .player-inputs {
    grid-template-columns: 1fr;
  }

  .count-btn {
    padding: 10px 0;
    font-size: 14px;
  }

  .table-felt {
    padding: 22px 12px 26px;
  }

  .die {
    --size: 46px;
    --pip-size: 7px;
    --pip-pad: 7px;
    --pip-gap: 2px;
    border-radius: 9px;
  }

  .die--banked {
    --size: 38px;
    --pip-size: 6px;
    --pip-pad: 6px;
    --pip-gap: 2px;
    border-radius: 7px;
  }

  .die-slot {
    --size: 38px;
    border-radius: 7px;
  }

  .dice-row {
    gap: 8px;
    min-height: 58px;
  }

  .dice-row--banked {
    gap: 6px;
    min-height: 50px;
  }

  .current-name {
    font-size: 22px;
  }

  .qual-chip {
    padding: 7px 10px;
    gap: 8px;
  }

  .qual-label {
    font-size: 10px;
  }

  .score-chip {
    padding: 5px 14px;
    min-width: 68px;
  }

  .score-chip .score-value {
    font-size: 18px;
  }

  .actions .btn,
  .results-actions .btn {
    min-width: 100%;
    width: 100%;
  }

  .overlay-card {
    padding: 32px 24px;
  }

  .overlay-name {
    font-size: 36px;
  }

  .result-row {
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    padding: 14px 16px;
  }

  .result-rank {
    font-size: 18px;
  }

  .result-name {
    font-size: 15px;
  }

  .result-dice {
    grid-column: 1 / -1;
    justify-content: center;
    margin-top: 6px;
    flex-wrap: wrap;
  }

  .result-score {
    font-size: 26px;
  }
}
