:root {
  --timber: #6b4326;
  --iron: #2b2e33;
  --parchment: #f3e6c8;
  --ink: #1c1610;
  --blue: #1d3f78;
  --gold: #c9a227;
  --accent: #e07a2f;
  --panel: rgba(28, 22, 16, 0.78);
  --line: rgba(243, 230, 200, 0.22);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --panel: rgba(243, 230, 200, 0.88);
    --ink: #1c1610;
    --line: rgba(28, 22, 16, 0.16);
  }
  .panel, .controls, .tuning {
    color: var(--ink);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #1a1612;
  color: var(--parchment);
  overflow: hidden;
}
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.panel, .controls, .tuning {
  position: fixed;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--parchment);
  padding: 10px 12px;
  font-size: 13px;
  letter-spacing: 0.01em;
  backdrop-filter: blur(6px);
}
.panel h2, .tuning h2 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  font-weight: 600;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.45;
}
.row span { opacity: 0.72; }
.row b { font-weight: 600; }
.setup { top: 12px; left: 12px; width: min(280px, 32vw); }
.result { top: 12px; right: 12px; width: min(280px, 32vw); }
.energy { bottom: 88px; left: 12px; width: min(260px, 34vw); }
.controls {
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--gold);
  background: #2a2118;
  color: var(--parchment);
  padding: 8px 12px;
  min-height: 40px;
}
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#btn-fire {
  background: var(--accent);
  color: #1c1610;
  font-size: 18px;
  font-weight: 700;
  min-width: 108px;
  border-color: #f0b27a;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.hint { font-size: 11px; opacity: 0.7; padding: 0 6px; }
.tuning {
  top: 268px;
  right: 12px;
  left: auto;
  transform: none;
  width: min(280px, 32vw);
  max-height: calc(100vh - 360px);
  overflow: auto;
}
.slider {
  display: grid;
  grid-template-columns: 92px 1fr 70px;
  gap: 6px;
  align-items: center;
  margin: 2px 0;
  font-size: 11px;
}
.slider input { width: 100%; }
details { margin-top: 8px; }
#tuning-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
}
@media (max-width: 759px) {
  .setup { display: none; }
  .result { width: calc(100% - 16px); left: 8px; right: 8px; font-size: 11px; }
  .tuning {
    display: none;
    top: auto;
    bottom: 78px;
    width: calc(100% - 20px);
    max-height: 46vh;
    transform: none;
    left: 10px;
    right: 10px;
  }
  .tuning.open { display: block; }
  #tuning-toggle {
    display: block;
    top: auto;
    bottom: 14px;
    right: 10px;
    left: auto;
    transform: none;
  }
  .energy { display: none; }
  .controls { width: calc(100% - 96px); left: 8px; transform: none; justify-content: flex-start; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
