/* Layout */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e2330;
  --text: #e8e8e8;
  --muted: #a9b0c0;
  --accent: #7aa2ff;
  --danger: #ff5a67;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: linear-gradient(180deg, #0f1115, #0b0d12);
  color: var(--text);
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(23, 26, 33, .9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  position: sticky;
  top: 10px;
  z-index: 5;
}

.title {
  font-weight: 800;
  letter-spacing: .04em;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(30, 35, 48, .9);
}

.hud-label {
  color: var(--muted);
  font-size: 12px;
}

.hp {
  font-size: 16px;
  white-space: nowrap;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: grid;
  grid-template-columns: 42px 160px 44px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1;
}

.bar-name {
  color: var(--muted);
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  outline: 1px solid rgba(255, 255, 255, .10);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, .75);
  transform-origin: left center;
  transform: scaleX(1);
}

.bar-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #fff;
  opacity: .85;
}

.stage {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 14px;
  margin-top: 14px;
}

#gameCanvas {
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: #111420;
  outline: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
  touch-action: none;
}

.help {
  border-radius: 16px;
  background: rgba(23, 26, 33, .9);
  outline: 1px solid rgba(255, 255, 255, .08);
  padding: 12px 14px;
  height: fit-content;
}

.help-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: #dbe2ff;
}

.help ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.footer {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* Dialogue */
.dialogue {
  position: absolute;
  z-index: 10;
  left: calc((100% - 640px) / 2);
  top: calc(14px + 54px + 14px);
  /* topbar approx */
  width: 640px;
  max-width: calc(100% - 28px);
  transform: translateY(450px);
  /* place over bottom part of canvas */
  background: rgba(23, 26, 33, .95);
  border-radius: 16px;
  padding: 12px 12px 10px;
  outline: 1px solid rgba(255, 255, 255, .10);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  pointer-events: auto;
}

.hidden {
  display: none;
}

.dialogue-text {
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(30, 35, 48, .65);
  outline: 1px solid rgba(255, 255, 255, .06);
  max-height: 300px;
  overflow: auto;
}

/* Choices */
.choice-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.choice-btn {
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(122, 162, 255, .12);
  outline: 1px solid rgba(122, 162, 255, .25);
  color: var(--text);
  cursor: pointer;
  transition: transform .05s ease, background .15s ease;
  font-size: 16px;
  line-height: 1.35;
}

.choice-btn:hover {
  background: rgba(122, 162, 255, .18);
}

.choice-btn:active {
  transform: translateY(1px);
}

.choice-btn.selected {
  outline: 2px solid rgba(122, 162, 255, .55);
}

/* Touch bar removed */

@media (max-width: 920px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .help {
    order: 2;
  }

  .dialogue {
    left: 14px;
    width: calc(100% - 28px);
    transform: translateY(0);
    bottom: 14px;
    top: auto;
    position: fixed;
  }
}