/* ============================================================================
 * APT: Neon Rooftop — prototype stylesheet
 * Palette & tokens per docs/05-art-bible.md (CANON §6). Mobile-portrait-first.
 * ==========================================================================*/

:root {
  --coral:  #FF6B5E;
  --pink:   #FF3E9A;
  --blue:   #2E6BFF;
  --cyan:   #3EE6E0;
  --lemon:  #FFE94A;
  --mint:   #7CF5C4;
  --purple: #8A5CFF;
  --white:  #FFFFFF;
  --black:  #101014;

  --bg0: #0B0B0F;
  --bg1: #101014;
  --bg2: #1A1A22;
  --bg3: #26262F;
  --stroke: #33333E;
  --text2: #B8B8C6;
  --text-dis: #5C5C6B;

  --grad-climb: linear-gradient(180deg, #FF6B5E, #FF3E9A);
  --grad-bank:  linear-gradient(180deg, #7CF5C4, #3EE6E0);
  --grad-rooftop: linear-gradient(115deg, #FF3E9A, #8A5CFF);
  --grad-sky: linear-gradient(180deg, #1B1030 0%, #101014 70%);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg0);
  color: var(--white);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
}

#app {
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg1);
  box-shadow: 0 0 60px rgba(138, 92, 255, 0.12);
  position: relative;
  overflow: hidden;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; color: var(--white); }
button:disabled { cursor: not-allowed; }

/* Numbers never jitter */
#balance, #bet-amount, #mult-now, #mult-next, #cash-value, #session-timer,
#bank-sub, #climb-sub, .ladder-row, #decision-mult, #decision-value,
#celebrate-amount, #wheel-staked { font-variant-numeric: tabular-nums; }

/* ===================== HUD ================================================ */
#hud {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 10px;
  background: var(--bg1); border-bottom: 1px solid var(--stroke);
  flex: 0 0 auto; z-index: 5;
}
#session-timer { font-size: 13px; color: var(--text2); min-width: 70px; }
#hud-title { font-weight: 800; letter-spacing: 2px; font-size: 15px; color: var(--white); }
.hud-kr { color: var(--pink); font-size: 11px; margin-left: 5px; letter-spacing: 0; }
#hud-right { display: flex; align-items: center; gap: 8px; }
#balance { font-weight: 700; font-size: 14px; color: var(--mint); }
.icon-btn {
  background: var(--bg2); border: 1px solid var(--stroke); border-radius: 8px;
  width: 30px; height: 30px; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg3); }

/* ===================== GAME LAYOUT ======================================== */
#game { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* --- Tower + ladder rail --- */
#tower-wrap {
  flex: 1 1 auto; min-height: 0;
  display: flex; gap: 8px;
  padding: 8px 10px 4px;
  background: var(--grad-sky);
  position: relative;
}
#tower {
  flex: 1 1 62%;
  display: flex; flex-direction: column;
  min-height: 0;
  border-radius: 10px;
}
#rooftop-cap {
  flex: 0 0 auto;
  text-align: center; font-size: 10px; font-weight: 700; letter-spacing: 3px;
  color: var(--purple);
  border: 1px solid var(--purple); border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 3px 0; margin: 0 14%;
  background: rgba(138, 92, 255, 0.10);
  transition: all 0.4s;
  position: relative; overflow: hidden;
}
#rooftop-cap.lit {
  color: var(--white); background: var(--grad-rooftop);
  box-shadow: 0 0 24px rgba(255, 62, 154, 0.55);
}
#floors {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column-reverse;
  margin: 0 6%;
  border-left: 1px solid var(--stroke); border-right: 1px solid var(--stroke);
  background: rgba(16, 16, 20, 0.65);
}
.floor {
  flex: 1 1 0; min-height: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-top: 1px solid #1c1c26;
  position: relative;
  transition: background 0.3s;
}
.floor .fnum {
  width: 20px; font-size: 9px; color: var(--text-dis); font-weight: 700;
  transition: color 0.3s;
}
.floor .windows { flex: 1; display: flex; gap: 6px; justify-content: center; }
.floor .win {
  width: 16%; max-width: 26px; height: 62%; min-height: 8px;
  background: #1d1d29; border-radius: 2px;
  transition: background 0.35s, box-shadow 0.35s;
}
/* climbed floors: the party follows you up */
.floor.climbed .win { background: rgba(46, 107, 255, 0.5); }
.floor.climbed .win.mid { background: var(--blue); box-shadow: 0 0 8px rgba(46, 107, 255, 0.7); }
.floor.climbed .fnum { color: var(--text2); }
.floor.climbed.zone2 .win.mid { background: var(--cyan); box-shadow: 0 0 8px rgba(62, 230, 224, 0.7); }
.floor.climbed.zone3 .win.mid { background: var(--pink); box-shadow: 0 0 10px rgba(255, 62, 154, 0.8); }
/* current floor: brightest window */
.floor.current { background: rgba(255, 255, 255, 0.05); }
.floor.current .win { background: rgba(255, 233, 74, 0.35); }
.floor.current .win.mid {
  background: var(--lemon);
  box-shadow: 0 0 14px rgba(255, 233, 74, 0.9);
}
.floor.current .fnum { color: var(--lemon); }
/* bust: lights out */
.floor.busted .win, .floor.busted .win.mid {
  background: #17171f; box-shadow: none;
}
#street {
  flex: 0 0 auto;
  text-align: center; font-size: 9px; letter-spacing: 1px; color: var(--text-dis);
  padding: 4px 0 2px;
  border-top: 1px solid var(--stroke);
}

