/* ==================== VARIABLES ==================== */
:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a3e;
  --bg-card: #252552;
  --bg-card-hover: #2e2e65;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.15);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --accent: #6c63ff;
  --accent-light: #8b83ff;
  --accent-glow: rgba(108, 99, 255, 0.3);
  --success: #00e676;
  --success-bg: rgba(0, 230, 118, 0.15);
  --danger: #ff5252;
  --danger-bg: rgba(255, 82, 82, 0.15);
  --warning: #ffab40;
  --warning-bg: rgba(255, 171, 64, 0.15);
  --gold: #ffd700;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Baloo 2', cursive;
}

/* ==================== RESET ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==================== PARTICLES BG ==================== */
#particles-bg {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
#particles-bg::before {
  content: ''; position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  background:
    radial-gradient(circle at 20% 50%, rgba(108,99,255,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,82,82,0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(0,230,118,0.06) 0%, transparent 50%);
  animation: bgFloat 20s ease-in-out infinite;
}
@keyframes bgFloat {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  33% { transform: translate(30px,-30px) rotate(1deg); }
  66% { transform: translate(-20px,20px) rotate(-1deg); }
}

/* ==================== SCREENS ==================== */
.screen { display: none; position: relative; z-index: 1; }
.screen.active { display: flex; }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 24px; border: none; border-radius: var(--radius);
  font-family: var(--font); font-weight: 600; font-size: 0.95rem;
  cursor: pointer; transition: var(--transition); text-decoration: none;
  white-space: nowrap; position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(255,255,255,0.1), transparent);
  opacity: 0; transition: var(--transition);
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5a52d5);
  color: white; box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 25px var(--accent-glow); transform: translateY(-1px); }

.btn-accent {
  background: linear-gradient(135deg, #ff6b35, #ff4444);
  color: white; box-shadow: 0 4px 15px rgba(255,107,53,0.3);
}
.btn-accent:hover { box-shadow: 0 6px 25px rgba(255,107,53,0.4); transform: translateY(-1px); }

.btn-outline {
  background: transparent; border: 2px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); background: var(--accent-glow); }

.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 16px 36px; font-size: 1.1rem; }

.btn-reveal {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #1a1a3e; font-weight: 800;
  box-shadow: 0 4px 20px rgba(255,215,0,0.4);
  animation: revealPulse 1.5s ease-in-out infinite;
}
.btn-reveal:hover { box-shadow: 0 6px 30px rgba(255,215,0,0.6); transform: translateY(-2px); }
@keyframes revealPulse {
  0%,100% { box-shadow: 0 4px 20px rgba(255,215,0,0.4); }
  50% { box-shadow: 0 4px 35px rgba(255,215,0,0.7); }
}

/* ==================== FORMS ==================== */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; margin-bottom: 8px; font-size: 0.85rem;
  font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input {
  width: 100%; padding: 14px 18px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-family: var(--font); font-size: 1rem;
  transition: var(--transition); outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: rgba(108,99,255,0.05);
}
.form-group input::placeholder { color: var(--text-muted); }

.select-group { display: flex; gap: 8px; }
.select-btn {
  flex: 1; padding: 10px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-secondary); font-family: var(--font);
  font-weight: 600; font-size: 0.95rem; cursor: pointer;
  transition: var(--transition);
}
.select-btn:hover { border-color: var(--accent); }
.select-btn.active { border-color: var(--accent); background: var(--accent-glow); color: var(--accent-light); }

.error-msg {
  margin-top: 16px; padding: 12px 16px;
  background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius-sm); color: var(--danger);
  font-size: 0.9rem; text-align: center; animation: shake 0.4s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ==================== AUTH SCREEN ==================== */
#screen-auth {
  min-height: 100vh; min-height: 100dvh;
  align-items: center; justify-content: center; padding: 20px;
}
.auth-container {
  width: 100%; max-width: 420px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.auth-container::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--danger), var(--warning), var(--success), var(--accent));
  background-size: 200% 100%; animation: gradientSlide 3s linear infinite;
}
@keyframes gradientSlide { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }

