
/* =====================================================================
   OVERLAYS (phase screens) + POPUPS (deck, map peek, settings)
   ===================================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: calc(var(--hud-h, 0px) + 16px) 16px 20px;
  backdrop-filter: blur(4px); overflow-y: auto; background: rgba(13, 20, 48, .82);
}
.overlay.cover { z-index: 130; padding-top: 20px; }
.overlay.solid { background: rgba(9,11,21,0.96); }
.overlay.show { display: grid; animation: fadeIn .25s ease; }
#popup { z-index: 150; padding-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(960px, 100%); padding: 28px 24px; border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); box-shadow: 0 30px 80px var(--shade-60), 0 0 0 1px rgba(201,161,59,0.12) inset;
  text-align: center; animation: rise .3s ease;
}
.modal.narrow { width: min(620px, 100%); }
.modal.map-modal { width: min(760px, 100%); padding: 20px 18px; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.modal h1 { font-weight: 700; font-size: 34px; margin: 0 0 6px; color: var(--gold-2); }
.modal h1.bad { color: var(--claw) !important; }
.modal h3 { color: var(--gold-2); font-size: 18px; margin: 18px 0 4px; }
.modal .sub {
  margin: 0 0 18px; font-size: 15px; line-height: 1.5; color: var(--ink-muted);
}
.modal .big-icon { font-size: 54px; margin-bottom: 4px; filter: none !important; color: var(--royal); }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.link-btn { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 6px; }
.link-btn:hover { color: var(--text); }
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.title-actions .btn { min-width: 240px; }
.save-info { font-size: 12px; color: var(--muted); margin: -4px 0 6px; }
.fine { color: var(--muted); font-size: 11px; margin-top: 30px; opacity: 0.8; }

/* Card rows / grids */
.card-row { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; padding: 14px 0 6px; }
.card-row .card { --card-w: 150px; --card-h: 210px; }
.card-row .card .card-name { font-size: 14.5px !important; }
.card-row .card .card-art { height: 70px; font-size: 40px; }
.card.selectable { cursor: pointer; }
.card.chosen { transform: translateY(-10px) scale(1.05); filter: drop-shadow(0 0 0 var(--claw)) drop-shadow(0 0 4px var(--claw)) !important; box-shadow: 0 10px 14px -6px var(--night-55) !important; }
.card.not-chosen { opacity: 0.3; filter: grayscale(1); cursor: default; }
.card.not-chosen:hover { transform: none; box-shadow: none; }
.pile-grid { display: flex; flex-wrap: wrap; gap: 18px 10px; justify-content: center; padding: 14px 4px; max-height: calc(58 * var(--hvh)); overflow-y: auto; }
.pile-grid .card { cursor: default; }
.pile-grid .card:hover { transform: none; }
.pile-grid.removable .card { cursor: pointer; }
.pile-grid.removable .card:hover { transform: translateY(-6px); box-shadow: 0 0 0 2px var(--hp-2), 0 0 20px rgba(255,107,94,0.4); }

/* Map */
.map-head h1 { font-size: 28px !important; }
.map-scroll {
  border-radius: 12px; background: radial-gradient(ellipse at center, #222942, #121625); border: 1px solid var(--line); scrollbar-width: thin;
  scrollbar-color: var(--line) transparent; max-height: none !important; overflow-x: auto !important; padding: 0 !important;
  overflow-y: hidden !important; box-shadow: inset 0 0 40px rgba(63,74,117,.25); overflow: hidden !important; cursor: default !important;
  width: 100%; max-width: 100%;
}
.map {
  position: relative; width: 100%; max-width: none !important; margin: 0 !important;
}
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.map line { stroke: #3e4a79; stroke-width: 2; stroke-dasharray: 3 6; vector-effect: non-scaling-stroke; }
.map line.open { stroke: #9c8bb8; stroke-width: 2.5; }
.map line.traveled { stroke: var(--gold); stroke-dasharray: none; stroke-width: 3; }
.map-node {
  position: absolute; transform: translate(-50%, -50%); padding: 0; border-radius: 50%; font-size: 22px; display: grid; place-items: center;
  transition: transform .15s, box-shadow .15s; width: 50px !important; height: 50px !important; background: var(--ivory) !important;
  border: 2px solid var(--royal) !important;
}
.map-node.boss {
  font-size: 40px; border-color: #b8433a; background: radial-gradient(circle, #3a1d22, #1a1216); width: 86px !important; height: 86px !important;
}
.map-node.available { border-color: var(--gold-2); animation: nodePulse 1.4s ease-in-out infinite; cursor: pointer; }
.map-node.available:hover { transform: translate(-50%, -50%) scale(1.18); }
.map-node.visited { border-color: var(--gold); filter: saturate(0.5); opacity: 0.7; }
.map-node.current { opacity: 1; filter: none; box-shadow: 0 0 0 5px rgba(201,161,59,0.45); }
.map-node:disabled { cursor: default; }
@keyframes nodePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(233,198,106,0.55); } 50% { box-shadow: 0 0 0 9px rgba(233,198,106,0); } }
.legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 12px 0 0; }