/* --- Multiplier ladder rail --- */
#ladder {
  flex: 1 1 38%;
  display: flex; flex-direction: column-reverse;
  min-height: 0;
  padding: 12px 0 18px;
}
.ladder-row {
  flex: 1 1 0; min-height: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px;
  font-size: 11px; color: var(--text-dis);
  border-radius: 6px;
  transition: all 0.25s;
  border: 1px solid transparent;
}
.ladder-row .lf { font-weight: 600; font-size: 9px; }
.ladder-row .lm { font-weight: 700; }
.ladder-row.reached { color: var(--text2); }
.ladder-row.reached .lm { color: var(--cyan); }
.ladder-row.current {
  background: rgba(62, 230, 224, 0.12);
  border-color: rgba(62, 230, 224, 0.5);
  color: var(--white);
}
.ladder-row.current .lm { color: var(--cyan); text-shadow: 0 0 10px rgba(62, 230, 224, 0.8); }

/* ===================== STATUS STRIP ======================================= */
#status-strip {
  flex: 0 0 64px;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  background: var(--bg1); border-top: 1px solid var(--stroke);
}
#status-left { flex: 0 0 auto; }
#floor-label { font-size: 10px; letter-spacing: 2px; color: var(--text2); font-weight: 700; }
#mult-now {
  font-size: 32px; font-weight: 800; line-height: 1.05; color: var(--cyan);
  text-shadow: 0 0 18px rgba(62, 230, 224, 0.45);
  transition: transform 0.15s var(--ease-pop);
}
#mult-now .x { font-size: 22px; }
#mult-now.bump { transform: scale(1.12); }
#status-mid { flex: 1 1 auto; font-size: 11px; color: var(--text2); }
.status-row { display: flex; justify-content: space-between; max-width: 150px; line-height: 1.5; }
.status-row span { color: var(--white); font-weight: 600; }
#cash-value { color: var(--mint) !important; }
#status-right { flex: 0 0 auto; text-align: right; }
#pips { font-size: 13px; letter-spacing: 2px; }
.pip { opacity: 0.18; filter: grayscale(1); transition: all 0.25s; }
.pip.filled { opacity: 1; filter: none; }
#shield-badge {
  margin-top: 2px; font-size: 10px; font-weight: 800; letter-spacing: 1px;
  color: var(--black); background: var(--mint);
  border-radius: 6px; padding: 2px 6px; display: inline-block;
  box-shadow: 0 0 12px rgba(124, 245, 196, 0.6);
}

/* ===================== ACTION BAR ========================================= */
#actions {
  flex: 0 0 84px;
  display: flex; gap: 8px;
  padding: 8px 10px;
  background: var(--bg1);
}
#actions button {
  border-radius: 14px;
  font-size: 19px; font-weight: 800; letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.08s, filter 0.12s;
}
#actions button:active:not(:disabled) { transform: scale(0.97); }
#actions button span { font-size: 12px; font-weight: 600; letter-spacing: 0; opacity: 0.9; }
#btn-bank {
  flex: 0 0 40%;
  background: var(--grad-bank); color: var(--black);
  box-shadow: 0 4px 18px rgba(124, 245, 196, 0.25);
}
#btn-climb {
  flex: 1 1 60%;
  background: var(--grad-climb);
  box-shadow: 0 4px 18px rgba(255, 62, 154, 0.3);
}
#actions button:disabled {
  background: var(--bg2); color: var(--text-dis); box-shadow: none;
}

