:root {
  color-scheme: dark;
  --ink: #14110e;
  --panel: #221c17;
  --panel-2: #2c241d;
  --line: #4a3d32;
  --paper: #f3ead7;
  --muted: #b3a28c;
  --gold: #e2b657;
  --cinnabar: #d85a3a;
  --good: #9dcfb2;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, p { margin: 0; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 0%, #3a2a22 0%, transparent 42%),
    #0c0b09;
  color: var(--paper);
}

#app {
  width: min(430px, 100vw);
  height: min(920px, 100dvh);
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--ink);
  overflow: hidden;
  border: 1px solid #3c332b;
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

#hud, #hero-bar, #dock {
  min-width: 0;
  background: var(--panel);
}

#hud { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.hud-top { display: grid; grid-template-columns: 72px 1fr 72px; gap: 10px; align-items: center; }
.kicker { color: var(--muted); font-size: 12px; }
.strong { font-size: 22px; font-weight: 750; letter-spacing: 0.02em; }
.gold-readout { text-align: right; }
.core-line { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bar, .energy {
  height: 8px;
  background: #3a3128;
  border-radius: 99px;
  overflow: hidden;
}
#core-bar { width: 100%; height: 100%; background: linear-gradient(90deg, #e07a3a, #f0c56d); }
.hud-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}
.bond-on { color: var(--gold); }
#gem-bonds { display: flex; flex-direction: column; gap: 8px; }
#gem-bonds p { color: var(--muted); font-size: 13px; line-height: 1.5; }
#gem-bonds b { display: block; color: var(--paper); }
#gem-bonds .bond-on b { color: var(--gold); }

#stage { min-width: 0; min-height: 0; background: #100e0c; overflow: hidden; }
#board { width: 100%; height: 100%; display: block; touch-action: none; }

#hero-bar {
  display: grid;
  grid-template-columns: 1fr 88px auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}
#hero-name { font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
#energy-bar { width: 0%; height: 100%; background: #7eb6ff; }
#btn-ult {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #3d4e68;
  color: var(--paper);
  font: inherit;
}
#btn-ult:not(:disabled) {
  background: #d85a3a;
  color: #fff8f2;
}

#dock { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
#chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip, #btn-rotate, .inspect-actions button, #btn-wave, .screen button, .choice, .gem-item, .gem-slot, .draft-card {
  font: inherit;
  color: var(--paper);
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
}
.chip {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 8px 10px;
  text-align: left;
}
.chip span, .chip small { display: block; }
.chip small, .gem-item small, .gem-slot small { color: var(--muted); font-size: 11px; }
.choice span, .draft-card span { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
.chip.on { border-color: var(--gold); background: #3a2e1d; }
#btn-rotate { padding: 8px 10px; align-self: flex-start; }
#tip { min-height: 2.6em; color: var(--muted); font-size: 12px; line-height: 1.45; }
#btn-wave, .primary {
  border: 0;
  background: var(--cinnabar);
  color: #fff8f2;
  font-weight: 700;
}
#btn-wave { padding: 12px 14px; border-radius: 14px; font-size: 16px; }
#btn-wave:disabled { background: #4a342c; color: #c8b09f; }

#inspect { display: flex; flex-direction: column; gap: 8px; }
.inspect-copy { display: flex; flex-direction: column; gap: 2px; }
.inspect-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inspect-actions button { padding: 10px 8px; }
#inspect-meta { color: var(--muted); font-size: 12px; }

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 20px 24px;
  background: rgba(20, 17, 14, 0.96);
  overflow: auto;
}
.screen.dim { background: rgba(12, 10, 8, 0.94); justify-content: center; }
.screen-head { display: flex; align-items: center; gap: 12px; }
.screen-head h1, .screen h1 { font-family: "Songti SC", "STSong", "PingFang SC", serif; font-size: 40px; line-height: 1.1; margin: 0; }
.screen-head h1 { font-size: 28px; }
.screen-body { display: flex; flex-direction: column; gap: 10px; }
.eyebrow { color: var(--gold); letter-spacing: 0.18em; font-size: 12px; }
.pitch { font-size: 16px; line-height: 1.55; white-space: pre-wrap; }
.fine { color: var(--muted); font-size: 12px; line-height: 1.5; }
.menu-stats { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.screen button { padding: 12px 14px; text-align: left; }
.screen button.primary {
  background: var(--cinnabar);
  color: #fff8f2;
  border: 0;
  text-align: center;
  font-weight: 700;
}
.choice-grid, #draft-cards, #gem-list, #gem-slots { display: flex; flex-direction: column; gap: 8px; }
.choice, .draft-card, .gem-item, .gem-slot { padding: 12px; text-align: left; }
.choice b, .draft-card b, .gem-item b, .gem-slot b { display: block; margin-bottom: 4px; }
.choice.on, .gem-item.on { border-color: var(--gold); }
#gem-slots { display: grid; grid-template-columns: 1fr 1fr; }
h2 { margin: 8px 0 0; font-size: 15px; color: var(--gold); font-weight: 650; }

#toast {
  position: absolute;
  left: 50%;
  bottom: 168px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f3ead7;
  color: #24180f;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

#app[data-mode="menu"] #hud,
#app[data-mode="menu"] #hero-bar,
#app[data-mode="menu"] #dock { display: none; }
#app[data-mode="menu"] { grid-template-rows: 1fr; }
#app[data-mode="menu"] #stage { display: none; }
