:root {
  --panel: rgba(12, 18, 32, 0.78);
  --panel-solid: #0f1729;
  --border: rgba(255, 255, 255, 0.14);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --gold: #ffd23f;
  --good: #4ade80;
  --bad: #f87171;
  --raid: #ff4d6d;
  --cyan: #38bdf8;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --display: "Fredoka", "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1220; color: var(--text); font-family: var(--font); user-select: none; }
canvas#game { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
kbd { background: rgba(255,255,255,.14); border-radius: 4px; padding: 0 5px; font-size: 10px; font-family: var(--font); margin-left: 4px; }

.panel { position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; backdrop-filter: blur(10px) saturate(1.3); box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08); }

#stats { top: 14px; left: 14px; width: 240px; }
#stats .cash { font-family: var(--display); font-size: 30px; font-weight: 700; color: var(--gold); display: flex; align-items: center; gap: 8px; text-shadow: 0 0 18px rgba(255,210,63,.45); }
.coin { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6b0, #ffc400 55%, #b37f00); box-shadow: 0 0 10px rgba(255,200,0,.7); }
#stats .row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 14px; }
#stats .row span { color: var(--muted); }
#income { color: var(--good); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--border); }
.chip.on { background: rgba(56,189,248,.2); border-color: var(--cyan); }
.chip.raid { background: rgba(255,77,109,.25); border-color: var(--raid); color: #ffd0d8; }
.chip.good { background: rgba(74,222,128,.15); border-color: var(--good); }

#quest { top: 262px; left: 14px; width: 240px; border-color: rgba(255,210,63,.4); }
#quest .qh { font-family: var(--display); font-weight: 600; color: var(--gold); margin-bottom: 4px; }
#questText { font-size: 13px; line-height: 1.4; }
#questReward { color: var(--good); margin-top: 4px; }

#event { top: 14px; left: 50%; transform: translateX(-50%); text-align: center; max-width: 480px; border-color: var(--gold); box-shadow: 0 0 30px rgba(255,210,63,.25); }
#event .ev-title { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--gold); }

#lb { top: 14px; right: 14px; width: 250px; }
#lb h3 { margin: 0 0 6px; font-family: var(--display); font-size: 16px; font-weight: 600; }
#lb ol { margin: 0; padding-left: 22px; font-size: 13px; }
#lb li { padding: 1px 0; }
.lbrow { display: flex; justify-content: space-between; gap: 6px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #475569; margin-right: 5px; vertical-align: middle; }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }

#chat { left: 14px; bottom: 14px; width: 370px; padding: 8px; }
#chatLog { height: 160px; overflow-y: auto; font-size: 13px; line-height: 1.4; margin-bottom: 6px; user-select: text; }
#chatLog .sys { color: var(--muted); font-style: italic; }
#chatLog .steal { color: #ff8fa3; font-weight: 600; }
#chatLog .rare { color: #e879f9; }
#chatLog .event { color: var(--gold); font-weight: 700; }
#chatInput { width: 100%; background: rgba(255,255,255,.07); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; outline: none; }
#chatInput:focus { border-color: var(--gold); }

#toolbar { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; }
#toolbar button { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 64px; background: var(--panel); backdrop-filter: blur(10px); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 7px 8px 6px; font: 600 11px var(--font); cursor: pointer; transition: transform .1s, border-color .1s; }
#toolbar button i { font-style: normal; font-size: 20px; }
#toolbar button kbd { margin: 0; }
#toolbar button:hover { transform: translateY(-2px); border-color: var(--gold); }
#toolbar button.active { background: rgba(255,210,63,.18); border-color: var(--gold); }
#toolbar button.raidon { background: rgba(255,77,109,.3); border-color: var(--raid); }

#hotbar { bottom: 86px; left: 398px; right: 250px; display: flex; gap: 6px; padding: 8px; overflow-x: auto; }
.hb { min-width: 86px; background: rgba(255,255,255,.05); border: 2px solid transparent; border-radius: 12px; padding: 6px; cursor: pointer; text-align: center; font-size: 11px; }
.hb .sw { width: 30px; height: 30px; margin: 0 auto 4px; border-radius: 8px; box-shadow: inset 0 -6px 0 rgba(0,0,0,.25), 0 0 12px currentColor; }
.hb .nm { font-weight: 700; }
.hb .cs { color: var(--gold); font-weight: 800; }
.hb.sel { border-color: var(--gold); background: rgba(255,210,63,.14); }
.hb.poor .cs { color: var(--bad); }
.hb.locked { opacity: .35; }
.hb-help { align-self: center; font-size: 11px; color: var(--muted); min-width: 160px; line-height: 1.5; }

#prompt { position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.72); padding: 9px 18px; border-radius: 999px; font-weight: 700; border: 1px solid var(--gold); white-space: nowrap; }
#banner { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(127,29,29,.9); border: 1px solid var(--raid); padding: 9px 18px; border-radius: 12px; font-weight: 800; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .75; } }
#channel { position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%); width: 280px; text-align: center; font-weight: 800; text-shadow: 0 2px 6px #000; }
#channel .bar { height: 14px; background: rgba(0,0,0,.6); border-radius: 999px; overflow: hidden; border: 1px solid var(--raid); margin-top: 6px; }
#channelFill { height: 100%; background: linear-gradient(90deg, #ff4d6d, #ffd23f); width: 0; }
#tooltip { position: fixed; pointer-events: none; background: rgba(5,10,20,.92); border: 1px solid var(--border); padding: 8px 10px; border-radius: 10px; font-size: 12px; max-width: 260px; line-height: 1.45; }
#stun { position: fixed; top: 38%; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 34px; color: #fde047; text-shadow: 0 0 20px #38bdf8; }

#minimap { position: fixed; right: 14px; bottom: 14px; border-radius: 14px; border: 1px solid var(--border); background: rgba(0,0,0,.5); }

#toasts { position: fixed; top: 140px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 5; }
.toast { background: var(--panel-solid); border: 1px solid var(--border); padding: 9px 16px; border-radius: 12px; font-weight: 600; animation: tin .2s ease-out; max-width: 560px; text-align: center; box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.toast.err { border-color: var(--bad); color: #fecaca; }
.toast.good { border-color: var(--good); }
.toast.alarm { border-color: var(--raid); background: #7f1d1d; font-size: 16px; }
@keyframes tin { from { transform: translateY(-8px) scale(.96); opacity: 0; } }
#floats { position: fixed; inset: 0; pointer-events: none; }
.float { position: absolute; font-family: var(--display); font-weight: 700; font-size: 18px; text-shadow: 0 2px 4px #000, 0 0 10px rgba(0,0,0,.6); white-space: nowrap; transform: translate(-50%, -50%); }
#alarm { position: fixed; inset: 0; pointer-events: none; transition: box-shadow .3s; }
#alarm.on { box-shadow: inset 0 0 140px 40px rgba(255,40,70,.55); }

#modal { position: fixed; inset: 0; background: rgba(3,6,14,.6); display: flex; align-items: center; justify-content: center; z-index: 10; backdrop-filter: blur(3px); }
.modal-box { position: relative; background: linear-gradient(180deg, #131d33, #0d1528); border: 1px solid var(--border); border-radius: 20px; padding: 22px 24px; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 60px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-box h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 700; }
.modal-box h3 { font-family: var(--display); font-weight: 600; margin: 16px 0 6px; }
.modal-box .close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.btn { background: rgba(255,255,255,.07); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font: 600 12px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, #f5b301, #c98a00); border-color: #ffd23f; color: #1d1400; }
.btn.danger { background: rgba(255,77,109,.2); border-color: var(--raid); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
table.mk { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.mk th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.mk td { padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
.sw-i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; box-shadow: 0 0 6px currentColor; }
.up { color: var(--good); } .down { color: var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.card { background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.card.done { border-color: var(--good); background: rgba(74,222,128,.07); }
.card.locked { opacity: .5; }
.card .t { font-weight: 800; margin-bottom: 4px; }
.bar { height: 10px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; background: linear-gradient(90deg, #f5b301, #ffe066); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.help p { margin: 7px 0; line-height: 1.5; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; }
.toggle input { accent-color: var(--good); }
.notice { background: rgba(56,189,248,.1); border: 1px solid rgba(56,189,248,.4); border-radius: 10px; padding: 8px 10px; font-size: 12px; margin-top: 8px; }

#chat { bottom: 86px !important; }
#minimap { bottom: 86px !important; }
#toolbar button { min-width: 58px !important; padding: 6px 6px 5px !important; position: relative; }
.dotc { position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #f43f5e; box-shadow: 0 0 8px #f43f5e; }
.lvl { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.badge { min-width: 34px; height: 34px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font: 700 18px var(--display); background: linear-gradient(180deg, #a78bfa, #6d28d9); box-shadow: 0 0 14px rgba(167,139,250,.6); }
.xpwrap { flex: 1; }
.xpbar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
#xpFill { height: 100%; width: 0; background: linear-gradient(90deg, #a78bfa, #f0abfc); transition: width .3s; }
#bossBar { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); text-align: center; z-index: 3; }
.bb-name { font: 700 18px var(--display); color: #fca5a5; text-shadow: 0 2px 6px #000; }
.bb-track { height: 16px; border-radius: 999px; background: rgba(0,0,0,.6); border: 1px solid #f87171; overflow: hidden; margin-top: 4px; }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, #dc2626, #f97316); transition: width .2s; }
#bossGo { margin-top: 6px; }
#levelUp { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 8; animation: lu 2.6s ease-out forwards; }
.lu-t { font: 700 30px var(--display); color: #f0abfc; letter-spacing: 6px; text-shadow: 0 0 20px #a78bfa; }
.lu-n { font: 700 110px var(--display); line-height: 1; color: #fff; text-shadow: 0 6px 0 #6d28d9, 0 0 40px #a78bfa; }
.lu-r { font: 600 16px var(--font); color: #fde68a; text-shadow: 0 2px 4px #000; }
@keyframes lu { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 20% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); } }
#fps { position: fixed; top: 4px; left: 50%; transform: translateX(-50%); font-size: 11px; color: #94a3b8; }
.reel { position: relative; height: 96px; overflow: hidden; border-radius: 14px; background: rgba(0,0,0,.4); border: 1px solid var(--border); margin: 14px 0; }
.reel-strip { position: absolute; top: 8px; left: 0; display: flex; gap: 8px; will-change: transform; }
.reel-item { width: 120px; height: 80px; flex: none; border-radius: 10px; display: grid; place-items: center; text-align: center; font-size: 12px; font-weight: 700; padding: 6px; border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.05); }
.reel-item.common { border-color: #94a3b8; } .reel-item.rare { border-color: #3b82f6; background: rgba(59,130,246,.15); } .reel-item.legendary { border-color: #f59e0b; background: rgba(245,158,11,.18); }
.reel-mark { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tabs .btn.on { border-color: var(--gold); background: rgba(255,210,63,.15); }
.ach { display: flex; gap: 8px; align-items: center; }
.ach.locked { opacity: .45; }
input.txt, select.txt { background: rgba(255,255,255,.07); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 7px 9px; font: inherit; }
#minePanel { top: 14px; right: 14px; width: 280px; z-index: 2; }
.mp-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.mp-head .t { font-family: var(--display); font-weight: 700; font-size: 18px; }
.rank { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font: 700 28px var(--display); background: linear-gradient(180deg, #ffd23f, #f59e0b); color: #2a1a00; box-shadow: 0 0 18px rgba(255,200,0,.5); }
#minePanel .row { display: flex; justify-content: space-between; font-size: 14px; padding: 2px 0; }
#minePanel .row span { color: var(--muted); }
#mpBpFill { width: 0; }
.auth { display: flex; flex-direction: column; gap: 8px; }
.auth input { width: 100%; padding: 13px; font: 600 17px var(--font); border-radius: 14px; border: 2px solid var(--border); background: rgba(255,255,255,.08); color: var(--text); text-align: center; outline: none; }
.auth input:focus { border-color: var(--gold); }
.auth-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-btns button { padding: 13px; font: 700 17px var(--display); letter-spacing: 1px; border: none; border-radius: 14px; background: linear-gradient(180deg, #ffd23f, #f59e0b); color: #2a1a00; cursor: pointer; box-shadow: 0 5px 0 #b45309; }
.auth-btns button.alt { background: linear-gradient(180deg, #7dd3fc, #0ea5e9); box-shadow: 0 5px 0 #0369a1; color: #032033; }
.auth-btns button:active { transform: translateY(3px); box-shadow: none; }
#loginStatus { min-height: 18px; color: #fecaca; }
.stance-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stance-pick .card { cursor: pointer; }
.stance-pick .card.sel { border-color: var(--gold); background: rgba(255,210,63,.1); }
canvas.landmap { width: 100%; max-width: 460px; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; display: block; margin: 10px auto; image-rendering: pixelated; }
#login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 20%, #24467a 0%, #0c1830 55%, #050a16 100%); z-index: 20; }
.login-box { width: min(560px, calc(100vw - 32px)); text-align: center; }
.logo { font-family: var(--display); font-weight: 700; font-size: 54px; line-height: .95; letter-spacing: 1px; color: #fff; text-shadow: 0 6px 0 #b45309, 0 10px 30px rgba(255,180,0,.4); }
.logo span { display: block; font-size: 30px; color: var(--gold); letter-spacing: 12px; margin-top: 8px; text-shadow: 0 4px 0 #78350f; }
.login-box .tag { color: #cbd5e1; margin: 18px 0; font-size: 16px; }
#nameInput { width: 100%; padding: 14px; font: 600 18px var(--font); border-radius: 14px; border: 2px solid var(--border); background: rgba(255,255,255,.08); color: var(--text); text-align: center; outline: none; }
#nameInput:focus { border-color: var(--gold); }
#playBtn { margin-top: 10px; width: 100%; padding: 14px; font: 700 22px var(--display); letter-spacing: 3px; border: none; border-radius: 14px; background: linear-gradient(180deg, #ffd23f, #f59e0b); color: #2a1a00; cursor: pointer; box-shadow: 0 6px 0 #b45309; }
#playBtn:active { transform: translateY(3px); box-shadow: 0 3px 0 #b45309; }
.feat { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; text-align: left; }
.feat div { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px; padding: 10px; font-size: 13px; color: #cbd5e1; }
.feat b { display: block; color: #fff; margin-bottom: 3px; }

@media (max-width: 1100px) {
  #lb, #minimap, #quest { display: none; }
  #chat { width: calc(100vw - 28px); bottom: 84px; }
  #chatLog { height: 80px; }
  #toolbar { flex-wrap: wrap; justify-content: center; width: calc(100vw - 28px); }
  #hotbar { left: 14px; right: 14px; bottom: 240px; }
  .feat { grid-template-columns: 1fr; }
}

/* first-person crosshair */
#crosshair { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 3; text-align: center; }
#crosshair span { display: block; width: 6px; height: 6px; margin: 0 auto; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 0 0 2px rgba(0,0,0,.45); }
#crosshair em { display: block; margin-top: 14px; font-style: normal; font-size: 12px; color: #fff; background: rgba(5,10,20,.6); padding: 4px 10px; border-radius: 8px; white-space: nowrap; }
body.looking #crosshair em { display: none; }

/* upgrades */
.upg { margin-bottom: 12px; border-color: rgba(255,210,63,.35); background: linear-gradient(180deg, rgba(255,210,63,.07), rgba(255,255,255,.02)); }
.pips { display: flex; gap: 4px; margin: 6px 0 4px; }
.pips span { flex: 1; max-width: 34px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.1); }
.pips span.on { box-shadow: 0 0 8px currentColor; }
.upg-next { font-size: 13px; margin-top: 4px; }

#crosshair.hot span { width: 14px; height: 14px; background: #4ade80; box-shadow: 0 0 0 3px rgba(0,0,0,.5), 0 0 12px #4ade80; }

#btnInfo { position: fixed; left: 50%; top: calc(50% + 26px); transform: translateX(-50%); pointer-events: none; z-index: 3; text-align: center; font-size: 13px; line-height: 1.45;
  background: rgba(5,10,20,.85); border: 1px solid rgba(255,210,63,.4); padding: 7px 12px; border-radius: 10px; white-space: nowrap; }
#btnInfo div { margin-top: 3px; font-weight: 800; }

#mapHint { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none; background: rgba(5,10,20,.85); border: 1px solid rgba(253,224,71,.45);
  padding: 8px 14px; border-radius: 12px; font-size: 13px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#mapHint kbd { font-size: 11px; }

/* plot picker */
.plotwrap { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; }
canvas.plotmap { flex: 1 1 320px; width: 100%; max-width: 520px; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; image-rendering: pixelated; }
.plotside { flex: 1 1 200px; min-width: 200px; line-height: 1.7; }

.floorgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; margin-bottom: 8px; }
.floorgrid .btn { padding: 6px 0; min-width: 0; }
/* connection / update notice (reconnecting after a server update, or reloading into a new version) */
#netNotice { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 10px 18px; border-radius: 999px;
  background: rgba(15, 23, 42, .92); color: #fde68a; font: 600 15px Fredoka, Inter, sans-serif; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  border: 1px solid rgba(253, 230, 138, .35); pointer-events: none; animation: netPulse 1.6s ease-in-out infinite; }
#netNotice.hidden { display: none; }
@keyframes netPulse { 50% { opacity: .75; } }