/* ===================== BET STRIP ========================================== */
#bet-strip {
  flex: 0 0 auto;
  padding: 6px 10px 8px;
  background: var(--bg1); border-top: 1px solid var(--stroke);
}
#bet-row { display: flex; align-items: center; gap: 10px; justify-content: center; }
.bet-label { font-size: 11px; letter-spacing: 2px; color: var(--text2); font-weight: 700; }
.stepper {
  width: 34px; height: 30px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--stroke);
  font-size: 17px; font-weight: 700;
}
.stepper:disabled { color: var(--text-dis); }
#bet-amount { font-size: 17px; font-weight: 800; min-width: 64px; text-align: center; }

#vibe-row { display: flex; gap: 6px; margin-top: 6px; }
.vibe-card {
  flex: 1;
  background: var(--bg2); border: 1px solid var(--stroke); border-radius: 10px;
  padding: 6px 4px 5px; text-align: center;
  transition: all 0.2s;
}
.vibe-card .v-emoji { font-size: 15px; display: block; }
.vibe-card .v-name { font-size: 10px; font-weight: 800; letter-spacing: 1px; display: block; margin-top: 1px; }
.vibe-card .v-odds { font-size: 9px; color: var(--text2); display: block; }
.vibe-card .v-max { font-size: 9px; color: var(--text-dis); display: block; }
.vibe-card.selected { border-color: var(--pink); background: rgba(255, 62, 154, 0.10); box-shadow: 0 0 12px rgba(255, 62, 154, 0.25); }
.vibe-card.selected .v-max { color: var(--lemon); }
.vibe-card:disabled { opacity: 0.45; }

/* ===================== FOOTER ============================================= */
#footer {
  flex: 0 0 auto;
  text-align: center; font-size: 10px; color: var(--text-dis);
  padding: 4px 0 6px;
  background: var(--bg1); border-top: 1px solid var(--stroke);
}

/* ===================== OVERLAYS =========================================== */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(11, 11, 15, 0.86);
  backdrop-filter: blur(3px);
  animation: ov-in 0.18s var(--ease-out);
}
@keyframes ov-in { from { opacity: 0; } to { opacity: 1; } }

.skip-hint {
  position: absolute; bottom: 18px; left: 0; right: 0;
  text-align: center; font-size: 11px; color: var(--text-dis);
}

