@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  color-scheme: dark;
  --ink: #071018;
  --panel: #0c1821;
  --panel-2: #12232e;
  --line: #29414d;
  --cyan: #67e8f9;
  --cyan-soft: #1c8997;
  --amber: #ffb547;
  --amber-hot: #ffe0a3;
  --red: #ff5d67;
  --text: #edf7f5;
  --muted: #76909a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Barlow Condensed", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #03080c; overscroll-behavior: none; }
body { color: var(--text); overflow: hidden; touch-action: none; }
button { font: inherit; }
.is-hidden { display: none !important; }

#app {
  width: 100%; height: 100dvh; max-width: 720px; margin: 0 auto; position: relative;
  overflow: hidden; background: var(--ink); border-inline: 1px solid #162a34;
}
.screen { position: absolute; inset: 0; }

.title-screen {
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: max(42px, 8vh) 28px calc(30px + var(--safe-bottom)); text-align: center; overflow: hidden;
  background:
    radial-gradient(circle at 50% 39%, rgba(255,181,71,.16) 0 2%, transparent 33%),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(103,232,249,.035) 40px),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(103,232,249,.035) 40px), #071018;
}
.title-screen::before {
  content: ""; position: absolute; width: min(90vw, 540px); aspect-ratio: 1; top: 11%; border: 1px solid #1f4c59;
  border-radius: 50%; box-shadow: inset 0 0 70px rgba(103,232,249,.04), 0 0 0 42px rgba(20,58,68,.18), 0 0 0 43px #183744;
  animation: reactor 8s linear infinite;
}
@keyframes reactor { to { transform: rotate(360deg); } }
.brand-lockup { position: relative; z-index: 1; margin-top: 4vh; }
.eyebrow { color: var(--cyan); letter-spacing: .24em; font: 700 11px "JetBrains Mono", monospace; }
h1 { margin: 13vh 0 18px; font-size: clamp(68px, 19vw, 118px); line-height: .72; letter-spacing: -.055em; font-weight: 800; text-shadow: 0 8px 40px #000; }
h1 span { color: var(--amber); font-size: .64em; letter-spacing: .08em; }
.tagline { color: #b8c7c9; font-size: 18px; line-height: 1.45; letter-spacing: .08em; }
.primary-button {
  position: relative; z-index: 1; width: min(100%, 390px); border: 1px solid #ffc765; border-radius: 4px; color: #11100b;
  background: linear-gradient(180deg, #ffd27b, var(--amber)); padding: 17px 22px; font-weight: 800; font-size: 21px; letter-spacing: .15em;
  box-shadow: 0 0 32px rgba(255,181,71,.25), inset 0 1px #fff1cc; cursor: pointer;
}
.primary-button:active { transform: translateY(2px); filter: brightness(.92); }
.title-meta { position: relative; z-index: 1; display: flex; align-items: center; color: var(--muted); letter-spacing: .13em; font-size: 12px; }
.title-meta i { width: 34px; height: 1px; background: var(--line); margin: 0 10px; }
.record-summary { position: relative; z-index: 1; min-height: 18px; color: var(--muted); font: 500 10px "JetBrains Mono", monospace; letter-spacing: .08em; }
.title-settings { position: relative; z-index: 1; display: flex; gap: 6px; }
.title-settings button { color: var(--muted); border: 1px solid var(--line); background: rgba(7,16,24,.78); padding: 5px 8px; font: 600 9px "JetBrains Mono", monospace; letter-spacing: .08em; }
.title-settings button[aria-pressed="false"] { opacity: .48; }

.game-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #050c11; }
.enemy-panel { min-height: 92px; padding: 12px 14px 11px; display: flex; gap: 12px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #10202a, #0a151d); }
.enemy-panel.is-hit { animation: enemy-hit .22s ease-out; }
@keyframes enemy-hit { 0% { translate: 0 0; filter: brightness(2); } 35% { translate: 7px 0; } 70% { translate: -4px 0; } }
.stage-chip { width: 67px; display: grid; place-content: center; text-align: center; border-right: 1px solid var(--line); }
.stage-chip span { color: var(--amber); font: 700 20px "JetBrains Mono", monospace; }
.stage-chip small { color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.enemy-copy { flex: 1; min-width: 0; }
.enemy-heading, .health-row, .hp-copy { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.enemy-heading h2 { margin: 0; font-size: 23px; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enemy-heading span { color: var(--red); font-size: 12px; letter-spacing: .06em; }
.health-track { overflow: hidden; background: #03080b; border: 1px solid #253a43; height: 10px; margin: 6px 0 3px; transform: skewX(-12deg); }
.health-track > div { height: 100%; transition: width .35s ease; }
.enemy-health > div { width: 100%; background: linear-gradient(90deg, #ff4658, #ff7c67); box-shadow: 0 0 12px #ff4658; }
.health-row { color: var(--muted); font: 500 10px "JetBrains Mono", monospace; }
.health-row strong { color: #d9e5e5; }

.board-wrap { position: relative; min-height: 0; overflow: hidden; background: #050b10; }
.board-wrap::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 18%, rgba(103,232,249,.06), transparent 42%); }
#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.aim-hint { pointer-events: none; position: absolute; left: 50%; top: 69px; translate: -50% 0; display: flex; flex-direction: column; align-items: center; opacity: .86; transition: opacity .2s; }
.aim-hint b { color: var(--cyan); font: 700 13px "JetBrains Mono", monospace; letter-spacing: .28em; }
.aim-hint span { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.combo-readout { position: absolute; pointer-events: none; top: 15px; left: 16px; opacity: 0; transform: translateY(-4px); transition: .16s; }
.combo-readout.active { opacity: 1; transform: none; }
.combo-readout strong { display: block; color: var(--amber-hot); font: 800 38px/1 "JetBrains Mono", monospace; text-shadow: 0 0 18px rgba(255,181,71,.75); }
.combo-readout span { color: var(--amber); font: 700 10px "JetBrains Mono", monospace; letter-spacing: .18em; }
.shot-total { position: absolute; right: 16px; top: 18px; color: var(--cyan); font: 700 20px "JetBrains Mono", monospace; text-shadow: 0 0 14px #1e8c9e; }
.turn-banner { position: absolute; pointer-events: none; left: 50%; top: 42%; translate: -50% -50%; opacity: 0; color: #fff; font: 800 28px "JetBrains Mono", monospace; letter-spacing: .12em; text-shadow: 0 2px 22px #000, 0 0 28px var(--cyan); white-space: nowrap; }
.turn-banner.show { animation: banner .9s ease-out; }
@keyframes banner { 0% { opacity: 0; scale: .75; } 22% { opacity: 1; scale: 1.05; } 72% { opacity: 1; } 100% { opacity: 0; scale: 1.12; } }

.player-panel { padding: 10px 14px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--line); background: linear-gradient(180deg, #10212b, #0a151c); }
.player-vitals { margin-bottom: 9px; }
.hp-copy { color: var(--muted); font: 600 11px "JetBrains Mono", monospace; }
.hp-copy strong { color: var(--text); }
.player-health { height: 8px; margin-top: 4px; }
.player-health > div { width: 100%; background: linear-gradient(90deg, #21bea8, var(--cyan)); box-shadow: 0 0 10px rgba(103,232,249,.5); }
.orb-dock { display: flex; gap: 10px; align-items: stretch; }
.orb-button { flex: 1; display: flex; gap: 10px; align-items: center; color: var(--text); border: 1px solid #36525d; background: #0a151b; padding: 8px 10px; text-align: left; border-radius: 3px; }
.orb-button > span:first-child { display: grid; place-items: center; width: 38px; height: 38px; color: var(--cyan); font-size: 30px; border: 1px solid var(--cyan-soft); border-radius: 50%; box-shadow: inset 0 0 12px rgba(103,232,249,.18); }
.orb-button small, .run-currency small { display: block; color: var(--muted); font: 500 9px "JetBrains Mono", monospace; letter-spacing: .12em; }
.orb-button b { font-size: 17px; letter-spacing: .08em; }
.run-currency { min-width: 84px; padding: 8px 10px; border: 1px solid #493b25; background: #17130c; text-align: right; }
.run-currency strong { color: var(--amber); font: 700 22px "JetBrains Mono", monospace; }
.relic-strip { display: flex; gap: 5px; margin-top: 7px; overflow: hidden; min-height: 21px; }
.relic-pip { flex: 0 0 auto; max-width: 90px; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b8c7c9; border: 1px solid #30454e; background: #091218; font-size: 9px; letter-spacing: .04em; border-radius: 2px; }
.relic-pip.RARE { border-color: #3b81a5; color: #8edcff; }
.relic-pip.EPIC { border-color: #8357a6; color: #d8a2ff; }
.relic-pip.LEGENDARY { border-color: #a67c31; color: #ffd27b; box-shadow: inset 0 0 9px rgba(255,181,71,.12); }

.overlay-screen {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; overflow-y: auto; padding: max(28px, 6vh) 18px calc(24px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 12%, rgba(103,232,249,.12), transparent 35%), rgba(4,10,14,.98); backdrop-filter: blur(8px);
}
.overlay-header { text-align: center; margin-bottom: 18px; }
.overlay-header .eyebrow { margin: 0 0 8px; }
.overlay-header h2, .end-screen h2 { margin: 0; font-size: clamp(32px, 9vw, 50px); letter-spacing: .035em; }
.overlay-header > p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 14px; letter-spacing: .05em; }
.choice-cards { width: min(100%, 560px); margin: auto; display: grid; gap: 10px; }
.choice-card {
  position: relative; width: 100%; color: var(--text); border: 1px solid #36505b; border-radius: 4px; background: linear-gradient(135deg, #11232d, #0a141b 68%);
  padding: 14px 14px 13px 18px; text-align: left; cursor: pointer; overflow: hidden; box-shadow: 0 7px 24px rgba(0,0,0,.22);
}
.choice-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #758892; }
.choice-card[data-rarity="RARE"]::before { background: #51b9ee; }
.choice-card[data-rarity="EPIC"]::before { background: #c27cff; }
.choice-card[data-rarity="LEGENDARY"]::before { background: var(--amber); box-shadow: 0 0 18px var(--amber); }
.choice-card:active { transform: scale(.985); }
.choice-card:disabled { opacity: .38; cursor: default; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-top strong { font-size: 22px; letter-spacing: .04em; }
.rarity { color: var(--muted); font: 700 9px "JetBrains Mono", monospace; letter-spacing: .14em; }
.choice-card[data-rarity="RARE"] .rarity { color: #7ed7ff; }
.choice-card[data-rarity="EPIC"] .rarity { color: #d8a2ff; }
.choice-card[data-rarity="LEGENDARY"] .rarity { color: var(--amber); }
.choice-card p { margin: 7px 0 0; color: #aebfc2; font-size: 14px; line-height: 1.35; letter-spacing: .025em; }
.card-tags { display: flex; gap: 4px; margin-top: 9px; }
.card-tags span { color: #738f99; border: 1px solid #29414d; padding: 2px 4px; font: 500 8px "JetBrains Mono", monospace; }
.card-price { color: var(--amber); font: 700 14px "JetBrains Mono", monospace; }
.choice-card.sold { opacity: .32; filter: grayscale(1); }
.choice-actions { width: min(100%, 560px); margin: 16px auto 0; display: flex; gap: 8px; justify-content: center; }
.secondary-button, .text-button { border: 1px solid #36505b; background: #0b171e; color: #c5d5d6; padding: 11px 15px; border-radius: 3px; font-weight: 700; letter-spacing: .06em; cursor: pointer; }
.secondary-button span { color: var(--amber); margin-left: 8px; font: 600 10px "JetBrains Mono", monospace; }
.secondary-button:disabled { opacity: .35; }
.primary-button.compact { width: auto; flex: 1; padding: 10px 16px; font-size: 17px; }

.end-screen { justify-content: center; align-items: center; text-align: center; }
.end-sigil { color: var(--red); font-size: 82px; line-height: 1; text-shadow: 0 0 34px currentColor; }
.end-screen.victory .end-sigil, .end-screen.victory h2 { color: var(--amber); }
.end-screen .eyebrow { margin: 14px 0 6px; }
.end-screen h2 { font-size: clamp(52px, 15vw, 92px); line-height: .9; }
.end-screen > p:not(.eyebrow) { color: #aebfc2; font-size: 17px; letter-spacing: .06em; }
.end-stats { width: min(100%, 390px); display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0 22px; border-block: 1px solid var(--line); }
.end-stat { padding: 12px 5px; border-right: 1px solid var(--line); }
.end-stat:last-child { border: 0; }
.end-stat small { display: block; color: var(--muted); font: 500 8px "JetBrains Mono", monospace; letter-spacing: .1em; }
.end-stat strong { color: var(--cyan); font: 700 18px "JetBrains Mono", monospace; }
.end-screen .primary-button { width: min(100%, 390px); }
.text-button { margin-top: 8px; background: transparent; border: 0; color: var(--muted); }

.route-screen { padding-top: max(18px, 3vh); background: radial-gradient(circle at 50% 55%, rgba(103,232,249,.1), transparent 42%), #050b10; }
.route-header { margin-bottom: 10px; }
.route-header h2 { font-size: clamp(29px, 8vw, 44px); }
.seed-chip { display: inline-flex; gap: 8px; margin-top: 9px; padding: 4px 8px; border: 1px solid #29414d; color: var(--muted); font: 500 8px "JetBrains Mono", monospace; letter-spacing: .1em; }
.seed-chip strong { color: var(--cyan); }
.route-map { position: relative; width: min(100%, 520px); margin: auto; display: flex; flex-direction: column; gap: 6px; }
.route-map::before { content: ""; position: absolute; z-index: 0; left: 50%; top: 12px; bottom: 12px; width: 1px; background: linear-gradient(var(--amber), var(--cyan) 25%, #23404c 70%, #172b34); opacity: .7; }
.route-row { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; align-items: center; }
.route-row.single { display: flex; justify-content: center; }
.route-node { min-height: 56px; position: relative; color: #8aa0a7; border: 1px solid #263d47; background: rgba(7,16,24,.94); padding: 8px 10px; text-align: left; border-radius: 3px; }
.route-node strong { display: block; color: #b6c7ca; font-size: 15px; letter-spacing: .04em; }
.route-node small { display: flex; justify-content: space-between; color: #657b84; font: 500 8px "JetBrains Mono", monospace; letter-spacing: .08em; }
.route-node.available { color: var(--cyan); border-color: #3fa6b4; cursor: pointer; box-shadow: 0 0 18px rgba(103,232,249,.1), inset 0 0 15px rgba(103,232,249,.04); animation: route-pulse 1.9s ease-in-out infinite; }
.route-node.available strong { color: var(--text); }
.route-node.available[data-risk="2"] { border-color: #b26aee; box-shadow: 0 0 18px rgba(194,124,255,.15); }
.route-node.available[data-risk="3"] { border-color: var(--amber); box-shadow: 0 0 22px rgba(255,181,71,.2); }
.route-node.locked { opacity: .33; }
.route-node.completed { opacity: .52; border-color: #2b665f; }
.route-node.completed::after { content: "✓"; position: absolute; right: 7px; top: 5px; color: #68d6b8; }
.route-node.skipped { opacity: .18; }
.route-node .node-glyph { float: left; margin-right: 8px; color: currentColor; font-size: 22px; line-height: 32px; }
@keyframes route-pulse { 50% { filter: brightness(1.2); } }
.route-build { width: min(100%, 520px); margin: 10px auto 0; display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); color: var(--muted); font: 500 9px "JetBrains Mono", monospace; }
.route-build strong { color: var(--amber); }

.event-glyph { color: var(--cyan); font-size: 58px; line-height: 1; text-shadow: 0 0 24px currentColor; margin-bottom: 7px; }
.archive-screen { align-items: center; }
.archive-list { width: min(100%, 560px); margin: auto; display: grid; gap: 8px; }
.archive-entry { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid #2c444e; background: #09141a; }
.archive-entry > b { color: var(--amber); font: 700 16px "JetBrains Mono", monospace; }
.archive-entry strong { display: block; font-size: 15px; }
.archive-entry small { color: var(--muted); font: 500 8px "JetBrains Mono", monospace; }
.archive-entry .archive-score { text-align: right; color: var(--cyan); font: 700 11px "JetBrains Mono", monospace; }
.archive-empty { padding: 34px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.archive-screen > button { width: min(100%, 560px); margin-top: 14px; }

.debug-panel { position: absolute; z-index: 99; right: 6px; top: 102px; width: 122px; padding: 6px; display: grid; gap: 4px; background: rgba(0,0,0,.86); border: 1px solid #f05; }
.debug-panel b { color: #ff6d82; font: 700 10px "JetBrains Mono", monospace; }
.debug-panel button { border: 1px solid #50303a; background: #191014; color: #eee; font-size: 10px; padding: 4px; }

#app.shake { animation: shake .2s linear; }
@keyframes shake { 0%,100% { translate: 0; } 20% { translate: -5px 2px; } 40% { translate: 5px -2px; } 60% { translate: -3px; } 80% { translate: 3px 1px; } }

@media (min-width: 700px) {
  body { background: radial-gradient(circle at center, #132630, #03080c 62%); }
  #app { box-shadow: 0 0 90px #000; }
}
@media (max-height: 640px) {
  .enemy-panel { min-height: 78px; padding-block: 8px; }
  .player-panel { padding-top: 7px; }
  .player-vitals { margin-bottom: 5px; }
  .tagline { display: none; }
}
@media (min-width: 580px) and (min-height: 720px) {
  .choice-cards { grid-template-columns: repeat(3, 1fr); align-items: stretch; }
  .choice-card { min-height: 210px; display: flex; flex-direction: column; }
  .choice-card p { flex: 1; }
}
@media (max-width: 380px) {
  .enemy-heading h2 { font-size: 19px; }
  .enemy-heading span { font-size: 10px; }
  .stage-chip { width: 56px; }
  .choice-card { padding-block: 11px; }
  .card-top strong { font-size: 19px; }
  .choice-card p { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation-duration: .001ms !important; animation-iteration-count: 1 !important; } }
