:root { color-scheme: dark; --ink: #fff; --panel: rgba(14, 12, 28, .82); --gold: #ffb93a; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1020; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden, [hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }

/* ---------- menu ---------- */
#menu { position: fixed; inset: 0; display: flex; align-items: center; padding-left: clamp(12px, 5vw, 80px);
  background: linear-gradient(90deg, rgba(8,8,22,.86) 0%, rgba(8,8,22,.55) 45%, rgba(8,8,22,0) 75%); }
.card { width: min(480px, 100%); max-height: 94vh; overflow-y: auto; padding: 22px 26px; border-radius: 16px; background: var(--panel); backdrop-filter: blur(6px); box-shadow: 0 10px 40px rgba(0,0,0,.45); }
h1 { font-size: clamp(34px, 5vw, 52px); margin: 0 0 10px; letter-spacing: 2px; text-transform: uppercase; line-height: 1;
  background: linear-gradient(180deg, #ffe27a, #ff7a1a 60%, #d93a1a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; opacity: .65; border-bottom: 3px solid transparent; font-weight: 600; }
.tabs button.on { opacity: 1; border-bottom-color: var(--gold); }
.tabs button:hover { opacity: 1; }
.sub { margin: 0 0 14px; opacity: .85; font-size: 17px; }
.small { font-size: 13px; opacity: .7; margin: 8px 0; line-height: 1.4; }
.bar { height: 10px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; }
#loadbar { height: 100%; width: 0; background: linear-gradient(90deg, #ff7a1a, #ffe27a); transition: width .2s; }
#loadtext { opacity: .7; font-size: 14px; margin: 8px 0 14px; }
.big { font-size: 20px; font-weight: 700; padding: 11px 30px; border: 0; border-radius: 10px; cursor: pointer; color: #2a1000;
  background: linear-gradient(180deg, #ffd86b, #ff9a2a); box-shadow: 0 5px 0 #b3560b, 0 10px 24px rgba(0,0,0,.35); }
.big:disabled { filter: grayscale(.8) brightness(.7); cursor: wait; }
.big:not(:disabled):hover { filter: brightness(1.08); }
.big:not(:disabled):active { transform: translateY(3px); box-shadow: 0 2px 0 #b3560b; }
.chip { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.chip:hover { background: rgba(255,255,255,.2); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 1px; border-radius: 5px; background: rgba(255,255,255,.14); border-bottom: 2px solid rgba(255,255,255,.3); font: 600 12px ui-monospace, monospace; text-align: center; }
.controls { display: grid; gap: 9px; font-size: 14px; }

/* dragon customizer */
.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.row > span { width: 62px; opacity: .8; font-size: 14px; flex: none; }
#dragon-name, #fb-text { flex: 1; width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 8px 10px; }
#fb-text { resize: vertical; margin: 10px 0; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.preset { width: 28px; height: 28px; border-radius: 8px; border: 2px solid rgba(255,255,255,.35); cursor: pointer; padding: 0; }
.preset:hover { border-color: #fff; transform: scale(1.08); }
.colors { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 10px 0; }
.colors label { display: grid; gap: 4px; justify-items: center; font-size: 12px; opacity: .9; }
.colors input[type=color] { width: 100%; height: 34px; border: 2px solid rgba(255,255,255,.3); border-radius: 8px; padding: 0; background: none; cursor: pointer; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.seg button { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; text-transform: capitalize; }
.seg button.on { background: var(--gold); color: #2a1000; border-color: var(--gold); font-weight: 700; }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0 2px; font-size: 14px; }
.actions { display: flex; gap: 12px; align-items: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: rgba(255,255,255,.85); box-shadow: 0 0 3px rgba(0,0,0,.8); }
#crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; }
#crosshair::after { top: 8px; left: 0; height: 2px; width: 18px; }
#clock { position: absolute; top: 14px; right: 18px; font: 600 16px ui-monospace, monospace; text-shadow: 0 1px 3px #000; opacity: .85; }
#online { position: absolute; top: 40px; right: 18px; font: 600 14px system-ui, sans-serif; text-shadow: 0 1px 3px #000; opacity: .9; text-align: right; max-width: 40vw; }
#debug { position: absolute; top: 12px; left: 14px; margin: 0; font: 13px ui-monospace, monospace; text-shadow: 0 1px 3px #000; }
#toasts { position: absolute; top: 14%; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; }
.toast { background: rgba(10,10,20,.72); padding: 6px 14px; border-radius: 20px; font-weight: 600; text-shadow: 0 1px 2px #000; animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#itemname { position: absolute; bottom: 118px; left: 50%; transform: translateX(-50%); font-weight: 700; text-shadow: 0 2px 4px #000; opacity: 0; transition: opacity .4s; }
#itemname.show { opacity: 1; transition: none; }

#bars { position: absolute; bottom: 82px; left: 50%; transform: translateX(-50%); width: min(540px, 96vw); display: flex; justify-content: space-between; }
.icons { display: flex; gap: 1px; }
.ico { position: relative; width: 22px; height: 22px; background: var(--empty) center/contain no-repeat; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.ico i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; overflow: hidden; }
.ico i::before { content: ""; position: absolute; left: 0; top: 0; width: 22px; height: 22px; background: var(--full) center/contain no-repeat; }
#hearts.low .ico { animation: pulse .7s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

#hotbar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; border-radius: 10px; background: rgba(10,10,20,.55); }
.slot { position: relative; width: 56px; height: 56px; border-radius: 7px; border: 3px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); display: grid; place-items: center; }
.slot.sel { border-color: #fff; background: rgba(255,255,255,.18); transform: translateY(-4px); box-shadow: 0 0 12px rgba(255,200,80,.5); }
.slot .num { position: absolute; top: 1px; left: 4px; font-size: 11px; opacity: .8; font-weight: 700; text-shadow: 0 1px 2px #000; }
.slot .cnt { position: absolute; bottom: 1px; right: 4px; font-size: 14px; font-weight: 800; text-shadow: 0 1px 3px #000; }
.slot .sw { width: 32px; height: 32px; border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.35); }
.slot svg { width: 34px; height: 34px; }
.slot.empty svg { opacity: .35; }

#hurt { position: fixed; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(230,20,20,.85); transition: opacity .4s; z-index: 3; }
#hurt.on { opacity: 1; transition: none; }
#underwater { position: fixed; inset: 0; background: rgba(20, 90, 170, .35); opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 2; }

/* ---------- palette & death ---------- */
#palette { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5,5,15,.55); z-index: 5; }
.panel { background: var(--panel); border-radius: 16px; padding: 20px 24px; text-align: center; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.panel h2 { margin: 0 0 4px; }
#palette-grid { display: grid; grid-template-columns: repeat(6, 64px); gap: 8px; margin: 14px 0 18px; justify-content: center; }
.pal { width: 64px; height: 64px; border-radius: 8px; border: 3px solid rgba(255,255,255,.2); cursor: pointer; padding: 0; position: relative; }
.pal:hover { border-color: #fff; transform: scale(1.06); }
.pal.cur { border-color: var(--gold); box-shadow: 0 0 10px rgba(255,185,58,.7); }
#death { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; background: rgba(120,10,10,.45); z-index: 4; }
#death h2 { font-size: 44px; margin: 0; text-shadow: 0 3px 8px #000; }
#death p { font-size: 18px; text-shadow: 0 2px 4px #000; }

@media (max-width: 720px) { #menu { padding: 8px; } #palette-grid { grid-template-columns: repeat(4, 64px); } .slot { width: 40px; height: 40px; } }

/* multiplayer radar */
#radar { position: absolute; left: 16px; bottom: 16px; width: 168px; font: 600 13px system-ui, sans-serif; text-shadow: 0 1px 3px #000; }
#radar canvas { display: block; }
.radar-list { margin-top: 6px; display: grid; gap: 3px; }
.radar-list div { background: rgba(8,14,28,.62); padding: 3px 9px; border-radius: 12px; white-space: nowrap; }
.radar-list i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; border: 1.5px solid #fff; vertical-align: -1px; }
.radar-empty { font-weight: 500; opacity: .85; white-space: normal !important; }

/* boss health bar */
#bossbar { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); width: min(420px, 60vw); text-align: center; }
#bossbar.hidden { display: none; }
#bossname { font: 800 17px system-ui, sans-serif; letter-spacing: .06em; text-shadow: 0 2px 4px #000; margin-bottom: 4px; color: #ffd8b0; }
.bosstrack { height: 14px; background: rgba(10,6,8,.75); border: 2px solid #5a1a1a; border-radius: 8px; overflow: hidden; }
.bosstrack i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff5a3c, #b01818); transition: width .15s; }

/* ice-breath hint on the first hotbar slot */
.slot .icebadge { position: absolute; right: 3px; bottom: 1px; font-size: 14px; color: #bfe8ff; text-shadow: 0 0 6px #4aa8ff, 0 1px 2px #000; }

/* special attacks with cooldowns */
#abilities { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 8px; }
#abilities .ab { position: relative; width: 52px; height: 52px; border-radius: 12px; background: rgba(8,14,28,.7); border: 2px solid rgba(255,255,255,.35); display: grid; place-items: center; font-size: 24px; overflow: hidden; text-shadow: 0 1px 3px #000; }
#abilities .ab kbd { position: absolute; left: 4px; top: 2px; font: 700 11px system-ui, sans-serif; background: none; border: none; padding: 0; opacity: .9; }
#abilities .ab .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.62); height: 0; }
#abilities .ab.ready { border-color: #ffe27a; box-shadow: 0 0 10px rgba(255,226,122,.45); }
