/* ╔══════════════════════════════════════════════════════════════╗
   ║  BANK DICE GAME — Premium Dark Design System               ║
   ╚══════════════════════════════════════════════════════════════╝ */

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
  /* Core palette */
  --bg-deep: #060918;
  --bg-primary: #0a0e27;
  --bg-card: rgba(15, 20, 50, 0.65);
  --bg-card-hover: rgba(20, 28, 65, 0.75);
  
  /* Accent colors */
  --accent-primary: #6366f1;
  --accent-primary-glow: rgba(99, 102, 241, 0.4);
  --accent-secondary: #06b6d4;
  --accent-secondary-glow: rgba(6, 182, 212, 0.3);
  --accent-success: #10b981;
  --accent-success-glow: rgba(16, 185, 129, 0.3);
  --accent-danger: #ef4444;
  --accent-danger-glow: rgba(239, 68, 68, 0.4);
  --accent-warning: #f59e0b;
  --accent-gold: #fbbf24;
  --accent-silver: #94a3b8;
  --accent-bronze: #d97706;
  
  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --text-accent: #a5b4fc;
  
  /* Borders */
  --border-subtle: rgba(99, 102, 241, 0.15);
  --border-glow: rgba(99, 102, 241, 0.35);
  
  /* Glass */
  --glass-bg: rgba(15, 20, 55, 0.55);
  --glass-border: rgba(99, 102, 241, 0.2);
  --glass-blur: 20px;
  
  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  
  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-subtle);
  --shadow-glow: 0 0 30px var(--accent-primary-glow), 0 0 60px rgba(99, 102, 241, 0.15);
  --shadow-button: 0 4px 15px rgba(0, 0, 0, 0.3);
  
  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
  
  /* Die */
  --die-size: 80px;
  --die-bg: #f8fafc;
  --die-pip: #1e293b;
  --die-border: #cbd5e1;
  --die-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Background Grid ────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}
.bg-grid::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

/* ── Screen Management ──────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  z-index: 1;
  overflow-y: auto;
  padding: 20px;
}
.screen.active {
  opacity: 1;
  visibility: visible;
}

/* ── Glass Card ─────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-card);
  padding: 28px;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); }
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-button);
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn-lg { padding: 16px 32px; font-size: 1.1rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #818cf8);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-button), 0 0 25px var(--accent-primary-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(99, 102, 241, 0.12);
  color: var(--text-accent);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--border-glow);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-secondary), #22d3ee);
  color: #0a0e27;
}
.btn-accent:hover:not(:disabled) {
  box-shadow: var(--shadow-button), 0 0 25px var(--accent-secondary-glow);
  transform: translateY(-2px);
}

.btn-icon { font-size: 1.2em; }

/* ── Inputs ─────────────────────────────────────────────────── */
.input-group {
  margin-bottom: 18px;
}
.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.input-group input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(10, 14, 39, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.input-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}
.input-group input::placeholder {
  color: var(--text-muted);
}
.code-input {
  text-align: center;
  font-family: var(--font-display) !important;
  font-size: 1.8rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.3em !important;
  text-transform: uppercase;
}

/* ── Error Text ─────────────────────────────────────────────── */
.error-text {
  color: var(--accent-danger);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 14px;
  animation: shake 0.4s ease;
}
.hidden { display: none !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ═══════════════════════════════════════════════════════════════
   WELCOME SCREEN
   ═══════════════════════════════════════════════════════════════ */
.welcome-container {
  width: 100%;
  max-width: 420px;
  z-index: 2;
}

.logo-area {
  text-align: center;
  margin-bottom: 36px;
}

.dice-icon {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}
.mini-die {
  width: 44px;
  height: 44px;
  background: var(--die-bg);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 6px;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.mini-die .pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--die-pip);
  align-self: center;
  justify-self: center;
}
.die-a { animation: dieFloat 3s ease-in-out infinite; transform: rotate(-8deg); }
.die-b { animation: dieFloat 3s ease-in-out infinite 1.5s; transform: rotate(12deg); }