.auth-logo { text-align: center; margin-bottom: 36px; }
.logo-dice {
  display: inline-flex; align-items: center; justify-content: center;
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--accent), #5a52d5);
  border-radius: 20px; font-size: 40px; margin-bottom: 16px;
  box-shadow: 0 8px 30px var(--accent-glow);
  animation: diceBounce 2s ease-in-out infinite;
}
@keyframes diceBounce {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(5deg); }
}
.auth-logo h1 {
  font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; line-height: 1.1;
  background: linear-gradient(135deg, #fff, var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.auth-logo h1 span {
  background: linear-gradient(135deg, var(--warning), var(--danger));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.tagline { margin-top: 8px; color: var(--text-muted); font-size: 0.9rem; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 0.9rem; }
.auth-switch a { color: var(--accent-light); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ==================== LOBBY NAV ==================== */
.lobby-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; backdrop-filter: blur(20px);
}
.nav-logo {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.nav-center { display: flex; gap: 4px; background: var(--surface); border-radius: var(--radius); padding: 4px; }
.nav-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  font-family: var(--font); font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: var(--transition);
}
.nav-tab:hover { color: var(--text-primary); }
.nav-tab.active { background: var(--accent); color: white; }

.user-info { display: flex; align-items: center; gap: 16px; }
.user-balance {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; background: var(--success-bg);
  border: 1px solid rgba(0,230,118,0.3); border-radius: var(--radius);
  color: var(--success); font-weight: 700; font-size: 0.95rem;
}
.user-name { font-weight: 600; color: var(--text-secondary); }

/* ==================== LOBBY CONTENT ==================== */
#screen-lobby { flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.lobby-content { max-width: 1200px; margin: 0 auto; padding: 24px; width: 100%; }
.lobby-tab { display: none; }
.lobby-tab.active { display: block; }
.lobby-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.lobby-header h2 { font-family: var(--font-display); font-size: 1.5rem; }

.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.room-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden;
}
.room-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  opacity: 0; transition: var(--transition);
}
.room-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(108,99,255,0.15); }
.room-card:hover::before { opacity: 1; }
.room-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.room-card-name { font-weight: 700; font-size: 1.1rem; }
.room-card-state {
  padding: 4px 10px; border-radius: 20px; font-size: 0.75rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.room-card-state.waiting { background: var(--success-bg); color: var(--success); }
.room-card-state.playing { background: var(--warning-bg); color: var(--warning); }
.room-card-info { display: flex; gap: 20px; color: var(--text-secondary); font-size: 0.9rem; }
.room-card-info span { display: flex; align-items: center; gap: 6px; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 4rem; margin-bottom: 16px; }

/* Leaderboard */
.leaderboard-table { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lb-row { display: flex; align-items: center; padding: 14px 20px; gap: 16px; border-bottom: 1px solid var(--border); transition: var(--transition); }
.lb-row:hover { background: var(--surface-hover); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.lb-rank.top-1 { background: linear-gradient(135deg, #ffd700, #ffb300); color: #000; }
.lb-rank.top-2 { background: linear-gradient(135deg, #e0e0e0, #bdbdbd); color: #000; }
.lb-rank.top-3 { background: linear-gradient(135deg, #cd7f32, #a0522d); color: #fff; }
.lb-rank.other { background: var(--surface); color: var(--text-muted); }
.lb-name { flex: 1; font-weight: 600; }
.lb-balance { font-weight: 700; color: var(--gold); }
.lb-games { color: var(--text-muted); font-size: 0.85rem; }

/* ==================== MODAL ==================== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  max-width: 440px; width: 100%; box-shadow: var(--shadow-lg); animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-content h3 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 28px; }

/* ==================== GAME LAYOUT ==================== */
#screen-game { flex-direction: column; height: 100vh; height: 100dvh; }

.game-layout { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* Mobile sidebar toggle - hidden on desktop */
.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

/* Sidebar */
.game-sidebar {
  width: 300px; min-width: 300px;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.btn-back { margin-bottom: 8px; }
.room-info h3 { font-size: 1rem; font-weight: 700; }
.room-id { font-size: 0.8rem; color: var(--text-muted); font-family: monospace; }

.player-list { flex: 1; overflow-y: auto; padding: 12px; }
.player-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 4px; transition: var(--transition); }
.player-item:hover { background: var(--surface); }
.player-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.player-avatar.dealer { background: linear-gradient(135deg, var(--gold), #ffb300); box-shadow: 0 2px 10px rgba(255,215,0,0.3); }
.player-avatar.normal { background: var(--surface); }
.player-details { flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-name .dealer-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--warning-bg); color: var(--warning); font-size: 0.7rem; margin-left: 6px; font-weight: 700; vertical-align: middle; }
.player-bal { font-size: 0.8rem; color: var(--text-muted); }
.player-bet-indicator { font-size: 0.8rem; color: var(--accent-light); font-weight: 600; }

/* Chat */
.chat-box { height: 200px; min-height: 200px; border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 0.85rem; line-height: 1.5; }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-msg-system { color: var(--text-muted); font-style: italic; padding: 2px 0; }
.chat-msg-result { padding: 2px 0; font-weight: 600; }
.chat-msg-player .chat-name { font-weight: 700; color: var(--accent-light); }
.chat-msg-player .chat-text { color: var(--text-secondary); }
.chat-input-wrap { display: flex; padding: 8px 12px; gap: 8px; border-top: 1px solid var(--border); }
.chat-input-wrap input { flex: 1; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font); font-size: 0.85rem; outline: none; }
.chat-input-wrap input:focus { border-color: var(--accent); }
.btn-send { padding: 8px; background: var(--accent); border: none; border-radius: var(--radius-sm); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.btn-send:hover { background: var(--accent-light); }

/* ==================== GAME MAIN ==================== */
.game-main {
  flex: 1; display: flex; flex-direction: column;
  overflow-y: auto; position: relative; min-width: 0;
}

/* Top bar */
.game-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.round-info { display: flex; align-items: center; gap: 8px; }
.round-label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.round-number { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--accent-light); }

.game-status {
  padding: 6px 16px; border-radius: 30px; font-weight: 700;
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px;
  background: var(--surface); color: var(--text-secondary);
}
.game-status.betting { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0,230,118,0.3); }
.game-status.rolling { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(255,171,64,0.3); }
.game-status.result { background: var(--accent-glow); color: var(--accent-light); border: 1px solid rgba(108,99,255,0.3); }

.my-balance { display: flex; align-items: baseline; gap: 4px; }
.balance-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.balance-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: var(--gold); }
.balance-unit { font-size: 0.85rem; color: var(--text-muted); }

/* ==================== DICE AREA ==================== */
.dice-area {
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px; flex-shrink: 0;
  background: radial-gradient(ellipse at center, rgba(108,99,255,0.08) 0%, transparent 70%);
}
.dice-plate { position: relative; display: flex; align-items: center; justify-content: center; }
.dice-bowl {
  display: flex; gap: 16px; padding: 20px 32px;
  background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 4px 20px rgba(0,0,0,0.2), var(--shadow);
}
.dice {
  width: 80px; height: 80px;
  background: linear-gradient(145deg, #3a3a6e, #252550);
  border: 2px solid var(--border-light); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3); transition: var(--transition);
}
.dice-face { font-size: 2.5rem; line-height: 1; }
.dice.rolling { animation: diceRoll 0.3s ease-in-out infinite; }
.dice.covered {
  background: linear-gradient(145deg, #4a4a8a, #35356a);
  border: 2px solid rgba(255,215,0,0.4);
  box-shadow: 0 4px 20px rgba(255,215,0,0.15);
  animation: diceBob 1.5s ease-in-out infinite;
}
.dice.result {
  animation: diceReveal 0.5s ease;
  border-color: var(--gold); box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

@keyframes diceRoll {
  0% { transform: rotateX(0) rotateY(0) scale(1); }
  25% { transform: rotateX(90deg) rotateY(45deg) scale(0.9); }
  50% { transform: rotateX(180deg) rotateY(90deg) scale(1); }
  75% { transform: rotateX(270deg) rotateY(135deg) scale(0.9); }
  100% { transform: rotateX(360deg) rotateY(180deg) scale(1); }
}
@keyframes diceReveal {
  0% { transform: scale(1.3) rotate(10deg); }
  50% { transform: scale(0.95) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes diceBob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ==================== BETTING BOARD ==================== */
.betting-board {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; padding: 0 20px 16px;
  max-width: 720px; margin: 0 auto; width: 100%;
  flex-shrink: 0;
}
.bet-card {
  position: relative; background: var(--bg-card);
  border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px 12px; text-align: center;
  cursor: pointer; transition: var(--transition);
  overflow: hidden; user-select: none;
}
.bet-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(108,99,255,0.1) 0%, transparent 70%);
  opacity: 0; transition: var(--transition);
}
.bet-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 20px rgba(108,99,255,0.15); }
.bet-card:hover::before { opacity: 1; }
.bet-card.has-bet { border-color: var(--gold); box-shadow: 0 0 20px rgba(255,215,0,0.15); }
.bet-card.winner { animation: winPulse 0.6s ease; border-color: var(--success); box-shadow: 0 0 30px rgba(0,230,118,0.3); }
.bet-card.loser { opacity: 0.5; }
@keyframes winPulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.bet-card-img { position: relative; z-index: 1; margin-bottom: 4px; }
.symbol-svg { width: 60px; height: 60px; }
.bet-card-name { position: relative; z-index: 1; font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.bet-card-amount { position: relative; z-index: 1; font-weight: 700; color: var(--gold); font-size: 0.95rem; }

/* ==================== BET CONTROLS ==================== */
.bet-controls {
  padding: 12px 20px 16px; background: var(--bg-secondary);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.chip-selector {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; justify-content: center; margin-bottom: 10px;
}
.chip-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-right: 4px; }
.chip-btn {
  padding: 6px 14px; border: 2px solid var(--border);
  border-radius: 30px; background: var(--surface);
  color: var(--text-secondary); font-family: var(--font);
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
  transition: var(--transition); min-width: 44px;
}
.chip-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip-btn.active {
  background: linear-gradient(135deg, var(--accent), #5a52d5);
  border-color: var(--accent); color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.bet-actions { display: flex; align-items: center; justify-content: center; gap: 16px; }
.total-bet { font-size: 0.9rem; color: var(--text-secondary); }
.total-bet strong { color: var(--gold); font-size: 1.1rem; }

/* ==================== DEALER CONTROLS ==================== */
.dealer-controls {
  display: flex; justify-content: center; gap: 12px;
  padding: 16px 20px; background: var(--bg-secondary);
  border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ==================== RESULT OVERLAY ==================== */
.result-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease; padding: 16px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.result-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  max-width: 460px; width: 100%; text-align: center;
  animation: modalIn 0.4s ease; box-shadow: var(--shadow-lg);
  max-height: 90vh; max-height: 90dvh; overflow-y: auto;
}
.result-card h3 { font-family: var(--font-display); font-size: 1.6rem; margin-bottom: 20px; }
.result-card h3.win { color: var(--success); }
.result-card h3.lose { color: var(--danger); }

.result-dice { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
.result-dice .result-die {
  width: 60px; height: 60px; background: var(--bg-card);
  border: 2px solid var(--gold); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; box-shadow: 0 0 20px rgba(255,215,0,0.2);
}
.result-details { margin-bottom: 20px; }
.result-row { display: flex; justify-content: space-between; padding: 6px 12px; border-radius: var(--radius-sm); margin-bottom: 4px; font-size: 0.9rem; }
.result-row.win { background: var(--success-bg); color: var(--success); }
.result-row.lose { background: var(--danger-bg); color: var(--danger); }
.result-total { display: flex; justify-content: space-between; padding: 10px 14px; border-radius: var(--radius-sm); margin-top: 10px; font-weight: 700; font-size: 1.1rem; }
.result-total.profit { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0,230,118,0.3); }
.result-total.loss { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(255,82,82,0.3); }

/* ==================== TOAST ==================== */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius); font-weight: 600; font-size: 0.85rem; box-shadow: var(--shadow); animation: toastIn 0.3s ease; max-width: 320px; }
.toast.success { background: var(--success-bg); border: 1px solid rgba(0,230,118,0.4); color: var(--success); }
.toast.error { background: var(--danger-bg); border: 1px solid rgba(255,82,82,0.4); color: var(--danger); }
.toast.info { background: rgba(108,99,255,0.15); border: 1px solid rgba(108,99,255,0.4); color: var(--accent-light); }
.toast.fadeOut { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(50px); } }

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ==================== CONFETTI ==================== */
.confetti-piece { position: fixed; width: 10px; height: 10px; border-radius: 2px; z-index: 400; pointer-events: none; animation: confettiFall 3s ease-in-out forwards; }
@keyframes confettiFall { 0% { opacity: 1; transform: translateY(0) rotate(0deg); } 100% { opacity: 0; transform: translateY(100vh) rotate(720deg); } }

/* ============================================================
   RESPONSIVE - TABLET (<=900px)
   ============================================================ */
@media (max-width: 900px) {
  .game-sidebar { width: 260px; min-width: 260px; }
  .chat-box { height: 160px; min-height: 160px; }
  .dice { width: 70px; height: 70px; }
  .dice-face { font-size: 2.2rem; }
  .dice-bowl { gap: 12px; padding: 16px 24px; }
  .betting-board { gap: 10px; padding: 0 16px 12px; }
  .symbol-svg { width: 50px; height: 50px; }
  .bet-card { padding: 12px 10px; }
  .bet-card-name { font-size: 1rem; }
}

/* ============================================================
   RESPONSIVE - MOBILE (<=768px)
   ============================================================ */
@media (max-width: 768px) {
  /* --- Lobby nav --- */
  .lobby-nav { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .nav-center { order: 3; width: 100%; justify-content: center; }
  .nav-tab { padding: 6px 14px; font-size: 0.8rem; }
  .nav-tab svg { display: none; }
  .user-info { gap: 10px; }
  .user-name { display: none; }
  .lobby-content { padding: 16px; }
  .lobby-header h2 { font-size: 1.2rem; }
  .room-grid { grid-template-columns: 1fr; gap: 10px; }
  .room-card { padding: 16px; }

  /* --- Game layout: sidebar as slide-over --- */
  .game-layout { flex-direction: column; height: 100vh; height: 100dvh; }

  .sidebar-toggle {
    display: flex; position: fixed; top: 10px; left: 10px; z-index: 150;
    width: 44px; height: 44px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 50%; align-items: center; justify-content: center;
    color: var(--text-primary); cursor: pointer;
    box-shadow: var(--shadow); transition: var(--transition);
  }
  .sidebar-toggle:hover { background: var(--accent); }
  .toggle-badge {
    position: absolute; top: -4px; right: -4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); color: white;
    font-size: 0.7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }

  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 190;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open { display: block; }

  .game-sidebar {
    position: fixed; top: 0; left: -300px; z-index: 200;
    width: 280px; min-width: 280px; height: 100vh; height: 100dvh;
    transition: left 0.3s ease; border-right: 1px solid var(--border);
  }
  .game-sidebar.open { left: 0; }

  /* --- Game main fills screen --- */
  .game-main { height: 100vh; height: 100dvh; overflow-y: auto; }

  /* --- Topbar compact --- */
  .game-topbar {
    padding: 10px 16px; gap: 8px;
    padding-left: 60px; /* space for toggle button */
  }
  .round-label { display: none; }
  .round-number { font-size: 1.2rem; }
  .balance-value { font-size: 1.3rem; }
  .balance-label { display: none; }
  .game-status { padding: 4px 12px; font-size: 0.75rem; }

  /* --- Dice compact --- */
  .dice-area { padding: 14px 12px; }
  .dice-bowl { gap: 10px; padding: 14px 20px; }
  .dice { width: 64px; height: 64px; border-radius: 12px; }
  .dice-face { font-size: 2rem; }

  /* --- Betting board 3x2 fits screen --- */
  .betting-board {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px; padding: 0 12px 10px;
  }
  .bet-card { padding: 10px 6px; border-radius: 10px; }
  .symbol-svg { width: 42px; height: 42px; }
  .bet-card-name { font-size: 0.9rem; margin-bottom: 1px; }
  .bet-card-amount { font-size: 0.8rem; }
  .bet-card-img { margin-bottom: 2px; }

  /* --- Chips compact --- */
  .bet-controls { padding: 10px 12px 14px; }
  .chip-selector { gap: 4px; margin-bottom: 8px; }
  .chip-label { display: none; }
  .chip-btn { padding: 5px 10px; font-size: 0.78rem; min-width: 38px; border-width: 1.5px; }
  .bet-actions { gap: 12px; }
  .total-bet { font-size: 0.85rem; }

  /* --- Dealer controls compact --- */
  .dealer-controls { padding: 12px 16px; gap: 10px; }
  .dealer-controls .btn-lg { padding: 12px 24px; font-size: 0.95rem; }

  /* --- Result overlay --- */
  .result-card { padding: 24px 20px; }
  .result-card h3 { font-size: 1.3rem; margin-bottom: 16px; }
  .result-dice .result-die { width: 50px; height: 50px; font-size: 1.6rem; }
  .result-dice { gap: 10px; margin-bottom: 16px; }
}

/* ============================================================
   RESPONSIVE - SMALL MOBILE (<=400px)
   ============================================================ */
@media (max-width: 400px) {
  .auth-container { padding: 24px 16px; }
  .auth-logo h1 { font-size: 1.8rem; }
  .logo-dice { width: 64px; height: 64px; font-size: 32px; }

  .dice { width: 56px; height: 56px; }
  .dice-face { font-size: 1.7rem; }
  .dice-bowl { gap: 8px; padding: 12px 16px; }

  .betting-board { gap: 6px; padding: 0 8px 8px; }
  .bet-card { padding: 8px 4px; }
  .symbol-svg { width: 36px; height: 36px; }
  .bet-card-name { font-size: 0.8rem; }
  .bet-card-amount { font-size: 0.75rem; }

  .chip-btn { padding: 4px 8px; font-size: 0.72rem; min-width: 34px; }
  .game-topbar { padding: 8px 12px; padding-left: 56px; }
}
