/* ==========================================================================
   Bungeoppang Tycoon — game.css
   ========================================================================== */

:root {
  --bt-bg: #0f172a;
  --bt-bg2: #1e293b;
  --bt-amber: #ffb347;
  --bt-amber-deep: #d97706;
  --bt-ink: #1f2937;
  --bt-muted: #6b7280;
  --bt-soft: #f3f4f6;
  --bt-accent: #a855f7;
  --bt-ok: #10b981;
  --bt-bad: #ef4444;
  --bt-card: #ffffff;
}

body.bt-body {
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: var(--bt-ink);
}

/* ==========================================================================
   Intro
   ========================================================================== */
.bt-intro-hero { text-align: center; padding: 24px 0 12px; }
.bt-intro-marks { font-size: 28px; letter-spacing: 8px; }
.bt-intro-title { font-size: 30px; font-weight: 900; color: var(--bt-amber-deep); margin-top: 8px; }
.bt-intro-lede { color: var(--bt-muted); margin-top: 8px; font-size: 14px; line-height: 1.5; }

.bt-card {
  background: var(--bt-card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  margin-top: 16px;
}
.bt-card-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; }

.bt-rules { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.bt-rules li { display: flex; align-items: center; gap: 10px; }
.bt-icon { font-size: 20px; width: 28px; text-align: center; }

.bt-cta-group { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.bt-cta {
  display: block; text-align: center; padding: 14px 20px; border-radius: 12px;
  font-weight: 700; font-size: 16px; text-decoration: none;
  transition: transform 100ms ease, filter 100ms ease;
}
.bt-cta:active { transform: scale(0.98); }
.bt-cta-primary { background: var(--bt-amber-deep); color: #fff; }
.bt-cta-secondary { background: var(--bt-soft); color: var(--bt-ink); border: 1px solid #e5e7eb; }

/* Leaderboard */
.bt-leaderboard .bt-lb-tabs, .bt-leaderboard .bt-lb-charfilter {
  display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.bt-lb-tab, .bt-lb-char {
  border: 1px solid #e5e7eb; background: #fff; color: var(--bt-muted);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.bt-lb-tab.is-active, .bt-lb-char.is-active {
  background: var(--bt-ink); color: #fff; border-color: var(--bt-ink);
}

.bt-top-list { list-style: none; padding: 0; margin: 0; }
.bt-top-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto auto auto;
  gap: 8px; align-items: center;
  padding: 8px 4px; border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.bt-top-rank { font-weight: 800; color: var(--bt-amber-deep); }
.bt-top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-top-char { font-size: 11px; color: var(--bt-muted); }
.bt-top-branch { font-size: 11px; color: var(--bt-accent); font-weight: 700; }
.bt-top-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.bt-top-empty { color: var(--bt-muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* ==========================================================================
   Choose Character
   ========================================================================== */
.bt-choose-hero { text-align: center; padding: 16px 0 8px; }
.bt-choose-title { font-size: 22px; font-weight: 900; color: var(--bt-amber-deep); }
.bt-choose-lede { color: var(--bt-muted); margin-top: 6px; font-size: 13px; }

.bt-choose-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.bt-choose-card {
  width: 100%; text-align: left; background: var(--bt-card);
  border: 2px solid transparent; border-radius: 18px; padding: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  display: grid; grid-template-columns: 80px 1fr; gap: 12px;
  cursor: pointer; transition: border-color 120ms ease, transform 100ms ease;
}
.bt-choose-card:hover { border-color: var(--bt-amber); }
.bt-choose-card:active { transform: scale(0.99); }

.bt-choose-portrait {
  width: 80px; height: 96px; border-radius: 12px;
  background: linear-gradient(180deg, #fef3c7, #fde68a);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.bt-choose-portrait img { width: 100%; height: 100%; object-fit: cover; }

.bt-choose-body { min-width: 0; }
.bt-choose-name { font-weight: 800; font-size: 17px; }
.bt-choose-age { color: var(--bt-muted); font-size: 12px; font-weight: 500; margin-left: 4px; }
.bt-choose-tagline { color: var(--bt-amber-deep); font-size: 13px; font-weight: 600; margin-top: 2px; }
.bt-choose-bg { color: var(--bt-muted); font-size: 12px; line-height: 1.5; margin-top: 4px; }

.bt-choose-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.bt-choose-stats > div { background: var(--bt-soft); border-radius: 8px; padding: 6px; text-align: center; }
.bt-choose-stats dt { font-size: 10px; color: var(--bt-muted); }
.bt-choose-stats dd { font-size: 12px; font-weight: 700; margin: 0; }

/* ==========================================================================
   Play field
   ========================================================================== */
.bt-root {
  position: relative; padding-bottom: 80px;
}

/* HUD */
.bt-hud {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 8px; padding: 10px 4px; margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  font-size: 14px; font-weight: 700;
}
.bt-hud-left { padding-left: 10px; }
.bt-hud-center { display: flex; gap: 10px; justify-content: center; }
.bt-hud-right { text-align: right; padding-right: 10px; }
.bt-hud-money { color: var(--bt-amber-deep); font-variant-numeric: tabular-nums; }
.bt-hud-day { color: var(--bt-ink); }
.bt-hud-rep { color: var(--bt-accent); }
.bt-hud-event {
  display: inline-block; background: #fff7ed; color: var(--bt-amber-deep);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}

/* Field */
.bt-field {
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, var(--bt-bg) 0%, var(--bt-bg2) 100%);
  border-radius: 16px; padding: 12px; min-height: 380px;
  color: #fff;
}

/* 손님 대기열 */
.bt-customers {
  display: flex; gap: 6px; height: 56px; align-items: flex-end;
  padding: 4px; overflow-x: auto;
}
.bt-customer {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 48px; flex-shrink: 0;
  animation: bt-customer-enter 260ms ease-out;
}
.bt-customer-emoji { font-size: 28px; line-height: 1; }
.bt-customer-want {
  font-size: 10px; background: rgba(255, 255, 255, 0.12);
  padding: 1px 4px; border-radius: 6px;
}
.bt-customer-bar {
  width: 44px; height: 3px; background: rgba(255, 255, 255, 0.15);
  border-radius: 2px; overflow: hidden;
}
.bt-customer-bar > span {
  display: block; height: 100%; background: var(--bt-ok); transition: width 120ms linear, background-color 200ms ease;
}
.bt-customer.is-impatient .bt-customer-bar > span { background: var(--bt-bad); }

@keyframes bt-customer-enter {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 틀 그리드 */
.bt-tray {
  display: grid; gap: 6px; padding: 6px;
  background: rgba(0, 0, 0, 0.25); border-radius: 12px;
  grid-template-columns: repeat(4, 1fr);
}
.bt-tray.bt-slots-6 { grid-template-columns: repeat(3, 1fr); }
.bt-tray.bt-slots-8 { grid-template-columns: repeat(4, 1fr); }
.bt-tray.bt-slots-12 { grid-template-columns: repeat(4, 1fr); }

.bt-slot {
  aspect-ratio: 1 / 1; border-radius: 10px;
  background: #334155; border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  cursor: pointer; transition: transform 80ms ease, background-color 180ms ease;
  position: relative;
}
.bt-slot:active { transform: scale(0.94); }
.bt-slot.is-batter  { background: #7c4a2e; }
.bt-slot.is-filling { background: #8c3e2e; }
.bt-slot.is-cooking { background: #a35d2a; }
.bt-slot.is-ready   { background: #facc15; color: #422006; }
.bt-slot-label {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; background: rgba(0, 0, 0, 0.4);
  padding: 1px 4px; border-radius: 4px;
}
.bt-slot-progress {
  position: absolute; left: 4px; right: 4px; bottom: 4px; height: 3px;
  background: rgba(0, 0, 0, 0.35); border-radius: 2px; overflow: hidden;
}
.bt-slot-progress > span { display: block; height: 100%; background: var(--bt-amber); }

/* 진열대 */
.bt-display {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
  padding: 6px; background: rgba(255, 255, 255, 0.08);
  border-radius: 10px; min-height: 56px;
}
.bt-display-slot {
  aspect-ratio: 1 / 1; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.bt-display-slot.is-filled { background: #facc15; color: #422006; }

/* Drawer */
.bt-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px);
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  z-index: 20;
}
.bt-drawer-btn, .bt-close-day {
  padding: 10px 8px; border-radius: 10px; border: 0; font-weight: 700;
  font-size: 13px; cursor: pointer;
  background: var(--bt-soft); color: var(--bt-ink);
}
.bt-close-day { background: var(--bt-amber-deep); color: #fff; padding: 10px 14px; }
.bt-drawer-btn:active, .bt-close-day:active { transform: scale(0.97); }

/* Sheet / Modal */
.bt-sheet, .bt-modal {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
.bt-modal { align-items: center; }
.bt-sheet-backdrop, .bt-modal::before {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45);
}
.bt-sheet-backdrop { cursor: pointer; }
.bt-sheet-body, .bt-modal-body {
  position: relative; width: 100%; max-width: 32rem;
  background: #fff; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  max-height: 80vh; overflow-y: auto;
  animation: bt-sheet-up 220ms ease-out;
}
.bt-modal-body {
  border-radius: 18px; max-height: 85vh;
  padding: 20px; margin: 0 16px;
  animation: bt-modal-pop 220ms ease-out;
}
@keyframes bt-sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bt-modal-pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.bt-sheet-close {
  position: absolute; top: 10px; right: 12px; width: 32px; height: 32px;
  border: 0; border-radius: 999px; background: var(--bt-soft);
  font-size: 16px; cursor: pointer;
}
.bt-sheet-content h3 { font-weight: 800; font-size: 16px; margin-bottom: 12px; }

.bt-shop-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #f3f4f6;
}
.bt-shop-item h4 { font-weight: 700; font-size: 14px; }
.bt-shop-item p { color: var(--bt-muted); font-size: 12px; margin-top: 2px; }
.bt-shop-buy {
  padding: 8px 14px; border-radius: 10px; border: 0;
  background: var(--bt-amber-deep); color: #fff; font-weight: 700;
  cursor: pointer;
}
.bt-shop-buy:disabled { background: #e5e7eb; color: var(--bt-muted); cursor: not-allowed; }
.bt-shop-owned { color: var(--bt-ok); font-weight: 700; font-size: 13px; }

/* Toast */
.bt-toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 60px);
  left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 700;
  z-index: 40;
  animation: bt-toast-pop 260ms ease-out;
}
@keyframes bt-toast-pop { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Dialogue */
.bt-dialogue {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, 0.85);
  display: flex; align-items: flex-end;
}
.bt-dialogue-portrait {
  position: absolute; left: 12px; bottom: calc(40% + 16px);
  width: 128px; height: 160px; border-radius: 14px;
  background: linear-gradient(180deg, #fef3c7, #fde68a);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.bt-dialogue-portrait img { width: 100%; height: 100%; object-fit: cover; }
.bt-dlg-fallback { font-size: 72px; }

.bt-dialogue-panel {
  width: 100%; background: rgba(255, 255, 255, 0.98);
  padding: 16px 18px calc(env(safe-area-inset-bottom) + 16px);
  border-radius: 18px 18px 0 0;
  min-height: 40vh; max-height: 50vh;
  display: flex; flex-direction: column;
}
.bt-dialogue-speaker {
  font-weight: 800; color: var(--bt-amber-deep); font-size: 14px; margin-bottom: 6px;
}
.bt-dialogue-text {
  flex: 1; font-size: 16px; line-height: 1.6; color: var(--bt-ink);
  white-space: pre-wrap;
}
.bt-dialogue-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.bt-dlg-choice {
  padding: 12px 14px; border-radius: 12px; border: 2px solid var(--bt-amber);
  background: #fff7ed; color: var(--bt-ink); font-weight: 700; font-size: 14px;
  cursor: pointer; text-align: left;
}
.bt-dlg-choice:active { transform: scale(0.98); }
.bt-dialogue-next {
  align-self: flex-end; margin-top: 10px;
  padding: 8px 14px; border-radius: 10px; border: 0;
  background: var(--bt-ink); color: #fff; font-weight: 700; font-size: 13px;
  cursor: pointer;
}

/* Settlement modal */
.bt-settle h3 { font-weight: 900; font-size: 20px; color: var(--bt-amber-deep); text-align: center; }
.bt-settle-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid #f3f4f6; font-size: 14px;
}
.bt-settle-row.is-total { font-weight: 800; font-size: 16px; border-bottom: 0; margin-top: 8px; }
.bt-settle-row.is-total.is-plus { color: var(--bt-ok); }
.bt-settle-row.is-total.is-minus { color: var(--bt-bad); }
.bt-settle-next {
  display: block; width: 100%; margin-top: 14px;
  padding: 14px; border-radius: 12px; border: 0;
  background: var(--bt-amber-deep); color: #fff; font-weight: 800; font-size: 16px;
  cursor: pointer;
}

/* Nickname form */
.bt-nick-input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 2px solid #e5e7eb; font-size: 16px; margin-top: 8px;
}
.bt-nick-input:focus { outline: none; border-color: var(--bt-amber); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .bt-sheet-body, .bt-modal-body, .bt-toast, .bt-customer {
    animation: none !important;
  }
  .bt-slot { transition: none; }
}

/* Responsive */
@media (min-width: 640px) {
  .bt-hud { font-size: 15px; }
  .bt-slot { font-size: 30px; }
  .bt-customer-emoji { font-size: 34px; }
}
