/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --surface: #1e1e2a;
  --surface2: #252535;
  --border: #2e2e42;
  --accent: #e8c840;
  --accent2: #f0a030;
  --danger: #e84040;
  --safe: #40c870;
  --freeze: #4080e8;
  --flip3: #c040e8;
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #606075;
  --radius: 8px;
}

/* Number card colors per value */
:root {
  --n0:  #888899; --n0b:  #555566;
  --n1:  #e8c840; --n1b:  #a08020;
  --n2:  #40c8e8; --n2b:  #208090;
  --n3:  #e87040; --n3b:  #903020;
  --n4:  #40e870; --n4b:  #208040;
  --n5:  #e840a0; --n5b:  #901060;
  --n6:  #40a0e8; --n6b:  #205080;
  --n7:  #e8e040; --n7b:  #908800;
  --n8:  #a040e8; --n8b:  #601090;
  --n9:  #40e8c0; --n9b:  #109060;
  --n10: #e86040; --n10b: #903020;
  --n11: #60e840; --n11b: #308020;
  --n12: #e84060; --n12b: #901030;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 720px;
  margin: 0 auto;
}

/* ─── Screens ───────────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ─── Entry ─────────────────────────────────────────────────────────────── */
#screen-entry { align-items: center; justify-content: center; position: relative; }
.entry-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(232,200,64,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(232,64,64,0.05) 0%, transparent 50%),
    repeating-linear-gradient(45deg, transparent, transparent 40px, rgba(255,255,255,0.012) 40px, rgba(255,255,255,0.012) 41px);
}
.entry-content { position: relative; display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 32px 20px; width: 100%; }
.logo { font-family: 'Bebas Neue', sans-serif; line-height: 1; letter-spacing: 2px; text-align: center; }
.logo-flip { font-size: clamp(60px, 15vw, 100px); color: var(--text); }
.logo-seven { font-size: clamp(80px, 20vw, 130px); color: var(--accent); display: block; margin-top: -16px; text-shadow: 0 0 60px rgba(232,200,64,0.4); }
.tagline { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text3); letter-spacing: 3px; text-transform: uppercase; margin-top: -12px; }
.entry-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.entry-tables { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.data-notice { font-size: 11px; color: var(--text3); text-align: center; }
.lobby-empty { color: var(--text3); font-family: 'DM Mono', monospace; font-size: 13px; padding: 10px 0; }

/* ─── Table cards on entry ──────────────────────────────────────────────── */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.table-card-name { font-family: 'Bebas Neue', sans-serif; font-size: 20px; color: var(--accent); letter-spacing: 1px; }
.table-card-meta { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ─── Inputs ────────────────────────────────────────────────────────────── */
input[type="text"] { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: 'DM Mono', monospace; font-size: 15px; padding: 12px 16px; outline: none; transition: border-color 0.2s; }
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--text3); }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn { flex: 1; padding: 12px 16px; border: none; border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 500; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #0a0a0f; }
.btn-primary:hover { background: #f0d840; }
.btn-flip { background: var(--safe); color: #0a0a0f; font-weight: 700; font-size: 20px; padding: 18px 20px; }
.btn-flip:hover { background: #50d880; }
.btn-flip:active { transform: scale(0.97); }
.btn-flip.spinning { background: var(--surface2); color: var(--accent); border: 2px solid var(--accent); cursor: not-allowed; font-family: 'DM Mono', monospace; font-size: 18px; }
.btn-stop { background: rgba(232,64,64,0.15); color: var(--danger); border: 1px solid var(--danger); font-size: 18px; padding: 18px 20px; }
.btn-stop:hover { background: rgba(232,64,64,0.25); border-color: #ff6060; color: #ff6060; }
.btn-leave { background: none; border: 1px solid var(--border); color: var(--text3); font-family: 'DM Mono', monospace; font-size: 12px; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; margin-left: auto; transition: all 0.15s; }
.btn-leave:hover { border-color: var(--danger); color: var(--danger); }
.btn-bot { background: transparent; color: var(--flip3); border: 1px solid var(--flip3); padding: 12px 16px; border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-bot:hover { background: rgba(192,64,232,0.1); }
.btn-log-toggle { background: none; border: 1px solid var(--border); color: var(--text3); font-family: 'DM Mono', monospace; font-size: 11px; padding: 4px 10px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.btn-log-toggle:hover { border-color: var(--text2); color: var(--text2); }

/* ─── Room Header ───────────────────────────────────────────────────────── */
.room-header { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); flex-shrink: 0; }
.room-header span { color: var(--accent); }

/* ─── Players Area ──────────────────────────────────────────────────────── */
.players-area { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; padding: 8px; flex: 1; overflow-y: auto; align-content: start; }

.player-panel {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color 0.2s, opacity 0.2s;
  position: relative;
  cursor: default;
}
.player-panel.is-turn { animation: pulseGlow 1.5s infinite; }
.player-panel.state-busted { opacity: 0.5; }
.player-panel.state-frozen { opacity: 0.7; }
.player-panel.state-stopped { opacity: 0.75; }
.player-panel.state-disconnected { opacity: 0.35; border-style: dashed; }
.player-panel.targeting-active { cursor: pointer; }
.player-panel.targeting-active:hover { transform: translateY(-2px); filter: brightness(1.2); }

/* Large X for inactive players */
.player-x {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-family: 'Bebas Neue', sans-serif;
  font-weight: 900;
  pointer-events: none;
  border-radius: var(--radius);
  z-index: 2;
}
.state-busted .player-x { display: flex; color: var(--danger); background: rgba(232,64,64,0.08); }
.state-frozen .player-x { display: flex; color: var(--freeze); background: rgba(64,128,232,0.08); }

.player-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; gap: 4px; }
.player-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-score { font-family: 'DM Mono', monospace; font-size: 11px; flex-shrink: 0; }
.player-score .prev { color: var(--text2); }
.player-score .round { font-weight: 700; }
.player-score .round.green { color: var(--safe); }
.player-score .round.red { color: var(--danger); }
.player-score .round.blue { color: var(--freeze); }

/* Bust card display */
.bust-card-display { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--danger); margin-top: 4px; }

.card-rows { display: flex; flex-direction: column; gap: 3px; }
.card-row { display: flex; flex-wrap: wrap; gap: 3px; min-height: 4px; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  width: 36px; height: 50px;
  border-radius: 5px;
  background: #f0ece0;
  color: #1a1a1a;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  flex-shrink: 0;
  transition: transform 0.12s;
  position: relative;
  border: 2px solid transparent;
}
.card .card-val {
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
.card small {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.85;
  display: block;
  line-height: 1;
  margin-top: 1px;
}
.card.action small, .card.modifier small {
  font-size: 8px;
  opacity: 0.8;
}

/* Number card colors */
.card.n0  { color: var(--n0);  border-color: var(--n0b);  }
.card.n1  { color: var(--n1);  border-color: var(--n1b);  }
.card.n2  { color: var(--n2);  border-color: var(--n2b);  }
.card.n3  { color: var(--n3);  border-color: var(--n3b);  }
.card.n4  { color: var(--n4);  border-color: var(--n4b);  }
.card.n5  { color: var(--n5);  border-color: var(--n5b);  }
.card.n6  { color: var(--n6);  border-color: var(--n6b);  }
.card.n7  { color: var(--n7);  border-color: var(--n7b);  }
.card.n8  { color: var(--n8);  border-color: var(--n8b);  }
.card.n9  { color: var(--n9);  border-color: var(--n9b);  }
.card.n10 { color: var(--n10); border-color: var(--n10b); font-size: 19px; }
.card.n11 { color: var(--n11); border-color: var(--n11b); font-size: 19px; }
.card.n12 { color: var(--n12); border-color: var(--n12b); font-size: 19px; }

/* Modifier cards */
.card.modifier { width: 42px; height: 50px; font-size: 13px; font-family: 'DM Sans', sans-serif; font-weight: 700; text-align: center; padding: 3px; line-height: 1.2; }
.card.modifier-x2   { background: #201400; color: var(--accent2); border-color: var(--accent2); }
.card.modifier-plus { background: #0e1a00; color: #90d040;        border-color: #507020; }

/* Action cards */
.card.action { width: 46px; height: 58px; font-size: 11px; font-family: 'DM Sans', sans-serif; font-weight: 700; text-align: center; padding: 3px 2px; line-height: 1.2; }
.card.action-freeze      { background: #081828; color: #60b8ff; border-color: #4080e8; }
.card.action-flipthree   { background: #180028; color: #d080ff; border-color: #c040e8; }
.card.action-secondchance{ background: #001a10; color: #40e080; border-color: #40c870; }

.card.used { opacity: 0.3; filter: grayscale(0.8); }
.discard-pair { display: flex; align-items: flex-end; gap: 2px; }
.card.discarded { opacity: 0.25; filter: grayscale(1); transform: rotate(8deg); margin-left: -10px; width: 30px; height: 40px; font-size: 18px; }

@keyframes dealIn { from { transform: translateY(-12px) scale(0.8); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.card.new { animation: dealIn 0.18s ease-out; }

/* ─── Slot Machine ──────────────────────────────────────────────────────── */
.slot-machine {
  width: 100%; max-width: 340px;
  background: #0a0a0a;
  border: 3px solid var(--accent);
  border-radius: 16px;
  overflow: hidden;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  box-shadow: 0 0 24px rgba(232,200,64,0.3), inset 0 0 20px rgba(0,0,0,0.8);
}
.slot-machine::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 3;
}
.slot-track {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  border-right: 1px solid rgba(232,200,64,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot-track:last-child { border-right: none; }
.slot-reel-inner {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 46px;
  text-align: center;
  line-height: 1;
  text-shadow: 0 0 16px currentColor, 0 0 32px currentColor;
  position: relative;
  z-index: 2;
  transition: color 0.1s;
  min-width: 80px;
}
.slot-reel-inner.spinning {
  animation: reelSpin 0.12s steps(1) infinite;
}
.slot-reel-inner.landing {
  animation: reelLand 0.3s ease-out forwards;
}
.slot-reel-inner.busting {
  animation: reelBust 0.2s steps(1) infinite;
}
@keyframes reelSpin {
  0%   { transform: translateY(0);    opacity: 1; }
  25%  { transform: translateY(-8px); opacity: 0.7; }
  50%  { transform: translateY(0);    opacity: 1; }
  75%  { transform: translateY(8px);  opacity: 0.7; }
  100% { transform: translateY(0);    opacity: 1; }
}
@keyframes reelLand {
  0%   { transform: translateY(-10px) scale(1.2); opacity: 0.8; }
  60%  { transform: translateY(4px)   scale(0.95); }
  100% { transform: translateY(0)     scale(1); opacity: 1; }
}
@keyframes reelBust {
  0%   { transform: scale(1);    }
  50%  { transform: scale(1.1);  }
  100% { transform: scale(1);    }
}
.slot-divider {
  width: 2px;
  height: 60%;
  background: rgba(232,200,64,0.15);
  flex-shrink: 0;
}

/* ─── Log Panel ─────────────────────────────────────────────────────────── */
.log-panel {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  height: 52px;
  overflow-y: auto;
  padding: 4px 12px;
  flex-shrink: 0;
}
.log-entries { display: flex; flex-direction: column; gap: 1px; }
.log-entry { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); white-space: nowrap; }
.log-entry.new { color: var(--text2); }

/* ─── Action Zone ───────────────────────────────────────────────────────── */
.action-zone { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg2); border-top: 1px solid var(--border); flex-shrink: 0; }
.action-top-row { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 320px; gap: 8px; }
.action-message { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text2); letter-spacing: 1px; flex: 1; text-align: center; }
.timer-bar-wrap { width: 100%; max-width: 320px; background: var(--surface); border-radius: 20px; height: 6px; position: relative; }
.timer-bar { height: 100%; border-radius: 20px; background: var(--accent); width: 100%; transition: width 1s linear, background 0.5s; }
.timer-bar.urgent { background: var(--danger); }
.timer-label { position: absolute; right: 0; top: -16px; font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); }
.action-buttons { display: flex; gap: 10px; width: 100%; max-width: 320px; }

/* Target overlay message */
.target-overlay { width: 100%; max-width: 320px; }
.target-message { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--flip3); text-align: center; padding: 8px; background: rgba(192,64,232,0.1); border: 1px solid var(--flip3); border-radius: var(--radius); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ─── Waiting ───────────────────────────────────────────────────────────── */
.waiting-area { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; background: var(--bg2); border-top: 1px solid var(--border); flex-shrink: 0; }
.waiting-area p { color: var(--text2); font-size: 14px; }
.waiting-sub { font-size: 12px; color: var(--text3); font-family: 'DM Mono', monospace; }
.waiting-buttons { display: flex; gap: 10px; }

/* ─── Overlays ──────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(10,10,15,0.9); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); padding: 16px; }
.overlay-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.overlay-card h2 { font-family: 'Bebas Neue', sans-serif; font-size: 32px; letter-spacing: 2px; color: var(--accent); }
.overlay-card h3 { font-family: 'Bebas Neue', sans-serif; font-size: 24px; letter-spacing: 2px; color: var(--accent); }
.score-list { display: flex; flex-direction: column; gap: 5px; max-height: 50vh; overflow-y: auto; }
.score-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; background: var(--bg2); border-radius: var(--radius); font-family: 'DM Mono', monospace; font-size: 12px; }
.score-row.winner { border: 1px solid var(--accent); }
.score-row .sname { color: var(--text); }
.score-row .srnd { color: var(--text3); font-size: 11px; }
.score-row .stotal { color: var(--accent); font-weight: 500; }
.winner-text { font-family: 'Bebas Neue', sans-serif; font-size: 20px; color: var(--safe); letter-spacing: 1px; }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 18px; font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text); z-index: 200; transition: opacity 0.3s; white-space: nowrap; max-width: 90vw; text-align: center; }
.toast.hidden { opacity: 0; pointer-events: none; }

/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(232,200,64,0.4); } 50% { box-shadow: 0 0 0 6px rgba(232,200,64,0); } }
@keyframes bustShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.bust-animate { animation: bustShake 0.35s ease; }

.hidden { display: none !important; }

/* ─── Action info bar ───────────────────────────────────────────────────── */
.action-info {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 1px;
  flex: 1;
  text-align: center;
}

/* ─── Table Groups on Entry Screen ─────────────────────────────────────── */
.table-group {
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.table-group-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--accent);
  text-align: center;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(232,200,64,0.2);
}

/* ─── Stopped player checkmark ──────────────────────────────────────────── */
.player-x.stopped-check {
  color: var(--safe);
  background: rgba(64,200,112,0.08);
  font-size: 42px;
}
.state-stopped .player-x { display: flex; }
.btn-remove-bot { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 12px 16px; border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-remove-bot:hover { background: rgba(232,64,64,0.1); }