@keyframes dieFloat {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-8px) rotate(-5deg); }
}
.die-b { animation-name: dieFloat2; }
@keyframes dieFloat2 {
  0%, 100% { transform: translateY(0) rotate(12deg); }
  50% { transform: translateY(-8px) rotate(8deg); }
}

.title-bank {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #818cf8 0%, var(--accent-secondary) 50%, #818cf8 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.welcome-card { width: 100%; }

.button-group {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}
.button-group .btn { flex: 1; }

.join-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.join-panel .btn { width: 100%; }

/* ═══════════════════════════════════════════════════════════════
   LOBBY SCREEN
   ═══════════════════════════════════════════════════════════════ */
.lobby-container {
  width: 100%;
  max-width: 480px;
  z-index: 2;
}

.lobby-header {
  text-align: center;
  margin-bottom: 24px;
}
.lobby-header h2 { margin-bottom: 16px; }

.room-code-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 16px 32px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed var(--border-glow);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}
.room-code-display:hover {
  background: rgba(99, 102, 241, 0.15);
}
.code-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.code-value {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--accent-primary);
  text-shadow: 0 0 20px var(--accent-primary-glow);
}
.code-copy-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: color 0.3s;
}
.room-code-display:hover .code-copy-hint { color: var(--text-secondary); }
.room-code-display.copied .code-copy-hint { color: var(--accent-success); }

/* QR Code */
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.qr-code {
  background: white;
  padding: 10px;
  border-radius: var(--radius-md);
  display: inline-block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.qr-code img,
.qr-code canvas {
  display: block;
  width: 140px;
  height: 140px;
}
.qr-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.lobby-card { margin-top: 8px; }

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.3s ease;
  animation: playerJoin 0.4s ease;
}
@keyframes playerJoin {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
.player-item.is-host { border-color: var(--accent-primary); background: rgba(99, 102, 241, 0.1); }
.player-item.is-you { border-color: var(--accent-secondary); }

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
}
.player-name { font-weight: 600; flex: 1; }
.player-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
}
.tag-host { background: var(--accent-primary); color: white; }
.tag-you { background: var(--accent-secondary); color: var(--bg-primary); }

/* Host controls */
.host-controls { margin-top: 10px; }
.setting-row {
  margin-bottom: 20px;
}
.setting-row > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.score-selector {
  display: flex;
  gap: 8px;
}
.score-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(10, 14, 39, 0.5);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
}
.score-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.score-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-primary-glow);
}

/* Toggle switches */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color 0.3s;
}
.toggle-label:hover { color: var(--text-primary); }
.toggle-label input { display: none; }
.toggle-switch {
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  position: relative;
  transition: background 0.3s ease;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s ease;
}
.toggle-label input:checked + .toggle-switch {
  background: var(--accent-primary);
}
.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

.btn-start {
  width: 100%;
  margin-top: 24px;
  font-size: 1.2rem;
  padding: 18px;
}
.btn-start:not(:disabled) {
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--shadow-button); }
  50% { box-shadow: var(--shadow-button), 0 0 30px var(--accent-primary-glow); }
}

.guest-waiting {
  text-align: center;
  padding: 30px 0 10px;
  color: var(--text-secondary);
}

.waiting-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════════ */
.game-container {
  width: 100%;
  max-width: 480px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 12px 0;
  gap: 10px;
}

/* Scoreboard */
.scoreboard {
  padding: 14px 18px;
  flex-shrink: 0;
}
.scoreboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.scoreboard-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.target-display {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.target-display strong {
  color: var(--accent-primary);
}

.scoreboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}
.sb-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.04);
  transition: all 0.3s ease;
  font-size: 0.9rem;
}
.sb-player.current-turn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-glow);
}
.sb-player.is-me {
  background: rgba(6, 182, 212, 0.08);
}
.sb-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  width: 22px;
  text-align: center;
  color: var(--text-muted);
}
.sb-rank.rank-1 { color: var(--accent-gold); }
.sb-rank.rank-2 { color: var(--accent-silver); }
.sb-rank.rank-3 { color: var(--accent-bronze); }
.sb-name { flex: 1; font-weight: 600; }
.sb-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-primary);
}
.sb-gap {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: right;
}
.sb-gap:empty { min-width: 0; }
.sb-crown { margin-right: 2px; }

