:root {
  color-scheme: dark;
  --ink: #090712;
  --paper: #eee8dc;
  --red: #eb4d5c;
  --gold: #e5bd6b;
  --purple: #6b4fa0;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow-x: hidden;
  color: var(--paper);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background:
    radial-gradient(circle at 20% 10%, rgba(113, 77, 153, .22), transparent 28rem),
    radial-gradient(circle at 90% 80%, rgba(157, 48, 71, .16), transparent 32rem),
    linear-gradient(125deg, #090710, #141022 55%, #090710);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E");
}

.game-shell { width: min(100%, 780px); }

.masthead { margin-bottom: 14px; }
.eyebrow {
  margin-bottom: 2px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: .28em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font: 700 clamp(30px, 6vw, 46px)/.9 Georgia, "Times New Roman", serif;
  letter-spacing: .02em;
}
h1 span { color: var(--red); font-style: italic; }

.arcade-layout {
  display: grid;
  grid-template-columns: minmax(0, 480px) 220px;
  gap: 18px;
  align-items: start;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid rgba(229, 189, 107, .55);
  border-radius: 3px;
  background: #080611;
  box-shadow: 0 25px 70px #000a, inset 0 0 0 4px #090712, 0 0 0 1px #000;
}

canvas { display: block; width: 100%; height: 100%; }

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #000 3px 4px);
}

