:root {
  --bg: #0b0a08;
  --bg-alt: #111009;
  --ink: #ffffff;
  --ink-dim: #b3b3b3;
  --gold: #af9128;
  --gold-bright: #c9a83e;
  --line: color-mix(in srgb, var(--ink) 18%, transparent);
  --serif: 'Cinzel', serif;
  --sans: 'Literata', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: var(--gold-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.4rem, 3.4vw, 2.1rem);
  letter-spacing: 0.14em;
  margin: 0;
  color: var(--gold-bright);
  text-transform: uppercase;
}

.subtitle {
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 4px 0 0;
}

.back {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- stage ---------- */
#stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border: 1px solid var(--line);
  padding: 10px;
  min-height: 200px;
}

#stage:fullscreen { padding: 0; border: 0; }

#screen {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  touch-action: none;
  outline: none;
  cursor: crosshair;
}

#screen:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--gold);
}

/* ---------- control bar ---------- */
.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}

.bar button {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
  min-height: 40px;
}

.bar button:hover { border-color: var(--gold); color: var(--gold-bright); }

.bar button.is-active {
  border-color: var(--gold-bright);
  color: #120e05;
  background: var(--gold-bright);
  font-weight: 600;
}

.bar .sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}

/* Hold-to-act buttons must never linger in a "pressed" look after release. */
.bar button.hold { user-select: none; -webkit-user-select: none; }
.bar button.hold.is-active { background: var(--gold-bright); border-color: var(--gold-bright); color: #120e05; }

.weapon-fire.is-active { background: #e08a2a; border-color: #e08a2a; }
.weapon-frost.is-active { background: #8ed3f2; border-color: #8ed3f2; }
.weapon-storm.is-active { background: #b48ae8; border-color: #b48ae8; }

/* ---------- help ---------- */
.help {
  margin: 22px auto 0;
  max-width: 720px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--ink-dim);
  font-size: 0.9rem;
  line-height: 1.7;
}

.help h2 {
  font-family: var(--serif);
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 10px;
}

.help dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 18px;
  margin: 0 0 16px;
}

.help dt {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.help dd { margin: 0; }

.help .note { margin: 0; font-size: 0.84rem; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  background: var(--bg-alt);
  color: var(--ink);
}

@media (max-width: 560px) {
  .wrap { padding: 14px 12px 32px; }
  #stage { padding: 6px; }
  /* The divider only makes sense while the row is unwrapped. */
  .bar .sep { display: none; }
  .bar { gap: 6px; }
  .bar button { padding: 9px 10px; font-size: 0.72rem; letter-spacing: 0.06em; }
  .help dl { grid-template-columns: 1fr; gap: 2px 0; }
  .help dt { margin-top: 8px; }
}

/* On touch devices the on-screen hints matter more than the key list. */
.touch-only { display: none; }

@media (hover: none) and (pointer: coarse) {
  .touch-only { display: block; }
  .key-only { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
