/*
  Aetherreach: styles follow the student's design sheet.
  Titles: Cinzel, gold, uppercase, wide spacing. Menus: Montserrat, white, emerald when selected.
  Lore: Cormorant Garamond italic. Transparent menus, thin gold borders with dragon/sacred-geometry
  corners, stone and parchment texture, floating gold and green particles, soft glow on selection.
*/

/* ---------- Fonts (self-hosted, Latin subset, SIL OFL: see fonts/OFL-*.txt) ---------- */
@font-face { font-family: "Cinzel"; font-weight: 400 900; font-display: swap; src: url("./fonts/cinzel-latin.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 100 900; font-display: swap; src: url("./fonts/montserrat-latin.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: italic; font-weight: 300 700; font-display: swap; src: url("./fonts/cormorant-garamond-italic-latin.woff2") format("woff2"); }

:root {
  --gold: #e8c473;
  --gold-deep: #b48a3c;
  --gold-pale: #f6e3b4;
  --emerald: #3ee69a;
  --emerald-deep: #12a86a;
  --night: #07050c;
  --ink: #f4efe4;
  --ink-2: #c9bfae;
  --panel: rgb(8 6 14 / 52%);
  --panel-strong: rgb(6 4 10 / 72%);
  --accent: var(--emerald);
  --font: "Montserrat", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Cinzel", "Cormorant Garamond", "Trajan Pro", Georgia, serif;
  --font-lore: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --bg: var(--night);
  --tap: 48px;
  color-scheme: dark;

  /* Thin gold border with diamond corners and quarter arcs (sacred geometry). */
  --c-tl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg transform='rotate(0 8 8)'%3E%3Cpath d='M1.5 13A11.5 11.5 0 0 0 13 1.5' fill='none' stroke='%23e8c473'/%3E%3Cpath d='M3 0l3 3-3 3-3-3z' fill='%23e8c473'/%3E%3C/g%3E%3C/svg%3E");
  --c-tr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg transform='rotate(90 8 8)'%3E%3Cpath d='M1.5 13A11.5 11.5 0 0 0 13 1.5' fill='none' stroke='%23e8c473'/%3E%3Cpath d='M3 0l3 3-3 3-3-3z' fill='%23e8c473'/%3E%3C/g%3E%3C/svg%3E");
  --c-br: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg transform='rotate(180 8 8)'%3E%3Cpath d='M1.5 13A11.5 11.5 0 0 0 13 1.5' fill='none' stroke='%23e8c473'/%3E%3Cpath d='M3 0l3 3-3 3-3-3z' fill='%23e8c473'/%3E%3C/g%3E%3C/svg%3E");
  --c-bl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg transform='rotate(270 8 8)'%3E%3Cpath d='M1.5 13A11.5 11.5 0 0 0 13 1.5' fill='none' stroke='%23e8c473'/%3E%3Cpath d='M3 0l3 3-3 3-3-3z' fill='%23e8c473'/%3E%3C/g%3E%3C/svg%3E");
  /* Stone and parchment grain. */
  --grain: 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='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .9 0 0 0 0 .8 0 0 0 0 .6 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  /* Faint hexagram and circles. */
  --geometry: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120' width='120' height='120'%3E%3Cg fill='none' stroke='%23e8c473' stroke-opacity='.05'%3E%3Ccircle cx='60' cy='60' r='40'/%3E%3Cpath d='M60 20L94.6 80H25.4zM60 100L25.4 40H94.6z'/%3E%3C/g%3E%3C/svg%3E");
}

html, body { height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- Layers ---------- */
.backdrop, #world, #fx { position: fixed; inset: 0; width: 100vw; height: 100dvh; }
.backdrop { z-index: 0; display: none; transition: filter .4s ease; }
body.show-backdrop .backdrop { display: block; }
#sky { width: 100%; height: 100%; }
#world { z-index: 1; transition: filter .3s ease; background: linear-gradient(#2b1d4a, #8a4a6b 60%, #e0905e); }
/* Soft vignette so the HUD reads as part of the world. */
.hud::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgb(10 4 18 / 55%) 100%); }
#world[hidden] { display: none; }
#fx { z-index: 2; pointer-events: none; }
.hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.hud[hidden] { display: none; }
.screen-root {
  position: fixed; inset: 0; z-index: 4; max-width: none; margin: 0;
  padding: calc(18px + var(--safe-top)) calc(18px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(18px + var(--safe-left));
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
.screen-root.s-game { pointer-events: none; padding: 0; }

body.over-game:not([data-screen="game"]) #world { filter: blur(2px) brightness(.7) saturate(.9); }
body[data-screen="saves-game"] #world,
body[data-screen="skills"] #world,
body[data-screen="dead"] #world { filter: blur(6px) brightness(.4); }
body[data-screen="saves-menu"] .backdrop,
body[data-screen="options-menu"] .backdrop { filter: blur(6px) brightness(.42); }
body[data-screen="loading"] { background: #020104; }

/* ---------- Shared pieces ---------- */
.frame, .frame-panel {
  border: 1px solid rgb(232 196 115 / 62%);
  box-shadow: inset 0 0 0 3px rgb(0 0 0 / 0%), inset 0 0 0 4px rgb(232 196 115 / 14%);
  background-color: var(--panel);
  background-image: var(--c-tl), var(--c-tr), var(--c-br), var(--c-bl), var(--grain), var(--geometry);
  background-position: top left, top right, bottom right, bottom left, 0 0, 0 0;
  background-size: 16px 16px, 16px 16px, 16px 16px, 16px 16px, auto, auto;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, repeat, repeat;
  background-origin: border-box;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.frame-panel { padding: 14px 24px 18px; background-color: var(--panel); }

.screen-title {
  font-family: var(--font-display);
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .24em;
  font-weight: 600;
  font-size: clamp(1.3rem, 3.2vw, 2rem);
  margin: 6px 0 4px;
  text-shadow: 0 0 18px rgb(232 196 115 / 35%);
}
.screen-title.big { font-size: clamp(1.7rem, 5vw, 3.2rem); }
.screen-sub { color: var(--ink-2); margin: 0 0 14px; font-size: .9rem; }
.lore-line, .lore-text {
  font-family: var(--font-lore);
  font-style: italic;
  color: var(--gold-pale);
  font-size: 1.15rem;
  line-height: 1.45;
}

/* Menu items: white text; selected glows emerald, grows, and shows golden lines. */
.menu-list { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.menu-item {
  position: relative;
  display: grid; grid-template-columns: auto auto auto; align-items: center; column-gap: 14px;
  min-height: var(--tap);
  padding: 6px 4px;
  background: none; border: 0; color: var(--ink);
  font: 600 clamp(1rem, 2.3vw, 1.25rem)/1.2 var(--font);
  text-transform: uppercase; letter-spacing: .22em;
  cursor: pointer;
  transform-origin: left center;
  transition: transform .18s ease, color .18s ease, text-shadow .18s ease;
}
.menu-item .mi-line {
  width: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold));
  position: relative; transition: width .22s ease;
}
.menu-item .mi-line.r { background: linear-gradient(90deg, var(--gold), transparent); }
.menu-item .mi-line::after {
  content: ""; position: absolute; top: -3px; width: 7px; height: 7px; background: var(--gold);
  transform: rotate(45deg); opacity: 0; transition: opacity .2s ease;
}
.menu-item .mi-line.l::after { right: -2px; }
.menu-item .mi-line.r::after { left: -2px; }
.menu-item .mi-hint {
  grid-column: 2; font: italic 400 .95rem/1.2 var(--font-lore); letter-spacing: .02em; text-transform: none;
  color: var(--ink-2); margin-top: 2px;
}
.menu-item.is-selected, .menu-item:focus-visible {
  color: var(--emerald);
  transform: scale(1.08);
  text-shadow: 0 0 14px rgb(62 230 154 / 75%), 0 0 30px rgb(62 230 154 / 35%);
  outline: none;
}
.menu-item.is-selected .mi-line, .menu-item:focus-visible .mi-line { width: clamp(22px, 5vw, 56px); }
.menu-item.is-selected .mi-line::after, .menu-item:focus-visible .mi-line::after { opacity: 1; }
.menu-item[disabled] { color: rgb(244 239 228 / 34%); cursor: default; }
.menu-item[disabled] .mi-hint { color: rgb(201 191 174 / 45%); }

.btn-rune {
  min-height: var(--tap); padding: 8px 20px;
  font: 600 .9rem var(--font); letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink); background: rgb(62 230 154 / 10%);
  border: 1px solid var(--gold-deep); border-radius: 2px; cursor: pointer;
  transition: box-shadow .2s ease, color .2s ease, border-color .2s ease;
}
.btn-rune:hover:not([disabled]), .btn-rune:focus-visible {
  color: var(--emerald); border-color: var(--emerald); outline: none;
  box-shadow: 0 0 16px rgb(62 230 154 / 45%), inset 0 0 12px rgb(62 230 154 / 20%);
}
.btn-rune[disabled] { opacity: .45; cursor: default; }
.screen-actions { margin-top: 16px; }

/* ---------- Ancient emblem ---------- */
.emblem { width: 100%; height: 100%; overflow: visible; }
.emblem .e-ring, .emblem .e-geo, .emblem .e-body, .emblem .e-spines { fill: none; stroke: var(--gold); }
.emblem .e-ring { stroke-width: 1.6; }
.emblem .e-ring.thin { stroke-width: .8; stroke-opacity: .7; }
.emblem .e-geo { stroke-width: .8; stroke-opacity: .55; }
.emblem .e-body { stroke-width: 7; stroke-linecap: round; }
.emblem .e-spines path, .emblem .e-fill { fill: var(--gold); stroke: none; }
.emblem .e-eye { fill: var(--emerald); }
.emblem .spin { transform-box: view-box; transform-origin: 100px 100px; }
.emblem-energy .e-ring, .emblem-energy .e-geo, .emblem-energy .e-body { stroke: var(--emerald); }
.emblem-energy .e-spines path, .emblem-energy .e-fill { fill: var(--emerald); }
.emblem-energy .e-geo { stroke-opacity: 1; }

/* ---------- A. Title screen ---------- */
.hero-wrap {
  position: absolute; right: 12vw; bottom: 20.5vh; height: 34vh; aspect-ratio: 140 / 280;
  filter: drop-shadow(0 0 10px rgb(255 190 110 / 30%));
}
.hero { width: 100%; height: 100%; animation: breathe 6s ease-in-out infinite; transform-origin: bottom center; }
@keyframes breathe { 50% { transform: scaleY(1.008) skewX(-.6deg); } }

.title-screen { height: 100%; position: relative; }
.logo-block {
  position: absolute; left: 6vw; top: 18vh; width: min(58vw, 720px);
  display: grid; justify-items: start;
}
.logo-emblem {
  position: absolute; left: 50%; top: 50%; width: min(48vw, 46vh, 420px); aspect-ratio: 1;
  transform: translate(-58%, -54%); opacity: .55; pointer-events: none;
  filter: drop-shadow(0 0 22px rgb(232 196 115 / 60%));
  animation: emblem-glow 5s ease-in-out infinite;
}
.logo-emblem .spin { animation: spin 90s linear infinite; }
@keyframes emblem-glow { 50% { opacity: .8; filter: drop-shadow(0 0 34px rgb(232 196 115 / 85%)); } }
.logo {
  position: relative; margin: 0;
  font: 700 clamp(2.4rem, 8vw, 6.4rem)/1 var(--font-display);
  text-transform: uppercase; letter-spacing: .12em;
  background: linear-gradient(180deg, #fff3cf 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgb(60 30 10 / 60%)) drop-shadow(0 0 24px rgb(232 196 115 / 45%));
}
.logo.small { font-size: clamp(1.3rem, 3.4vw, 2.2rem); }
.logo-sub {
  position: relative; margin: 10px 0 0 .3em;
  font: italic 500 clamp(1rem, 2.2vw, 1.55rem)/1.2 var(--font-lore); color: var(--gold-pale);
  letter-spacing: .06em; text-shadow: 0 1px 8px rgb(0 0 0 / 60%);
}
.press {
  position: absolute; left: 0; right: 0; bottom: calc(5vh + var(--safe-bottom)); text-align: center; margin: 0;
  font: 600 clamp(.8rem, 1.8vw, 1rem) var(--font); letter-spacing: .5em; text-transform: uppercase;
  color: var(--ink); text-shadow: 0 0 12px rgb(232 196 115 / 80%);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- B. Main menu ---------- */
.main-menu { min-height: 100%; display: grid; grid-template-rows: auto 1fr auto; gap: 18px; padding-left: 4vw; }
.menu-logo { display: flex; align-items: center; gap: 14px; }
.mini-emblem { width: 64px; height: 64px; flex: none; filter: drop-shadow(0 0 10px rgb(232 196 115 / 55%)); }
.main-menu .menu-list { align-self: center; gap: 10px; }
.menu-foot { max-width: 30ch; opacity: .85; }

/* ---------- C. Save / Load ---------- */
.saves-screen { max-width: 980px; margin: 0 auto; }
.slot-list { display: grid; gap: 12px; }
.slot-wrap { position: relative; }
.slot-card {
  width: 100%; display: grid; grid-template-columns: clamp(110px, 20vw, 192px) 1fr auto; align-items: center; gap: clamp(10px, 2vw, 22px);
  padding: 10px 110px 10px 10px; text-align: left; color: var(--ink); cursor: pointer;
  background-color: rgb(0 0 0 / 58%);
  transition: box-shadow .2s ease, transform .2s ease;
  font: inherit;
}
.slot-card:hover:not([disabled]), .slot-card:focus-visible {
  outline: none; transform: translateX(4px);
  box-shadow: 0 0 22px rgb(62 230 154 / 30%);
}
.slot-card:focus-visible .slot-loc, .slot-card:hover:not([disabled]) .slot-loc { color: var(--emerald); }
.slot-card[data-confirm] { box-shadow: 0 0 0 1px var(--emerald), 0 0 22px rgb(62 230 154 / 40%); }
.slot-card.empty { opacity: .8; }
.slot-card[disabled] { cursor: default; opacity: .5; }
.slot-thumb {
  aspect-ratio: 16 / 10; display: block; overflow: hidden; border: 1px solid rgb(232 196 115 / 55%);
  background: linear-gradient(135deg, var(--tint, #333), #120d1a);
}
.slot-thumb img { width: 100%; height: 100%; object-fit: cover; }
.slot-thumb.blank { background: repeating-linear-gradient(45deg, rgb(232 196 115 / 6%) 0 6px, transparent 6px 12px); }
.slot-info { display: grid; gap: 2px; min-width: 0; }
.slot-label { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); }
.slot-loc {
  font: 600 clamp(1rem, 2.4vw, 1.35rem) var(--font-display); color: var(--gold); letter-spacing: .08em;
  text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-meta { font-size: .85rem; color: var(--ink-2); }
.slot-stats { display: grid; gap: 6px; padding-right: 8px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.stat svg { width: 18px; height: 18px; }
.stat.hp svg { fill: #e25b5b; filter: drop-shadow(0 0 4px rgb(226 91 91 / 70%)); }
.stat.st svg { fill: var(--emerald); filter: drop-shadow(0 0 4px rgb(62 230 154 / 70%)); }
.stat.pr svg { fill: var(--gold); filter: drop-shadow(0 0 4px rgb(232 196 115 / 70%)); }
.erase {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%); min-height: 32px; padding: 2px 10px;
  background: rgb(0 0 0 / 60%); color: var(--ink-2); border: 1px solid rgb(232 196 115 / 35%);
  font: 500 .72rem var(--font); letter-spacing: .14em; text-transform: uppercase; cursor: pointer;
}
.erase[data-confirm] { color: #ff8b8b; border-color: #ff8b8b; }
.slot-status { min-height: 1.5em; color: var(--emerald); margin: 10px 0 0; }

/* ---------- D. Loading ---------- */
.loading-screen { position: relative; height: 100%; }
.lore-box { position: absolute; left: 6vw; bottom: 12vh; max-width: min(560px, 60vw); }
.lore-kind { font: 600 .75rem var(--font); letter-spacing: .4em; text-transform: uppercase; color: var(--emerald); margin: 0 0 6px; }
.lore-title {
  font: 600 clamp(1.2rem, 2.8vw, 1.8rem) var(--font-display); color: var(--gold);
  letter-spacing: .16em; text-transform: uppercase; margin: 0 0 10px;
}
.lore-box .lore-text { font-size: clamp(1.1rem, 2.2vw, 1.4rem); color: #e9dfc8; }
.loading-emblem {
  position: absolute; right: calc(4vw + var(--safe-right)); bottom: calc(5vh + var(--safe-bottom));
  width: clamp(84px, 13vw, 140px); aspect-ratio: 1;
}
.loading-emblem .emblem-base { opacity: .35; }
.loading-emblem .spin { animation: spin 6s linear infinite; }
.loading-emblem .emblem-energy { filter: drop-shadow(0 0 8px rgb(62 230 154 / 85%)); }
.load-pct {
  position: absolute; left: 0; right: 0; bottom: -22px; text-align: center;
  font: 600 .72rem var(--font); letter-spacing: .3em; color: var(--emerald);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Pause, options, dead, victory ---------- */
.pause-screen, .options-screen {
  max-width: 460px; margin: 6vh 0 0 4vw;
}
.pause-screen .menu-list { gap: 2px; }
.controls-help { margin-top: 12px; color: var(--ink-2); font-size: .85rem; }
.controls-help summary { cursor: pointer; letter-spacing: .18em; text-transform: uppercase; font-size: .75rem; min-height: 32px; }
.controls-help ul { padding-left: 18px; margin: 6px 0 0; }
.controls-help b { color: var(--ink); font-weight: 600; }
.opt-list { display: grid; gap: 4px; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px;
  border-bottom: 1px solid rgb(232 196 115 / 18%); letter-spacing: .1em; text-transform: uppercase; font-size: .85rem;
}
.opt input[type="range"] { accent-color: var(--emerald); width: 44%; min-height: var(--tap); }
.opt input[type="checkbox"] { accent-color: var(--emerald); width: 24px; height: 24px; }
.opt select {
  font: 500 16px var(--font); color: var(--ink); background: rgb(0 0 0 / 50%);
  border: 1px solid var(--gold-deep); min-height: 40px; padding: 4px 8px;
}
.opt .btn-rune { font-size: .72rem; padding: 6px 12px; }
.dead-screen { height: 100%; display: grid; place-content: center; text-align: center; justify-items: center; gap: 10px; background: radial-gradient(circle, rgb(60 0 10 / 25%), rgb(0 0 0 / 70%)); }
.dead-screen .screen-title { color: #e9a2a2; }
.dead-screen .lore-text { max-width: 44ch; }
.dead-screen .menu-list, .victory-screen .menu-list { align-items: center; }
.victory-screen { max-width: 620px; margin: 10vh auto 0; text-align: center; display: grid; justify-items: center; }
.victory-screen .mini-emblem { width: 110px; height: 110px; }

/* ---------- Skill tree ---------- */
.skills-screen { display: grid; gap: 14px; grid-template-columns: 1fr minmax(240px, 300px); grid-template-areas: "head head" "tree detail" "actions actions"; max-width: 1180px; margin: 0 auto; }
.skills-head { grid-area: head; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.points { margin: 0; letter-spacing: .16em; text-transform: uppercase; font-size: .85rem; color: var(--ink-2); }
.points b { color: var(--emerald); font-size: 1.3rem; text-shadow: 0 0 10px rgb(62 230 154 / 70%); }
.branches { grid-area: tree; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.branch { padding: 8px 12px 10px; background-color: rgb(0 0 0 / 45%); }
.branch header { display: flex; justify-content: space-between; align-items: baseline; }
.branch h3 { font: 600 1.05rem var(--font-display); color: var(--gold); letter-spacing: .2em; text-transform: uppercase; margin: 6px 0 0; }
.branch-level { font-size: .8rem; color: var(--emerald); letter-spacing: .1em; }
.branch-blurb { font-size: .95rem; margin: 0 0 4px; }
.branch-grid { position: relative; aspect-ratio: 1 / 1.45; margin: 8px 6px 30px; }
.branch-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.branch-lines line { stroke: rgb(232 196 115 / 40%); stroke-width: .8; vector-effect: non-scaling-stroke; }
.branch-lines line.on { stroke: var(--emerald); stroke-width: 2; filter: drop-shadow(0 0 3px var(--emerald)); }
.skill-node {
  position: absolute; transform: translate(-50%, -18px); display: grid; justify-items: center; gap: 4px;
  background: none; border: 0; color: var(--ink); cursor: pointer; padding: 0; width: 33%; min-height: var(--tap);
}
.node-gem {
  width: clamp(22px, 3vw, 32px); aspect-ratio: 1; transform: rotate(45deg); margin-bottom: 4px;
  border: 1.5px solid var(--gold-deep); background: rgb(10 8 16 / 85%);
  transition: box-shadow .2s ease, background .2s ease;
}
.node-name { font-size: clamp(.58rem, 1.1vw, .72rem); letter-spacing: .08em; text-transform: uppercase; text-align: center; line-height: 1.15; text-shadow: 0 1px 3px #000; }
.skill-node.locked { opacity: .5; }
.skill-node.available .node-gem, .skill-node.no-points .node-gem { border-color: var(--gold); }
.skill-node.available .node-gem { animation: gem-pulse 1.8s ease-in-out infinite; }
@keyframes gem-pulse { 50% { box-shadow: 0 0 14px rgb(232 196 115 / 80%); } }
.skill-node.unlocked .node-gem { background: radial-gradient(circle, #b6ffd9, var(--emerald) 45%, var(--emerald-deep)); border-color: var(--gold); box-shadow: 0 0 14px rgb(62 230 154 / 80%); }
.skill-node.unlocked .node-name { color: var(--emerald); }
.skill-node.is-selected .node-gem, .skill-node:focus-visible .node-gem { outline: 2px solid var(--emerald); outline-offset: 4px; }
.skill-node:focus-visible { outline: none; }
.skill-detail { grid-area: detail; align-self: start; padding: 10px 18px 18px; background-color: rgb(0 0 0 / 55%); }
.skill-detail h3 { font: 600 1.2rem var(--font-display); color: var(--gold); letter-spacing: .14em; text-transform: uppercase; margin: 8px 0 6px; }
.skill-detail .effect { color: var(--emerald); font-weight: 600; }
.skill-detail .reason { color: var(--ink-2); font-size: .85rem; min-height: 1.3em; }
.skills-screen .screen-actions { grid-area: actions; }

/* ---------- HUD ---------- */
.vitals {
  position: absolute; left: calc(10px + var(--safe-left)); top: calc(10px + var(--safe-top));
  width: min(300px, 62vw); padding: 8px 14px 10px; display: grid; gap: 4px;
}
.vit-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lvl { font: 600 .8rem var(--font-display); color: var(--gold); letter-spacing: .18em; }
.lvl b { font-size: 1.05rem; }
.loc { font: italic .95rem var(--font-lore); color: var(--gold-pale); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { display: grid; grid-template-columns: 16px 1fr 30px; align-items: center; gap: 6px; }
.bar .ico svg { width: 15px; height: 15px; }
.bar.hp .ico svg { fill: #e25b5b; }
.bar.st .ico svg { fill: var(--emerald); }
.bar b { font-size: .72rem; font-weight: 600; text-align: right; color: var(--ink-2); }
.track { height: 8px; border: 1px solid rgb(232 196 115 / 55%); background: rgb(0 0 0 / 55%); overflow: hidden; }
.track i { display: block; height: 100%; width: 100%; transition: width .15s linear; }
.bar.hp i { background: linear-gradient(90deg, #8d1f2c, #e25b5b); }
.bar.st i { background: linear-gradient(90deg, var(--emerald-deep), var(--emerald)); box-shadow: 0 0 8px rgb(62 230 154 / 60%); }
.bar.xp { grid-template-columns: 1fr; }
.bar.xp .track { height: 3px; border: 0; background: rgb(232 196 115 / 18%); }
.bar.xp i { background: var(--gold); }
.hud.low-hp .vitals { animation: low 1s ease-in-out infinite; }
@keyframes low { 50% { box-shadow: inset 0 0 18px rgb(226 91 91 / 45%); } }
.objective {
  position: absolute; left: calc(10px + var(--safe-left)); top: calc(124px + var(--safe-top));
  padding: 6px 12px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
}
.hud-right { position: absolute; right: calc(10px + var(--safe-right)); top: calc(10px + var(--safe-top)); display: flex; gap: 8px; pointer-events: auto; }
.weapon-chip {
  display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 14px;
  color: var(--ink); font: 600 .72rem var(--font); letter-spacing: .14em; text-transform: uppercase; cursor: pointer;
}
.weapon-chip svg { width: 20px; height: 20px; fill: var(--gold); color: var(--gold); }
.icon-btn { width: 60px; min-height: var(--tap); display: grid; place-content: center; gap: 4px; cursor: pointer; }
.icon-btn span { display: block; width: 18px; height: 2px; background: var(--gold); }
.banner {
  position: absolute; left: 50%; top: calc(16vh + var(--safe-top)); transform: translateX(-50%);
  width: max-content; max-width: 88vw; text-align: center; opacity: 0;
  font: 600 clamp(1rem, 2.6vw, 1.6rem) var(--font-display); color: var(--gold); letter-spacing: .22em; text-transform: uppercase;
  text-shadow: 0 0 16px rgb(232 196 115 / 60%), 0 2px 4px rgb(0 0 0 / 80%);
}
.banner::before, .banner::after { content: ""; display: block; height: 1px; margin: 6px auto; width: 70%; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.banner.show { animation: banner 2.8s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 6px); } 12%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.prompt {
  position: absolute; left: 50%; bottom: calc(150px + var(--safe-bottom)); transform: translateX(-50%);
  pointer-events: auto; min-height: var(--tap); padding: 0 18px; cursor: pointer;
  color: var(--emerald); font: 600 .85rem var(--font); letter-spacing: .16em; text-transform: uppercase;
  text-shadow: 0 0 10px rgb(62 230 154 / 70%);
}
.prompt[hidden] { display: none; }

.touch[hidden] { display: none; }
.stick {
  position: absolute; left: calc(26px + var(--safe-left)); bottom: calc(26px + var(--safe-bottom));
  width: 128px; height: 128px; border-radius: 50%; pointer-events: auto; touch-action: none;
  border: 1px solid rgb(232 196 115 / 55%); background: radial-gradient(circle, rgb(232 196 115 / 8%), rgb(0 0 0 / 35%));
}
.knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  border: 1px solid var(--gold); background: radial-gradient(circle, rgb(62 230 154 / 45%), rgb(0 0 0 / 40%));
  box-shadow: 0 0 12px rgb(62 230 154 / 40%);
}
.pad { position: absolute; right: calc(22px + var(--safe-right)); bottom: calc(22px + var(--safe-bottom)); width: 190px; height: 160px; }
.pad-btn {
  position: absolute; border-radius: 50%; pointer-events: auto; touch-action: none; cursor: pointer;
  border: 1px solid var(--gold); color: var(--ink); background: rgb(8 6 14 / 55%);
  font: 600 .7rem var(--font); letter-spacing: .12em;
}
.pad-btn.down { color: var(--emerald); border-color: var(--emerald); box-shadow: 0 0 16px rgb(62 230 154 / 70%); }
.pad-btn.attack { right: 0; bottom: 0; width: 86px; height: 86px; font-size: .8rem; }
.pad-btn.dodge { right: 100px; bottom: 4px; width: 62px; height: 62px; }
.pad-btn.swap { right: 18px; bottom: 98px; width: 54px; height: 54px; }

/* ---------- Small screens and portrait ---------- */
@media (max-width: 760px), (orientation: portrait) {
  .logo-block { top: 14vh; left: 7vw; width: 86vw; }
  .hero-wrap { right: 8vw; height: 26vh; }
  .skills-screen { grid-template-columns: 1fr; grid-template-areas: "head" "tree" "detail" "actions"; }
}
@media (max-width: 640px) {
  .branches { grid-template-columns: 1fr; }
  .branch-grid { max-width: 320px; margin-inline: auto; }
  .node-name { font-size: .7rem; }
  .slot-card { grid-template-columns: 96px 1fr; padding-right: 10px; }
  .erase { top: auto; bottom: 8px; transform: none; }
  .slot-stats { grid-column: 1 / -1; grid-auto-flow: column; justify-content: start; gap: 16px; padding: 0 0 4px 4px; }
  .pause-screen, .options-screen { margin: 4vh auto 0; }
  .lore-box { max-width: 78vw; bottom: 22vh; }
  .objective { top: calc(112px + var(--safe-top)); }
  .pad { transform: scale(.9); transform-origin: bottom right; }
  .stick { transform: scale(.9); transform-origin: bottom left; }
}
@media (max-height: 520px) {
  .logo-block { top: 8vh; }
  .main-menu .menu-list { gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .press, .logo-emblem, .hero, .skill-node.available .node-gem, .hud.low-hp .vitals { animation: none; }
  .logo-emblem .spin, .loading-emblem .spin { animation: none; }
  .press { opacity: 1; }
  .menu-item, .slot-card { transition: none; }
}

.hint-host { position: fixed; z-index: 6; left: 0; right: 0; top: calc(10px + var(--safe-top)); padding: 0 16px; max-width: 760px; margin: 0 auto; }
.hint-host:empty { display: none; }
.hint-host .notice { background: rgb(8 6 14 / 80%); color: var(--ink); border: 1px solid rgb(232 196 115 / 50%); }
.menu-item { text-shadow: 0 1px 6px rgb(20 8 30 / 70%); }
body:not([data-screen="title"]):not([data-screen="menu"]) .hint-host { display: none; }
