:root {
  --bg: #0c0d11;
  --bg-2: #12141a;
  --panel: #171920;
  --panel-2: #1d2028;
  --line: #2b2f3a;
  --text: #f1f2f4;
  --muted: #959baa;
  --gold: #d3a24d;
  --danger: #cc4a4a;
  --success: #58b870;
  --common: #91959e;
  --uncommon: #55b85a;
  --rare: #4384e6;
  --epic: #a35ae0;
  --legendary: #ed8e2f;
  --slot-size: clamp(58px, 5.3vw, 78px);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(132, 87, 41, .18), transparent 42%),
    linear-gradient(180deg, #0d0e12 0%, #090a0d 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

#app { min-height: 100vh; }
.topbar {
  min-height: 82px;
  padding: 14px clamp(16px, 3vw, 34px);
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #262933;
  background: rgba(13, 14, 18, .92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid #645036; border-radius: 12px;
  color: #f4c879; background: linear-gradient(145deg, #282318, #15130f);
  font-family: Georgia, serif; font-size: 27px; font-weight: 800;
  box-shadow: inset 0 0 18px rgba(211,162,77,.08), 0 6px 20px rgba(0,0,0,.28);
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.15; letter-spacing: .02em; }
.brand span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.run-stats { display: flex; gap: 9px; align-items: stretch; flex-wrap: wrap; justify-content: flex-end; }
.run-stats > div {
  min-width: 78px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: #14161c; display: flex; flex-direction: column; gap: 1px;
}
.run-stats .muted { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.run-stats strong { font-size: 13px; white-space: nowrap; }
.run-stats .gold-pill { border-color: #5b482a; background: #1d1912; }
.run-stats .gold-pill span { color: #c3a46e; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.run-stats .gold-pill strong { color: #f2c773; }

.layout {
  width: min(1840px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2.2vw, 28px);
  display: grid;
  grid-template-columns: minmax(320px, .85fr) minmax(520px, 1.45fr) minmax(330px, .9fr);
  gap: clamp(12px, 1.5vw, 20px);
  align-items: start;
}
.panel {
  min-width: 0;
  background: linear-gradient(180deg, rgba(26,28,35,.98), rgba(20,22,28,.98));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 55px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.02);
  padding: clamp(14px, 1.5vw, 20px);
  overflow: hidden;
}
.panel-heading, .shop-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading h2, .shop-header h2 { margin: 1px 0 0; font-size: 17px; }
.eyebrow { font-size: 10px; color: #a58d67; text-transform: uppercase; letter-spacing: .13em; font-weight: 700; }
.panel-note { color: var(--muted); font-size: 12px; line-height: 1.45; margin: -5px 0 13px; }
.icon-button, .text-button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; font-size: 20px; }
.icon-button:hover, .text-button:hover { color: #fff; border-color: #454b59; }
.text-button { padding: 3px 6px; font-size: 11px; }

.equipment-stage {
  position: relative;
  min-height: 500px;
  display: grid;
  place-items: center;
  border: 1px solid #292c35;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 38%, rgba(118,90,53,.12), transparent 34%),
    linear-gradient(180deg, #15171d, #111319);
  overflow: hidden;
}
.equipment-stage::before {
  content: ""; position: absolute; inset: 12%; border: 1px solid rgba(193,157,96,.07); border-radius: 50%;
  box-shadow: 0 0 70px rgba(185,134,63,.035);
}
.hero-silhouette { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.hero-glow { position: absolute; width: 210px; height: 310px; background: radial-gradient(ellipse, rgba(166,122,69,.11), transparent 70%); filter: blur(8px); }
.hero-body { position: relative; width: 126px; height: 300px; opacity: .6; }
.hero-head { position:absolute; left:45px; top:8px; width:38px; height:44px; border-radius: 46% 46% 38% 38%; background:#2b2e36; border:1px solid #383c47; }
.hero-torso { position:absolute; left:27px; top:57px; width:74px; height:128px; clip-path: polygon(15% 0,85% 0,100% 23%,82% 100%,18% 100%,0 23%); background:linear-gradient(#2f333d,#242730); border:1px solid #383c47; }
.hero-leg { position:absolute; top:176px; width:31px; height:115px; background:linear-gradient(#292d35,#20232a); border:1px solid #343842; border-radius:8px; }
.hero-leg.left { left:29px; transform: rotate(3deg); } .hero-leg.right { right:29px; transform: rotate(-3deg); }
.hero-arm { position:absolute; top:69px; width:27px; height:126px; background:linear-gradient(#30343e,#22262d); border:1px solid #383c47; border-radius:12px; }
.hero-arm.left { left:4px; transform: rotate(8deg); } .hero-arm.right { right:4px; transform: rotate(-8deg); }

.equipment-grid { position: relative; width: 100%; height: 500px; z-index: 2; }
.equipment-slot, .inventory-slot {
  position: relative;
  width: var(--slot-size); height: var(--slot-size);
  border-radius: 11px;
  border: 1px solid #3a3e49;
  background: linear-gradient(145deg, #1b1e25, #13151a);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.018), inset 0 0 18px rgba(0,0,0,.22);
  display: grid; place-items: center;
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
.equipment-slot { position: absolute; }
.equipment-slot.valid-drop-target {
  border-color: #79c96b;
  background: linear-gradient(145deg, rgba(65,105,55,.34), #151a16);
  box-shadow: inset 0 0 0 1px rgba(145,224,126,.22), 0 0 0 2px rgba(92,181,78,.12), 0 0 18px rgba(92,181,78,.22);
}
.equipment-slot.drag-over, .inventory-slot.drag-over { border-color: #c0a06c; background: #282318; transform: scale(1.04); }
.equipment-slot.valid-drop-target.drag-over {
  border-color: #a5e195;
  background: #263322;
  box-shadow: inset 0 0 0 1px rgba(180,240,164,.28), 0 0 20px rgba(92,181,78,.30);
}
.equipment-slot.invalid-drop { animation: shake .22s ease; border-color: var(--danger); }
.slot-label {
  font-size: 9px; color: #707685; text-transform: uppercase; letter-spacing: .08em;
  text-align: center; padding: 4px; line-height: 1.1; user-select: none;
}
.equipment-slot.has-item .slot-label, .inventory-slot.has-item .slot-label { opacity: 0; }
.slot-head { left: 50%; top: 12px; transform: translateX(-50%); }
.slot-head.drag-over { transform: translateX(-50%) scale(1.04); }
.slot-head.invalid-drop { animation: headShake .22s ease; }
.slot-shoulders { left: 14px; top: 83px; }
.slot-amulet { right: 14px; top: 83px; }
.slot-chest { left: 14px; top: 164px; }
.slot-cloak { right: 14px; top: 164px; }
.slot-gloves { left: 14px; top: 245px; }
.slot-belt { right: 14px; top: 245px; }
.slot-weapon { left: 14px; top: 326px; }
.slot-offhand { right: 14px; top: 326px; }
.slot-legs { left: calc(50% - var(--slot-size) - 7px); bottom: 12px; }
.slot-boots { left: calc(50% + 7px); bottom: 12px; }
.slot-ring1 { left: calc(50% - var(--slot-size) - 7px); top: 164px; }
.slot-ring2 { left: calc(50% + 7px); top: 164px; }

.item-icon {
  position: absolute;
  inset: 5px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: grab;
  border: 2px solid var(--rarity-color);
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--rarity-color) 16%, transparent), transparent 66%),
    #181a20;
  box-shadow: inset 0 0 16px color-mix(in srgb, var(--rarity-color) 9%, transparent), 0 0 8px rgba(0,0,0,.25);
  overflow: hidden;
}
.item-icon:active { cursor: grabbing; }
.item-icon::after { content: ""; position: absolute; inset: 2px; border: 1px solid rgba(255,255,255,.045); border-radius: 6px; pointer-events: none; }
.item-icon img { width: 78%; height: 78%; object-fit: contain; display: block; pointer-events: none; filter: drop-shadow(0 4px 4px rgba(0,0,0,.4)); }
.item-icon:hover { box-shadow: inset 0 0 22px color-mix(in srgb, var(--rarity-color) 14%, transparent), 0 0 0 1px color-mix(in srgb, var(--rarity-color) 25%, transparent); }
.equipment-slot.twohand-occupied { border-style: dashed; border-color: #535965; background: #17191e; }
.equipment-slot.twohand-occupied .item-icon.twohand-shadow {
  opacity: .38;
  filter: grayscale(.9) saturate(.25);
  cursor: help;
  border-color: #747984;
  background: #14161a;
  box-shadow: inset 0 0 12px rgba(255,255,255,.025);
}
.equipment-slot.twohand-occupied .item-icon.twohand-shadow img { opacity: .72; }
.twohand-badge {
  position: absolute; right: 4px; bottom: 4px; z-index: 2;
  min-width: 22px; height: 18px; padding: 0 4px; border-radius: 5px;
  display: grid; place-items: center;
  border: 1px solid #8f949e; background: rgba(12,13,16,.92); color: #d7dae0;
  font-size: 9px; font-weight: 900; letter-spacing: .05em;
}

.stats-box {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--line);
}
.stats-box > div { background: #15171d; padding: 9px 10px; display: flex; justify-content: space-between; gap: 6px; }
.stats-box span { color: var(--muted); font-size: 10px; } .stats-box strong { font-size: 11px; }

.battle-panel { position: relative; }
.battle-heading { margin-bottom: 12px; }
.battle-state { padding: 6px 9px; border: 1px solid #3b404c; background:#14161c; color:#afb5c1; border-radius: 999px; font-size:11px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; }
.battle-state.active { border-color: #74582f; color:#f0c474; background:#211b13; }
.battle-state.win { border-color:#356943; color:#81d291; background:#122017; }
.battle-state.loss { border-color:#773f3f; color:#e37c7c; background:#241414; }

.arena {
  min-height: 390px;
  position: relative;
  border: 1px solid #30333d;
  border-radius: 15px;
  background:
    linear-gradient(rgba(11,12,16,.1), rgba(11,12,16,.58)),
    radial-gradient(circle at 50% 26%, rgba(188,123,57,.11), transparent 34%),
    linear-gradient(180deg, #232028 0%, #15171b 61%, #101216 61%, #111319 100%);
  display: grid;
  grid-template-columns: minmax(0,1fr) 58px minmax(0,1fr);
  gap: 10px;
  align-items: stretch;
  padding: 16px;
  overflow: hidden;
}
.arena::before { content:""; position:absolute; left:0; right:0; top:61%; height:1px; background:rgba(255,255,255,.045); box-shadow:0 20px 80px rgba(0,0,0,.75); }
.combatant { min-width: 0; display: flex; flex-direction: column; position: relative; z-index:2; }
.combatant-name-row { display:flex; justify-content:space-between; gap:10px; align-items:baseline; margin-bottom:7px; }
.combatant-name-row strong { font-size: 13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.combatant-name-row span { font-size:10px; color:var(--muted); white-space:nowrap; }
.health-shell { height: 26px; position:relative; background:#111318; border:1px solid #40444f; border-radius:7px; overflow:hidden; box-shadow: inset 0 2px 8px rgba(0,0,0,.45); }
.health-fill { height:100%; width:100%; transition: width .2s ease; }
.player-health { background: linear-gradient(90deg,#296b41,#4ba564); }
.enemy-health { background: linear-gradient(90deg,#8d3030,#c14a4a); }
.health-text { position:absolute; inset:0; display:grid; place-items:center; font-size:11px; font-weight:800; text-shadow:0 1px 3px #000; }
.fighter { flex:1; min-height:235px; position:relative; display:grid; place-items:end center; padding-bottom:20px; }
.fighter-shadow { position:absolute; bottom:10px; width:145px; height:28px; border-radius:50%; background:rgba(0,0,0,.43); filter: blur(4px); }
.fighter-body { position:relative; width:132px; height:190px; transition: transform .15s ease, filter .15s ease; background-position:center bottom; background-repeat:no-repeat; background-size:contain; filter:drop-shadow(0 8px 8px rgba(0,0,0,.38)); }
.fighter-body.knight { background-image:url("assets/hero.svg"); }
.fighter-body.demon { background-image:url("assets/enemy.svg"); }
.combatant.attacking .fighter-body { transform: translateX(12px) scale(1.03); }
.enemy-combatant.attacking .fighter-body { transform: translateX(-12px) scale(1.03); }
.combatant.dead .fighter-body { transform: rotate(78deg) translate(25px,25px); filter: grayscale(.8) brightness(.5); }
.hit-flash { position:absolute; width:150px; height:150px; border-radius:50%; background:radial-gradient(circle, rgba(255,237,180,.65), rgba(255,120,60,.12) 33%, transparent 68%); opacity:0; pointer-events:none; }
.combatant.hit .hit-flash { animation: hitFlash .2s ease; }
.attack-timer { display:grid; grid-template-columns:auto 1fr; align-items:center; gap:8px; font-size:9px; color:var(--muted); }
.timer-track { height:5px; border-radius:999px; background:#0e1014; border:1px solid #2d3038; overflow:hidden; }
.timer-track > div { height:100%; width:0%; background:#aa8b55; transition:width .06s linear; }
.versus { display:grid; place-items:center; color:#625d58; font-family:Georgia,serif; font-weight:800; font-size:17px; z-index:2; }
.damage-layer { position:absolute; inset:0; pointer-events:none; z-index:6; }
.float-damage { position:absolute; font-weight:900; font-size:18px; text-shadow:0 2px 4px #000; animation: floatDamage .9s ease forwards; }
.float-damage.player { left:24%; top:41%; color:#f0d7b1; }
.float-damage.enemy { right:24%; top:41%; color:#f0d7b1; }
.float-damage.crit { color:#ffd56f; font-size:23px; }
.float-heal { color:#76d58b !important; }

.spell-row { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap:8px; margin-top:10px; }
.spell-card { min-width:0; border:1px solid #323640; background:#14161c; border-radius:10px; padding:8px 9px; display:grid; grid-template-columns:36px 1fr auto; align-items:center; gap:8px; }
.spell-icon { width:36px; height:36px; border-radius:8px; display:grid; place-items:center; font-size:18px; border:1px solid #4f4b5b; background:radial-gradient(circle,#34303e,#1b1c23); }
.spell-copy { min-width:0; } .spell-copy strong { display:block; font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } .spell-copy span { display:block; color:var(--muted); font-size:9px; margin-top:2px; }
.spell-cd { width:36px; text-align:right; font-size:10px; color:#c4c8d0; font-variant-numeric: tabular-nums; }

.battle-controls { display:flex; gap:9px; align-items:center; margin-top:12px; min-height:42px; flex-wrap:wrap; }
.primary-button, .secondary-button {
  border-radius:9px; padding:10px 14px; cursor:pointer; font-weight:800; font-size:12px; transition:transform .1s ease, border-color .1s ease, filter .1s ease;
}
.primary-button { border:1px solid #9b7438; background:linear-gradient(#a27337,#765026); color:#fff3dc; box-shadow: inset 0 1px rgba(255,255,255,.09); }
.secondary-button { border:1px solid #3b404c; background:#1a1c23; color:#d9dce2; }
.secondary-button.small { padding:7px 10px; font-size:10px; }
.primary-button:hover, .secondary-button:hover { filter:brightness(1.08); }
.primary-button:active, .secondary-button:active { transform:translateY(1px); }
button:disabled { opacity:.45; cursor:not-allowed; filter:none; }
.battle-hint { color:var(--muted); font-size:10px; margin-left:auto; }

.combat-log-wrap { margin-top:12px; border:1px solid #2e313a; border-radius:11px; overflow:hidden; }
.combat-log-heading { padding:8px 10px; display:flex; align-items:center; justify-content:space-between; background:#16181e; border-bottom:1px solid #292c35; }
.combat-log-heading strong { font-size:10px; text-transform:uppercase; letter-spacing:.07em; color:#b4b8c1; }
.combat-log { height:132px; overflow:auto; padding:7px 10px; background:#101216; scrollbar-width:thin; }
.log-line { font-size:10px; line-height:1.55; color:#aeb3be; display:grid; grid-template-columns:46px 1fr; gap:7px; }
.log-line time { color:#5f6571; font-variant-numeric:tabular-nums; }
.log-line.important { color:#f0d19a; font-weight:700; }
.log-line.good { color:#77c98a; } .log-line.bad { color:#dc7a7a; }

.battle-result { position:absolute; inset:52px 0 0; z-index:12; background:rgba(8,9,12,.68); backdrop-filter:blur(5px); display:grid; place-items:center; padding:24px; }
.battle-result[hidden] { display:none; }
.result-card { width:min(390px, 90%); border:1px solid #4c4438; background:linear-gradient(180deg,#1e1b18,#151516); border-radius:15px; padding:22px; text-align:center; box-shadow:0 22px 70px rgba(0,0,0,.55); }
.result-kicker { color:#a99b86; font-size:10px; text-transform:uppercase; letter-spacing:.13em; }
.result-card h3 { margin:5px 0 7px; font-family:Georgia,serif; font-size:32px; }
.result-card p { margin:0 0 14px; color:#aeb1b8; font-size:12px; line-height:1.45; }
.result-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.result-stats > div { border:1px solid #34312e; border-radius:8px; background:#121315; padding:8px 5px; }
.result-stats span { display:block; color:#777b83; font-size:9px; text-transform:uppercase; } .result-stats strong { font-size:12px; }
.result-next { width:100%; margin-top:14px; }

.inventory-grid { display:grid; grid-template-columns:repeat(5, minmax(0,1fr)); gap:7px; }
.inventory-slot { width:100%; aspect-ratio:1; height:auto; min-width:0; }
.slot-count { color:var(--muted); font-size:11px; }
.shop-divider { height:1px; background:var(--line); margin:17px 0; }
.shop-header { margin-bottom:9px; }
.shop-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.shop-item { min-width:0; border:1px solid #30333c; border-radius:11px; background:#14161b; padding:9px; display:grid; grid-template-columns:50px minmax(0,1fr); gap:9px; align-items:center; }
.shop-item .shop-icon-wrap { width:50px; height:50px; position:relative; }
.shop-upgrade-arrow {
  position:absolute; z-index:4; right:-4px; top:-5px; width:20px; height:20px; border-radius:50%;
  display:grid; place-items:center; border:1px solid #4d9c60; background:#15331d; color:#72dc87;
  font-size:14px; line-height:1; font-weight:1000; box-shadow:0 2px 8px rgba(0,0,0,.48),0 0 10px rgba(88,184,112,.18);
  pointer-events:none;
}
.shop-item.upgrade-ready { border-color:#355c40; box-shadow:inset 0 0 0 1px rgba(88,184,112,.05); }
.shop-item .item-icon { inset:0; }
.shop-item-copy { min-width:0; }
.shop-item-name { font-size:10px; font-weight:800; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.shop-item-rarity { font-size:9px; margin-top:2px; color:var(--rarity-color); font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
.shop-buy { width:100%; margin-top:6px; border:1px solid #534124; background:#211b12; color:#e8c27e; border-radius:7px; padding:5px 6px; font-size:9px; font-weight:800; cursor:pointer; }
.shop-buy:disabled { opacity:.35; }

.tooltip {
  position:fixed; z-index:1000; width:min(310px, calc(100vw - 20px));
  border:2px solid var(--rarity-color, var(--common));
  border-radius:10px; padding:11px 12px;
  background:rgba(13,14,18,.98); box-shadow:0 18px 50px rgba(0,0,0,.55), inset 0 0 30px color-mix(in srgb, var(--rarity-color) 6%, transparent);
  pointer-events:none;
}
.tooltip[hidden] { display:none; }
.tooltip-name { font-size:13px; font-weight:900; margin-bottom:2px; }
.tooltip-rarity { color:var(--rarity-color); font-size:10px; font-weight:900; text-transform:uppercase; letter-spacing:.08em; margin-bottom:8px; }
.tooltip-slot { color:#8e939e; font-size:9px; margin-bottom:8px; }
.tooltip-slot.weapon-type { display:flex; align-items:center; gap:7px; color:#b7bbc4; font-size:9px; }
.tooltip-slot.weapon-type strong { display:grid; place-items:center; min-width:28px; height:20px; padding:0 5px; border:1px solid var(--rarity-color); border-radius:5px; color:var(--rarity-color); background:#16181d; font-size:10px; letter-spacing:.05em; }
.tooltip-slot.weapon-type span { line-height:1.25; }
.tooltip-stats { border-top:1px solid #2b2e35; border-bottom:1px solid #2b2e35; padding:7px 0; margin-bottom:8px; }
.tooltip-stat { display:flex; justify-content:space-between; gap:12px; font-size:10px; line-height:1.55; }
.tooltip-stat span:first-child { color:#9ca1ad; } .tooltip-stat strong { color:#edf0f4; }
.tooltip-desc { font-size:10px; line-height:1.45; color:#c8cbd2; }
.tooltip-price { margin-top:8px; font-size:9px; color:#d8ae67; }

.toast-layer { position:fixed; right:16px; bottom:16px; z-index:2000; display:flex; flex-direction:column; gap:7px; pointer-events:none; }
.toast { padding:9px 12px; border:1px solid #444956; background:#171920; border-radius:9px; box-shadow:0 10px 30px rgba(0,0,0,.42); font-size:11px; animation:toastIn .18s ease, toastOut .2s ease 2.35s forwards; }
.toast.error { border-color:#734343; color:#efa0a0; }
.toast.good { border-color:#3d6a48; color:#95d6a2; }

@keyframes hitFlash { 0%{opacity:0} 35%{opacity:1;transform:scale(.75)} 100%{opacity:0;transform:scale(1.15)} }
@keyframes floatDamage { 0%{opacity:0;transform:translateY(8px) scale(.9)} 15%{opacity:1} 100%{opacity:0;transform:translateY(-45px) scale(1.06)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
@keyframes headShake { 0%,100%{transform:translateX(-50%)} 25%{transform:translateX(-50%) translateX(-4px)} 75%{transform:translateX(-50%) translateX(4px)} }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes toastOut { to{opacity:0;transform:translateY(6px)} }

@media (max-width: 1320px) {
  .layout { grid-template-columns: minmax(300px,.9fr) minmax(500px,1.4fr); }
  .inventory-panel { grid-column: 1 / -1; }
  .inventory-grid { grid-template-columns: repeat(10, minmax(0,1fr)); }
  .shop-grid { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .shop-item { grid-template-columns:44px 1fr; }
  .shop-item .shop-icon-wrap { width:44px;height:44px; }
}

@media (max-width: 860px) {
  .topbar { position:relative; align-items:flex-start; flex-direction:column; }
  .run-stats { justify-content:flex-start; width:100%; }
  .layout { grid-template-columns:1fr; padding:10px; }
  .equipment-panel, .battle-panel, .inventory-panel { grid-column:auto; }
  .equipment-stage { min-height:480px; }
  .equipment-grid { height:480px; }
  .inventory-grid { grid-template-columns:repeat(5,minmax(0,1fr)); }
  .shop-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .arena { min-height:355px; padding:12px; grid-template-columns:minmax(0,1fr) 32px minmax(0,1fr); }
  .fighter { min-height:205px; }
  .spell-card { grid-template-columns:32px 1fr; }
  .spell-icon { width:32px;height:32px; }
  .spell-cd { grid-column:2; width:auto; text-align:left; }
}

@media (max-width: 520px) {
  :root { --slot-size: 58px; }
  .panel { border-radius:12px; padding:12px; }
  .brand span { display:none; }
  .run-stats > div { min-width:67px; padding:7px 8px; }
  .equipment-stage { min-height:450px; }
  .equipment-grid { height:450px; }
  .stats-box { grid-template-columns:repeat(2,1fr); }
  .slot-shoulders,.slot-chest,.slot-gloves,.slot-weapon { left:7px; }
  .slot-amulet,.slot-cloak,.slot-belt,.slot-offhand { right:7px; }
  .arena { min-height:330px; }
  .fighter-body { transform:scale(.85); }
  .combatant.attacking .fighter-body { transform:translateX(8px) scale(.9); }
  .enemy-combatant.attacking .fighter-body { transform:translateX(-8px) scale(.9); }
  .spell-row { grid-template-columns:1fr; }
  .battle-hint { width:100%; margin:0; }
  .shop-grid { grid-template-columns:1fr; }
}

/* v0.2a combat clarity + mirrored opponent loadout */
.equipment-slot.locked, .inventory-slot.locked { opacity:.82; }
.equipment-slot.locked .item-icon, .inventory-slot.locked .item-icon { cursor:default; }

.enemy-fighter.unknown .fighter-body { filter:brightness(.18) grayscale(1) blur(1px); opacity:.62; }
.enemy-fighter.unknown::after {
  content:"?"; position:absolute; inset:0; display:grid; place-items:center; padding-bottom:38px;
  font:800 42px/1 Georgia,serif; color:#77706a; text-shadow:0 4px 12px #000;
}
.combatant.casting .fighter-body { transform:translateX(6px) scale(1.05); filter:drop-shadow(0 8px 8px rgba(0,0,0,.38)) brightness(1.18); }

.status-row { min-height:24px; display:flex; gap:5px; align-items:center; flex-wrap:wrap; padding:5px 0 3px; }
.status-chip { border:1px solid #3d414b; border-radius:999px; padding:3px 7px; font-size:8px; font-weight:800; letter-spacing:.02em; background:#14161b; white-space:nowrap; }
.status-chip.bleed { border-color:#703939; color:#ee8888; background:#221314; }
.status-chip.chill { border-color:#3b617c; color:#8ccdf5; background:#111d25; }

.combat-fx-layer { position:absolute; inset:0; z-index:7; pointer-events:none; overflow:hidden; }
.combat-projectile { position:absolute; left:-8px; top:-8px; width:16px; height:16px; border-radius:50%; transform-origin:center; }
.combat-projectile.fire { background:radial-gradient(circle at 35% 35%,#fff6bd 0 14%,#ffb04b 30%,#d74a27 63%,transparent 72%); box-shadow:0 0 18px #f48b32,0 0 35px rgba(228,78,35,.45); }
.combat-projectile.execute { width:22px; height:6px; border-radius:999px; background:#d7d0c3; box-shadow:0 0 12px rgba(255,232,190,.5); }
.combat-burst { position:absolute; width:14px; height:14px; margin:-7px 0 0 -7px; border-radius:50%; animation:combatBurst .45s ease-out forwards; }
.combat-burst.fire { background:#ffb34b; box-shadow:0 0 0 8px rgba(232,96,40,.25),0 0 24px 10px rgba(255,136,53,.42); }
.combat-burst.execute { background:#e7dcc8; box-shadow:0 0 0 7px rgba(232,222,203,.18); }
.combat-burst.heal { background:#6ed18a; box-shadow:0 0 0 8px rgba(84,184,112,.18),0 0 22px rgba(84,184,112,.35); }
.float-damage.status-damage { color:#e87878; font-size:15px; }
.float-damage.reflect-damage { color:#c8b18a; font-size:15px; }

.enemy-loadout[hidden], .player-inventory-content[hidden] { display:none; }
.heading-spacer { width:36px; height:36px; flex:0 0 36px; }
.enemy-loadout .equipment-slot { pointer-events:auto; }
.enemy-loadout .equipment-slot .item-icon { cursor:help; }

.tooltip-effect { margin:-1px 0 8px; padding:7px 8px; border:1px solid color-mix(in srgb,var(--rarity-color) 42%,#2b2e35); border-radius:7px; background:color-mix(in srgb,var(--rarity-color) 7%,#121318); }
.tooltip-effect strong { display:block; color:var(--rarity-color); font-size:9px; text-transform:uppercase; letter-spacing:.07em; }
.tooltip-effect span { display:block; color:#d6d8de; font-size:9px; line-height:1.4; margin-top:2px; }

@keyframes combatBurst { from{opacity:1;transform:scale(.4)} to{opacity:0;transform:scale(2.5)} }


/* v0.3 items + crafting */
.forge-section { min-width:0; }
.forge-header { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:6px; }
.forge-note { margin-bottom:10px; }
.forge-recipes { display:flex; flex-direction:column; gap:8px; }
.forge-empty {
  min-height:62px; border:1px dashed #343844; border-radius:10px; background:#121419;
  display:flex; flex-direction:column; justify-content:center; padding:11px 12px;
}
.forge-empty strong { font-size:10px; color:#c9ccd3; }
.forge-empty span { margin-top:3px; color:#737986; font-size:9px; line-height:1.4; }
.forge-recipe {
  min-width:0; border:1px solid #30343d; border-left:3px solid var(--rarity-color);
  border-radius:10px; background:#14161b; padding:8px;
  display:grid; grid-template-columns:minmax(150px,.9fr) minmax(170px,1.1fr); gap:9px; align-items:center;
}
.forge-recipe-info { min-width:0; display:grid; grid-template-columns:46px minmax(0,1fr); gap:8px; align-items:center; }
.forge-icon-wrap { width:46px; height:46px; position:relative; }
.forge-icon-wrap .item-icon { inset:0; cursor:help; }
.forge-recipe-copy { min-width:0; }
.forge-recipe-copy strong { display:block; font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.forge-recipe-copy span { display:block; margin-top:3px; color:#8e94a0; font-size:9px; }
.forge-actions { display:flex; justify-content:flex-end; gap:6px; min-width:0; }
.forge-actions.branching { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
.forge-button {
  border:1px solid #5b4728; background:#211b12; color:#e8c27e; border-radius:8px;
  padding:7px 9px; font-size:9px; font-weight:800; cursor:pointer; min-width:0;
}
.forge-button:hover { border-color:#8b6a35; background:#282015; }
.forge-button.branch { text-align:left; padding:7px 8px; }
.forge-button.branch span { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.forge-button.branch small { display:block; margin-top:2px; color:#9fa4af; font-size:8px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tooltip-build { margin:-3px 0 7px; color:#888e99; font-size:9px; }
.tooltip-build strong { color:#c9cdd5; font-weight:800; }
.tooltip-craft { margin-top:8px; padding-top:7px; border-top:1px solid #2b2e35; color:#d4ad67; font-size:9px; line-height:1.4; }
.tooltip-stat strong.negative { color:#e17979; }
.status-chip.poison { border-color:#47703b; color:#9cda7e; background:#152011; }

@media (max-width: 1320px) {
  .forge-recipes { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .forge-recipe { grid-template-columns:1fr; align-items:stretch; }
  .forge-actions { justify-content:stretch; }
  .forge-button { width:100%; }
}

@media (max-width: 860px) {
  .forge-recipes { grid-template-columns:1fr; }
  .forge-recipe { grid-template-columns:minmax(140px,.8fr) minmax(170px,1.2fr); }
}

@media (max-width: 520px) {
  .forge-recipe { grid-template-columns:1fr; }
  .forge-actions.branching { grid-template-columns:1fr; }
}


/* v0.4 shop progression + advanced crafting */
.shop-progression {
  display:grid; grid-template-columns:minmax(0,1fr) auto; gap:9px; align-items:stretch;
  margin:8px 0 7px;
}
.shop-level-card {
  position:relative; z-index:210; min-width:0; border:1px solid #343944; border-radius:10px;
  background:linear-gradient(180deg,#171a20,#121419); padding:8px 10px; outline:none;
}
.shop-level-card:hover, .shop-level-card:focus { border-color:#646b79; }
.shop-level-top { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:6px; }
.shop-level-top span { color:#949aa6; font-size:9px; text-transform:uppercase; letter-spacing:.08em; font-weight:800; }
.shop-level-top strong { color:#f0cc8b; font-size:15px; }
.shop-xp-track { height:8px; background:#0d0f13; border:1px solid #2d323b; border-radius:999px; overflow:hidden; }
.shop-xp-track > div { height:100%; width:0; background:linear-gradient(90deg,#755225,#c49349); transition:width .2s ease; }
.shop-xp-copy { display:flex; justify-content:space-between; gap:8px; margin-top:5px; color:#747b88; font-size:8px; }
.shop-xp-buy { white-space:nowrap; min-width:132px; }
.shop-chance-tooltip {
  display:none; position:absolute; z-index:200; left:0; top:calc(100% + 7px); bottom:auto; width:min(230px, calc(100vw - 40px));
  padding:10px 11px; border:1px solid #414753; border-radius:10px; background:rgba(12,14,18,.985);
  box-shadow:0 16px 42px rgba(0,0,0,.58);
}
.shop-level-card:hover .shop-chance-tooltip, .shop-level-card:focus .shop-chance-tooltip { display:block; }
.shop-chance-tooltip > strong { display:block; margin-bottom:6px; color:#d6d9df; font-size:9px; text-transform:uppercase; letter-spacing:.06em; }
.shop-chance-tooltip div { display:flex; justify-content:space-between; gap:12px; padding:3px 0; font-size:9px; }
.shop-chance-tooltip b { font-variant-numeric:tabular-nums; }
.shop-note { margin-bottom:9px; }
.shop-item { position:relative; }
.shop-item.frozen { border-color:#466078; box-shadow:inset 0 0 20px rgba(94,145,192,.08); }
.shop-freeze {
  position:absolute; z-index:5; left:-4px; top:-5px; width:20px; height:20px; border-radius:50%;
  border:1px solid #46505e; background:#171c22; color:#8193a7; display:grid; place-items:center;
  font-size:10px; padding:0; cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,.45);
}
.shop-freeze:hover { border-color:#6c8298; color:#bcd9ef; }
.shop-freeze.active { border-color:#6d9eca; background:#163047; color:#bfe5ff; box-shadow:0 0 12px rgba(100,173,230,.25); }

.forge-recipe.advanced { border-left-color:var(--epic); background:linear-gradient(90deg,rgba(163,90,224,.06),#14161b 35%); }
.advanced-info { grid-template-columns:92px minmax(0,1fr); }
.forge-dual-icons { width:92px; display:flex; align-items:center; gap:4px; }
.forge-icon-wrap.mini { width:38px; height:38px; flex:0 0 38px; }
.forge-plus { color:#777e89; font-size:12px; font-weight:900; }
.advanced-button { border-color:#6f448a; background:#25172d; color:#d9a8f4; }
.advanced-button:hover { border-color:#a35ae0; background:#301c3a; }
.recipe-book-heading { margin-top:13px; padding-top:11px; border-top:1px solid #292d35; display:flex; justify-content:space-between; align-items:end; gap:10px; }
.recipe-book-heading > div { display:flex; flex-direction:column; gap:2px; }
.recipe-book-heading strong { font-size:11px; }
.recipe-book { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin-top:8px; }
.recipe-book-card { min-width:0; min-height:67px; border:1px solid #30343d; border-radius:9px; background:#121419; padding:8px 9px; }
.recipe-book-card.discovered { border-color:#604074; box-shadow:inset 0 0 16px rgba(163,90,224,.05); }
.recipe-book-card.unknown { border-style:dashed; opacity:.78; }
.recipe-book-result { color:#d7d9df; font-size:9px; font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.recipe-book-result.obscured { color:#797f8a; }
.recipe-book-line { display:flex; align-items:center; gap:4px; margin-top:5px; font-size:8px; white-space:nowrap; overflow:hidden; }
.recipe-book-line span { overflow:hidden; text-overflow:ellipsis; }
.recipe-book-line b { color:#676d78; }
.recipe-book-output { margin-top:4px; font-size:8px; font-weight:800; }
.recipe-silhouette { margin-top:5px; color:#575d68; letter-spacing:.12em; font-size:9px; }
.recipe-book-hint { margin-top:4px; color:#7b818c; font-size:8px; line-height:1.3; }

@media (max-width: 1320px) {
  .shop-progression { grid-template-columns:1fr; }
  .shop-xp-buy { width:100%; }
}
@media (max-width: 520px) {
  .recipe-book { grid-template-columns:1fr; }
  .advanced-info { grid-template-columns:82px minmax(0,1fr); }
  .forge-dual-icons { width:82px; }
  .forge-icon-wrap.mini { width:34px; height:34px; flex-basis:34px; }
}


/* v0.4a compact shop/crafting layout */
.forge-note, .shop-note { display:none !important; }
.recipe-book-toggle {
  width:100%; margin-top:11px; min-height:38px; border:1px solid #30343d; border-radius:9px;
  background:#15171c; color:#d7d9df; padding:7px 9px; cursor:pointer; display:flex;
  align-items:center; justify-content:space-between; gap:10px; font-size:10px; font-weight:800; line-height:1.2; font-family:inherit; text-align:left;
}
.recipe-book-toggle:hover { border-color:#655074; background:#1b1720; }
.recipe-book-toggle[aria-expanded="true"] { border-color:#604074; background:#201725; }
.recipe-book-panel[hidden] { display:none; }
.recipe-book-panel { padding-top:8px; }
.recipe-book { margin-top:0; }

/* v0.4d phase-specific center layout */
.shop-main-panel[hidden], .battle-panel[hidden] { display:none; }
.shop-main-panel { position:relative; overflow:visible; z-index:20; }
.shop-main-heading { margin-bottom:12px; }
.shop-main-progression { margin:0 0 16px; }
.shop-main-grid {
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
}
.shop-main-grid .shop-item {
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:9px;
  padding:12px 10px 10px;
  min-height:182px;
}
.shop-main-grid .shop-item .shop-icon-wrap {
  width:76px;
  height:76px;
  margin:0 auto;
  flex:0 0 76px;
}
.shop-main-grid .shop-item-copy { text-align:center; }
.shop-main-grid .shop-item-name { font-size:11px; }
.shop-main-grid .shop-item-rarity { font-size:9px; min-height:12px; }
.shop-main-grid .shop-buy { margin-top:8px; min-height:30px; }
.shop-main-grid .shop-freeze { left:-5px; top:-5px; width:22px; height:22px; }
.shop-main-grid .shop-upgrade-arrow { right:-5px; top:-5px; width:22px; height:22px; }
.shop-start-row { margin-top:16px; padding-top:14px; border-top:1px solid var(--line); }
.shop-fight-button { width:100%; min-height:44px; font-size:12px; }
.battle-status-controls { justify-content:flex-end; min-height:28px; }
.battle-status-controls .battle-hint { margin-left:0; }

/* Right side is now dedicated to loot + forging in the shop phase. */
.inventory-panel .forge-recipes { grid-template-columns:1fr; }
.inventory-panel .forge-recipe { grid-template-columns:1fr; align-items:stretch; }
.inventory-panel .forge-actions { justify-content:stretch; }
.inventory-panel .forge-button { width:100%; }
.inventory-panel .recipe-book { grid-template-columns:1fr; }

@media (max-width: 1320px) {
  .shop-main-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .shop-main-grid .shop-item { min-height:168px; }
  .inventory-panel { grid-column:1 / -1; }
  .inventory-panel .forge-recipes { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .inventory-panel .recipe-book { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width: 860px) {
  .shop-main-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .inventory-panel .forge-recipes, .inventory-panel .recipe-book { grid-template-columns:1fr; }
}

@media (max-width: 520px) {
  .shop-main-grid { grid-template-columns:1fr; }
  .shop-main-grid .shop-item {
    min-height:0;
    display:grid;
    grid-template-columns:58px minmax(0,1fr);
    align-items:center;
    text-align:left;
  }
  .shop-main-grid .shop-item .shop-icon-wrap { width:58px; height:58px; margin:0; }
  .shop-main-grid .shop-item-copy { text-align:left; }
}

/* v0.5 Combat & Spells */
.shop-main-panel[hidden], .teacher-panel[hidden], .battle-panel[hidden] { display:none; }

.loadout-spells { margin-top:12px; }
.loadout-spells-heading { display:flex; justify-content:space-between; align-items:center; margin-bottom:7px; }
.loadout-spells-heading span { color:#a9aeb8; font-size:9px; font-weight:900; text-transform:uppercase; letter-spacing:.09em; }
.loadout-spells-heading small { color:#646a76; font-size:8px; }
.loadout-spell-slots { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.loadout-spell-slot {
  min-width:0; min-height:58px; position:relative; display:grid; grid-template-columns:34px minmax(0,1fr); gap:7px; align-items:center;
  border:1px solid #333742; border-radius:10px; padding:7px; background:linear-gradient(145deg,#171920,#121419);
}
.loadout-spell-slot.empty { display:grid; place-items:center; border-style:dashed; color:#5e6470; font-size:9px; text-transform:uppercase; letter-spacing:.07em; }
.loadout-spell-slot .mini-spell-icon { width:34px; height:34px; border-radius:8px; display:grid; place-items:center; border:1px solid var(--spell-color,#565b67); background:radial-gradient(circle,color-mix(in srgb,var(--spell-color,#777) 18%,#252833),#15171d); font-size:17px; }
.loadout-spell-copy { min-width:0; }
.loadout-spell-copy strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:9px; }
.loadout-spell-copy span { display:block; margin-top:2px; color:var(--spell-color,#979ca7); font-size:8px; font-weight:800; }

.teacher-panel { position:relative; overflow:visible; z-index:20; }
.teacher-heading { margin-bottom:12px; }
.teacher-intro { display:grid; grid-template-columns:64px minmax(0,1fr); gap:12px; align-items:center; padding:12px; border:1px solid #3a3346; border-radius:12px; background:linear-gradient(135deg,rgba(113,77,139,.13),#14161b 55%); margin-bottom:14px; }
.teacher-portrait { width:64px; height:64px; display:grid; place-items:center; border-radius:50%; border:1px solid #75578b; background:radial-gradient(circle,#3b2947,#17141d 68%); color:#d7a9f0; font-size:29px; box-shadow:0 0 26px rgba(163,90,224,.12); }
.teacher-intro strong { display:block; font-family:Georgia,serif; font-size:16px; }
.teacher-intro span { display:block; margin-top:4px; color:#9297a3; font-size:10px; line-height:1.45; }
.teacher-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.teacher-spell-card { min-width:0; min-height:250px; position:relative; display:flex; flex-direction:column; align-items:stretch; border:1px solid #373b46; border-radius:13px; padding:13px; background:linear-gradient(180deg,#181a21,#121419); box-shadow:inset 0 1px rgba(255,255,255,.018); }
.teacher-spell-card.sold { opacity:.55; filter:saturate(.55); }
.teacher-spell-emblem { width:70px; height:70px; margin:2px auto 11px; border-radius:16px; display:grid; place-items:center; border:2px solid var(--spell-color); color:var(--spell-color); background:radial-gradient(circle,color-mix(in srgb,var(--spell-color) 17%,#2a2d35),#15171c 70%); font-size:29px; box-shadow:0 0 24px color-mix(in srgb,var(--spell-color) 12%,transparent); }
.teacher-spell-build { color:var(--spell-color); font-size:8px; font-weight:900; text-transform:uppercase; letter-spacing:.08em; text-align:center; }
.teacher-spell-card h3 { margin:5px 0 0; text-align:center; font-size:13px; }
.teacher-spell-level { margin-top:4px; text-align:center; color:#8f95a1; font-size:9px; }
.teacher-spell-desc { margin:11px 0 12px; color:#b6bac3; font-size:10px; line-height:1.48; flex:1; }
.teacher-spell-cd { display:flex; justify-content:space-between; gap:8px; margin-bottom:8px; padding-top:8px; border-top:1px solid #2b2e36; color:#777e8a; font-size:9px; }
.teacher-spell-buy { width:100%; border:1px solid #624f2e; border-radius:8px; background:#211b12; color:#e6bf77; padding:8px; cursor:pointer; font-size:10px; font-weight:900; }
.teacher-spell-buy:disabled { opacity:.4; cursor:not-allowed; }
.teacher-start-row { margin-top:16px; padding-top:14px; border-top:1px solid var(--line); }
.teacher-fight-button { width:100%; min-height:44px; }

.spell-replace-modal { position:fixed; inset:0; z-index:3000; display:grid; place-items:center; padding:18px; background:rgba(7,8,11,.78); backdrop-filter:blur(5px); }
.spell-replace-modal[hidden] { display:none; }
.spell-replace-card { width:min(610px,96vw); border:1px solid #55445f; border-radius:15px; padding:20px; background:linear-gradient(180deg,#1d1a22,#131419); box-shadow:0 28px 90px rgba(0,0,0,.65); }
.spell-replace-card h3 { margin:4px 0 6px; font-family:Georgia,serif; font-size:23px; }
.spell-replace-card p { margin:0 0 14px; color:#999eaa; font-size:11px; }
.spell-replace-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.spell-replace-option { min-width:0; border:1px solid #343944; border-radius:10px; padding:11px; background:#15171d; color:#e5e7eb; cursor:pointer; text-align:left; }
.spell-replace-option:hover { border-color:var(--spell-color,#75578b); background:#1a171f; }
.spell-replace-option .replace-icon { width:38px; height:38px; display:grid; place-items:center; border:1px solid var(--spell-color); color:var(--spell-color); border-radius:9px; margin-bottom:7px; font-size:19px; }
.spell-replace-option strong { display:block; font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.spell-replace-option span { display:block; margin-top:3px; color:#878d99; font-size:8px; }
.spell-replace-cancel { width:100%; margin-top:10px; }

.spell-tooltip { --rarity-color:var(--spell-color,#a35ae0); }
.spell-tooltip .tooltip-rarity { color:var(--spell-color,#a35ae0); }
.spell-tooltip-level { margin-bottom:8px; color:#aeb3be; font-size:9px; }
.spell-replace-tooltip { z-index:3200; }

.spell-card { border-color:color-mix(in srgb,var(--spell-color,#535866) 45%,#323640); }
.spell-card .spell-icon { border-color:var(--spell-color,#4f4b5b); color:var(--spell-color,#ddd); }
.spell-card .spell-copy em { display:block; margin-top:2px; color:var(--spell-color,#8f95a1); font-style:normal; font-size:8px; font-weight:800; }

.status-chip.shield { border-color:#58728f; color:#a9d4ff; background:#142231; }
.status-chip.haste { border-color:#5f8b57; color:#a6df9a; background:#172619; }
.status-chip.precision { border-color:#8e7443; color:#f1cf86; background:#281f12; }

.battle-result { overflow:auto; align-items:start; }
.result-card { width:min(760px,96%); margin:auto; }
.result-stats { grid-template-columns:repeat(2,minmax(0,1fr)); text-align:left; }
.result-side { border:1px solid #34312e; border-radius:10px; background:#121315; padding:10px; }
.result-side > strong { display:block; margin-bottom:7px; color:#d8dadd; font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.result-metric-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; }
.result-metric { border:1px solid #292b31; border-radius:7px; padding:6px 7px; background:#0e1013; }
.result-metric span { display:block; color:#737984; font-size:8px; text-transform:uppercase; }
.result-metric b { display:block; margin-top:2px; font-size:11px; }
.result-spell-breakdown { grid-column:1/-1; margin-top:7px; padding-top:7px; border-top:1px solid #2b2d33; }
.result-spell-breakdown > span { display:block; margin-bottom:5px; color:#7b818c; font-size:8px; text-transform:uppercase; letter-spacing:.07em; }
.result-spell-line { display:flex; justify-content:space-between; gap:8px; padding:2px 0; font-size:9px; }
.result-spell-line b { color:#d8dae0; }

@media (max-width: 1320px) {
  .teacher-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .equipment-panel, .shop-main-panel, .teacher-panel, .battle-panel, .inventory-panel { grid-column:auto; }
  .teacher-grid { grid-template-columns:1fr; }
  .teacher-spell-card { min-height:0; }
  .spell-replace-options { grid-template-columns:1fr; }
}
@media (max-width: 520px) {
  .loadout-spell-slots { grid-template-columns:1fr; }
  .loadout-spell-slot { min-height:50px; }
  .result-stats { grid-template-columns:1fr; }
}
.combat-projectile.arcane { background:radial-gradient(circle at 35% 35%,#fff 0 10%,#c896ff 24%,#7c4dc7 58%,transparent 72%); box-shadow:0 0 18px #9f6ce3,0 0 34px rgba(126,76,200,.42); }
.combat-projectile.blood { width:22px; height:7px; border-radius:80% 20%; background:#df6670; box-shadow:0 0 12px rgba(207,68,82,.55); transform:rotate(-18deg); }
.combat-projectile.frost { background:radial-gradient(circle at 35% 35%,#f4fdff 0 12%,#8bd8ff 30%,#4b89d7 62%,transparent 73%); box-shadow:0 0 18px #6dbcf0,0 0 34px rgba(88,166,224,.4); }
.combat-projectile.poison { background:radial-gradient(circle at 35% 35%,#e9ffd8 0 10%,#70db78 30%,#31914a 62%,transparent 74%); box-shadow:0 0 18px #5fca70,0 0 32px rgba(67,174,89,.38); }
.combat-burst.arcane { background:#b27bea; box-shadow:0 0 0 8px rgba(159,108,227,.20),0 0 24px 10px rgba(126,76,200,.35); }
.combat-burst.blood { background:#d95662; box-shadow:0 0 0 8px rgba(206,72,84,.18),0 0 22px rgba(206,72,84,.36); }
.combat-burst.frost { background:#80cef7; box-shadow:0 0 0 8px rgba(92,181,231,.19),0 0 24px rgba(92,181,231,.4); }
.combat-burst.poison { background:#68cf70; box-shadow:0 0 0 8px rgba(86,194,101,.18),0 0 22px rgba(86,194,101,.36); }
.combat-burst.shield { background:#8cc8ff; box-shadow:0 0 0 10px rgba(106,168,224,.16),0 0 26px rgba(106,168,224,.36); }

/* v0.5a QoL fixes; v0.5c keeps these styles */
.spell-card.empty {
  min-height:72px;
  border-style:dashed;
  border-color:#343841;
  background:linear-gradient(145deg,#15171c,#101216);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.012);
}
.battle-hint:empty { display:none; }
.item-sell-modal { position:fixed; inset:0; z-index:3200; display:grid; place-items:center; padding:18px; background:rgba(7,8,11,.72); backdrop-filter:blur(4px); }
.item-sell-modal[hidden] { display:none; }
.item-sell-card { width:min(390px,94vw); border:1px solid #4a4236; border-radius:14px; padding:18px; background:linear-gradient(180deg,#1c1a17,#121316); box-shadow:0 28px 90px rgba(0,0,0,.65); }
.item-sell-card h3 { margin:5px 0 7px; font-family:Georgia,serif; font-size:21px; }
.item-sell-card p { margin:0 0 15px; color:#a8acb5; font-size:11px; line-height:1.55; }
.item-sell-card p strong { color:#d7bb83; }
.item-sell-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.sell-confirm-button { border:1px solid #567a4d; border-radius:8px; background:#182317; color:#9bdb8b; padding:9px 10px; cursor:pointer; font-weight:900; }
.sell-confirm-button:hover { background:#1e2d1c; border-color:#70a064; }


/* v0.6 · Sets & Build Identity */
.set-item-badge {
  position:absolute; left:4px; bottom:4px; z-index:3; width:17px; height:17px; border-radius:5px;
  display:grid; place-items:center; border:1px solid color-mix(in srgb,var(--rarity-color) 70%,#fff 10%);
  background:rgba(10,11,14,.9); color:var(--rarity-color); font-size:9px; line-height:1; box-shadow:0 2px 7px rgba(0,0,0,.45);
}
.set-summary { display:flex; flex-wrap:wrap; gap:6px; margin-top:9px; }
.set-summary[hidden] { display:none; }
.set-summary-chip { min-width:0; display:flex; align-items:center; justify-content:space-between; gap:8px; border:1px solid #323640; border-radius:8px; background:#14161b; padding:6px 8px; color:#8f949f; font-size:9px; flex:1 1 120px; }
.set-summary-chip span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.set-summary-chip strong { color:#a6abb5; font-size:9px; }
.set-summary-chip.active { border-color:color-mix(in srgb,var(--set-color) 55%,#30343d); color:#d4d7dd; box-shadow:inset 0 0 18px color-mix(in srgb,var(--set-color) 7%,transparent); }
.set-summary-chip.active strong { color:var(--set-color); }
.set-summary-chip.complete { border-color:var(--set-color); box-shadow:inset 0 0 22px color-mix(in srgb,var(--set-color) 12%,transparent),0 0 12px color-mix(in srgb,var(--set-color) 8%,transparent); }
.tooltip-set { margin:0 0 8px; padding:8px; border:1px solid #353945; border-radius:8px; background:#111319; }
.tooltip-set-title { display:flex; justify-content:space-between; gap:8px; color:#e1e3e8; font-size:10px; font-weight:900; margin-bottom:6px; }
.tooltip-set-title span { color:#8f949f; font-size:8px; font-weight:700; }
.tooltip-set-bonus { display:grid; gap:2px; padding:5px 0; border-top:1px solid #282c34; opacity:.52; }
.tooltip-set-bonus:first-of-type { border-top:0; }
.tooltip-set-bonus.active { opacity:1; }
.tooltip-set-bonus b { font-size:9px; color:#afb4be; }
.tooltip-set-bonus.active b { color:var(--rarity-color); }
.tooltip-set-bonus span { font-size:8px; line-height:1.35; color:#9ca1aa; }
.tooltip-legendary { margin:0 0 8px; padding:8px; border:1px solid #8c5725; border-radius:8px; background:linear-gradient(135deg,#21160e,#141318); box-shadow:inset 0 0 18px rgba(237,142,47,.07); }
.tooltip-legendary strong { display:block; color:#ed8e2f; font-size:9px; text-transform:uppercase; letter-spacing:.07em; }
.tooltip-legendary span { display:block; margin-top:3px; color:#e4c39d; font-size:9px; line-height:1.4; }
.recipe-book-panel { max-height:420px; overflow:auto; padding-right:3px; }

/* v0.7 · async ghost profile */
.player-profile {
  min-width: 210px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #14161c;
  display: grid;
  grid-template-columns: 9px minmax(110px,1fr) auto;
  align-items: center;
  gap: 8px;
}
.profile-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #777d89;
  box-shadow: 0 0 0 3px rgba(119,125,137,.08);
}
.player-profile.online .profile-status-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(88,184,112,.12); }
.player-profile.offline .profile-status-dot { background: #b46b58; box-shadow: 0 0 0 3px rgba(180,107,88,.12); }
.profile-copy { min-width: 0; display:flex; flex-direction:column; }
.profile-copy > span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing:.08em; }
#playerNameInput {
  width: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
}
#playerNameInput:focus { color: #f4c879; }
#profileStatusText { color: var(--muted); font-size: 9px; white-space: nowrap; }
.player-profile.online #profileStatusText { color: #85c895; }
.player-profile.offline #profileStatusText { color: #c58a7c; }

@media (max-width: 1250px) {
  .player-profile { order: 3; min-width: 190px; }
}

/* v0.8 · Run Events */
.shop-main-panel[hidden], .teacher-panel[hidden], .event-panel[hidden], .battle-panel[hidden] { display:none; }
.event-panel { position:relative; overflow:visible; z-index:18; }
.event-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
.event-heading h2 { margin:2px 0 0; font-size:18px; }
.event-round-badge { border:1px solid #4b4232; border-radius:999px; background:#1d1912; color:#d6b36f; padding:6px 9px; font-size:9px; font-weight:900; white-space:nowrap; }
.event-hero { display:grid; grid-template-columns:78px minmax(0,1fr); align-items:center; gap:14px; padding:14px; border:1px solid #3b3940; border-radius:14px; background:linear-gradient(135deg,rgba(173,132,72,.11),#14161b 55%); }
.event-emblem { width:78px; height:78px; display:grid; place-items:center; border:1px solid var(--event-color,#8c7048); border-radius:18px; background:radial-gradient(circle,color-mix(in srgb,var(--event-color,#8c7048) 18%,#29241c),#14151a 72%); color:var(--event-color,#d1a75d); font-family:Georgia,serif; font-size:34px; box-shadow:0 0 28px color-mix(in srgb,var(--event-color,#8c7048) 12%,transparent); }
.event-hero strong { display:block; font-family:Georgia,serif; font-size:17px; }
.event-hero p { margin:5px 0 0; color:#9ca1ac; font-size:10px; line-height:1.55; }
.event-choices { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-top:14px; }
.event-choice { min-width:0; min-height:182px; display:flex; flex-direction:column; align-items:stretch; border:1px solid #343842; border-radius:13px; padding:12px; background:linear-gradient(180deg,#191b21,#121419); color:#e7e9ed; text-align:left; }
.event-choice.available { cursor:pointer; }
.event-choice.available:hover { border-color:var(--event-color,#806a4b); background:linear-gradient(180deg,#1d1d20,#15151a); transform:translateY(-1px); }
.event-choice:disabled { opacity:.42; cursor:not-allowed; }
.event-choice-icon { width:46px; height:46px; display:grid; place-items:center; border:1px solid var(--choice-color,var(--event-color,#806a4b)); border-radius:11px; color:var(--choice-color,var(--event-color,#d1a75d)); background:#14161b; font-size:21px; }
.event-choice-kicker { margin-top:10px; color:var(--choice-color,var(--event-color,#b79a67)); font-size:8px; font-weight:900; text-transform:uppercase; letter-spacing:.09em; }
.event-choice strong { display:block; margin-top:4px; font-size:12px; }
.event-choice p { flex:1; margin:6px 0 10px; color:#a2a7b1; font-size:9px; line-height:1.5; }
.event-choice-cost { padding-top:8px; border-top:1px solid #292d34; color:#d7ba7d; font-size:9px; font-weight:900; }
.event-choice .event-item-preview { display:flex; align-items:center; gap:8px; margin-top:8px; padding:7px; border:1px solid #292d35; border-radius:9px; background:#111318; }
.event-choice .event-item-preview .item-icon { position:relative; width:38px; height:38px; flex:0 0 38px; inset:auto; cursor:help; }
.event-choice .event-item-preview span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#c7cad1; font-size:9px; font-weight:800; }
.event-outcome { margin-top:14px; border:1px solid #40553d; border-radius:12px; background:#131b14; color:#acd2a4; padding:11px 12px; font-size:10px; line-height:1.5; }
.event-outcome[hidden] { display:none; }
.event-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:15px; padding-top:13px; border-top:1px solid var(--line); }
.event-footer span { color:#777e89; font-size:9px; }
.event-footer button { min-width:190px; }
@media (max-width: 1100px) { .event-choices { grid-template-columns:1fr; } .event-choice { min-height:0; } }
@media (max-width: 520px) { .event-hero { grid-template-columns:56px minmax(0,1fr); } .event-emblem { width:56px; height:56px; font-size:25px; } .event-footer { align-items:stretch; flex-direction:column; } .event-footer button { width:100%; } }

/* v0.8b */
.recipe-result-preview {
  display:flex;
  align-items:center;
  gap:6px;
  width:max-content;
  max-width:100%;
  padding:4px 6px;
  margin-left:-2px;
  border:1px solid color-mix(in srgb,var(--rarity-color) 45%,#30343d);
  border-radius:6px;
  background:color-mix(in srgb,var(--rarity-color) 7%,#121419);
  cursor:help;
  outline:none;
}
.recipe-result-preview:hover,
.recipe-result-preview:focus {
  border-color:var(--rarity-color);
  box-shadow:0 0 12px color-mix(in srgb,var(--rarity-color) 22%,transparent);
}
.recipe-result-preview img {
  width:20px;
  height:20px;
  object-fit:contain;
  opacity:.95;
}
.item-icon { -webkit-touch-callout:none; }
