/* Andromeda: The Shattered Chain — style.css
   Deep Aegean night, bronze, coral light. Serif display, restrained chrome. */

:root {
  --ink: #eaf6f4;
  --ink-soft: #b6d2d2;
  --mute: #7f9ea2;
  --deep: #04131a;
  --deep-2: #08222c;
  --panel: rgba(7, 26, 33, .82);
  --panel-2: rgba(10, 34, 42, .92);
  --coral: #ff7a63;
  --coral-deep: #b9423a;
  --gold: #e8c37a;
  --gold-lt: #ffe6b4;
  --cyan: #7fe3dd;
  --violet: #a78bfa;
  --line: rgba(232, 195, 122, .26);
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: #02090d;
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

.game {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: radial-gradient(120% 90% at 50% 0%, #0e3340 0%, #06181f 55%, #02090d 100%);
  overflow: hidden;
  isolation: isolate;
}

#stage {
  grid-row: 2;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Ccircle cx='14' cy='14' r='8' fill='none' stroke='%23e8c37a' stroke-width='1.4'/%3E%3Ccircle cx='14' cy='14' r='1.6' fill='%23ffe6b4'/%3E%3C/svg%3E") 14 14, crosshair;
  z-index: 1;
}

.grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  opacity: .13; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(125% 100% at 50% 42%, rgba(0,0,0,0) 50%, rgba(0, 7, 10, .55) 100%);
}