/* --- Hand-stack reveal --- */
#reveal-chant {
  font-size: 22px; font-weight: 800; color: var(--pink);
  text-shadow: 0 0 20px rgba(255, 62, 154, 0.7);
  margin-bottom: 14px; letter-spacing: 1px;
  animation: chant-pulse 0.5s infinite alternate;
}
@keyframes chant-pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
#reveal-stack { display: flex; flex-direction: column-reverse; gap: 4px; min-height: 220px; justify-content: flex-start; }
.hand {
  font-size: 30px; line-height: 1.1; text-align: center;
  padding: 1px 20px; border-radius: 10px;
  border: 2px solid transparent;
  opacity: 0; transform: translateY(-16px) scale(1.15);
  transition: opacity 0.1s, transform 0.12s var(--ease-pop), border-color 0.1s, background 0.1s, box-shadow 0.1s;
  position: relative;
}
.hand.slammed { opacity: 1; transform: translateY(0) scale(1); }
.hand.player { border-color: var(--coral); }
.hand.player::after {
  content: "YOU"; position: absolute; right: -38px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 800; color: var(--coral); letter-spacing: 1px;
}
.hand.counted { background: rgba(62, 230, 224, 0.18); box-shadow: 0 0 12px rgba(62, 230, 224, 0.5); }
.hand.landed-safe { background: rgba(124, 245, 196, 0.25); border-color: var(--mint); box-shadow: 0 0 18px rgba(124, 245, 196, 0.7); }
.hand.landed-bust { background: rgba(255, 107, 94, 0.3); border-color: var(--coral); box-shadow: 0 0 18px rgba(255, 107, 94, 0.8); }
#reveal-number {
  position: absolute; top: 16%;
  font-size: 54px; font-weight: 800; color: var(--lemon);
  text-shadow: 0 0 26px rgba(255, 233, 74, 0.8);
  animation: stamp 0.2s var(--ease-pop);
}
#reveal-result {
  position: absolute; bottom: 14%;
  font-size: 22px; font-weight: 800; letter-spacing: 1px;
  padding: 8px 22px; border-radius: 12px;
  animation: stamp 0.18s var(--ease-pop);
  text-align: center;
}
#reveal-result.good { background: rgba(124, 245, 196, 0.15); color: var(--mint); border: 1px solid var(--mint); }
#reveal-result.bad  { background: rgba(255, 107, 94, 0.15); color: var(--coral); border: 1px solid var(--coral); }
@keyframes stamp { from { transform: scale(1.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- Bust ritual --- */
#bust-overlay { background: radial-gradient(circle at 50% 45%, rgba(255, 107, 94, 0.30), rgba(11, 11, 15, 0.94) 65%); }
#bust-card { text-align: center; }
#bust-glyph { font-size: 40px; }
#bust-title { font-size: 24px; font-weight: 800; color: var(--coral); letter-spacing: 2px; margin: 4px 0 10px; }
#bust-soju { font-size: 56px; animation: soju-tip 0.7s 0.25s var(--ease-pop) both; }
@keyframes soju-tip { 0% { transform: rotate(0); } 60% { transform: rotate(-42deg) translateY(-6px); } 100% { transform: rotate(-38deg); } }
#bust-oneshot {
  font-size: 30px; font-weight: 800; color: var(--white);
  text-shadow: 0 0 24px rgba(255, 107, 94, 0.9);
  margin-top: 8px; animation: stamp 0.25s 0.55s var(--ease-pop) both;
}
#bust-note { font-size: 12px; color: var(--text2); margin-top: 10px; }

/* --- Floor-12 decision --- */
#decision-card {
  width: min(92%, 360px);
  background: var(--bg2); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 18px 16px; text-align: center;
  animation: modal-in 0.22s var(--ease-out);
}
@keyframes modal-in { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.decision-head { font-size: 11px; letter-spacing: 2px; color: var(--purple); font-weight: 800; }
.decision-sub { font-size: 15px; color: var(--text2); margin-top: 6px; }
#decision-mult { font-size: 42px; font-weight: 800; color: var(--cyan); text-shadow: 0 0 22px rgba(62, 230, 224, 0.5); }
#decision-value { font-size: 14px; color: var(--white); margin-bottom: 14px; }
#btn-decision-bank {
  width: 100%; padding: 14px; border-radius: 12px;
  background: var(--grad-bank); color: var(--black);
  font-size: 18px; font-weight: 800;
  margin-bottom: 10px;
}
#btn-decision-rooftop {
  width: 100%; padding: 12px; border-radius: 12px;
  background: var(--grad-rooftop);
  font-size: 16px; font-weight: 800;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.rooftop-odds { font-size: 11px; font-weight: 600; opacity: 0.95; }
.rooftop-warn { font-size: 10px; font-weight: 500; opacity: 0.85; }
.decision-quote { font-size: 11px; color: var(--text2); font-style: italic; margin-top: 12px; }
.decision-notimer { font-size: 10px; color: var(--text-dis); margin-top: 4px; }

/* --- Encore Wheel --- */
#wheel-scene { text-align: center; width: min(92%, 360px); }
.wheel-head { font-size: 12px; letter-spacing: 3px; font-weight: 800; color: var(--pink); margin-bottom: 10px; }
#wheel-pointer { color: var(--lemon); font-size: 26px; line-height: 0.8; text-shadow: 0 0 12px rgba(255, 233, 74, 0.8); position: relative; z-index: 2; }
#wheel-disc-wrap { position: relative; width: 260px; height: 260px; margin: -4px auto 10px; }
#wheel-disc {
  width: 100%; height: 100%; border-radius: 50%;
  border: 5px solid var(--purple);
  box-shadow: 0 0 30px rgba(138, 92, 255, 0.45), inset 0 0 24px rgba(0, 0, 0, 0.5);
  position: relative; overflow: hidden;
  /* segments drawn by JS conic-gradient */
}
.wheel-label {
  position: absolute; left: 50%; top: 50%;
  font-weight: 800; font-size: 17px; color: var(--white);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  transform-origin: 0 0;
}
#wheel-hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg1); border: 3px solid var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: var(--purple);
  z-index: 2;
}
.wheel-odds { font-size: 11px; color: var(--text2); }
.wheel-ev { color: var(--cyan); }
#wheel-staked { font-size: 13px; font-weight: 700; color: var(--lemon); margin: 8px 0 12px; }
#btn-spin, #btn-wheel-continue {
  padding: 13px 60px; border-radius: 12px;
  background: var(--grad-rooftop);
  font-size: 18px; font-weight: 800; letter-spacing: 2px;
  box-shadow: 0 4px 18px rgba(255, 62, 154, 0.35);
}
#btn-wheel-continue { background: var(--grad-bank); color: var(--black); margin-top: 10px; }
#wheel-result {
  margin-top: 10px; font-size: 20px; font-weight: 800;
  padding: 10px 16px; border-radius: 12px; display: inline-block;
  animation: stamp 0.2s var(--ease-pop);
}
#wheel-result.good { background: rgba(124, 245, 196, 0.15); color: var(--mint); border: 1px solid var(--mint); }
#wheel-result.bad { background: rgba(255, 107, 94, 0.12); color: var(--coral); border: 1px solid var(--coral); }

