/* ============================================================
   UNTIL IT BREAKS — base: tokens, reset, ambience, layout
   Desktop 3-column: crew-slot left rail · play center · roster right
   ============================================================ */
:root {
  --bg0: #05070b;
  --bg1: #0a0e16;
  --bg2: #10182a;
  --panel: rgba(13, 19, 32, 0.86);
  --panel-solid: #0d1320;
  --line: #1d2942;
  --line-bright: #2c3d63;

  --text: #d6dfeb;
  --dim: #8493ab;
  --faint: #55627c;

  --gold: #ffd75e;
  --gold-deep: #d9a13c;
  --red: #ff4d5e;
  --orange: #ff9f43;

  --hearts: #ff5d7a;
  --diamonds: #3fd9ff;
  --clubs: #58e07e;
  --spades: #c9d4ff;

  /* type colors — SURGE orange · LUCK violet · CRYPTO cyan-green */
  --surge: #ff7a3c;
  --surge-glow: rgba(255, 122, 60, 0.6);
  --luck: #b06bff;
  --luck-glow: rgba(176, 107, 255, 0.6);
  --crypto: #2ee6a8;
  --crypto-glow: rgba(46, 230, 168, 0.6);
  --green: #41f58f;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

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

html, body {
  height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  overflow: hidden;
}
body {
  background:
    radial-gradient(1200px 700px at 72% -10%, rgba(38, 60, 110, 0.26), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(120, 60, 30, 0.14), transparent 60%),
    var(--bg0);
}
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 4px; }