/* Event & rest */
.event-art { font-size: 64px; margin: 6px 0; }
.event-text { font-size: 16px; line-height: 1.6; color: var(--text); max-width: 520px; margin: 0 auto 18px; }
.choices { display: flex; flex-direction: column; gap: 10px; max-width: 520px; margin: 0 auto; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2);
  transition: border-color .15s, transform .12s, background .15s;
}
.choice b { font-family: var(--font-display); font-size: 17px; color: var(--gold-2); }
.choice span { font-size: 13px; color: var(--muted); }
.choice:hover:not(:disabled) { border-color: var(--gold); background: #1c223a; transform: translateX(4px); }
.choice:disabled { opacity: 0.4; }
.result-box {
  max-width: 520px; margin: 0 auto; padding: 14px 16px; border-radius: 12px; font-size: 15px; line-height: 1.5; background: var(--paper);
  color: var(--ink); border: 0; border-left: 5px solid var(--royal); box-shadow: 0 3px 0 rgba(30,27,22,.15); font-family: var(--font-body);
}
.option-grid { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.option-card {
  width: 170px; padding: 18px 14px; border: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 6px;
  align-items: center; transition: transform .15s, border-color .15s; border-radius: 8px !important;
}
.option-card .ico { font-size: 40px; }
.option-card b { font-family: var(--font-display); font-size: 18px; color: var(--gold-2); }
.option-card span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.option-card:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--gold); }
.option-card:disabled { opacity: 0.45; }

.stat-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.stat { padding: 10px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 110px; }
.stat b { display: block; font-family: var(--font-display); font-size: 24px; color: var(--gold-2); }
.stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 14px; text-align: left; max-width: 420px; margin: 0 auto; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.setting-row label { font-weight: 600; }
.setting-row small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.setting-row input[type=range] { width: 150px; accent-color: var(--gold); }
.setting-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--claw); }