/* ------------------------------------------------------------------ HUD */
.hud {
  position: relative; z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px clamp(12px, 3vw, 28px) 10px;
  background: linear-gradient(180deg, rgba(2, 12, 16, .82), rgba(2, 12, 16, 0));
  color: var(--ink);
}
.hud-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-kicker {
  font-size: 9.5px; letter-spacing: .22em; text-transform: uppercase;
  color: rgba(232, 195, 122, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-chapter {
  font-family: var(--serif); font-size: clamp(13px, 1.5vw, 17px);
  color: #f2fbf9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .6);
}
.hud-goal { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.goal-label { font-size: 8.5px; letter-spacing: .2em; color: rgba(182, 210, 210, .78); }
.goal-num { font-family: var(--serif); font-size: 15px; letter-spacing: .08em; color: #fff; }
.goal-bar {
  width: clamp(86px, 15vw, 160px); height: 3px; border-radius: 3px;
  background: rgba(255, 255, 255, .16); overflow: hidden;
}
.goal-bar i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold-lt));
  box-shadow: 0 0 12px rgba(255, 122, 99, .7);
  transition: width .3s ease;
}
.hud-right { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.hud-shields { display: flex; gap: 4px; align-items: center; }
.hud-shields i {
  width: 13px; height: 15px;
  background: linear-gradient(180deg, #ffe9b8, #c08c3f 70%, #7a5220);
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
  filter: drop-shadow(0 0 5px rgba(232, 195, 122, .55));
  transition: opacity .25s, transform .25s;
}
.hud-shields i.spent { opacity: .16; transform: scale(.82); filter: none; }
.hud-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; min-width: 46px; }
.hud-stat span { font-family: var(--serif); font-size: 16px; color: #fff; }
.hud-stat small { font-size: 7.5px; letter-spacing: .16em; color: rgba(182, 210, 210, .62); margin-top: 3px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(232, 195, 122, .32);
  background: rgba(4, 20, 26, .55);
  color: var(--gold-lt); font-size: 12px; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
  transition: background .2s, border-color .2s, transform .2s;
}
.icon-btn:hover { background: rgba(232, 195, 122, .14); border-color: rgba(232, 195, 122, .6); }
.icon-btn:active { transform: scale(.94); }

/* ----------------------------------------------------------------- dock */
.dock {
  position: relative; z-index: 4;
  display: flex; align-items: center; gap: 14px;
  padding: 8px clamp(12px, 3vw, 28px) 12px;
  background: linear-gradient(0deg, rgba(2, 10, 14, .86), rgba(2, 10, 14, 0));
  min-height: 44px;
}
.fx { display: flex; gap: 6px; min-width: 0; }
.fx-chip[hidden] { display: none; }
.fx-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 8.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--cyan); border: 1px solid rgba(127, 227, 221, .35);
  background: rgba(8, 40, 44, .6); border-radius: 999px; padding: 4px 9px;
  white-space: nowrap;
}
.fx-chip i { font-style: normal; font-size: 10px; }
.fx-chip b { font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.dock-hint {
  flex: 1; text-align: center;
  font-size: 10.5px; letter-spacing: .08em; color: rgba(182, 210, 210, .62);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dock-keys { font-size: 9.5px; color: rgba(182, 210, 210, .4); white-space: nowrap; }
.dock-keys kbd, .keys kbd {
  font: 10px/1 var(--sans); padding: 3px 5px; border-radius: 4px;
  border: 1px solid rgba(182, 210, 210, .22); color: var(--ink-soft);
  background: rgba(255, 255, 255, .04); margin: 0 1px;
}

/* --------------------------------------------------------------- screens */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: clamp(14px, 4vw, 40px);
  background:
    radial-gradient(90% 70% at 50% 30%, rgba(10, 42, 52, .66), rgba(2, 9, 13, .92) 78%);
  -webkit-backdrop-filter: blur(7px) saturate(.9);
  backdrop-filter: blur(7px) saturate(.9);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .34s ease, visibility .34s;
  overflow: auto;
}
.screen.on { opacity: 1; visibility: visible; pointer-events: auto; }

.title-screen {
  background:
    radial-gradient(70% 60% at 50% 38%, rgba(18, 62, 72, .34), rgba(2, 9, 13, .88) 76%),
    linear-gradient(180deg, rgba(2, 9, 13, .12), rgba(2, 9, 13, .92));
}
.title-wrap { max-width: 760px; text-align: center; padding: 10px 0 4px; }
.chain-mark { color: rgba(232, 195, 122, .5); width: clamp(180px, 42vw, 300px); margin: 0 auto 6px; }
.chain-mark svg { width: 100%; height: auto; display: block; }
.eyebrow {
  margin: 0 0 10px; font-size: 9.5px; letter-spacing: .28em;
  text-transform: uppercase; color: rgba(232, 195, 122, .78);
}
.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 8.4vw, 84px);
  line-height: .98;
  letter-spacing: .11em;
  font-weight: 400;
  background: linear-gradient(180deg, #fff8e6 6%, #f0d49a 42%, #c79a4b 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-shadow: 0 18px 60px rgba(232, 195, 122, .14);
}
.wordmark em {
  display: block; margin-top: 10px;
  font-size: clamp(12px, 2.1vw, 17px);
  letter-spacing: .42em; text-transform: uppercase; font-style: normal;
  color: rgba(182, 210, 210, .8);
  -webkit-text-fill-color: rgba(182, 210, 210, .8);
}
.tagline {
  margin: 20px auto 0; max-width: 520px;
  font-family: var(--serif); font-style: italic;
  font-size: clamp(13.5px, 1.7vw, 17px); line-height: 1.7;
  color: rgba(214, 235, 233, .82);
}
.title-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.title-note { margin: 16px 0 0; font-size: 10.5px; letter-spacing: .14em; color: rgba(182, 210, 210, .5); text-transform: uppercase; }
.btn.endless {
  margin-top: 14px; font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  background: transparent; color: var(--cyan); border: 1px solid rgba(127, 227, 221, .35);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  font-family: var(--sans); font-size: 13px; letter-spacing: .1em;
  padding: 13px 26px; border-radius: 999px;
  transition: transform .18s ease, box-shadow .25s ease, background .25s ease, color .25s;
}
.btn.primary {
  background: linear-gradient(180deg, #ffe6b4, #e8c37a 46%, #c79a4b);
  color: #2a1a06; font-weight: 600;
  box-shadow: 0 10px 30px rgba(232, 195, 122, .22), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 38px rgba(232, 195, 122, .3); }
.btn.primary:active { transform: translateY(0) scale(.99); }
.btn.ghost {
  background: rgba(255, 255, 255, .03);
  border-color: rgba(232, 195, 122, .32);
  color: var(--gold-lt);
}
.btn.ghost:hover { background: rgba(232, 195, 122, .12); border-color: rgba(232, 195, 122, .6); }
.btn.tiny { padding: 8px 15px; font-size: 10.5px; }

/* ------------------------------------------------------------------ map */
.map-wrap {
  width: min(980px, 100%); max-height: calc(100dvh - 40px);
  background: linear-gradient(180deg, rgba(9, 32, 40, .92), rgba(4, 16, 21, .96));
  border: 1px solid rgba(232, 195, 122, .18);
  border-radius: 18px; padding: clamp(16px, 3vw, 30px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
  overflow: auto;
}
.map-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.map-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(22px, 3vw, 30px); }
.map-side { display: flex; align-items: center; gap: 12px; }
.map-stars { font-size: 11px; letter-spacing: .12em; color: var(--gold); white-space: nowrap; }
.acts { display: flex; flex-direction: column; gap: 16px; }
.act { border-top: 1px solid rgba(182, 210, 210, .1); padding-top: 12px; }
.act-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.act-roman {
  font-family: var(--serif); font-size: 17px; color: var(--gold);
  width: 24px; flex: none;
}
.act-name { font-family: var(--serif); font-size: 14.5px; letter-spacing: .04em; }
.act-note { font-size: 10px; color: rgba(182, 210, 210, .5); }
.act-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.ch {
  position: relative; appearance: none; cursor: pointer;
  border: 1px solid rgba(182, 210, 210, .16); border-radius: 10px;
  background: rgba(255, 255, 255, .025);
  color: var(--ink-soft); padding: 9px 5px 7px; text-align: center;
  transition: border-color .2s, background .2s, transform .15s;
}
.ch b { display: block; font-family: var(--serif); font-size: 16px; font-weight: 400; color: var(--ink); }
.ch small { display: block; font-size: 8px; letter-spacing: .1em; color: var(--gold); margin-top: 3px; height: 10px; }
.ch:hover:not(.locked) { border-color: rgba(232, 195, 122, .55); background: rgba(232, 195, 122, .08); transform: translateY(-1px); }
.ch.locked { opacity: .45; cursor: not-allowed; }
.ch.boss { border-color: rgba(255, 122, 99, .4); }
.ch.boss::after {
  content: ''; position: absolute; inset: 3px; border-radius: 8px;
  border: 1px dashed rgba(255, 122, 99, .25); pointer-events: none;
}
.ch.now { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232, 195, 122, .18) inset; }
.map-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 10.5px; color: rgba(182, 210, 210, .55); }