/* Eliminated players */
.sb-player.eliminated {
  opacity: 0.45;
  background: rgba(239, 68, 68, 0.05);
}
.sb-player.eliminated .sb-name {
  text-decoration: line-through;
  text-decoration-color: rgba(239, 68, 68, 0.5);
}
.sb-player.eliminated .sb-gap {
  color: var(--accent-danger);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

/* Dice area */
.dice-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 0;
}

.turn-indicator {
  padding: 8px 24px;
  border-radius: 30px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--border-subtle);
  color: var(--text-accent);
  transition: all 0.4s ease;
}
.turn-indicator.my-turn {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  color: white;
  box-shadow: 0 0 20px var(--accent-primary-glow);
  animation: pulse-glow 2s ease-in-out infinite;
}

/* 3D Dice */
.dice-container {
  display: flex;
  gap: 30px;
  perspective: 600px;
  padding: 20px;
}

.die-3d {
  width: var(--die-size);
  height: var(--die-size);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.die-face {
  position: absolute;
  width: var(--die-size);
  height: var(--die-size);
  background: var(--die-bg);
  border: 2px solid var(--die-border);
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  align-content: space-evenly;
  justify-content: space-evenly;
  padding: 12px;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.5);
}

.die-face .pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--die-pip);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.3);
}

/* Face positions */
.face-1 { transform: rotateY(0deg) translateZ(calc(var(--die-size) / 2)); }
.face-2 { transform: rotateY(180deg) translateZ(calc(var(--die-size) / 2)); }
.face-3 { transform: rotateY(-90deg) translateZ(calc(var(--die-size) / 2)); }
.face-4 { transform: rotateY(90deg) translateZ(calc(var(--die-size) / 2)); }
.face-5 { transform: rotateX(90deg) translateZ(calc(var(--die-size) / 2)); }
.face-6 { transform: rotateX(-90deg) translateZ(calc(var(--die-size) / 2)); }

/* Pip positioning within faces */
.face-1 { justify-content: center; align-items: center; }
.face-1 .pip.center { /* Already centered by flex */ }

.face-2 { padding: 14px; }
.face-2 .pip.top-left { align-self: flex-start; }
.face-2 .pip.bottom-right { align-self: flex-end; }

.face-3 { padding: 14px; }
.face-3 .pip.top-left { align-self: flex-start; }
.face-3 .pip.center { align-self: center; justify-self: center; }
.face-3 .pip.bottom-right { align-self: flex-end; }

.face-4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  padding: 14px;
}
.face-4 .pip { align-self: center; justify-self: center; }

.face-5 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  padding: 12px;
}
.face-5 .pip { align-self: center; justify-self: center; }
.face-5 .pip.center { grid-column: 1 / -1; }

.face-6 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  padding: 12px;
}
.face-6 .pip { align-self: center; justify-self: center; }

/* Dice rolling animation */
@keyframes diceRoll {
  0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
  20% { transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg); }
  40% { transform: rotateX(360deg) rotateY(270deg) rotateZ(90deg); }
  60% { transform: rotateX(540deg) rotateY(180deg) rotateZ(180deg); }
  80% { transform: rotateX(630deg) rotateY(360deg) rotateZ(270deg); }
  100% { transform: rotateX(720deg) rotateY(540deg) rotateZ(360deg); }
}
.die-3d.rolling {
  animation: diceRoll 0.8s ease-out;
}

/* Roll result text */
.roll-result {
  min-height: 32px;
  text-align: center;
}
#result-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 6px 20px;
  border-radius: 20px;
  display: inline-block;
  animation: fadeInUp 0.4s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-bust {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.result-doubles {
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.result-normal {
  color: var(--accent-success);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Round info */
.round-info {
  text-align: center;
  width: 100%;
  max-width: 280px;
}
.round-total-container {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.round-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}
.round-total {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent-secondary);
  transition: color 0.3s;
}
.round-total.high-risk { color: var(--accent-warning); }
.round-total.very-high-risk { color: var(--accent-danger); }

.risk-meter {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.risk-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-success), var(--accent-warning), var(--accent-danger));
  transition: width 0.5s ease;
}

