/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --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;
}

* { 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; }

/* ─── 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: 24px; padding: 40px 20px; width: 100%; max-width: 400px; }
.logo { font-family: 'Bebas Neue', sans-serif; line-height: 1; letter-spacing: 2px; text-align: center; }
.logo-flip { font-size: clamp(72px, 15vw, 120px); color: var(--text); }
.logo-seven { font-size: clamp(100px, 20vw, 160px); color: var(--accent); display: block; margin-top: -20px; text-shadow: 0 0 60px rgba(232,200,64,0.4); }
.tagline { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text3); letter-spacing: 3px; text-transform: uppercase; margin-top: -16px; }
.entry-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.entry-tables { display: flex; flex-direction: column; gap: 10px; 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; }

/* ─── 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 20px; 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; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--text2); color: var(--text); }
.btn-flip { background: var(--safe); color: #0a0a0f; font-weight: 600; font-size: 18px; padding: 16px 20px; }
.btn-flip:hover { background: #50d880; transform: translateY(-1px); }
.btn-stop { background: transparent; color: var(--text2); border: 1px solid var(--border); font-size: 18px; padding: 16px 20px; }
.btn-stop:hover { border-color: var(--accent2); color: var(--accent2); }
.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 20px; border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-bot:hover { background: rgba(192,64,232,0.1); }

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

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

/* ─── Players Area ──────────────────────────────────────────────────────── */
.players-area { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; flex: 1; align-content: flex-start; overflow-y: auto; }

.player-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; min-width: 150px; flex: 1; transition: border-color 0.2s, opacity 0.2s; }
.player-panel.is-turn { border-color: var(--accent); animation: pulseGlow 1.5s infinite; }
.player-panel.state-busted { opacity: 0.4; }
.player-panel.state-frozen { border-color: var(--freeze); }
.player-panel.state-stopped { border-color: var(--safe); opacity: 0.75; }
.player-panel.state-disconnected { opacity: 0.35; border-style: dashed; }
.player-panel.is-me { border-color: var(--accent2); }

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

/* Card rows inside player panel */
.card-rows { display: flex; flex-direction: column; gap: 4px; }
.card-row { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  width: 42px; height: 58px; border-radius: 6px;
  background: #f5f0e0; color: #1a1a1a;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Bebas Neue', sans-serif; font-size: 22px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  flex-shrink: 0; transition: transform 0.15s;
  position: relative;
}
.card:hover { transform: translateY(-3px); }
.card .card-val { line-height: 1; }
.card.number-0 { color: var(--text3); }

/* Modifier cards */
.card.modifier {
  width: 46px; height: 58px;
  font-size: 14px; font-family: 'DM Sans', sans-serif; font-weight: 700;
  text-align: center; padding: 4px; line-height: 1.2;
}
.card.modifier-x2 { background: #2a1a00; color: var(--accent2); border: 2px solid var(--accent2); }
.card.modifier-plus { background: #1a2a00; color: #90d040; border: 2px solid #70a830; }

/* Action cards — distinct colors, bigger */
.card.action {
  width: 52px; height: 64px;
  font-size: 11px; font-family: 'DM Sans', sans-serif; font-weight: 700;
  text-align: center; padding: 4px 3px; line-height: 1.2;
}
.card.action-freeze { background: #0d2a4a; color: #60b8ff; border: 2px solid #4080e8; }
.card.action-flipthree { background: #2a0040; color: #d080ff; border: 2px solid #c040e8; }
.card.action-secondchance { background: #002a18; color: #40e080; border: 2px solid #40c870; }

/* Used action cards — greyed out */
.card.used {
  opacity: 0.35;
  filter: grayscale(0.7);
}

/* Discarded card shown next to used second chance */
.discard-pair { display: flex; align-items: flex-end; gap: 2px; }
.card.discarded {
  opacity: 0.3;
  filter: grayscale(1);
  transform: rotate(8deg);
  margin-left: -10px;
  width: 34px; height: 48px;
  font-size: 17px;
}

/* ─── Action Zone ───────────────────────────────────────────────────────── */
.action-zone { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; background: var(--bg2); border-top: 1px solid var(--border); }
.action-message { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text2); letter-spacing: 1px; }
.timer-bar-wrap { width: 100%; max-width: 320px; background: var(--surface); border-radius: 20px; height: 8px; 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: -18px; font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); }
.action-buttons { display: flex; gap: 12px; width: 100%; max-width: 320px; }
.target-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 400px; }
.target-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; padding: 10px 16px; cursor: pointer; transition: all 0.15s; }
.target-btn:hover { border-color: var(--flip3); color: var(--flip3); }

/* ─── Waiting ───────────────────────────────────────────────────────────── */
.waiting-area { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--bg2); border-top: 1px solid var(--border); }
.waiting-area p { color: var(--text2); }
.waiting-sub { font-size: 13px; 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.88); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
.overlay-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px 32px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.overlay-card h2 { font-family: 'Bebas Neue', sans-serif; font-size: 36px; letter-spacing: 2px; color: var(--accent); }
.overlay-card h3 { font-family: 'Bebas Neue', sans-serif; font-size: 26px; letter-spacing: 2px; color: var(--accent); }
.score-list { display: flex; flex-direction: column; gap: 6px; }
.score-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--bg2); border-radius: var(--radius); font-family: 'DM Mono', monospace; font-size: 13px; }
.score-row.winner { border: 1px solid var(--accent); }
.score-row .sname { color: var(--text); }
.score-row .srnd { color: var(--text3); font-size: 12px; }
.score-row .stotal { color: var(--accent); font-weight: 500; }
.winner-text { font-family: 'Bebas Neue', sans-serif; font-size: 22px; color: var(--safe); letter-spacing: 1px; }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 20px; font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text); z-index: 200; transition: opacity 0.3s; white-space: nowrap; }
.toast.hidden { opacity: 0; pointer-events: none; }

/* ─── State badges ──────────────────────────────────────────────────────── */
.state-badge { font-family: 'DM Mono', monospace; font-size: 10px; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 1px; }
.state-badge.active { background: rgba(64,200,112,0.15); color: var(--safe); }
.state-badge.stopped { background: rgba(232,200,64,0.15); color: var(--accent); }
.state-badge.busted { background: rgba(232,64,64,0.15); color: var(--danger); }
.state-badge.frozen { background: rgba(64,128,232,0.15); color: var(--freeze); }
.state-badge.waiting { background: rgba(144,144,168,0.15); color: var(--text3); }
.state-badge.disconnected { background: rgba(144,144,168,0.1); color: var(--text3); }

/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes dealIn { from { transform: translateY(-16px) scale(0.85); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.card.new { animation: dealIn 0.2s ease-out; }
@keyframes bustShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.bust-animate { animation: bustShake 0.4s ease; }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(232,200,64,0.3); } 50% { box-shadow: 0 0 0 8px rgba(232,200,64,0); } }

.hidden { display: none !important; }