.boss-hud {
  position: absolute;
  z-index: 2;
  top: 13px;
  left: 18px;
  right: 18px;
  pointer-events: none;
  transition: opacity .2s;
}
.boss-hud.hidden { opacity: 0; }
.boss-hud > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.boss-hud span { color: var(--gold); font-size: 7px; letter-spacing: .14em; text-transform: uppercase; }
.boss-hud strong { overflow: hidden; color: white; font: 700 14px Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.boss-track { height: 4px; margin-top: 6px; background: rgba(255,255,255,.13); }
.boss-track i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .12s linear; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  background: radial-gradient(circle, rgba(25, 15, 45, .74), rgba(5, 4, 12, .92));
  transition: opacity .25s ease, visibility .25s;
}
.overlay.hidden { opacity: 0; visibility: hidden; }
.overlay.stage-clear-drop {
  visibility: visible;
  opacity: 1;
  animation: stage-clear-drop 1.15s cubic-bezier(.18, .78, .2, 1) both;
  background: radial-gradient(circle, rgba(25, 15, 45, .82), rgba(5, 4, 12, .94));
}
.overlay.stage-clear-drop > p:not(.overlay-kicker) { min-width: 260px; line-height: 2; }
.overlay.stage-clear-drop > p b { color: var(--gold); }
@keyframes stage-clear-drop {
  from { transform: translateY(-105%); }
  to { transform: translateY(0); }
}
.seal {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 24px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--red);
  font-size: 25px;
  box-shadow: 0 0 28px rgba(235, 77, 92, .25);
}
.overlay-kicker { margin: 0 0 8px; color: var(--gold); font-size: 9px; letter-spacing: .24em; text-transform: uppercase; }
.overlay h2 { margin: 0; font: 700 52px/1 Georgia, "Times New Roman", serif; }
.overlay > p:not(.overlay-kicker) { margin: 14px 0 26px; color: #bdb5c7; font: 12px/1.8 "SFMono-Regular", Consolas, monospace; }
.overlay button {
  padding: 12px 17px 12px 22px;
  border: 1px solid var(--red);
  border-radius: 2px;
  color: white;
  background: rgba(235, 77, 92, .12);
  font: 600 10px "SFMono-Regular", Consolas, monospace;
  letter-spacing: .15em;
  text-transform: uppercase;
  cursor: pointer;
}
.overlay button:hover { background: var(--red); }
.overlay button span { margin-left: 12px; color: var(--gold); }
.choice-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(100%, 330px); }
.choice-buttons.hidden, .single-action.hidden { display: none; }
.choice-buttons button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  padding: 12px;
  text-align: left;
  letter-spacing: 0;
}
.choice-buttons .choice-key {
  grid-row: 1 / 3;
  margin: 0 9px 0 0;
  color: var(--gold);
  font: 700 22px Georgia, serif;
}
.choice-buttons b { font: 700 15px Georgia, serif; }
.choice-buttons small { margin-top: 3px; color: #aaa1b2; font-size: 7px; letter-spacing: .06em; text-transform: uppercase; }
.choice-buttons button:last-child { border-color: #8d6bc1; background: rgba(107, 79, 160, .12); }
.choice-buttons button:last-child:hover { background: #6b4fa0; }
.difficulty-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; width: min(100%, 330px); margin-bottom: 9px; }
.difficulty-buttons.hidden { display: none; }
.difficulty-buttons button { padding: 7px 3px; border-color: #51465e; color: #82798b; font-size: 7px; letter-spacing: .06em; }
.difficulty-buttons button:hover, .difficulty-buttons button.active { border-color: var(--gold); color: var(--gold); background: rgba(229, 189, 107, .13); }
.simulation-option { display: flex; align-items: center; gap: 7px; width: min(100%, 330px); margin: 0 0 10px; color: #9990a3; font-size: 8px; cursor: pointer; }
.simulation-option.hidden { display: none; }
.simulation-option input { accent-color: var(--gold); }

.status-panel {
  min-height: 520px;
  padding: 18px;
  border-top: 1px solid rgba(229, 189, 107, .45);
  border-bottom: 1px solid rgba(229, 189, 107, .2);
  background: linear-gradient(180deg, rgba(255,255,255,.035), transparent);
}
.stat { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 13px; }
.stat span { color: #91899b; font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.stat strong { color: var(--gold); font-size: 14px; letter-spacing: .06em; }
.top-stat strong { color: white; font-size: 19px; }
.split-stat strong { color: var(--red); font-size: 12px; letter-spacing: .18em; }
.perf-stat strong { color: #8ddcf1; font-size: 9px; letter-spacing: .04em; }
.divider { display: flex; align-items: center; gap: 9px; margin: 21px 0; color: var(--gold); }
.divider i { flex: 1; height: 1px; background: rgba(229, 189, 107, .2); }
.divider b { font-size: 9px; font-weight: normal; }
.controls-card h3 { margin: 0 0 14px; color: var(--paper); font: 700 20px Georgia, "Times New Roman", serif; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; margin: 10px 0; }
dt { color: var(--gold); font-size: 9px; font-weight: 600; }
dd { margin: 0; color: #aaa1b2; font-size: 9px; }
.hint { margin: 25px 0 0; color: #665f70; font-size: 8px; line-height: 1.7; }

.touch-controls { display: none; justify-content: space-between; align-items: center; margin-top: 16px; }
.d-pad { display: grid; grid-template: repeat(3, 38px) / repeat(3, 38px); gap: 3px; }
.d-pad button, .fire-button, .bomb-button { border: 1px solid #746985; color: white; background: #201a2d; touch-action: none; }
.d-pad button:nth-child(1) { grid-area: 1 / 2; }
.d-pad button:nth-child(2) { grid-area: 2 / 1; }
.d-pad button:nth-child(3) { grid-area: 2 / 2; }
.d-pad button:nth-child(4) { grid-area: 2 / 3; }
.action-buttons { display: flex; align-items: end; gap: 10px; }
.fire-button, .bomb-button { border-radius: 50%; font: 700 16px "SFMono-Regular", Consolas, monospace; }
.fire-button { width: 82px; height: 82px; border-color: var(--red); color: var(--red); }
.bomb-button { width: 59px; height: 59px; border-color: var(--gold); color: var(--gold); }
.action-buttons small { font-size: 7px; letter-spacing: .08em; }

@media (max-width: 700px) {
  body { display: block; padding: 15px; }
  .game-shell { margin: auto; max-width: 480px; }
  .masthead { display: flex; align-items: end; justify-content: space-between; }
  .eyebrow { max-width: 120px; line-height: 1.5; }
  .arcade-layout { display: block; }
  .status-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; min-height: 0; padding: 14px 4px 0; border: 0; }
  .status-panel .divider, .controls-card, .hint { display: none; }
  .stat { margin-bottom: 7px; }
  .touch-controls { display: flex; }
}

@media (max-height: 820px) and (min-width: 701px) {
  body { padding: 14px; }
  .game-shell { width: 720px; }
  .arcade-layout { grid-template-columns: 440px 220px; }
  .masthead { margin-bottom: 9px; }
  h1 { font-size: 34px; }
}