#scanlines {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.022) 0, rgba(255,255,255,0.022) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
}
#screenfx { position: fixed; inset: 0; z-index: 78; pointer-events: none; }
#particles { position: fixed; inset: 0; z-index: 79; pointer-events: none; width: 100vw; height: 100vh; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  backdrop-filter: blur(4px);
}
.panel-title {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.12em; color: var(--dim); margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.zone-hint { color: var(--faint); font-weight: 400; letter-spacing: 0.04em; text-transform: none; font-size: 10px; }
.count-chip {
  font-family: var(--mono); font-size: 10px; background: var(--bg2);
  border: 1px solid var(--line); padding: 1px 7px; border-radius: 20px; color: var(--gold);
}

/* buttons */
.btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  border-radius: 8px; border: 1px solid var(--line-bright);
  background: var(--bg2); color: var(--text); padding: 9px 15px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--gold-deep); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-gold { background: linear-gradient(180deg, #443411, #2c210a); border-color: var(--gold-deep); color: var(--gold); text-shadow: 0 0 12px rgba(255,215,94,0.5); }
.btn-gold:hover:not(:disabled) { box-shadow: 0 0 18px rgba(255,215,94,0.25); border-color: var(--gold); }
.btn-red { border-color: #6e2733; color: var(--red); background: #26121a; }
.btn-red:hover:not(:disabled) { border-color: var(--red); box-shadow: 0 0 14px rgba(255,77,94,0.2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--dim); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-help {
  background: #f5f7fb;
  border-color: #fff;
  color: #101522;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.3), 0 0 18px rgba(255,255,255,0.12);
}
.btn-help:hover:not(:disabled) {
  background: #fff;
  color: #05070b;
  transform: translateY(-1px);
}
.btn-big { font-size: 14px; padding: 12px 24px; }
.btn.step-on { border-color: var(--crypto); color: var(--crypto); }
.btn-debug { font-size: 10px; padding: 5px 9px; border-color: #46325c; color: #b06bff; background: #191226; }

/* ============ PREP LAYOUT ============ */
.prep-header {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16,24,42,0.9), rgba(10,14,22,0.7));
}
.brand { font-family: var(--mono); font-size: 19px; font-weight: 800; letter-spacing: 0.1em; color: var(--crypto); text-shadow: 0 0 24px var(--crypto-glow); }
.brand span { color: var(--surge); text-shadow: 0 0 24px var(--surge-glow); }
.prep-title { flex: 1; }
.casino-name { font-size: 16px; font-weight: 600; }
.prep-sub { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: 0.08em; margin-top: 2px; }
.prep-header-right { display: flex; gap: 10px; align-items: center; }

.prep-main { flex: 1; display: grid; grid-template-columns: 290px 1.1fr 1.5fr; gap: 12px; padding: 12px 16px; min-height: 0; }
.prep-col { overflow-y: auto; min-height: 0; }
#prep-rules { display: flex; flex-direction: column; gap: 10px; }
.prep-crew { display: flex; flex-direction: column; }
.crew-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; overflow-y: auto; align-content: start; padding: 2px; }
.prep-loadout { margin: 0 16px 12px; display: flex; align-items: center; gap: 18px; min-height: 66px; }

/* ============ GAME LAYOUT ============ */
#ai-bar {
  display: flex; align-items: center; gap: 18px; padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16,24,42,0.95), rgba(10,14,22,0.8));
  position: relative; z-index: 5;
}
.ai-identity { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.ai-name { font-family: var(--mono); font-size: 15px; font-weight: 700; letter-spacing: 0.08em; color: #b06bff; }
.ai-status { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: 0.08em; margin-top: 2px; }
.ai-rules { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-bar-right { display: flex; gap: 14px; align-items: center; }
.counter { font-family: var(--mono); text-align: right; }
.counter-label { display: block; font-size: 9px; color: var(--faint); letter-spacing: 0.12em; }
.counter > span + span { font-size: 16px; }
.counter-gold > span + span { color: var(--gold); text-shadow: 0 0 12px rgba(255,215,94,0.35); }

.game-body { flex: 1; display: grid; grid-template-columns: 300px 1fr 285px; gap: 10px; padding: 10px 12px; min-height: 0; }
#left-rail, #right-rail { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; }
#center { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }

#board-panel { flex-shrink: 0; }
#log-panel { flex: 1; min-height: 110px; display: flex; flex-direction: column; }
#event-log { flex: 1; overflow-y: auto; font-family: var(--mono); font-size: 10.5px; line-height: 1.55; }

#preview-panel { min-height: 92px; }
#play-area { min-height: 132px; position: relative; }
.zone-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--faint); margin-bottom: 5px; padding-left: 4px; display: flex; gap: 8px; align-items: center; }

#hand-area { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 176px; padding-bottom: 4px; min-width: 0; }
#hand-strip { display: flex; align-items: flex-end; justify-content: center; gap: 14px; max-width: 100%; min-width: 0; }
#hand-cards { display: flex; justify-content: center; padding: 18px 0 6px; max-width: 100%; flex-wrap: wrap; row-gap: 14px; }
#type-hand-area { flex-shrink: 0; min-height: 124px; display: flex; flex-direction: column; justify-content: flex-end; }
#type-hand-area .zone-label { justify-content: center; padding-left: 0; margin-bottom: 4px; font-size: 9px; }
#type-cards { display: flex; justify-content: center; gap: 0; row-gap: 8px; padding: 0 0 6px; min-height: 96px; flex-wrap: nowrap; }

#actions { display: flex; gap: 8px; align-items: center; padding: 4px 2px 2px; flex-wrap: wrap; }
.action-spacer { flex: 1; }

@media (max-height: 760px) {
  .game-body { gap: 8px; padding: 8px 10px; }
  #center { gap: 6px; }
  #board-panel { padding: 10px; }
  #preview-panel { min-height: 76px; padding: 9px 10px; }
  #play-area { min-height: 58px; }
  #hand-area { min-height: 136px; padding-bottom: 0; }
  #hand-strip { gap: 10px; }
  #hand-cards { padding-top: 8px; padding-bottom: 2px; row-gap: 8px; flex-wrap: nowrap; }
  #type-hand-area { min-height: 112px; }
  #type-hand-area .zone-label { font-size: 8px; margin-bottom: 3px; }
  #type-cards { min-height: 88px; padding-bottom: 2px; }
  #actions { gap: 6px; padding-top: 0; }
  #actions .btn { font-size: 10px; padding: 7px 9px; }
  #actions .btn-big { font-size: 12px; padding: 9px 14px; }
}

/* debug drawer */
#debug-drawer { position: fixed; bottom: 0; right: 14px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; }
#debug-toggle { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; background: #191226; color: #b06bff; border: 1px solid #46325c; border-bottom: none; border-radius: 8px 8px 0 0; padding: 4px 12px; opacity: 0.65; }
#debug-toggle:hover { opacity: 1; }
#debug-controls { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; background: rgba(20,14,33,0.95); border: 1px solid #46325c; border-radius: 8px 0 0 0; padding: 8px; max-width: 460px; }
#debug-drawer.collapsed #debug-controls { display: none; }

/* modal + shop */
#modal-wrap, #shop-wrap, #tutorial-wrap {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,10,0.72); backdrop-filter: blur(3px);
}
#modal { width: 460px; max-width: 92vw; background: var(--panel-solid); border: 1px solid var(--line-bright); border-radius: 14px; padding: 28px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }

#step-next {
  position: fixed; z-index: 88; left: 50%; transform: translateX(-50%); bottom: 26px;
  font-family: var(--mono); font-size: 14px; font-weight: 800; letter-spacing: 0.08em;
  color: var(--gold); background: linear-gradient(180deg, #4a3812, #2c210a); border: 1px solid var(--gold);
  border-radius: 24px; padding: 12px 28px; box-shadow: 0 6px 26px rgba(0,0,0,0.55), 0 0 22px rgba(255,215,94,0.3);
}
#step-next span { font-size: 10px; opacity: 0.7; border: 1px solid var(--gold-deep); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
