:root {
  color-scheme: dark;
  --bg: #090713;
  --panel: rgba(21, 15, 37, .88);
  --panel-solid: #171027;
  --edge: rgba(255, 231, 176, .15);
  --ink: #f8f2e5;
  --muted: #aaa2ba;
  --faint: #6e667c;
  --gold: #f7cb65;
  --gold-dark: #9d6423;
  --ruby: #ff4568;
  --ruby-dark: #6b1028;
  --violet: #a97cff;
  --cyan: #72e8ff;
  --good: #72e7a8;
  --danger: #ff6b76;
  --serif: "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 16% 18%, rgba(126, 54, 158, .25), transparent 28%),
    radial-gradient(circle at 84% 70%, rgba(184, 48, 72, .18), transparent 30%),
    linear-gradient(145deg, #130c20, #07060d 72%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background-image:
    repeating-linear-gradient(115deg, transparent 0 18px, rgba(255,255,255,.035) 19px 20px),
    repeating-linear-gradient(25deg, transparent 0 23px, rgba(0,0,0,.14) 24px 25px);
  mix-blend-mode: soft-light;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--cyan); outline-offset: 4px; }

.prototype-shell { width: min(1480px, 100%); margin: 0 auto; padding: 22px clamp(14px, 2.5vw, 38px) 36px; }
.topbar { display: flex; align-items: center; gap: 18px; }
.back-link {
  display: grid; place-items: center; flex: 0 0 42px; height: 42px;
  color: var(--muted); text-decoration: none; font-size: 25px;
  border: 1px solid var(--edge); border-radius: 50%; background: rgba(255,255,255,.035);
  transition: transform .18s, color .18s, border-color .18s;
}
.back-link:hover { transform: translateX(-3px); color: var(--gold); border-color: rgba(247,203,101,.5); }
.title-lockup { flex: 1; min-width: 0; }
.eyebrow { color: #b9a5d5; font-size: 10px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.title-lockup h1 { margin: 3px 0 2px; font: 800 clamp(25px, 3vw, 42px)/1 var(--serif); letter-spacing: .035em; }
.title-lockup p { margin: 0; color: var(--muted); font-size: 13px; }

.run-stats { display: flex; gap: 8px; }
.stat {
  min-width: 78px; padding: 8px 12px; text-align: center;
  border: 1px solid var(--edge); border-radius: 13px;
  background: linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.02));
  box-shadow: inset 0 1px rgba(255,255,255,.06);
}
.stat span { display: block; margin-bottom: 1px; color: var(--faint); font-size: 8px; font-weight: 800; letter-spacing: .18em; }
.stat strong { font-size: 18px; }
.stat:first-child strong { color: var(--cyan); }
.stat:nth-child(2) strong { color: var(--gold); }
.stat.luck strong { color: #c39cff; }

.choice-banner {
  display: flex; align-items: center; gap: 16px; margin: 20px 0 14px; padding: 12px 16px;
  border: 1px solid rgba(247,203,101,.24); border-radius: 15px;
  background: linear-gradient(90deg, rgba(135,82,30,.18), rgba(45,28,71,.18));
}
.choice-icon { color: var(--gold); font-size: 26px; }
.choice-banner div { display: flex; flex-direction: column; }
.choice-banner strong { font-size: 11px; letter-spacing: .03em; }
.choice-banner small { color: var(--muted); font-size: 9px; }
.choice-divider { width: 1px; height: 27px; background: var(--edge); }
.text-button {
  margin-left: auto; padding: 7px 10px; border: 0; color: var(--muted); background: transparent;
  cursor: pointer; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.text-button:hover { color: var(--gold); }
.lab-link {
  padding: 7px 11px; color: var(--gold); text-decoration: none;
  border: 1px solid rgba(247,203,101,.28); border-radius: 9px;
  background: rgba(247,203,101,.055); font-size: 9px; font-weight: 900; letter-spacing: .04em;
}
.lab-link:hover { border-color: rgba(247,203,101,.65); filter: brightness(1.2); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(320px, .72fr); gap: 14px; }
.map-card, .room-panel, .spoils-drawer {
  border: 1px solid var(--edge); border-radius: 22px;
  background: var(--panel); box-shadow: 0 22px 55px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(16px);
}
.map-card { min-width: 0; padding: 18px; overflow: hidden; }
.map-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.map-heading h2, .spoils-drawer h2 { margin: 3px 0 0; font: 700 clamp(17px, 2vw, 23px)/1.15 var(--serif); }
.map-legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.dot { display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; }
.dot.available { background: var(--gold); box-shadow: 0 0 9px var(--gold); }
.dot.cleared { background: var(--good); }

.route-map {
  position: relative; min-height: 580px; overflow: hidden;
  border: 1px solid rgba(247,203,101,.12); border-radius: 17px;
  background:
    linear-gradient(rgba(9,7,14,.54), rgba(9,7,14,.72)),
    url("../../web2/assets/themes/ironkeep-hall.jpg") center / cover;
  isolation: isolate;
}
.route-map::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .6;
  background:
    radial-gradient(ellipse at 54% 22%, rgba(255,66,102,.19), transparent 22%),
    radial-gradient(ellipse at 58% 78%, rgba(138,86,255,.22), transparent 22%),
    radial-gradient(ellipse at 20% 52%, rgba(247,203,101,.14), transparent 32%),
    linear-gradient(90deg, rgba(5,4,10,.26), transparent 45%, rgba(5,4,10,.28));
}
.route-map::after {
  content: "OPTIONAL DEPTHS"; position: absolute; right: 17px; top: 13px;
  color: rgba(255,255,255,.11); font: 700 10px var(--serif); letter-spacing: .26em;
}
.cave-glow { position: absolute; width: 160px; height: 160px; border-radius: 50%; filter: blur(40px); opacity: .18; pointer-events: none; }
.glow-a { left: 47%; top: 2%; background: var(--ruby); }
.glow-b { left: 50%; bottom: 0; background: var(--violet); }

.map-edges { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; overflow: visible; pointer-events: none; }
.map-edge { fill: none; stroke: rgba(247,203,101,.9); stroke-linecap: round; }
.map-edge.idle { stroke-width: 3; stroke-opacity: .3; stroke-dasharray: 6 9; }
.map-edge.open { stroke-width: 4; stroke-opacity: .9; stroke-dasharray: 8 8; animation: edge-march 1s linear infinite; filter: drop-shadow(0 0 5px rgba(247,203,101,.5)); }
.map-edge.done { stroke-width: 4.5; stroke-opacity: .95; filter: drop-shadow(0 0 6px rgba(247,203,101,.5)); }
@keyframes edge-march { to { stroke-dashoffset: -16; } }

.map-node {
  --node-color: var(--gold);
  position: absolute; left: var(--x); top: var(--y); z-index: 2;
  display: flex; flex-direction: column; align-items: center; width: 150px;
  transform: translate(-50%, -50%); border: 0; background: transparent; cursor: pointer;
}
.node-ring {
  display: grid; place-items: center; width: 74px; height: 74px; overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--node-color) 60%, #fff); border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--node-color) 27%, #191123), #0b0812 72%);
  box-shadow: 0 0 0 7px rgba(5,4,8,.62), 0 0 23px color-mix(in srgb, var(--node-color) 38%, transparent), inset 0 0 20px rgba(0,0,0,.65);
  transition: transform .2s cubic-bezier(.2,1.6,.4,1), filter .2s, box-shadow .2s;
}
.image-ring img { width: 94%; height: 94%; object-fit: contain; filter: drop-shadow(0 5px 6px rgba(0,0,0,.65)); }
.map-node:hover .node-ring, .map-node.active .node-ring { transform: scale(1.09); filter: brightness(1.2); box-shadow: 0 0 0 7px rgba(5,4,8,.72), 0 0 32px color-mix(in srgb, var(--node-color) 60%, transparent); }
.node-copy { display: flex; flex-direction: column; align-items: center; width: 168px; margin-top: 8px; text-shadow: 0 2px 7px #000, 0 2px 7px #000; }
.node-copy strong { font: 700 12px var(--serif); }
.node-copy small { color: #c6bdcc; font-size: 9px; }
.node-risk, .node-bonus {
  position: absolute; z-index: 3; top: -15px; padding: 3px 7px; border-radius: 99px;
  color: #ffccd3; background: rgba(87,14,32,.92); border: 1px solid rgba(255,80,112,.52);
  font-size: 7px; font-weight: 900; letter-spacing: .08em; white-space: nowrap;
}
.node-bonus { color: #ffe3a1; background: rgba(82,55,14,.94); border-color: rgba(247,203,101,.52); }
.start-node { --node-color: var(--good); }
.challenge-node { --node-color: var(--ruby); }
.rock-node { --node-color: #ff6e62; }
.chest-node { --node-color: var(--gold); }
.chance-node { --node-color: var(--violet); }
.deadend-node { --node-color: var(--cyan); }
.map-node.cleared .node-ring::after { content: "✓"; position: absolute; right: 30px; top: 1px; display: grid; place-items: center; width: 20px; height: 20px; color: #061d13; background: var(--good); border: 2px solid #caffdf; border-radius: 50%; font-size: 11px; font-weight: 900; }
.map-node.locked { filter: grayscale(.9); opacity: .42; cursor: not-allowed; }

.main-route {
  position: absolute; left: 15px; bottom: 13px; z-index: 3;
  display: flex; flex-direction: column; padding: 9px 14px; min-width: 196px;
  color: var(--muted); text-decoration: none; border: 1px solid rgba(255,255,255,.12); border-radius: 11px;
  background: rgba(8,6,12,.7); transition: border-color .18s, transform .18s, color .18s;
}
.main-route:hover { color: var(--ink); border-color: rgba(255,255,255,.35); transform: translateY(-2px); }
.main-route span { font-size: 7px; letter-spacing: .18em; }
.main-route strong { color: #eeb2c9; font: 700 11px var(--serif); }
.main-route small { font-size: 8px; }

.room-panel { position: relative; min-height: 660px; overflow: hidden; }
.room-panel::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 0, rgba(169,124,255,.13), transparent 35%); }
.panel-idle { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 660px; padding: 36px; text-align: center; }
.panel-idle .compass { display: grid; place-items: center; width: 110px; height: 110px; margin-bottom: 20px; color: var(--gold); font-size: 42px; border: 1px solid rgba(247,203,101,.26); border-radius: 50%; background: radial-gradient(circle, rgba(247,203,101,.13), transparent 68%); box-shadow: 0 0 45px rgba(247,203,101,.11), inset 0 0 32px rgba(247,203,101,.08); animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05) rotate(6deg); filter: brightness(1.3); } }
.panel-idle h2 { margin: 4px 0 8px; font: 700 24px var(--serif); }
.panel-idle > p:not(.eyebrow) { max-width: 300px; margin: 0; color: var(--muted); line-height: 1.6; font-size: 12px; }
.design-rule { margin-top: 25px; padding: 12px 15px; color: var(--muted); border: 1px solid var(--edge); border-radius: 12px; font-size: 10px; }
.design-rule span { display: block; margin-bottom: 3px; color: var(--gold); font-size: 7px; font-weight: 900; letter-spacing: .2em; text-transform: uppercase; }

.room { position: relative; min-height: 660px; padding: 19px; animation: room-in .3s ease both; }
@keyframes room-in { from { opacity: 0; transform: translateX(12px); } }
.room-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.room-kicker { color: var(--gold); font-size: 8px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.room h2 { margin: 4px 0; font: 700 23px var(--serif); }
.room-sub { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.close-room { border: 1px solid var(--edge); border-radius: 50%; width: 34px; height: 34px; background: rgba(255,255,255,.04); cursor: pointer; }
.close-room:hover { border-color: var(--gold); color: var(--gold); }
.room-art { position: relative; display: grid; place-items: center; height: 235px; margin: 13px 0; overflow: hidden; border: 1px solid var(--edge); border-radius: 16px; background: radial-gradient(circle at 50% 55%, rgba(138,67,51,.42), transparent 48%), linear-gradient(#161025, #09070d); }
.room-art::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 -35px 50px rgba(0,0,0,.4); }
.room-art img { position: relative; z-index: 1; max-width: 95%; max-height: 94%; object-fit: contain; filter: drop-shadow(0 12px 16px rgba(0,0,0,.7)); transition: transform .25s, filter .25s, opacity .25s; }
.rock-room .room-art img { width: 245px; }
.rock-room.crack-1 .room-art img { transform: scale(1.025) rotate(-1deg); filter: brightness(1.18) drop-shadow(0 0 22px rgba(255,56,81,.65)); }
.rock-room.crack-2 .room-art img { transform: scale(1.055) rotate(1deg); filter: brightness(1.38) drop-shadow(0 0 38px rgba(255,56,81,.85)); }
.rock-room.broken .room-art img { transform: scale(1.18); opacity: .2; filter: brightness(2); }
.room-meter { margin: 8px 0 13px; }
.meter-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.meter-head strong { color: var(--ink); }
.meter-track { height: 9px; margin-top: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); border-radius: 99px; background: rgba(0,0,0,.5); }
.meter-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ruby-dark), var(--ruby), #ffbf62); box-shadow: 0 0 12px var(--ruby); transition: width .5s cubic-bezier(.2,.9,.25,1); }

.hand-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.hand-choice, .sigil-choice, .fate-card, .primary-action, .secondary-action {
  border: 1px solid var(--edge); border-radius: 12px; background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.025)); cursor: pointer; transition: transform .15s, border-color .15s, filter .15s;
}
.hand-choice { padding: 9px; text-align: left; }
.hand-choice:hover:not(:disabled), .sigil-choice:hover:not(:disabled), .fate-card:hover:not(:disabled), .primary-action:hover:not(:disabled), .secondary-action:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(247,203,101,.55); filter: brightness(1.18); }
.hand-choice:disabled, .sigil-choice:disabled, .fate-card:disabled { opacity: .35; cursor: default; }
.mini-cards { display: flex; height: 31px; margin-bottom: 6px; }
.mini-card { display: grid; place-items: center; width: 24px; height: 31px; margin-right: -5px; color: #271621; background: #f7efe1; border: 1px solid #cdbb9d; border-radius: 4px; box-shadow: 1px 2px 3px rgba(0,0,0,.38); font: 800 9px Georgia, serif; transform: rotate(var(--tilt,0)); }
.mini-card.red { color: #bd2745; }
.hand-label { display: flex; justify-content: space-between; gap: 6px; font-size: 9px; }
.hand-label strong { color: var(--gold); }
.weakness { margin-top: 3px; color: #ff9a76; font-size: 7px; font-weight: 800; letter-spacing: .08em; }

.risk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.risk-cell { padding: 9px; border: 1px solid var(--edge); border-radius: 10px; background: rgba(255,255,255,.025); text-align: center; }
.risk-cell span { display: block; color: var(--faint); font-size: 7px; letter-spacing: .14em; }
.risk-cell strong { font-size: 12px; }
.primary-action, .secondary-action { width: 100%; padding: 11px 14px; font-weight: 900; letter-spacing: .06em; }
.primary-action { color: #2b1c00; border-color: #ffe1a0; background: linear-gradient(#ffe69f, #eeb747); }
.secondary-action { margin-top: 7px; color: var(--muted); }
.action-note { margin: 7px 0 0; color: var(--faint); text-align: center; font-size: 8px; }

.sigil-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-top: 13px; }
.sigil-choice { min-height: 67px; padding: 10px; }
.sigil-choice strong { display: block; font: 700 11px var(--serif); }
.sigil-choice span { color: var(--muted); font-size: 8px; }
.clue-scroll { margin: 12px 0; padding: 11px; color: #e1cfaa; border: 1px solid rgba(247,203,101,.27); border-radius: 10px; background: rgba(89,62,20,.13); font: italic 11px Georgia, serif; text-align: center; }

.fate-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 14px; }
.fate-card { position: relative; min-height: 152px; padding: 11px 7px; overflow: hidden; }
.fate-card::before { content: "✦"; display: grid; place-items: center; width: 54px; height: 54px; margin: 8px auto 13px; color: #dcc8ff; border: 1px solid rgba(169,124,255,.5); border-radius: 50%; background: radial-gradient(circle, rgba(169,124,255,.32), rgba(35,22,59,.7)); font-size: 23px; box-shadow: 0 0 18px rgba(169,124,255,.2); }
.fate-card strong { display: block; font: 700 9px var(--serif); }
.fate-card span { color: var(--muted); font-size: 7px; }
.fate-card.revealed::before { content: attr(data-glyph); color: var(--gold); }
.fate-card.winner { border-color: var(--gold); box-shadow: 0 0 20px rgba(247,203,101,.18); }
.odds { margin-top: 11px; color: var(--muted); font-size: 8px; line-height: 1.6; text-align: center; }
.odds strong { color: var(--ink); }

.result-card { margin-top: 13px; padding: 14px; border: 1px solid rgba(114,231,168,.4); border-radius: 13px; background: rgba(25,103,67,.15); text-align: center; animation: reward-in .45s cubic-bezier(.2,1.4,.35,1) both; }
@keyframes reward-in { from { opacity: 0; transform: scale(.82); } }
.result-card img { width: 74px; height: 74px; object-fit: contain; filter: drop-shadow(0 0 16px rgba(247,203,101,.55)); }
.result-card strong { display: block; color: var(--good); font: 700 14px var(--serif); }
.result-card span { color: var(--muted); font-size: 9px; }

.spoils-drawer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; margin-top: 14px; padding: 15px 18px; }
.spoils-list { display: flex; gap: 9px; min-width: 0; overflow-x: auto; }
.empty-spoil { color: var(--faint); font-size: 10px; font-style: italic; }
.spoil { display: flex; align-items: center; flex: 0 0 auto; gap: 8px; min-width: 150px; padding: 7px 9px; border: 1px solid var(--edge); border-radius: 10px; background: rgba(255,255,255,.035); }
.spoil img { width: 39px; height: 39px; object-fit: contain; }
.spoil strong, .spoil span { display: block; }
.spoil strong { font: 700 9px var(--serif); }
.spoil span { color: var(--muted); font-size: 7px; }
.route-status { display: flex; flex-direction: column; align-items: center; min-width: 78px; }
.route-status span { color: var(--gold); font: 700 18px var(--serif); }
.route-status small { color: var(--faint); font-size: 8px; }

.toast { position: fixed; left: 50%; bottom: 25px; z-index: 20; max-width: min(420px, calc(100vw - 30px)); padding: 11px 16px; opacity: 0; transform: translate(-50%, 18px); color: var(--ink); border: 1px solid rgba(247,203,101,.38); border-radius: 12px; background: rgba(19,13,31,.96); box-shadow: 0 16px 45px rgba(0,0,0,.55); pointer-events: none; font-size: 11px; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.shake { animation: shake .28s linear; }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.flash { animation: flash .35s ease; }
@keyframes flash { 50% { filter: brightness(1.65); } }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; }
  .room-panel, .panel-idle, .room { min-height: auto; }
  .room-panel { min-height: 420px; }
  .panel-idle { min-height: 420px; }
  .route-map { min-height: 560px; }
}

@media (max-width: 680px) {
  .prototype-shell { padding-inline: 10px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .title-lockup { order: 1; flex-basis: calc(100% - 64px); }
  .run-stats { order: 3; width: 100%; }
  .stat { flex: 1; }
  .choice-banner { align-items: flex-start; flex-wrap: wrap; gap: 8px 12px; }
  .choice-divider { display: none; }
  .choice-banner div { width: calc(50% - 30px); }
  .text-button { width: 100%; margin: 3px 0 0; text-align: left; }
  .lab-link { width: 100%; }
  .map-card { padding: 12px; }
  .map-heading { align-items: flex-start; flex-direction: column; }
  .map-legend { display: none; }
  .route-map { min-height: 650px; }
  .map-node { width: 120px; }
  .node-ring { width: 62px; height: 62px; }
  .node-copy { width: 126px; }
  .node-copy strong { font-size: 10px; }
  .start-node { --x: 16% !important; --y: 46% !important; }
  .challenge-node { --x: 44% !important; --y: 46% !important; }
  .rock-node { --x: 69% !important; --y: 20% !important; }
  .chest-node { --x: 84% !important; --y: 44% !important; }
  .chance-node { --x: 69% !important; --y: 72% !important; }
  .deadend-node { --x: 84% !important; --y: 89% !important; }
  .line-main { left: 16%; top: 46%; width: 29%; }
  .line-rock { left: 46%; top: 43%; width: 32%; transform: rotate(-48deg); }
  .line-vault { left: 69%; top: 23%; width: 28%; transform: rotate(61deg); }
  .line-chance { left: 46%; top: 49%; width: 32%; transform: rotate(48deg); }
  .main-route { left: 9px; bottom: 9px; }
  .spoils-drawer { grid-template-columns: 1fr auto; }
  .spoils-list { grid-column: 1 / -1; grid-row: 2; }
  .room-art { height: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
