/* Senko-hanabi app chrome. Palette: night indigo + ember orange.
   Text tokens keep >= 4.5:1 contrast on --bg; verified by unit tests. */
:root {
  --bg: #0b0a18;
  --panel: rgb(16 15 32 / 0.88);
  --line: rgb(255 180 90 / 0.22);
  --text: #f2ede4;
  --dim: #cfc4b0;
  --ember: #ffb45a;
  --ember-strong: #ff8a1a;
  --cool: #8fa2ff;
  --radius: 14px;
}

.app {
  position: relative;
  min-height: calc(100dvh - 56px);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text);
  font-family: inherit;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.panel {
  position: relative;
  z-index: 2;
  max-width: min(560px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.45);
}

.title-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(20px, 4.6vw, 30px);
  line-height: 1.15;
}

.lead {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.6;
}

.mode-pick {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 14px 0 6px;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-card {
  text-align: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 150 60 / 0.06);
  color: var(--text);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  min-height: 44px;
  transition:
    border-color 120ms,
    background 120ms;
}

.mode-card span {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.45;
}

.mode-card[aria-pressed='true'] {
  border-color: var(--ember);
  background: rgb(255 160 60 / 0.16);
  box-shadow: 0 0 0 1px var(--ember) inset;
}

.mode-card.small {
  min-height: 40px;
  text-align: center;
}

.warn {
  color: var(--ember);
  font-size: 12px;
  margin: 8px 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.05);
  color: var(--text);
  font: inherit;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 44px;
}

button.primary {
  background: linear-gradient(180deg, #ff9c33, #d96a0d);
  border-color: #ffb45a;
  color: #1a0d02;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cool);
  outline-offset: 2px;
}

.hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--dim);
}

/* Burning HUD */
.hud {
  position: absolute;
  z-index: 3;
  top: max(10px, env(safe-area-inset-top));
  inset-inline: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.hud-chip {
  background: rgb(10 9 24 / 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--dim);
}

.hud-chip b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.mode-chip {
  color: var(--ember);
}

/* Result */
.result-panel h2 {
  margin: 0 0 10px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 6px;
}

.result-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.result-grid dt {
  font-size: 11px;
  color: var(--dim);
}

.result-grid dd {
  margin: 2px 0 0;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

/* Drawers */
.drawer {
  position: absolute;
  z-index: 4;
  inset-inline: 16px;
  top: 50%;
  transform: translateY(-50%);
  margin-inline: auto;
  max-height: min(78dvh, 560px);
  overflow: auto;
}

.stats-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stat-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.stat-block p {
  margin: 2px 0;
  font-size: 13px;
}

.stat-block h4 {
  font-size: 11px;
  color: var(--dim);
  margin: 10px 0 4px;
  letter-spacing: 0.06em;
}

.hist {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  height: 74px;
  align-items: end;
}

.hist-col {
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100%;
  align-items: end;
}

.hist-bar {
  background: linear-gradient(180deg, var(--ember), rgb(255 120 20 / 0.35));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.hist-label {
  font-size: 9px;
  color: var(--dim);
  text-align: center;
}

/* Controls */
.controls {
  position: absolute;
  z-index: 3;
  bottom: max(10px, env(safe-area-inset-bottom));
  inset-inline: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-inline: 12px;
}

.controls button,
.controls .vol {
  min-height: 40px;
  font-size: 12px;
  padding: 6px 12px;
  background: rgb(10 9 24 / 0.72);
}

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--dim);
}

.vol input {
  width: 90px;
  accent-color: var(--ember);
}

.engine-tag {
  position: absolute;
  z-index: 2;
  right: 10px;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 56px));
  font-size: 10px;
  color: rgb(255 255 255 / 0.45);
  margin: 0;
}

.boot-panel {
  font-size: 14px;
  color: var(--dim);
}

/* Small screens / landscape iPhone */
@media (max-width: 620px) {
  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-cols {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 480px) {
  .panel {
    padding: 12px 14px;
  }
  .title-panel h1 {
    font-size: 18px;
  }
  .lead {
    display: none;
  }
  .mode-card span {
    display: none;
  }
  .hud {
    justify-content: flex-start;
    padding-inline-start: 8px;
  }
}
