:root {
  color-scheme: dark;
  --ink: #05030b;
  --panel: #0b0713;
  --paper: #f6eefc;
  --muted: #9b8da8;
  --violet: #b365ff;
  --hot: #ff3fa4;
  --cyan: #55f6e8;
  --gold: #ffd978;
  --danger: #ff5571;
  --line: rgba(222, 194, 255, .18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: "Arial Narrow", "Bahnschrift Condensed", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--paper);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% 20%, rgba(92, 35, 130, .23), transparent 38%),
    linear-gradient(120deg, #05030a, #0c0613 45%, #030208);
}

button { font: inherit; }

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.cabinet {
  width: 100vw;
  height: 100svh;
  display: grid;
  grid-template-columns: minmax(190px, 270px) minmax(300px, 540px) minmax(190px, 270px);
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vw, 54px);
  padding: 2.5vh 2.5vw;
}

.side-panel {
  height: min(90svh, 870px);
  max-width: 260px;
  position: relative;
  padding: 24px 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 11, 30, .64), rgba(5, 3, 11, .28));
  box-shadow: inset 0 0 45px rgba(129, 52, 190, .04);
  color: var(--muted);
}

.side-panel::before,
.side-panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(179, 101, 255, .55);
}

.side-panel::before { left: -1px; top: -1px; border-left: 1px solid; border-top: 1px solid; }
.side-panel::after { right: -1px; bottom: -1px; border-right: 1px solid; border-bottom: 1px solid; }