/* Action area */
.action-area {
  flex-shrink: 0;
  text-align: center;
  padding-bottom: 10px;
}

.action-buttons {
  display: flex;
  gap: 14px;
}

.btn-roll {
  flex: 1.5;
  background: linear-gradient(135deg, var(--accent-primary), #818cf8);
  color: white;
  font-size: 1.3rem;
  padding: 20px;
  border-radius: var(--radius-lg);
}
.btn-roll:hover:not(:disabled) {
  box-shadow: var(--shadow-button), var(--shadow-glow);
  transform: translateY(-2px);
}

.btn-bank {
  flex: 1;
  background: linear-gradient(135deg, var(--accent-success), #34d399);
  color: white;
  font-size: 1.2rem;
  padding: 20px;
  border-radius: var(--radius-lg);
}
.btn-bank:hover:not(:disabled) {
  box-shadow: var(--shadow-button), 0 0 25px var(--accent-success-glow);
  transform: translateY(-2px);
}

.shake-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 10px;
  animation: fadeInUp 0.5s ease 0.3s both;
}

.waiting-turn {
  padding: 20px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   RESULTS SCREEN
   ═══════════════════════════════════════════════════════════════ */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.results-container {
  width: 100%;
  max-width: 480px;
  z-index: 4;
  text-align: center;
}

.results-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-gold), #fde68a, var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.winner-announce {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}
.winner-announce strong {
  color: var(--accent-gold);
}

/* Podium */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
  height: 200px;
}
.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: podiumRise 0.6s ease both;
}
.podium-place:nth-child(1) { animation-delay: 0.4s; } /* 2nd place (left) */
.podium-place:nth-child(2) { animation-delay: 0.6s; } /* 1st place (center) */
.podium-place:nth-child(3) { animation-delay: 0.2s; } /* 3rd place (right) */

@keyframes podiumRise {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

.podium-bar {
  width: 90px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.5rem;
  color: rgba(255,255,255,0.9);
}
.podium-1st {
  height: 140px;
  background: linear-gradient(180deg, var(--accent-gold), #b45309);
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}
.podium-2nd {
  height: 100px;
  background: linear-gradient(180deg, var(--accent-silver), #475569);
}
.podium-3rd {
  height: 70px;
  background: linear-gradient(180deg, var(--accent-bronze), #78350f);
}

.podium-name {
  font-weight: 700;
  font-size: 0.9rem;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.results-card { text-align: left; margin-bottom: 24px; }

.final-standings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.standing-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.05);
}
.standing-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  width: 30px;
  text-align: center;
}
.standing-rank.gold { color: var(--accent-gold); }
.standing-rank.silver { color: var(--accent-silver); }
.standing-rank.bronze { color: var(--accent-bronze); }
.standing-name { flex: 1; font-weight: 600; }
.standing-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-primary);
}

.results-buttons {
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(20px);
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2.6s forwards;
  pointer-events: auto;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-20px) scale(0.95); }
}
.toast-info {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: var(--text-accent);
}
.toast-success {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}
.toast-danger {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.toast-warning {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

/* ═══════════════════════════════════════════════════════════════
   BUST FLASH OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.bust-flash {
  position: fixed;
  inset: 0;
  background: rgba(239, 68, 68, 0.2);
  z-index: 50;
  pointer-events: none;
  animation: bustFlash 0.6s ease;
}
@keyframes bustFlash {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 0; }
}

.bank-flash {
  position: fixed;
  inset: 0;
  background: rgba(16, 185, 129, 0.15);
  z-index: 50;
  pointer-events: none;
  animation: bustFlash 0.6s ease;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  :root { --die-size: 64px; }
  .title-bank { font-size: 3.5rem; }
  .code-value { font-size: 2.2rem; }
  .btn-lg { padding: 14px 24px; font-size: 1rem; }
  .glass-card { padding: 20px; }
  .scoreboard { padding: 12px 14px; }
  .sb-gap { display: none; }
}

@media (min-height: 800px) {
  .dice-area { gap: 24px; }
  :root { --die-size: 90px; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