/* ---------------------------------------------------------------- brief */
.brief-wrap, .result-wrap, .pause-wrap, .how-wrap {
  width: min(620px, 100%);
  background: linear-gradient(180deg, rgba(9, 32, 40, .94), rgba(4, 15, 20, .97));
  border: 1px solid rgba(232, 195, 122, .2);
  border-radius: 18px; padding: clamp(20px, 3.4vw, 34px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  text-align: left;
}
.brief-title {
  margin: 0 0 16px; font-family: var(--serif); font-weight: 400;
  font-size: clamp(22px, 3.2vw, 30px); line-height: 1.2; color: #fff;
}
.brief-story { border-left: 2px solid rgba(232, 195, 122, .4); padding-left: 14px; margin-bottom: 18px; }
.brief-story p {
  margin: 0 0 7px; font-family: var(--serif); font-style: italic;
  font-size: 14.5px; line-height: 1.65; color: rgba(216, 236, 233, .84);
}
.brief-story p:last-child { margin-bottom: 0; }
.brief-tip {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 18px; padding: 11px 13px; border-radius: 10px;
  background: rgba(127, 227, 221, .06); border: 1px solid rgba(127, 227, 221, .16);
  font-size: 12px; line-height: 1.55; color: rgba(206, 236, 233, .8);
}
.brief-tip span {
  flex: none; font-size: 8.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cyan); border: 1px solid rgba(127, 227, 221, .35);
  border-radius: 999px; padding: 3px 7px; margin-top: 1px;
}
.brief-tip em { font-style: normal; }
.brief-stats, .result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.result-stats { grid-template-columns: repeat(3, 1fr); }
.brief-stats > div, .result-stats > div {
  background: rgba(255, 255, 255, .03); border: 1px solid rgba(182, 210, 210, .12);
  border-radius: 10px; padding: 10px 8px; text-align: center;
}
.brief-stats b, .result-stats b { display: block; font-family: var(--serif); font-size: 19px; font-weight: 400; color: #fff; }
.brief-stats small, .result-stats small { display: block; margin-top: 4px; font-size: 7.5px; letter-spacing: .16em; color: rgba(182, 210, 210, .55); }
.brief-stats .brief-stars b { color: var(--gold); letter-spacing: .12em; }
.brief-actions, .result-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* --------------------------------------------------------------- result */
.result-wrap { text-align: center; }
.result-title { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 3.4vw, 32px); color: #fff; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 10px 0 6px; }
.stars i {
  font-style: normal; font-size: clamp(30px, 5vw, 42px); line-height: 1;
  color: rgba(255, 255, 255, .1);
  text-shadow: none;
}
.stars i.on { color: var(--gold); text-shadow: 0 0 24px rgba(232, 195, 122, .55); animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.stars i.on:nth-child(2) { animation-delay: .12s; }
.stars i.on:nth-child(3) { animation-delay: .24s; }
@keyframes pop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.result-line { margin: 0 0 16px; font-size: 11.5px; letter-spacing: .1em; color: rgba(182, 210, 210, .7); }
.result-story {
  margin: 16px 0 20px; padding-top: 14px; border-top: 1px solid rgba(182, 210, 210, .12);
  font-family: var(--serif); font-style: italic; font-size: 13.5px; line-height: 1.7;
  color: rgba(214, 235, 233, .78);
}
.result-wrap .brief-story { text-align: left; }
.fail .result-title { color: #ffb2a3; }
.fail .eyebrow { color: rgba(255, 122, 99, .8); }

/* ------------------------------------------------------------------ how */
.how-wrap { width: min(640px, 100%); }
.how-list { margin: 6px 0 0; padding-left: 20px; }
.how-list li { margin: 8px 0; font-size: 13px; line-height: 1.65; color: rgba(206, 230, 228, .86); }
.how-list b { color: var(--gold-lt); font-weight: 600; }
.how-note {
  margin: 16px 0 20px; padding: 11px 13px; border-radius: 10px;
  background: rgba(232, 195, 122, .05); border: 1px solid rgba(232, 195, 122, .16);
  font-size: 11.5px; line-height: 1.6; color: rgba(214, 235, 233, .72);
}
.pause-wrap { width: min(430px, 100%); text-align: center; }
.keys { list-style: none; padding: 0; margin: 16px 0 20px; display: flex; flex-direction: column; gap: 9px; }
.keys li { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: rgba(206, 230, 228, .8); }
.keys li span { margin-left: 8px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: absolute; left: 50%; bottom: 84px; z-index: 30;
  transform: translate(-50%, 12px);
  padding: 8px 16px; border-radius: 999px;
  background: rgba(4, 22, 27, .88); border: 1px solid rgba(232, 195, 122, .35);
  color: var(--gold-lt); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 700px) {
  .hud {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "left right" "goal goal";
    row-gap: 7px;
    padding: 9px 12px 8px;
  }
  .hud-left { grid-area: left; }
  .hud-right { grid-area: right; gap: 7px; }
  .hud-goal { grid-area: goal; flex-direction: row; gap: 9px; align-items: center; }
  .hud-goal .goal-label { font-size: 8px; }
  .goal-bar { width: 104px; }
  .hud-kicker { font-size: 8px; letter-spacing: .16em; }
  .hud-chapter { font-size: 12.5px; }
  .hud-stat { min-width: 38px; }
  .hud-stat span { font-size: 13px; }
  .hud-shields i { width: 10px; height: 12px; }
  .icon-btn { width: 27px; height: 27px; font-size: 10px; }
}
@media (max-width: 760px) {
  .dock-keys { display: none; }
  .dock { min-height: 40px; gap: 8px; }
  .dock-hint { font-size: 9.5px; }
  .act-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .map-head { flex-direction: column; align-items: flex-start; }
  .brief-stats { grid-template-columns: repeat(2, 1fr); }
  .hud { gap: 6px; padding-top: 9px; }
  .hud-shields i { width: 11px; height: 13px; }
  .icon-btn { width: 29px; height: 29px; }
  .hud-stat span { font-size: 14px; }
}
@media (max-width: 430px) {
  .wordmark { letter-spacing: .07em; }
  .title-actions .btn { padding: 12px 20px; font-size: 12px; }
  .btn { padding: 12px 20px; }
  .map-foot { flex-direction: column; align-items: flex-start; }
  .brief-wrap, .result-wrap, .pause-wrap, .how-wrap { padding: 18px; border-radius: 14px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .hud { padding-top: 6px; padding-bottom: 4px; }
  .hud-chapter { font-size: 13px; }
  .dock { min-height: 32px; padding-bottom: 6px; }
  .chain-mark { display: none; }
  .tagline { margin-top: 10px; }
  .title-actions { margin-top: 14px; }
  .map-wrap { max-height: calc(100dvh - 16px); padding: 14px 18px; }
}