.brand-mark { display: flex; align-items: center; gap: 8px; color: var(--paper); font-weight: 900; letter-spacing: .12em; }
.brand-mark i { width: 18px; height: 1px; background: var(--hot); transform: rotate(-60deg); box-shadow: 0 0 10px var(--hot); }
.eyebrow { margin: 8px 0; color: var(--violet); font-size: 10px; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; }
.ornament { height: 1px; margin: 26px 0; background: linear-gradient(90deg, transparent, var(--line), transparent); position: relative; }
.ornament::after { content: "◆"; position: absolute; left: 50%; top: 50%; padding: 0 8px; transform: translate(-50%, -51%); background: #09050f; color: var(--violet); font-size: 8px; }
.ornament--tall { height: 190px; width: 1px; margin: 35px auto; background: linear-gradient(transparent, var(--violet), transparent); opacity: .35; }
.ornament--tall::after { background: #0a0610; }

.readout { margin-top: 23px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.readout span { font-size: 9px; letter-spacing: .2em; }
.readout strong { color: var(--paper); font-size: 15px; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.side-panel blockquote { position: absolute; left: 22px; bottom: 28px; margin: 0; color: #766b82; font-family: Georgia, serif; font-size: 13px; font-style: italic; line-height: 1.6; }

.control-list { margin-top: 28px; display: grid; gap: 14px; }
.control-list div { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 14px; }
kbd { border: 1px solid var(--line); padding: 4px 6px; color: var(--cyan); background: rgba(85, 246, 232, .04); font: 700 9px/1 "Segoe UI", sans-serif; letter-spacing: .1em; text-align: center; }
.control-list span { font-size: 9px; letter-spacing: .14em; }
.doctrine { display: grid; gap: 8px; }
.doctrine b { color: var(--paper); font-size: 11px; letter-spacing: .18em; }
.doctrine p { margin: 0 0 14px; font: 12px/1.55 "Segoe UI", sans-serif; color: #82758f; }
.status-light { position: absolute; bottom: 24px; left: 22px; display: flex; align-items: center; gap: 8px; font-size: 8px; letter-spacing: .16em; }
.status-light i { width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 2.4s ease-in-out infinite; }

.machine {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(95svh, 960px);
  max-width: calc(100vw - 520px);
  overflow: hidden;
  isolation: isolate;
  background: #020106;
  border: 1px solid rgba(213, 175, 250, .3);
  box-shadow: 0 0 0 1px #030108, 0 0 0 7px rgba(15, 8, 23, .92), 0 30px 100px rgba(0, 0, 0, .74), 0 0 90px rgba(135, 58, 198, .12);
}

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #030108; }

.screen-vignette,
.scanlines { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.screen-vignette { box-shadow: inset 0 0 58px rgba(0, 0, 0, .62), inset 0 0 8px rgba(185, 101, 255, .14); }
.scanlines { opacity: .13; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.13) 4px); mix-blend-mode: overlay; }

.hud {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  padding: 15px 16px 20px;
  background: linear-gradient(180deg, rgba(4,2,9,.85), transparent);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .35s, transform .35s;
}
.playing .hud { opacity: 1; transform: none; }
.hud-block { display: flex; flex-direction: column; gap: 1px; }
.hud-block--right { text-align: right; align-items: flex-end; }
.hud-block span, .hud-center span { color: var(--violet); font-size: 7px; font-weight: 800; letter-spacing: .22em; }
.hud-block strong { font-size: 14px; font-weight: 900; letter-spacing: .07em; font-variant-numeric: tabular-nums; text-shadow: 0 0 16px rgba(255,255,255,.18); }
.hud-block small { color: var(--muted); font-size: 7px; letter-spacing: .18em; }
.hud-center { text-align: center; display: flex; flex-direction: column; padding-top: 1px; }
.hud-center strong { margin-top: 2px; font-size: 8px; letter-spacing: .16em; }

.boss-hud { position: absolute; z-index: 11; top: 65px; left: 16px; right: 16px; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .35s; }
.boss-hud.active { opacity: 1; transform: none; }
.boss-hud > div:first-child { display: flex; justify-content: space-between; align-items: baseline; }
.boss-hud span { color: var(--paper); font-size: 9px; font-weight: 900; letter-spacing: .2em; }
.boss-hud small { color: var(--hot); font-size: 7px; letter-spacing: .16em; }
.boss-track { height: 3px; margin-top: 5px; background: rgba(255,255,255,.12); overflow: hidden; }
.boss-track i { display: block; width: 100%; height: 100%; transform-origin: left; background: linear-gradient(90deg, var(--hot), var(--violet), var(--cyan)); box-shadow: 0 0 10px var(--hot); }

.lower-hud {
  position: absolute;
  z-index: 10;
  left: 14px;
  right: 14px;
  bottom: 12px;
  display: grid;
  grid-template-columns: 1fr 1.7fr 1fr;
  align-items: end;
  gap: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: .35s;
  pointer-events: none;
}
.playing .lower-hud { opacity: 1; transform: none; }
.hull > span, .echo-label span, .multiplier span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 6px; letter-spacing: .18em; }
#hearts { display: flex; gap: 4px; }
#hearts i { width: 14px; height: 6px; background: var(--danger); clip-path: polygon(0 0, 100% 0, 76% 100%, 24% 100%); box-shadow: 0 0 9px var(--danger); transition: .25s; }
#hearts i.empty { background: rgba(255,255,255,.12); box-shadow: none; }
.echo-label { display: flex; justify-content: space-between; align-items: baseline; }
.echo-label strong { font-size: 8px; color: var(--cyan); }
.echo-track { height: 6px; border: 1px solid rgba(85,246,232,.28); position: relative; overflow: hidden; background: rgba(4,20,22,.5); }
.echo-track i { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan)); box-shadow: 0 0 10px var(--cyan); transition: width .1s linear; }
.echo-track b { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255,255,255,.5); }
.resource-meters { display: grid; gap: 5px; }
.thread-track i { background: linear-gradient(90deg, var(--paper), var(--violet)); box-shadow: 0 0 9px var(--violet); }
.multiplier { text-align: right; }
.multiplier strong { font-size: 18px; font-weight: 900; color: var(--gold); text-shadow: 0 0 14px rgba(255,217,120,.33); }

.announcement { position: absolute; z-index: 18; left: 0; right: 0; top: 38%; display: flex; flex-direction: column; align-items: center; pointer-events: none; opacity: 0; transform: scale(1.08); }
.announcement.show { animation: announce 3.1s cubic-bezier(.2,.8,.2,1) both; }
.announcement small { color: var(--hot); font-size: 8px; font-weight: 900; letter-spacing: .35em; }
.announcement strong { margin: 8px 0 4px; font-size: 26px; line-height: 1; letter-spacing: .16em; text-shadow: 0 0 28px var(--violet); }
.announcement span { color: var(--muted); font-size: 7px; letter-spacing: .22em; }

.overlay { position: absolute; inset: 0; z-index: 30; display: none; flex-direction: column; align-items: center; justify-content: center; padding: 46px 34px 34px; background: rgba(4,2,9,.87); backdrop-filter: blur(8px); overflow: auto; }
.overlay.active { display: flex; animation: overlayIn .35s ease-out both; }
.overlay--title { justify-content: flex-start; background: radial-gradient(circle at 50% 18%, rgba(95,35,142,.32), transparent 38%), linear-gradient(180deg, rgba(5,2,12,.78), rgba(3,2,8,.96)); }
.title-geometry { position: absolute; top: -70px; left: 50%; width: 310px; height: 310px; transform: translateX(-50%); opacity: .26; animation: slowSpin 35s linear infinite; }
.title-geometry i { position: absolute; inset: 0; border: 1px solid var(--violet); transform: rotate(45deg); }
.title-geometry i:nth-child(2) { inset: 34px; border-color: var(--hot); transform: rotate(15deg); }
.title-geometry i:nth-child(3) { inset: 66px; border-radius: 50%; border-color: var(--cyan); }
.title-copy { position: relative; z-index: 1; width: 100%; text-align: center; margin-top: 40px; }
.title-copy .eyebrow { color: var(--cyan); }
h1 { display: flex; align-items: center; justify-content: center; margin: 12px 0 10px; font-size: clamp(38px, 9vh, 70px); line-height: .85; letter-spacing: -.055em; font-weight: 950; transform: scaleX(.88); }
h1 b { margin: 0 8px; color: var(--hot); font-size: .5em; font-weight: 300; text-shadow: 0 0 18px var(--hot); }
h1 span:last-child { color: transparent; -webkit-text-stroke: 1px var(--paper); }
.title-tagline { margin: 0; color: #b4a7be; font: italic 12px/1.55 Georgia, serif; }

.loadout-panel { position: relative; z-index: 1; width: 100%; margin-top: 38px; }
.choice-heading { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.choice-heading > span { color: var(--hot); font-size: 9px; }
.choice-heading div { display: flex; flex-direction: column; }
.choice-heading strong { font-size: 9px; letter-spacing: .2em; }
.choice-heading small { margin-top: 2px; color: var(--muted); font-size: 7px; letter-spacing: .08em; }
.vow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vow-card { min-height: 96px; padding: 12px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); background: rgba(12,7,19,.72); border: 1px solid var(--line); cursor: pointer; transition: .2s; }
.vow-card:hover { color: var(--paper); border-color: rgba(179,101,255,.6); transform: translateY(-2px); }
.vow-card.selected { color: var(--paper); border-color: var(--cyan); background: linear-gradient(180deg, rgba(85,246,232,.1), rgba(179,101,255,.07)); box-shadow: inset 0 0 22px rgba(85,246,232,.05), 0 0 16px rgba(85,246,232,.08); }
.vow-card strong { font-size: 10px; letter-spacing: .17em; }
.vow-card span { font-size: 7px; letter-spacing: .06em; }
.vow-icon { width: 30px; height: 30px; position: relative; display: block; }
.vow-icon--needle::before { content: ""; position: absolute; left: 14px; top: 1px; width: 2px; height: 29px; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); }
.vow-icon--needle::after { content: ""; position: absolute; left: 9px; bottom: 2px; width: 12px; height: 12px; border: 1px solid var(--violet); transform: rotate(45deg); }
.vow-icon--bloom { border: 1px solid var(--hot); transform: rotate(45deg) scale(.68); box-shadow: 0 0 9px rgba(255,63,164,.5); }
.vow-icon--bloom::before, .vow-icon--bloom::after { content: ""; position: absolute; inset: 6px -7px; border: 1px solid var(--hot); }
.vow-icon--bloom::after { transform: rotate(90deg); }
.vow-icon--halo { border: 1px solid var(--gold); border-radius: 50%; box-shadow: 0 0 9px rgba(255,217,120,.5); }
.vow-icon--halo::before { content: ""; position: absolute; left: 13px; top: -4px; width: 2px; height: 38px; background: var(--violet); transform: rotate(35deg); }

.difficulty-row { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; margin-top: 13px; border: 1px solid var(--line); }
.difficulty-row button { padding: 8px 4px; color: #776b83; border: 0; border-right: 1px solid var(--line); background: rgba(5,3,10,.7); font-size: 7px; font-weight: 900; letter-spacing: .16em; cursor: pointer; }
.difficulty-row button:last-child { border-right: 0; }
.difficulty-row button.selected { color: var(--gold); background: rgba(255,217,120,.09); }

.primary-button { position: relative; z-index: 1; width: 100%; min-height: 43px; margin-top: 14px; padding: 10px 13px; display: flex; justify-content: space-between; align-items: center; color: #06030b; background: var(--paper); border: 0; font-size: 10px; font-weight: 950; letter-spacing: .18em; cursor: pointer; transition: .2s; }
.primary-button:hover { background: var(--cyan); box-shadow: 0 0 24px rgba(85,246,232,.28); }
.primary-button kbd { border-color: rgba(0,0,0,.25); color: #160d1c; background: transparent; }
.title-footer { width: 100%; margin-top: 12px; display: flex; justify-content: space-between; color: #665b70; font-size: 6px; letter-spacing: .12em; }

.overlay--draft { background: radial-gradient(circle, rgba(68,26,104,.3), rgba(4,2,9,.95) 58%); }
.draft-heading { width: 100%; text-align: center; }
.draft-heading h2 { margin: 8px 0 5px; font-size: 21px; letter-spacing: .09em; }
.draft-heading > span { color: var(--muted); font-size: 8px; letter-spacing: .14em; }
.relic-grid { width: 100%; display: grid; gap: 10px; margin-top: 28px; }
.relic-card { position: relative; width: 100%; min-height: 114px; padding: 17px 16px 16px 82px; color: var(--paper); text-align: left; border: 1px solid var(--line); background: linear-gradient(110deg, rgba(179,101,255,.1), rgba(8,4,13,.86) 45%); cursor: pointer; overflow: hidden; transition: .2s; }
.relic-card:hover { transform: translateX(4px); border-color: var(--cyan); background: linear-gradient(110deg, rgba(85,246,232,.14), rgba(8,4,13,.88) 45%); }
.relic-card > i { position: absolute; left: 20px; top: 28px; width: 38px; height: 38px; border: 1px solid var(--violet); transform: rotate(45deg); box-shadow: inset 0 0 15px rgba(179,101,255,.16); }
.relic-card > b { position: absolute; right: 11px; top: 9px; color: var(--hot); font-size: 7px; letter-spacing: .12em; }
.relic-card strong { display: block; margin-bottom: 7px; font-size: 13px; letter-spacing: .16em; }
.relic-card span { display: block; color: var(--muted); font: 10px/1.45 "Segoe UI", sans-serif; }
.relic-card small { display: block; margin-top: 7px; color: var(--cyan); font-size: 7px; letter-spacing: .12em; }

.overlay--pause, .overlay--ending { text-align: center; }
.pause-sigil { width: 88px; height: 88px; margin-bottom: 30px; border: 1px solid var(--violet); transform: rotate(45deg); box-shadow: 0 0 35px rgba(179,101,255,.15); }
.pause-sigil::before { content: "Ⅱ"; display: grid; place-items: center; width: 100%; height: 100%; color: var(--cyan); font-size: 26px; transform: rotate(-45deg); }
.overlay h2 { margin: 7px 0 14px; font-size: 28px; line-height: .95; letter-spacing: .1em; }
.text-button { margin-top: 14px; padding: 4px 8px; color: var(--muted); border: 0; border-bottom: 1px solid transparent; background: none; font-size: 8px; letter-spacing: .16em; cursor: pointer; }
.text-button:hover { color: var(--paper); border-color: var(--hot); }
.overlay--ending > p:not(.eyebrow) { margin: 0 0 25px; color: var(--muted); font: italic 12px/1.5 Georgia, serif; }
.run-stats { width: 100%; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.run-stats div { padding: 12px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.run-stats div:nth-child(even) { border-right: 0; }
.run-stats div:nth-last-child(-n+2) { border-bottom: 0; }
.run-stats span { color: var(--muted); font-size: 7px; letter-spacing: .16em; }
.run-stats strong { font-size: 14px; letter-spacing: .08em; }

.touch-controls { display: none; position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.touch-controls button { pointer-events: auto; -webkit-tap-highlight-color: transparent; }
.touch-hint { position: absolute; left: 18px; bottom: calc(70px + var(--safe-bottom)); color: rgba(255,255,255,.24); font-size: 7px; letter-spacing: .15em; }
.touch-button { position: absolute; bottom: calc(60px + var(--safe-bottom)); width: 62px; height: 62px; border-radius: 50%; color: var(--paper); border: 1px solid rgba(255,255,255,.26); background: rgba(7,4,12,.48); backdrop-filter: blur(5px); font-size: 7px; font-weight: 900; letter-spacing: .08em; }
.touch-button--focus { right: calc(88px + var(--safe-right)); }
.touch-button--echo { right: calc(16px + var(--safe-right)); color: var(--cyan); border-color: rgba(85,246,232,.45); box-shadow: inset 0 0 20px rgba(85,246,232,.08); }
.touch-button--echo.ready { animation: readyPulse 1s ease-in-out infinite; }
.touch-pause { position: absolute; top: calc(58px + var(--safe-top)); right: calc(12px + var(--safe-right)); width: 30px; height: 30px; color: var(--muted); border: 1px solid var(--line); background: rgba(4,2,9,.45); }

.corner-tools { position: absolute; z-index: 40; right: 8px; top: 8px; display: flex; gap: 5px; }
.corner-tools button { width: 24px; height: 24px; padding: 0; color: #8f819c; border: 1px solid rgba(255,255,255,.12); background: rgba(4,2,9,.52); font-size: 11px; cursor: pointer; }
.corner-tools button.active { color: var(--cyan); border-color: rgba(85,246,232,.45); }
.playing .corner-tools { opacity: 0; pointer-events: none; }
.playing.paused .corner-tools { opacity: 1; pointer-events: auto; }

body.force-touch .touch-controls,
body.touch-device .touch-controls { display: block; }
body.force-touch .title-footer,
body.touch-device .title-footer { display: none; }

body.reduce-flash .scanlines { display: none; }
body.reduce-flash *, body.reduce-flash *::before, body.reduce-flash *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
body.reduce-flash .overlay.active { animation: none !important; opacity: 1; transform: none; }
body.reduce-flash .announcement.show { animation: none !important; opacity: 1; transform: none; }

@keyframes overlayIn { from { opacity: 0; transform: scale(1.015); } to { opacity: 1; transform: none; } }
@keyframes announce { 0% { opacity: 0; transform: scale(1.15); } 16%, 68% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.97); } }
@keyframes slowSpin { to { transform: translateX(-50%) rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; box-shadow: 0 0 2px var(--cyan); } }
@keyframes readyPulse { 50% { box-shadow: inset 0 0 28px rgba(85,246,232,.22), 0 0 20px rgba(85,246,232,.2); transform: scale(1.04); } }

@media (max-width: 980px) {
  .cabinet { display: flex; padding: 0; }
  .side-panel { display: none; }
  .machine { height: 100svh; max-width: 100vw; border: 0; box-shadow: none; }
}

@media (max-aspect-ratio: 9/16) {
  .machine { width: 100vw; height: auto; max-height: 100svh; }
}

@media (max-height: 760px) and (min-width: 981px) {
  .overlay--title { padding-top: 25px; }
  .title-copy { margin-top: 12px; }
  .loadout-panel { margin-top: 20px; }
  .vow-card { min-height: 80px; padding-top: 8px; }
  .vow-icon { width: 24px; height: 24px; transform: scale(.78); }
}

@media (max-width: 430px) {
  .overlay { padding-left: 22px; padding-right: 22px; }
  .overlay--title { padding-top: calc(25px + var(--safe-top)); }
  .title-copy { margin-top: 22px; }
  .loadout-panel { margin-top: 26px; }
  .vow-card { min-height: 91px; }
  .hud { padding-top: calc(12px + var(--safe-top)); }
  .boss-hud { top: calc(61px + var(--safe-top)); }
  .lower-hud { bottom: calc(10px + var(--safe-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .overlay.active { animation: none !important; opacity: 1; transform: none; }
  .announcement.show { animation: none !important; opacity: 1; transform: none; }
  .hud, .lower-hud, .boss-hud { transition: none !important; }
}