/* Class resources: Valor (gold), Focus (green), Mana (blue) */
.energy-orb.focus {
  border-color: #dcffd8; box-shadow: 0 0 22px rgba(79,191,106,0.45), inset 0 -6px 12px var(--shade-30); color: #04200b; background: #4f6a2a !important;
}
.energy-orb.mana {
  border-color: #e0ebff; box-shadow: 0 0 22px rgba(91,141,239,0.5), inset 0 -6px 12px var(--shade-30); color: #04102e; background: #2f4f74 !important;
}
.card.e-focus .cost { border-color: #dcffd8; color: #04200b; background: #4f6a2a !important; }
.card.e-mana .cost { border-color: #e0ebff; color: #04102e; background: #2f4f74 !important; }
.card.upgraded .card-name { color: #d4f7c8 !important; }
.card.upgraded { box-shadow: 0 8px 18px var(--shade-50), 0 0 0 1px rgba(166,244,197,0.35); }
.card-text .boosted { color: #9fe5c8; font-weight: 700; }
.card-text .reduced { color: #ff8f80; font-weight: 700; }
.pile-grid.upgradable .card { cursor: pointer; }
.pile-grid.upgradable .card:hover { transform: translateY(-6px); box-shadow: 0 0 0 2px #a6f4c5, 0 0 20px rgba(166,244,197,0.35); }
.gear-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.gear-row {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px !important;
}
.gear-row.empty { opacity: 0.55; border-style: dashed; }
.gear-row .gear-ico { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; font-size: 24px; border-radius: 10px; background: radial-gradient(circle at 35% 30%, #2f3a65, #161b2f 70%); border: 1px solid var(--gold); }
.gear-row.empty .gear-ico { border: 1px dashed var(--line); filter: grayscale(1); }
.gear-row b { font-family: var(--font-display); color: var(--gold-2); font-size: 15px; }
.gear-row small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; margin-left: 4px; }
.gear-row span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; margin-top: 2px; }

/* Build badges and statuses */
.card .build-tag {
  position: absolute; top: -9px; right: -8px; width: 24px; height: 24px; display: grid; place-items: center; font-size: 13px;
  box-shadow: 0 2px 5px var(--shade-50); cursor: help; background: var(--ivory) !important; border: 1px solid var(--ink) !important;
  border-radius: 50% !important;
}
.card .school-tag { right: 20px; }
.status.momentum {
  background: #131b3a; cursor: help; border-color: var(--moss) !important; color: #2f4421 !important;
}
.status.thorns {
  background: #16291c; cursor: help; border-color: var(--moss) !important; color: #2f4421 !important;
}
.intent.breath { border-color: #d5b667; background: linear-gradient(180deg, #152153, #0d1433); color: #ebdfc4; }
.status.evasion {
  background: #1c233e; cursor: help; border-color: var(--royal) !important; color: var(--royal) !important;
}
.status.charge {
  background: #1d264b; cursor: help; border-color: var(--gilt-dark) !important; color: #5b4712 !important;
}
.status.mark {
  background: #3a1a1a; cursor: help; border-color: var(--claw) !important; color: var(--claw-dark) !important;
}
.status.chill {
  background: #13283a; cursor: help; border-color: var(--royal) !important; color: var(--royal) !important;
}
.floater.evade { font-size: 20px; color: var(--royal) !important; }
.class-builds span.locked {
  border-style: dashed; background: none !important; border: none !important; padding: 3px 2px !important; opacity: .62;
}

/* Card rarity + Powers */
.card.power {
  border-color: #c77dff; background: linear-gradient(180deg, #263160 0%, #192142 55%, #181d32 100%); --tc2: #6d531a; --tc: var(--moss);
}
.card .card-type .rar { font-weight: 400 !important; }
.hand .card.power .card-text { font-size: 11.5px !important; line-height: 1.22 !important; }
.card.r-common .rar { color: #b9b0c8; }
.card.r-uncommon .rar { color: #6fd3ff; }
.card.r-rare .rar { color: var(--gilt-light); }
.card.r-legendary .rar { color: #e6b3ff; }
.card.r-uncommon { box-shadow: inset 0 0 0 3px var(--ivory), inset 0 0 0 5px var(--tc), 0 0 0 2px #2f5f7a, 0 6px 14px var(--shade-50) !important; }
.card.r-rare { box-shadow: inset 0 0 0 3px var(--ivory), inset 0 0 0 5px var(--tc), 0 0 0 2px var(--gilt-aged), 0 0 12px rgba(188,150,52,.35), 0 6px 14px var(--shade-50) !important; --paper-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 140' preserveAspectRatio='none'%3E%3Cpolygon points='0,3 7,1.2 14,2.8 22,0.6 30,2.2 38,0 46,2.6 54,0.9 62,2.4 70,0.2 78,2.5 86,0.7 93,2.2 100,0.9 100,140 0,140' fill='%23efe6d2'/%3E%3Crect x='0' y='137.5' width='100' height='2.5' fill='%23c9a13b'/%3E%3C/svg%3E"); }
.card.r-legendary { animation: legendGlow 2.6s ease-in-out infinite; box-shadow: inset 0 0 0 3px var(--ivory), inset 0 0 0 5px var(--tc), 0 0 0 2px #6a3a8a, 0 0 14px rgba(106,58,138,.45), 0 6px 14px var(--shade-50) !important; }
.card.r-legendary.draw-in { animation: drawIn .32s ease-out backwards; }
@keyframes legendGlow { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
.card-text .kw { color: #dfc78b; font-weight: 700; }
.status.power {
  background: #1d264b; cursor: help; border-color: var(--gilt-dark) !important; color: #5b4712 !important;
}
#playerStatus { flex-wrap: wrap; justify-content: center; max-width: 260px; }
.toast.big { max-width: min(560px, calc(92 * var(--hvw))); text-align: center; line-height: 1.4; padding: 12px 20px; box-shadow: 0 10px 30px var(--shade-50), 0 0 24px rgba(201,161,59,0.3); }
.status.persist { background: #2e1418; border-color: var(--claw) !important; color: var(--claw-dark) !important; }
#enemyPanel.final .portrait { border-color: #c77dff; box-shadow: 0 0 0 4px var(--shade-25), 0 0 40px rgba(199,125,255,0.55); font-size: 70px; }
#enemyPanel.final .role { color: #d9a8ff; }
.boss-bar {
  position: relative; height: 20px; margin: 8px auto 0; max-width: 420px; border: 1px solid #6b4a8a; overflow: hidden; background: #3a342b !important;
  border-color: var(--royal) !important; border-radius: 0 !important;
}
.boss-bar .boss-fill { position: absolute; inset: 0 auto 0 0; background: var(--claw) !important; }
.boss-bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px var(--black); color: var(--ivory) !important; }
.boss-status { margin: 22px auto 0; max-width: 460px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.boss-status b { color: #e3c2ff; }
.boss-status.won { color: #9fe5c8; }
.final-card { max-width: 520px; margin: 18px auto 0; padding: 16px; border-radius: 14px; background: linear-gradient(180deg, #1a2345, #12182d); border: 1px solid #6b4a8a; }
.final-card h3 { margin: 0 0 4px; color: #e3c2ff; }
.final-card p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 10px 0 0; }
.unlock-banner { display: inline-block; margin: 0 0 16px; padding: 8px 14px; border-radius: 10px; background: #1d3328; border: 1px solid #3a8f52; color: #9fe5c8; font-weight: 600; }
.btn.danger-glow { box-shadow: 0 6px 24px rgba(199,125,255,0.45); }
.ach-scroll { max-height: calc(60 * var(--hvh)); overflow-y: auto; text-align: left; padding-right: 4px; }
.ach-scroll h3 small { color: var(--muted); font-family: var(--font-body); font-size: 12px; font-weight: 600; }
.ach-list { display: flex; flex-direction: column; gap: 6px; }
.ach-row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--bg-2);
  border: 1px solid var(--line); opacity: 1 !important;
}
.ach-row.done { opacity: 1; border-color: #22378a; }
.ach-row .ach-ico { font-size: 18px; }
.ach-row b { display: block; font-size: 13.5px; color: var(--gold-2); }
.ach-row span { font-size: 12px; color: var(--muted); }
.ach-row em { font-style: normal; font-size: 12px; color: var(--text); text-align: right; }
.dev-tools { margin-top: 18px; font-size: 12px; color: var(--muted); }
.dev-tools summary { cursor: pointer; }

/* Codex card lists: room for each card's cost badge and specialization icon, which sit just outside its corners,
   so cards never overlap their neighbours and the left column isn't clipped by the scroll area */
.ach-scroll .card-dex { gap: 22px 26px; padding: 14px 6px 4px 14px; }
/* Settings: Report a Bug out in the open, then tabs */
.settings-bug { display: flex; align-items: center; justify-content: space-between; gap: 14px; max-width: 420px; margin: 4px auto 14px; padding: 12px 14px; border-radius: 10px; text-align: left;
  background: var(--bg-2); border: 1.5px solid var(--gold, var(--gilt)); }
.settings-bug small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; max-width: 230px; }
.settings-tabs { justify-content: center; margin: 0 auto 12px; max-width: 460px; }
.settings .danger-row { border-color: rgba(214,69,69,.45); }
.settings .reset-confirm { display: flex; gap: 6px; }
.settings-bug .btn { white-space: nowrap; flex: none; }
/* two-way choices in Settings */
.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg-btn { padding: 6px 12px; border: 0; background: var(--panel); color: inherit; font: 600 12px var(--font-body); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--gold, var(--gilt)); color: var(--ink); }
/* Graphics quality: Low */
body.gfx-low .stage-fx { display: none !important; }
body.gfx-low *, body.gfx-low *::before, body.gfx-low *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.gfx-low .mg-flicker { animation: none; }