/* --- Celebration --- */
#celebrate-overlay { background: rgba(11, 11, 15, 0.78); }
#celebrate-card { text-align: center; z-index: 2; animation: stamp 0.25s var(--ease-pop); }
#celebrate-title { font-size: 16px; letter-spacing: 4px; font-weight: 800; color: var(--mint); }
#celebrate-title.gold { color: var(--lemon); text-shadow: 0 0 26px rgba(255, 233, 74, 0.8); font-size: 22px; }
#celebrate-mult { font-size: 52px; font-weight: 800; color: var(--white); margin: 4px 0; }
#celebrate-amount { font-size: 24px; font-weight: 700; color: var(--mint); }
#confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetto {
  position: absolute; top: -12px;
  width: 8px; height: 12px; border-radius: 2px;
  animation: confetti-fall linear both;
}
@keyframes confetti-fall {
  from { transform: translateY(-5vh) rotate(0turn); }
  to   { transform: translateY(108vh) rotate(3turn); }
}

/* --- Toast --- */
#toast {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 220px; z-index: 30;
  background: var(--bg3); border: 1px solid var(--stroke);
  color: var(--white); font-size: 12px; font-weight: 600;
  padding: 9px 16px; border-radius: 20px;
  max-width: 88%; text-align: center;
  animation: toast-in 0.2s var(--ease-out);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* --- Info panel --- */
#info-overlay { align-items: stretch; justify-content: flex-end; }
#info-panel {
  background: var(--bg2); border-top: 1px solid var(--stroke);
  border-radius: 18px 18px 0 0;
  max-height: 86%;
  display: flex; flex-direction: column;
  animation: sheet-in 0.24s var(--ease-out);
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
#info-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  font-weight: 800; letter-spacing: 2px; font-size: 13px;
  border-bottom: 1px solid var(--stroke);
}
#info-body { overflow-y: auto; padding: 12px 16px 26px; font-size: 13px; color: var(--text2); line-height: 1.55; }
#info-body h3 { color: var(--white); font-size: 13px; letter-spacing: 1px; margin: 14px 0 6px; }
#info-body h3:first-child { margin-top: 0; }
#info-body table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
#info-body th, #info-body td {
  text-align: left; padding: 4px 6px; font-size: 12px;
  border-bottom: 1px solid #22222c;
}
#info-body th { color: var(--text-dis); font-weight: 600; }
#info-body td:last-child, #info-body th:last-child { text-align: right; }
#info-ladder-table td:nth-child(2) { color: var(--cyan); font-weight: 700; }
#info-body p { margin: 6px 0; }
#info-body strong { color: var(--white); }
#btn-reset-balance {
  background: var(--bg3); border: 1px solid var(--stroke); border-radius: 8px;
  padding: 8px 14px; font-size: 12px; color: var(--text2);
}

/* ===================== DESKTOP ============================================ */
@media (min-width: 700px) {
  #app { max-width: 480px; border-left: 1px solid var(--stroke); border-right: 1px solid var(--stroke); }
}

/* ===================== REDUCED MOTION ===================================== */
@media (prefers-reduced-motion: reduce) {
  #reveal-chant { animation: none; }
  .confetto { display: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  #wheel-disc { transition: none !important; }
}
