:root {
  --bg: #1e293b;
  --frame-bg: #fdf8ef;
  --panel-bg: #f5ebd8;
  --border: #d6c3a5;
  --text: #292524;
  --muted: #78716c;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --hp: #22c55e;
  --common: #94a3b8;
  --rare: #0284c7;
  --epic: #9333ea;
  --legendary: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top, #334155, #0f172a);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

.app-shell {
  width: 100%;
  max-width: 460px;
}

.game-frame {
  background: var(--frame-bg);
  border: 3px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: min(92vh, 790px);
}

/* Top HUD */
.top-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--panel-bg);
  border-bottom: 2px solid var(--border);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-badge {
  background: #78350f;
  color: #fef3c7;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.day-label {
  font-weight: 800;
  font-size: 15px;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gold-pill {
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  color: #92400e;
  font-weight: 700;
  font-size: 13px;
  padding: 3px 9px;
  border-radius: 999px;
}

.icon-btn {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}

.icon-btn:hover {
  background: #fef3c7;
}

.icon-btn.active {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fff;
}

.icon-btn.active:hover {
  background: var(--accent-hover);
}

/* Canvas Stage */
.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 440 / 230;
  background: #7dd3fc;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

#stage-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.stage-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.82);
  color: #fef08a;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Status Panel */
.status-panel {
  padding: 10px 14px;
  background: var(--panel-bg);
  border-bottom: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-bar-bg {
  position: relative;
  flex: 1;
  height: 22px;
  background: #e7e5e4;
  border-radius: 999px;
  border: 1.5px solid #a8a29e;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transition: width 0.2s ease;
}

.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #052e16;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.shield-badge {
  background: #e0f2fe;
  border: 1.5px solid #38bdf8;
  color: #0369a1;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.stats-strip {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #44403c;
}

.skills-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 26px;
  align-items: center;
}

.skills-empty {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #fff;
  border: 1.5px solid var(--common);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
}

.skill-chip.rare { border-color: var(--rare); background: #f0f9ff; }
.skill-chip.epic { border-color: var(--epic); background: #faf5ff; }
.skill-chip.legendary { border-color: var(--legendary); background: #fffbeb; }

/* Adventure Log */
.adventure-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  background: #fff;
  border: 1.5px solid #e7e5e4;
  border-left: 4px solid #a8a29e;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.38;
}

.log-entry.combat { border-left-color: #ef4444; }
.log-entry.event { border-left-color: #38bdf8; }
.log-entry.reward { border-left-color: #f59e0b; background: #fffbeb; }
.log-entry.heal { border-left-color: #22c55e; background: #f0fdf4; }
.log-entry.boss { border-left-color: #be123c; background: #fff1f2; font-weight: 600; }

.log-day {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  margin-right: 6px;
  text-transform: uppercase;
}

/* Action Area */
.action-area {
  padding: 12px 14px;
  background: var(--panel-bg);
  border-top: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.primary-btn,
.choice-btn,
.secondary-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 0 #9a3412;
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.primary-btn:active:not(:disabled),
.choice-btn:active:not(:disabled) {
  transform: translateY(2px);
}

.primary-btn:disabled,
.choice-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
}

.choice-btn {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  padding: 10px 12px;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #fff7ed;
}

.choice-hint {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  margin-left: 8px;
  white-space: nowrap;
}

.auto-status {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hover);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  z-index: 20;
}

.hidden {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--frame-bg);
  border: 3px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-card h2 {
  margin: 0;
  font-size: 19px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.draft-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draft-card {
  background: #fff;
  border: 2px solid var(--common);
  border-radius: 12px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.draft-card.rare { border-color: var(--rare); background: #f0f9ff; }
.draft-card.epic { border-color: var(--epic); background: #faf5ff; }
.draft-card.legendary { border-color: var(--legendary); background: #fffbeb; }

.draft-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.draft-icon {
  font-size: 26px;
  line-height: 1;
}

.draft-body {
  flex: 1;
}

.draft-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 14px;
}

.rarity-tag {
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
}

.draft-desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: #57534e;
}

.talents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.talent-row {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.talent-info strong {
  font-size: 14px;
}

.talent-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.talent-buy-btn {
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.talent-buy-btn:disabled {
  background: #d6d3d1;
  cursor: not-allowed;
}

.summary-stats {
  background: var(--panel-bg);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.summary-actions {
  display: flex;
  gap: 8px;
}
