
/* =====================================================================
   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; background: rgba(12, 9, 6, 0.82); backdrop-filter: blur(4px); overflow-y: auto;
}
.overlay.cover { z-index: 130; padding-top: 20px; }
.overlay.solid { background: rgba(14, 11, 8, 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 rgba(0,0,0,0.6), 0 0 0 1px rgba(217,178,95,0.12) inset;
  text-align: center; animation: rise .3s ease;
}
.modal.narrow { width: min(620px, 100%); }
.modal.map-modal { 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: #ff7b6e; }
.modal h3 { color: var(--gold-2); font-size: 18px; margin: 18px 0 4px; }
.modal .sub { color: var(--muted); margin: 0 0 18px; font-size: 15px; line-height: 1.5; }
.modal .big-icon { font-size: 54px; margin-bottom: 4px; }
.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 */
.title-screen { padding: 30px 10px 10px; }
.title-emblem { font-size: 40px; color: var(--gold); text-shadow: 0 0 24px rgba(217,178,95,0.6); }
.game-title { font-size: clamp(40px, calc(8 * var(--hvw)), 72px) !important; letter-spacing: 0.04em; margin: 4px 0 !important; text-shadow: 0 4px 30px rgba(217,178,95,0.25); }
.tagline { color: var(--gold); font-size: 15px; margin: 0 0 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.premise { color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 520px; margin: 0 auto 26px; }
.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; }

/* Class select */
.class-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.class-card { text-align: left; padding: 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 10px; transition: transform .15s, border-color .15s, box-shadow .15s; }
.class-card:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 12px 30px rgba(0,0,0,0.5), 0 0 24px rgba(217,178,95,0.15); }
.class-card .class-head { display: flex; gap: 12px; }
.class-card .class-art { font-size: 40px; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4e3f32, #231c16 70%); border: 1px solid var(--line); }
.class-card h3 { margin: 0; font-size: 23px; color: var(--gold-2); }
.class-card .stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 12px; font-weight: 700; }
.class-card .stats span { white-space: nowrap; padding: 3px 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.class-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.class-card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.class-card li { display: flex; gap: 8px; align-items: baseline; padding: 5px 8px; border-radius: 8px; background: rgba(0,0,0,0.2); }
.class-card li b { color: var(--text); white-space: nowrap; }
.class-card li em { font-style: normal; color: var(--muted); }
.class-card .starter-relic { font-size: 12.5px; color: var(--gold-2); padding: 6px 8px; border-radius: 8px; border: 1px dashed var(--line); }
.class-card .pick { margin-top: auto; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--gold-2); padding-top: 4px; }

/* Card rows / grids */
.card-row { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; padding: 14px 0 6px; }

.card-row .card .card-art { height: 70px; font-size: 40px; }

.card.selectable { cursor: pointer; }
.card.chosen { box-shadow: 0 0 0 3px var(--gold-2), 0 0 30px rgba(243,213,140,0.55); transform: translateY(-10px) scale(1.05); }
.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: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); }

/* Relic tiles */
.relic-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.relic-tile {
  width: 200px; padding: 14px; border: 1px solid var(--line); background: var(--bg-2);
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  transition: transform .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.relic-tile .art { font-size: 38px; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4e3f32, #231c16 70%); border: 1px solid var(--gold); }
.relic-tile b { font-family: var(--font-display); font-size: 16px; color: var(--gold-2); }
.relic-tile span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
button.relic-tile:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 0 24px rgba(217,178,95,0.2); }
.relic-tile.chosen { border-color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold-2), 0 0 24px rgba(243,213,140,0.4); }
.relic-tile.not-chosen { opacity: 0.3; }

