:root {
  --gold: #ffd54a;
  --gold-deep: #ff9d00;
  --panel: rgba(14, 12, 28, 0.88);
  --panel-edge: rgba(255, 214, 120, 0.35);
  --text: #f3eee0;
  --muted: #a49cb8;
  --r-common: #d8d8d8;
  --r-uncommon: #5dea6a;
  --r-rare: #4aa8ff;
  --r-epic: #c36bff;
  --r-legendary: #ffa526;
  --r-mythic: #ff3d6e;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; overflow: hidden;
  background: #07060d; color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  user-select: none;
}
canvas#game {
  position: fixed; inset: 0; width: 100vw; height: 100vh; display: block;
  image-rendering: pixelated;
  filter: saturate(1.12) contrast(1.04);
}

/* ---------- HD-2D post layers ---------- */
.dof {
  position: fixed; left: 0; right: 0; height: 16vh; pointer-events: none;
  backdrop-filter: blur(2.5px); -webkit-backdrop-filter: blur(2.5px);
}
#dof-top { top: 0; mask-image: linear-gradient(to bottom, #000, transparent); -webkit-mask-image: linear-gradient(to bottom, #000, transparent); }
#dof-bot { bottom: 0; mask-image: linear-gradient(to top, #000, transparent); -webkit-mask-image: linear-gradient(to top, #000, transparent); }
body.no-dof .dof { display: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud input, #hud .clickable { pointer-events: auto; }
.hidden { display: none !important; }

.bar { position: relative; height: 16px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.25); border-radius: 4px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0; width: 100%; transform-origin: left; }
.bar-text { position: absolute; inset: 0; font-size: 11px; line-height: 15px; text-align: center; font-weight: bold; text-shadow: 0 1px 2px #000, 0 0 3px #000; }

#hud-topleft { position: absolute; top: 12px; left: 14px; width: 270px; }
#hud-name { font-size: 22px; font-weight: 900; letter-spacing: 1px; text-shadow: 0 2px 4px #000, 0 0 12px rgba(255,200,80,0.5); margin-bottom: 4px; }
#hud-level { color: var(--gold); }
#hud-rebirth { margin-left: 10px; font-size: 14px; color: #ff9cf0; text-shadow: 0 0 8px #f0f; }
.bar.hp { height: 20px; }
.bar.hp .bar-fill { background: linear-gradient(to bottom, #ff7b7b, #d6213a 60%, #9b0f25); transition: transform 0.12s; }
.bar.hp .bar-text { line-height: 19px; font-size: 12px; }
#hud-floor { margin-top: 2px; font-size: 13px; color: #9ad8ff; font-weight: bold; text-shadow: 0 1px 3px #000; }
#hud-floor .gate { color: #ff8a8a; margin-left: 6px; }
#hud-power { margin-top: 4px; font-size: 13px; color: #ffcf8a; font-weight: bold; text-shadow: 0 1px 3px #000; }

#hud-topcenter { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 420px; text-align: center; }
#map-name { font-size: 17px; font-weight: bold; text-shadow: 0 2px 4px #000; letter-spacing: 1px; }
#stage-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.stage-btn { width: 26px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--gold);
  background: linear-gradient(to bottom, #3b3260, #1d1836); border: 1px solid var(--panel-edge); }
.stage-btn:hover:not(:disabled) { filter: brightness(1.4); box-shadow: 0 0 10px rgba(255,210,100,0.6); }
.stage-btn:disabled { opacity: 0.3; cursor: default; }
#toggle-row { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.pill { cursor: pointer; font-size: 10.5px; font-weight: 900; letter-spacing: 1px; padding: 3px 10px; border-radius: 12px;
  background: rgba(20,16,40,0.8); color: #8a82a0; border: 1px solid rgba(255,255,255,0.18); }
.pill:hover { filter: brightness(1.4); }
.pill.on { color: #1a1200; background: linear-gradient(to bottom, #7dff8a, #2fb84a); border-color: #b8ffc0; box-shadow: 0 0 10px rgba(110,255,140,0.6); }
#btn-idle.on { animation: idlePulse 1.6s ease-in-out infinite; }
@keyframes idlePulse { 50% { box-shadow: 0 0 18px rgba(110,255,140,0.9); } }
#stage-prompt { margin: 8px auto 0; width: 330px; padding: 8px 10px; border-radius: 10px; pointer-events: auto;
  background: rgba(16,12,34,0.88); border: 1px solid var(--gold); box-shadow: 0 0 18px rgba(255,200,80,0.35); animation: promptIn 0.3s ease-out; }
#stage-msg { font-size: 13px; font-weight: bold; margin-bottom: 6px; text-shadow: 0 1px 2px #000; }
#stage-msg .warn { color: #ff9a6a; }
.stage-go, .stage-stay { cursor: pointer; font-weight: 900; font-size: 13px; padding: 5px 14px; margin: 0 4px; border-radius: 6px; border: none; }
.stage-go { background: linear-gradient(to bottom, #ffcf4a, #c27a00); color: #2a1600; }
.stage-stay { background: linear-gradient(to bottom, #4a4270, #2a2448); color: #e8e0ff; }
.stage-go:hover, .stage-stay:hover { filter: brightness(1.25); }
@keyframes promptIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }
#map-name small { color: var(--muted); font-weight: normal; }
.bar.boss-gauge { height: 10px; width: 260px; margin: 0 auto; }
.bar.boss-gauge .bar-fill { background: linear-gradient(90deg, #7a3cff, #ff4fd8); }
.bar.boss-gauge .bar-text { font-size: 9px; line-height: 9px; }
#boss-bar { margin-top: 8px; }
#boss-name { font-size: 18px; font-weight: 900; color: #ff5a6e; text-shadow: 0 0 10px #f00, 0 2px 3px #000; letter-spacing: 2px; }
.bar.boss { height: 22px; border-color: #ff7a8a; box-shadow: 0 0 14px rgba(255,40,80,0.6); }
.bar.boss .bar-fill { background: linear-gradient(to bottom, #ff4a6a, #b0103a); }
.bar.boss .bar-fill-lag { position: absolute; inset: 0; background: #fff3c0; transform-origin: left; transition: transform 0.6s ease-out 0.15s; }
.bar.boss .bar-text { line-height: 21px; font-size: 12px; }

#hud-topright { position: absolute; top: 12px; right: 14px; text-align: right; }
#hud-gold { font-size: 20px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 4px #000, 0 0 10px rgba(255,190,40,0.5); }
.coin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 6px; vertical-align: -1px;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffc400 50%, #b07800); box-shadow: 0 0 6px #fc0; }
#hud-dps { font-size: 13px; color: #9fe3ff; font-weight: bold; text-shadow: 0 1px 3px #000; margin-top: 2px; }
#hud-scroll { font-size: 13px; color: #ffe27a; font-weight: bold; text-shadow: 0 1px 3px #000, 0 0 8px rgba(255,210,80,0.45); margin-top: 2px; }
#hud-manual { font-size: 13px; color: #8affc8; font-weight: bold; text-shadow: 0 1px 3px #000, 0 0 8px rgba(80,255,170,0.4); margin-top: 2px; }
#hud-manual.max { color: #b8ffde; text-shadow: 0 1px 3px #000, 0 0 12px rgba(80,255,170,0.8); }
#hud-kills { font-size: 13px; color: #ffb0b8; font-weight: bold; text-shadow: 0 1px 3px #000; margin-top: 2px; }
#hud-kills small { color: #a49cb8; font-weight: normal; font-size: 11px; }
#hud-kills .skull { color: #ff6a7a; }
#kills-rate { font-size: 11px; color: #a49cb8; font-weight: normal; }
#saved-ping { position: absolute; right: 14px; bottom: 30px; font-size: 12px; font-weight: bold; color: #7dff8a; text-shadow: 0 1px 3px #000; opacity: 0; }
#saved-ping.show { animation: savedPing 1.8s ease-out; }
@keyframes savedPing { 0% { opacity: 0; transform: translateY(4px); } 15% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; } }
#menu-buttons { margin-top: 8px; display: flex; gap: 5px; justify-content: flex-end; }
#menu-buttons button {
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  background: linear-gradient(to bottom, #3b3260, #1d1836); color: var(--gold);
  border: 1px solid var(--panel-edge); font-weight: 900; font-size: 14px;
}
#menu-buttons button:hover { filter: brightness(1.4); box-shadow: 0 0 10px rgba(255,210,100,0.6); }

#combo { position: absolute; right: 24px; top: 150px; text-align: right; }
#combo-num { font-size: 54px; font-weight: 900; font-style: italic; line-height: 1;
  background: linear-gradient(to bottom, #fff, #ffe066 45%, #ff7a00); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #6a1c00) drop-shadow(0 0 10px rgba(255,140,0,0.7)); }
#combo-num.pop { animation: comboPop 0.18s ease-out; }
@keyframes comboPop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#combo-label { font-size: 14px; font-weight: 900; letter-spacing: 6px; color: #ffcf6a; text-shadow: 0 2px 3px #000; }
#combo-bonus { font-size: 12px; color: #9fff9f; text-shadow: 0 1px 2px #000; }

#loot-feed { position: absolute; right: 14px; top: 250px; width: 300px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.loot-toast {
  padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: bold;
  background: linear-gradient(90deg, transparent, rgba(10,8,20,0.85) 25%);
  border-right: 3px solid currentColor; text-shadow: 0 0 8px currentColor, 0 1px 2px #000;
  animation: toastIn 0.25s ease-out, toastOut 0.5s ease-in 4s forwards;
}
.loot-toast.big { font-size: 16px; padding: 8px 14px; }
@keyframes toastIn { from { transform: translateX(80px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateX(40px); opacity: 0; } }

#chat { position: absolute; left: 14px; bottom: 34px; width: 380px; }
#chat-log { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 12.5px; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
#chat-log div { padding: 1px 4px; animation: fadeLine 0.3s; }
@keyframes fadeLine { from { opacity: 0; transform: translateY(4px); } }
#chat-input {
  width: 100%; margin-top: 4px; padding: 5px 8px; font-size: 13px; color: var(--text);
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; outline: none;
  font-family: inherit; opacity: 0.55;
}
#chat-input:focus { opacity: 1; background: rgba(10,8,25,0.85); border-color: var(--gold); }

#skillbar { position: absolute; left: 50%; bottom: 32px; transform: translateX(-50%); display: flex; gap: 6px; }
.skill {
  position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden;
  background: #15122a; border: 2px solid rgba(255,214,120,0.45);
  box-shadow: 0 3px 8px rgba(0,0,0,0.6), inset 0 0 10px rgba(0,0,0,0.6);
}
.skill img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.skill .cd { position: absolute; inset: 0; background: conic-gradient(rgba(0,0,0,0.72) var(--p, 0%), transparent 0); }
.skill .cd-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 18px; text-shadow: 0 0 4px #000, 0 2px 2px #000; }
.skill .key { position: absolute; left: 3px; top: 1px; font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 0 3px #000, 0 1px 2px #000; }
.skill.locked { filter: grayscale(1) brightness(0.4); }
.skill.move { margin-left: 14px; border-color: rgba(160,220,255,0.55); }
.skill.move .key { font-size: 10px; }
.skill.locked .lock { position: absolute; bottom: 2px; width: 100%; text-align: center; font-size: 10px; color: #ddd; font-weight: bold; }
.skill.ready-flash { animation: readyFlash 0.35s ease-out; }
@keyframes readyFlash { 0% { box-shadow: 0 0 22px #fff, inset 0 0 20px #fff; border-color: #fff; } 100% {} }
.skill.cast { animation: castPress 0.15s ease-out; }
@keyframes castPress { 0% { transform: scale(0.88); } 100% { transform: scale(1); } }

#expbar { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background: rgba(0,0,0,0.8); border-top: 1px solid rgba(255,255,255,0.2); }
#exp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(to bottom, #fff8b0, #ffd23a 40%, #e29400); box-shadow: 0 0 12px #ffc400; transition: width 0.15s; }
#exp-text { position: absolute; inset: 0; text-align: center; font-size: 12.5px; line-height: 22px; font-weight: 900; text-shadow: 0 0 3px #000, 0 1px 2px #000; }
#exp-gain { position: absolute; right: 12px; top: -22px; font-size: 14px; font-weight: 900; color: #fff3a0; text-shadow: 0 0 6px #fa0, 0 1px 2px #000; opacity: 0; transition: opacity 0.4s; }

#banner { position: absolute; top: 24%; left: 0; right: 0; text-align: center; opacity: 0; }
#banner.show { animation: bannerIn 2.2s ease-out forwards; }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(2.6); filter: blur(8px); }
  10% { opacity: 1; transform: scale(0.94); filter: blur(0); }
  16% { transform: scale(1.04); }
  22% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}
#banner-main {
  font-size: 76px; font-weight: 900; font-style: italic; letter-spacing: 4px; line-height: 1.05;
  background: linear-gradient(to bottom, #fff 10%, #ffe56b 45%, #ff8c00 75%, #ffd36b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #5a1e00) drop-shadow(0 0 22px rgba(255,170,0,0.85));
}
#banner.rebirth #banner-main { background-image: linear-gradient(to bottom, #fff 10%, #ffb6f8 45%, #9b4dff 80%); filter: drop-shadow(0 4px 0 #2a0050) drop-shadow(0 0 26px rgba(220,100,255,0.9)); }
#banner.boss #banner-main { background-image: linear-gradient(to bottom, #fff 10%, #ff8d8d 45%, #c80022 80%); filter: drop-shadow(0 4px 0 #300) drop-shadow(0 0 26px rgba(255,40,40,0.9)); }
#banner.mythic #banner-main { background-image: linear-gradient(90deg, #ff5c5c, #ffd65c, #6bff7c, #5cd6ff, #b85cff, #ff5cc8); filter: drop-shadow(0 4px 0 #000) drop-shadow(0 0 26px #fff); }
#banner-sub { font-size: 24px; font-weight: 900; color: #fff; text-shadow: 0 0 10px #ffb000, 0 2px 3px #000; margin-top: 4px; }

#notice { position: absolute; top: 38%; left: 0; right: 0; text-align: center; font-size: 20px; font-weight: bold; color: #fff; text-shadow: 0 0 8px #000, 0 2px 3px #000; opacity: 0; }
#notice.show { animation: noticeIn 2.5s ease-out forwards; }
@keyframes noticeIn { 0% { opacity: 0; transform: translateY(10px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Windows ---------- */
#windows { position: fixed; inset: 0; pointer-events: none; }
.window {
  position: absolute; pointer-events: auto; min-width: 320px; max-height: 84vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.7), inset 0 0 30px rgba(120,90,255,0.08);
  backdrop-filter: blur(4px); animation: winIn 0.15s ease-out;
}
@keyframes winIn { from { transform: scale(0.95); opacity: 0; } }
.win-head { display: flex; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--panel-edge); cursor: move;
  background: linear-gradient(to bottom, rgba(255,214,120,0.12), transparent); border-radius: 10px 10px 0 0; }
.win-title { flex: 1; font-weight: 900; letter-spacing: 2px; color: var(--gold); text-shadow: 0 0 8px rgba(255,180,0,0.5); }
.win-close { cursor: pointer; background: none; border: none; color: var(--muted); font-size: 18px; font-weight: bold; }
.win-close:hover { color: #fff; }
.win-body { padding: 12px; overflow-y: auto; font-size: 13.5px; }
.win-body::-webkit-scrollbar { width: 8px; }
.win-body::-webkit-scrollbar-thumb { background: rgba(255,214,120,0.3); border-radius: 4px; }

.btn {
  cursor: pointer; padding: 5px 12px; border-radius: 5px; font-weight: bold; font-family: inherit; font-size: 12.5px;
  background: linear-gradient(to bottom, #4a3f7a, #2a2350); color: #fff; border: 1px solid rgba(255,214,120,0.4);
}
.btn:hover:not(:disabled) { filter: brightness(1.35); box-shadow: 0 0 8px rgba(255,214,120,0.5); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.gold { background: linear-gradient(to bottom, #ffcf4a, #c27a00); color: #2a1600; }
.btn.pink { background: linear-gradient(to bottom, #e86bff, #7a1fb0); }
.btn.red { background: linear-gradient(to bottom, #ff6b6b, #a01f2a); }
.btn.small { padding: 2px 7px; font-size: 11.5px; }

.stat-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,0.07); }
.stat-row .lbl { flex: 1; color: var(--muted); }
.stat-row .val { font-weight: bold; min-width: 70px; text-align: right; }
.section-title { margin: 12px 0 6px; font-weight: 900; color: var(--gold); letter-spacing: 1px; font-size: 12.5px; text-transform: uppercase; }
.ap-left { font-size: 16px; font-weight: 900; color: #7dff8a; text-shadow: 0 0 8px rgba(0,255,80,0.5); }
select, input[type=range] { font-family: inherit; }
select { background: #1d1836; color: var(--text); border: 1px solid var(--panel-edge); border-radius: 4px; padding: 2px 4px; }

.inv-wrap { display: flex; gap: 14px; }
.equip-grid { display: grid; grid-template-columns: repeat(2, 58px); gap: 6px; align-content: start; }
.inv-grid { display: grid; grid-template-columns: repeat(8, 46px); gap: 4px; align-content: start; }
.slot {
  position: relative; width: 46px; height: 46px; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
}
.equip-grid .slot { width: 58px; height: 58px; }
.slot img { width: 100%; height: 100%; image-rendering: pixelated; }
.slot .enh { position: absolute; right: 2px; bottom: 0; font-size: 10px; font-weight: 900; color: #7dff8a; text-shadow: 0 0 3px #000; }
.slot .slot-lbl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: rgba(255,255,255,0.25); text-transform: uppercase; }
.slot.selected { outline: 2px solid #fff; box-shadow: 0 0 10px #fff; }
.slot.r0 { border-color: var(--r-common); }
.slot.r1 { border-color: var(--r-uncommon); box-shadow: inset 0 0 8px rgba(93,234,106,0.35); }
.slot.r2 { border-color: var(--r-rare); box-shadow: inset 0 0 10px rgba(74,168,255,0.45); }
.slot.r3 { border-color: var(--r-epic); box-shadow: inset 0 0 12px rgba(195,107,255,0.55); }
.slot.r4 { border-color: var(--r-legendary); box-shadow: inset 0 0 14px rgba(255,165,38,0.65), 0 0 6px rgba(255,165,38,0.5); }
.slot.r5 { border-color: var(--r-mythic); box-shadow: inset 0 0 16px rgba(255,61,110,0.75), 0 0 10px rgba(255,61,110,0.7); animation: mythicPulse 1.2s infinite alternate; }
@keyframes mythicPulse { to { filter: hue-rotate(60deg) brightness(1.2); } }
.item-detail { margin-top: 10px; min-height: 120px; padding: 10px; border-radius: 6px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.08); }
.inv-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }

.tt-name { font-weight: 900; font-size: 14px; margin-bottom: 2px; }
.tt-sub { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.tt-main { color: #fff; font-weight: bold; margin-bottom: 4px; }
.tt-line { color: #8fe3ff; font-size: 12.5px; }
.tt-cmp { margin-top: 6px; font-size: 12px; font-weight: bold; }
.up { color: #7dff8a; } .down { color: #ff7d7d; }
.rc0 { color: var(--r-common); } .rc1 { color: var(--r-uncommon); } .rc2 { color: var(--r-rare); }
.rc3 { color: var(--r-epic); } .rc4 { color: var(--r-legendary); } .rc5 { color: var(--r-mythic); text-shadow: 0 0 8px var(--r-mythic); }

#tooltip { position: fixed; z-index: 50; pointer-events: none; max-width: 280px; padding: 10px 12px; border-radius: 8px;
  background: rgba(10,8,22,0.96); border: 1px solid var(--panel-edge); box-shadow: 0 6px 20px rgba(0,0,0,0.7); font-size: 13px; }

.map-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; margin-bottom: 4px; background: rgba(255,255,255,0.03); }
.map-row.current { background: rgba(255,214,120,0.12); outline: 1px solid rgba(255,214,120,0.5); }
.map-row.locked { opacity: 0.45; }
.map-chip { width: 26px; height: 26px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.3); flex-shrink: 0; }
.map-info { flex: 1; }
.map-info .nm { font-weight: bold; }
.map-info .sub { font-size: 11.5px; color: var(--muted); }
.diff { font-size: 11px; font-weight: bold; padding: 1px 6px; border-radius: 10px; }

.class-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.win-body:has(.class-grid) { max-height: 82vh; }
.class-card { border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; padding: 10px; background: rgba(255,255,255,0.03); display: flex; flex-direction: column; gap: 6px; }
.class-card.current { border-color: var(--cc); box-shadow: 0 0 14px color-mix(in srgb, var(--cc) 45%, transparent), inset 0 0 20px color-mix(in srgb, var(--cc) 12%, transparent); }
.class-top { display: flex; gap: 10px; align-items: center; }
.class-top img { width: 84px; height: 84px; image-rendering: pixelated; border-radius: 8px;
  background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--cc) 30%, transparent), transparent 70%); }
.class-name { font-size: 18px; font-weight: 900; color: var(--cc); }
.class-role { font-size: 11.5px; color: var(--muted); }
.class-desc { font-size: 12px; }
.class-mods { font-size: 11.5px; color: #cfc6ff; }
.class-skills { display: flex; gap: 3px; flex-wrap: wrap; }
.class-skills img { width: 30px; height: 30px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.15); }
.class-card .btn { width: 100%; padding: 6px; }
.perk-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(255,255,255,0.08); }
.perk-row .info { flex: 1; }
.perk-row .nm { font-weight: bold; }
.perk-row .ds { font-size: 11.5px; color: var(--muted); }
.rp-big { font-size: 22px; font-weight: 900; color: #ff9cf0; text-shadow: 0 0 12px #f0f; }

.key-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.key-row .lbl { flex: 1; }
.keycap { min-width: 70px; text-align: center; cursor: pointer; padding: 3px 8px; border-radius: 5px; font-weight: 900;
  background: #241e44; border: 1px solid rgba(255,214,120,0.4); color: var(--gold); font-family: inherit; }
.keycap.listening { background: #ffd54a; color: #000; animation: blink 0.6s infinite alternate; }
@keyframes blink { to { opacity: 0.5; } }
.toggle-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.toggle-row label { flex: 1; cursor: pointer; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
kbd { background: #241e44; border: 1px solid rgba(255,214,120,0.4); border-radius: 4px; padding: 0 5px; color: var(--gold); font-family: inherit; font-weight: bold; }

/* ---------- Title ---------- */
#title-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(40,20,70,0.55), rgba(5,3,12,0.92)); z-index: 100; cursor: pointer;
  transition: opacity 0.6s;
}
#title-screen.gone { opacity: 0; pointer-events: none; }
#title-logo { font-size: 110px; font-weight: 900; font-style: italic; letter-spacing: 8px;
  background: linear-gradient(to bottom, #fff 10%, #ffe56b 40%, #ff8c00 75%, #ffd36b); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #4a1600) drop-shadow(0 0 40px rgba(255,160,0,0.8)); animation: logoFloat 3s ease-in-out infinite alternate; }
#title-logo span { margin-left: 10px; background: linear-gradient(to bottom, #fff, #ff9cf0 50%, #8a3cff); -webkit-background-clip: text; background-clip: text; }
@keyframes logoFloat { to { transform: translateY(-10px); } }
#title-by { margin-top: 10px; font-size: 15px; letter-spacing: 3px; color: #ffd54a; font-style: italic; text-shadow: 0 0 10px rgba(255,180,0,0.6); }
#title-sub { font-size: 18px; letter-spacing: 6px; color: #e8d9ff; text-transform: uppercase; margin-top: 6px; text-shadow: 0 0 10px #a0f; }
#title-press { margin-top: 60px; font-size: 22px; font-weight: bold; color: #fff; animation: blink 0.9s infinite alternate; }
#title-hint { margin-top: 18px; font-size: 13px; color: var(--muted); }

#death { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 48px; font-weight: 900; color: #ff4a5a; text-shadow: 0 0 20px #f00, 0 3px 0 #300; background: rgba(60,0,0,0.35); }

/* ---------- Enchant window ---------- */
.ench-mats { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 10px; background: rgba(0,0,0,0.25); border-radius: 8px; font-size: 12.5px; color: #c8c0da; }
.m-stone { color: #b8a0ff; }
.m-cron { color: #6ff0e0; }
.ench-wrap { display: flex; gap: 12px; margin-top: 10px; }
.ench-list { width: 196px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.ench-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 7px; cursor: pointer; background: rgba(255,255,255,0.03); border: 1px solid transparent; }
.ench-row:hover { background: rgba(255,255,255,0.07); }
.ench-row.sel { border-color: var(--gold); background: rgba(255,207,74,0.08); }
.ench-row img, .ench-empty { width: 28px; height: 28px; image-rendering: pixelated; flex-shrink: 0; }
.ench-sname { flex: 1; font-size: 12.5px; display: flex; flex-direction: column; }
.ench-pips { display: flex; gap: 2px; margin-top: 2px; }
.ench-pips i { width: 9px; height: 4px; border-radius: 2px; background: #2e2a3c; }
.ench-row b { font-size: 13px; min-width: 32px; text-align: right; }
.ench-main { flex: 1; min-width: 0; }
.ench-main .warn, .ench-protect + .warn { color: #ff7d7d; font-size: 12px; margin-top: 4px; }
.ench-cost { font-size: 12.5px; margin-top: 6px; }
.ench-btns { display: flex; gap: 8px; margin-top: 8px; }
.ench-btns .btn { flex: 1; padding: 9px; font-size: 14px; }
.ench-log { font-size: 12px; line-height: 1.5; }
.ench-stage { text-align: center; padding: 10px 6px 4px; border-radius: 12px;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.07), transparent 70%); }
.ench-icon { width: 72px; height: 72px; margin: 6px auto 16px; position: relative; border-radius: 14px; background: #17131f;
  border: 2px solid var(--c); box-shadow: 0 0 14px var(--c); display: flex; align-items: center; justify-content: center; }
.ench-icon img { width: 54px; height: 54px; image-rendering: pixelated; }
.ench-badge { position: absolute; right: -8px; bottom: -9px; font-weight: 900; font-size: 15px; text-shadow: 0 0 4px #000, 0 0 2px #000; }
.ench-arrow { font-size: 13px; color: #c8c0da; }
.ench-chance { font-size: 36px; font-weight: 900; color: #fff; text-shadow: 0 0 14px var(--n); line-height: 1.1; }
.ench-bar { height: 8px; margin: 8px 24px 4px; background: #0e0b16; border-radius: 4px; overflow: hidden; }
.ench-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--c), var(--n), #fff); }
.ench-result { height: 28px; font-size: 20px; font-weight: 900; letter-spacing: 2px; }
.charging .ench-icon { animation: enchCharge 1s ease-in both; }
.charging .ench-icon::before { content: ''; position: absolute; inset: -12px; border-radius: 50%; border: 2px dashed var(--n); animation: enchSpin 0.5s linear infinite; }
.charging .ench-fill { animation: enchFill 1s linear both; }
.res-ok .ench-icon { animation: enchOk 0.9s ease-out both; }
.res-ok .ench-result { color: #ffe27a; text-shadow: 0 0 14px #ffb000; animation: enchPop 0.6s cubic-bezier(.2,1.6,.4,1) both; }
.res-fail .ench-icon { animation: enchFail 0.6s ease-out both; }
.res-fail .ench-result { color: #ff5a6a; animation: enchPop 0.4s ease-out both; }
@keyframes enchCharge {
  0% { transform: scale(1); box-shadow: 0 0 6px var(--n); }
  70% { transform: scale(1.08); box-shadow: 0 0 26px 4px var(--n); }
  76% { transform: scale(1.1) translate(-2px, 1px); }
  82% { transform: scale(1.12) translate(2px, -1px); }
  88% { transform: scale(1.14) translate(-2px, -1px); }
  94% { transform: scale(1.16) translate(2px, 1px); }
  100% { transform: scale(1.2); box-shadow: 0 0 46px 12px var(--n), 0 0 90px var(--n); }
}
@keyframes enchSpin { to { transform: rotate(360deg); } }
@keyframes enchFill { to { width: 100%; } }
@keyframes enchOk {
  0% { transform: scale(1.35); filter: brightness(3); box-shadow: 0 0 90px 36px #fff; }
  100% { transform: scale(1); filter: none; box-shadow: 0 0 18px var(--c); }
}
@keyframes enchFail {
  0% { filter: grayscale(1) brightness(0.5); transform: translateX(0); }
  15% { transform: translateX(-9px); } 30% { transform: translateX(8px); } 45% { transform: translateX(-5px); }
  60% { transform: translateX(4px); } 75% { transform: translateX(-2px); }
  100% { filter: none; transform: translateX(0); }
}
@keyframes enchPop { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Full-screen enchant event ---------- */
#ench-event { position: fixed; inset: 0; z-index: 9000; cursor: pointer; user-select: none; }
#ench-event.hidden { display: none; }
#ench-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#ench-event > div { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; }
.ee-head { top: 9%; }
.ee-slot { font-size: 15px; letter-spacing: 6px; color: #c8c0da; text-transform: uppercase; }
.ee-levels { font-size: 40px; font-weight: 900; letter-spacing: 3px; color: #fff; text-shadow: 0 0 18px rgba(0,0,0,0.9); }
.ee-levels b { text-shadow: 0 0 22px currentColor; }
.ee-chance { top: 72%; font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 0 14px rgba(0,0,0,0.9); }
.ee-chance small { display: block; font-size: 12px; letter-spacing: 4px; color: #a8a0c0; font-weight: 600; }
.ee-result { top: 68%; font-size: 46px; font-weight: 900; letter-spacing: 6px; opacity: 0; }
.ee-sub { top: calc(68% + 62px); font-size: 20px; font-weight: 700; color: #e8e2f4; opacity: 0; }
.ee-hint { bottom: 4%; font-size: 12px; letter-spacing: 3px; color: rgba(255,255,255,0.45); }
#ench-event.ok .ee-result { color: #ffe27a; text-shadow: 0 0 24px #ffb000, 0 0 60px #ff8a00; animation: eePop 0.7s cubic-bezier(.2,1.5,.4,1) forwards; }
#ench-event.fail .ee-result { color: #ff5a6a; text-shadow: 0 0 24px #ff0030; animation: eeSlam 0.5s ease-out forwards; }
#ench-event.ok .ee-sub, #ench-event.fail .ee-sub { animation: eeFade 0.5s 0.35s ease-out forwards; }
#ench-event.ok .ee-chance, #ench-event.fail .ee-chance { display: none; }
@keyframes eePop { 0% { opacity: 0; transform: scale(2.6); letter-spacing: 30px; } 100% { opacity: 1; transform: scale(1); letter-spacing: 6px; } }
@keyframes eeSlam { 0% { opacity: 0; transform: translateY(-40px) scale(1.4); } 60% { opacity: 1; transform: translateY(6px) scale(1); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes eeFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Ascendant rarity + shop ---------- */
.slot.r6 { border-color: #7af8ff; box-shadow: inset 0 0 18px rgba(122,248,255,0.7), 0 0 14px rgba(255,255,255,0.6); animation: ascPulse 1.6s infinite alternate; }
@keyframes ascPulse { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(70deg) brightness(1.2); } }
.rc6 { background: linear-gradient(90deg, #7af8ff, #ffffff, #ff9cf0, #ffe27a, #7af8ff); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: ascText 3s linear infinite; font-weight: 900; }
@keyframes ascText { to { background-position: 300% 0; } }
.shop-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; background: rgba(255,255,255,0.03); margin-bottom: 5px; }
.shop-row img { width: 38px; height: 38px; image-rendering: pixelated; }
.shop-row .grow { flex: 1; min-width: 0; }
.shop-row .btn { min-width: 112px; }
.shop-price { color: #ffd54a; font-weight: 700; }
.shop-lock { color: #ff8a8a; font-size: 12px; }

/* ---------- Character select (title screen) ---------- */
#char-select { margin-top: 34px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#char-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 1100px; }
.cs-card { position: relative; width: 150px; padding: 10px; border-radius: 12px; text-align: center; background: rgba(20,14,34,0.75);
  border: 1px solid rgba(255,255,255,0.14); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cs-card.active { border-color: var(--cc); box-shadow: 0 0 18px color-mix(in srgb, var(--cc) 55%, transparent); }
.cs-card img { width: 84px; height: 84px; image-rendering: pixelated; }
.cs-name { font-weight: 900; font-size: 15px; color: #fff; }
.cs-meta { font-size: 12px; color: #c8c0da; }
.cs-card .btn { margin-top: 6px; width: 100%; padding: 6px; }
.cs-del { position: absolute; top: 4px; right: 6px; background: none; border: none; color: #8a82a0; cursor: pointer; font-size: 13px; }
.cs-del:hover, .cs-del.armed { color: #ff6a7a; font-weight: 900; }
#cs-new { display: flex; gap: 8px; }
#cs-new input { background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; color: #fff; padding: 6px 10px; font: inherit; width: 200px; }

.m-seal { color: #9ad8ff; }
.gate-tag { font-size: 11px; font-weight: 900; color: #ff8a8a; border: 1px solid #ff8a8a; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.gate-tag.done { color: #9ad8ff; border-color: #9ad8ff; }