/* Map */
.map-head h1 { font-size: 28px !important; }
.map-scroll { border-radius: 12px;
  background: radial-gradient(ellipse at center, #322a23, #1b1612); border: 1px solid var(--line);
}
.map { position: relative; width: 100%; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.map line { stroke: #5e4e41; 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; background: #2f261e; border: 2px solid #5e4e41;
  transition: transform .15s, box-shadow .15s;
}
.map-node.boss { font-size: 40px; border-color: #b8433a; background: radial-gradient(circle, #3a1d22, #1a1216); }
.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(217,178,95,0.45); }
.map-node:disabled { cursor: default; }
@keyframes nodePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(243,213,140,0.55); } 50% { box-shadow: 0 0 0 9px rgba(243,213,140,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: #2c241d; 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; }
.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; }
.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(--gold); }

/* 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 rgba(0,0,0,0.3); color: #04200b; }
.energy-orb.mana  { border-color: #e0ebff; box-shadow: 0 0 22px rgba(91,141,239,0.5), inset 0 -6px 12px rgba(0,0,0,0.3); color: #04102e; }
.card.e-focus .cost { border-color: #dcffd8; color: #04200b; }
.card.e-mana .cost  { border-color: #e0ebff; color: #04102e; }
.class-card .stats .res-valor { border-color: #a0781f; }
.class-card .stats .res-focus { border-color: #3a8f52; }
.class-card .stats .res-mana  { border-color: #4a6fc2; }

.card.upgraded { box-shadow: 0 8px 18px rgba(0,0,0,0.5), 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 tiles and gear popup */
.gear-tile .slot-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.gear-tile .replaces { font-style: normal; font-size: 11.5px; color: #ffb86b; margin-top: 2px; }
.gear-tile .replaces.free { color: #9fe5c8; }
.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); }
.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%, #4e3f32, #231c16 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; }

/* Knight builds: badges and statuses */
.card .build-tag { position: absolute; top: -9px; right: -8px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; box-shadow: 0 2px 5px rgba(0,0,0,0.5); cursor: help; }
.card .school-tag { right: 20px; }
.status.momentum { background: #2b2415; border-color: #c9a24a; color: #ffe2a3; cursor: help; }
.status.thorns { background: #16291c; border-color: #4f9a62; color: #bff0cb; cursor: help; }
.intent.breath { border-color: #ff8a3d; background: linear-gradient(180deg, #4a1e0e, #2a120a); color: #ffd3b0; }
.class-card .class-builds { display: flex; font-size: 12px; font-weight: 600; }
.class-card .class-builds span { padding: 3px 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.loot-grid .relic-tile { width: 180px; }
.status.evasion { background: #2f251d; border-color: #7f93b8; color: #dbe6ff; cursor: help; }
.status.charge { background: #392b1f; border-color: #b58cff; color: #eadcff; cursor: help; }
.status.mark { background: #3a1a1a; border-color: #e0685c; color: #ffd0c9; cursor: help; }
.status.chill { background: #13283a; border-color: #6fc3ff; color: #d5efff; cursor: help; }
.floater.evade { color: #dbe6ff; font-size: 20px; }

.loadout-builds { justify-content: center; margin-bottom: 4px; }

/* Card rarity + Powers */
.card.power { border-color: #c77dff; background: linear-gradient(180deg, #4a3829 0%, #32251b 55%, #251e18 100%); }
.card .card-type .rar { font-weight: 800; }

.card.r-legendary { animation: legendGlow 2.6s ease-in-out infinite; }
.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: #ffb86b; font-weight: 700; }
.status.power { background: #392b1f; border-color: #9b6ad6; color: #ecd8ff; cursor: help; }
#playerStatus { flex-wrap: wrap; justify-content: center; max-width: 260px; }

/* Meta progression: unlocks, loadout, game boss, achievements */
.loadout-head { display: flex; align-items: center; justify-content: center; gap: 14px; text-align: left; }
.loadout-head .big-icon { margin: 0; }
.loadout-head h1 { margin: 0 !important; }
.loadout-head .sub { margin: 2px 0 0 !important; }
.start-row { gap: 10px; }
.start-row .start-opt { padding: 10px; }
.start-row .start-opt .art { width: 46px; height: 46px; font-size: 26px; }
.start-row .start-opt b { font-size: 14px; }
.start-row .start-opt span { font-size: 11.5px; }
.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 rgba(0,0,0,0.5), 0 0 24px rgba(217,178,95,0.3); }
.status.persist { background: #2e1418; border-color: #b8433a; color: #ffc4bd; }
#enemyPanel.final .portrait { border-color: #c77dff; box-shadow: 0 0 0 4px rgba(0,0,0,0.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-radius: 999px; background: #2d231b; border: 1px solid #6b4a8a; overflow: hidden; }
.boss-bar .boss-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7b3fb8, #c77dff); }
.boss-bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.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, #34271c, #211913); 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); }
.class-card.locked { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.6); }
.class-card.locked:hover { transform: none; border-color: var(--line); box-shadow: none; }
.class-card .class-progress { font-size: 12px; color: var(--muted); }
.start-row .start-opt { width: 170px; cursor: pointer; gap: 4px; }
.start-row .start-opt:hover { transform: translateY(-4px); border-color: var(--gold); }
.mode-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.mode-btn { width: 230px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 3px; }
.mode-btn b { font-family: var(--font-display); color: var(--gold-2); font-size: 16px; }
.mode-btn span { font-size: 12px; color: var(--muted); }
.mode-btn.on { border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(243,213,140,0.35); }
.locked-list { margin-top: 18px; text-align: left; }
.locked-list summary { cursor: pointer; color: var(--muted); font-size: 13px; text-align: center; }
.locked-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin-top: 12px; }
.locked-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; border: 1px dashed var(--line); background: rgba(0,0,0,0.2); }
.locked-item .lk-art { font-size: 22px; filter: grayscale(1); opacity: 0.6; }
.locked-item b { display: block; font-size: 13px; color: var(--text); }
.locked-item small { color: var(--muted); font-size: 11.5px; }
.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: 0.65; }
.ach-row.done { opacity: 1; border-color: #6b5a2a; }
.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, #c9a24a); }
.settings-bug small { display: block; }
.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; }
.settings-bug small { max-width: 230px; color: var(--muted); font-size: 11px; font-weight: 400; }
/* 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, #c9a24a); color: #17110c; }
/* 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; }
