:root {
  --yellow: #ffcc33; --yellow-dark: #e0a800; --blue: #2d7ff9; --blue-dark: #1b5fc4; --navy: #1a1f3a; --navy-2: #252c52;
  --red: #ff4d5e; --green: #3ddc84; --white: #fff; --ink: #1a1f3a; --shadow: rgba(0,0,0,.28);
  --font: 'Fredoka', 'Segoe UI', 'Arial Rounded MT Bold', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3ff; font-family: var(--font); color: var(--white); user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* Screens */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 20; }
#loading { background: linear-gradient(160deg, #2d7ff9, #8fd3ff 60%, #ffe28a); }
.overlay { background: rgba(10, 14, 35, .55); backdrop-filter: blur(4px); z-index: 40; }

.logo { font-weight: 700; font-size: clamp(42px, 7vw, 84px); letter-spacing: 2px; line-height: 1; display: flex; align-items: baseline; gap: 6px; text-shadow: 0 6px 0 var(--shadow); transform: rotate(-2deg); }
.logo .k { color: var(--yellow); -webkit-text-stroke: 2px var(--navy); }
.logo .v { color: var(--white); -webkit-text-stroke: 2px var(--navy); }
.logo .badge { font-size: 16px; background: var(--red); color: #fff; padding: 4px 10px; border-radius: 999px; border: 3px solid var(--navy); transform: rotate(6deg) translateY(-18px); letter-spacing: 1px; -webkit-text-stroke: 0; text-shadow: none; }
.tagline { margin-top: 10px; color: var(--navy); font-weight: 600; font-size: 18px; opacity: .85; }

#loadbar { width: min(520px, 80vw); height: 28px; background: rgba(255,255,255,.4); border: 3px solid var(--navy); border-radius: 999px; margin-top: 34px; overflow: hidden; box-shadow: 0 5px 0 var(--shadow); }
#loadfill { height: 100%; width: 0%; background: repeating-linear-gradient(135deg, var(--yellow) 0 14px, var(--yellow-dark) 14px 28px); transition: width .15s; }
#loadtip { margin-top: 16px; color: var(--navy); font-weight: 600; font-size: 17px; text-align: center; max-width: 80vw; }

/* Menu */
#menu { justify-content: space-between; padding: 24px; background: radial-gradient(1200px 500px at 50% -10%, rgba(255,255,255,.45), transparent 70%); pointer-events: none; }
#menu > * { pointer-events: auto; }
.menu-top { text-align: center; }
.menu-body { display: flex; gap: 20px; width: min(1180px, 100%); align-items: stretch; justify-content: space-between; pointer-events: none; }
.menu-body > * { pointer-events: auto; }
.preview-gap { flex: 1; min-width: 160px; pointer-events: none; }
.panel { background: var(--navy); border: 3px solid #0d1030; border-radius: 22px; padding: 20px 22px; box-shadow: 0 10px 0 rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px; }
.panel.narrow { width: min(480px, 92vw); }
.panel.wide { width: min(760px, 94vw); max-height: 90vh; }
.panel.scroll { max-height: 86vh; overflow: auto; }
.panel h2 { margin: 0 0 6px; font-size: 24px; color: var(--yellow); display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.panel label { font-size: 14px; font-weight: 600; opacity: .8; margin-top: 4px; }
.panel label small { opacity: .7; font-weight: 400; }
.panel p { margin: 4px 0; line-height: 1.4; }
.look-panel, .rooms-panel { width: min(360px, 44vw); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }
.hint { font-size: 12px; opacity: .6; line-height: 1.3; }
.stats { font-size: 13px; opacity: .85; margin-top: 4px; }
input[type=text], input:not([type]), select { font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 12px; border: 3px solid #0d1030; background: #fff; color: var(--ink); outline: none; width: 100%; }
input:focus, select:focus { border-color: var(--yellow); }
input[type=range] { width: 100%; accent-color: var(--yellow); }

.btn { font: inherit; font-weight: 700; font-size: 17px; padding: 10px 18px; border-radius: 14px; border: 3px solid #0d1030; background: #fff; color: var(--ink); cursor: pointer; box-shadow: 0 5px 0 #0d1030; transition: transform .05s, box-shadow .05s, filter .1s; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 0 #0d1030; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #0d1030; }
.btn.primary { background: var(--yellow); }
.btn.danger { background: var(--red); color: #fff; }
.btn.big { font-size: 21px; padding: 14px 20px; width: 100%; }
.btn.small { font-size: 15px; padding: 8px 12px; }
.btn.tiny { font-size: 13px; padding: 3px 9px; box-shadow: 0 3px 0 #0d1030; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.tab { background: var(--navy-2); color: #fff; }
.btn.tab.active { background: var(--blue); }

.room-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; padding-right: 4px; }
.room { display: flex; justify-content: space-between; align-items: center; background: var(--navy-2); border: 3px solid transparent; border-radius: 12px; padding: 9px 12px; cursor: pointer; font-weight: 600; }
.room:hover { border-color: var(--blue); }
.room.selected { border-color: var(--yellow); background: #2f3a6b; }
.room .count { font-size: 13px; opacity: .8; }
.room .count.full { color: var(--red); }
.room .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; }
.room .dot.off { background: #666; }
.msg { min-height: 20px; font-size: 14px; color: #ffd0d4; text-align: center; }
.menu-bottom { display: flex; gap: 10px; align-items: center; width: min(1180px, 100%); }
.version { margin-left: auto; font-size: 13px; color: var(--navy); opacity: .7; font-weight: 600; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-weight: 600; }
#hud > * { pointer-events: none; }
#topleft { position: absolute; left: 18px; top: 16px; display: flex; flex-direction: column; gap: 6px; }
#nameTag { font-size: 18px; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#hpWrap { width: 230px; height: 26px; background: rgba(0,0,0,.45); border: 3px solid #0d1030; border-radius: 999px; overflow: hidden; position: relative; }
#hpFill { height: 100%; width: 100%; background: linear-gradient(90deg, #3ddc84, #a6ff5c); transition: width .15s; }
#hpFill.low { background: linear-gradient(90deg, #ff4d5e, #ff9b3d); }
#hpText { position: absolute; inset: 0; text-align: center; line-height: 20px; font-size: 15px; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
#pingText { font-size: 12px; opacity: .7; }
#topright { position: absolute; right: 18px; top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#coinsBox { background: rgba(0,0,0,.45); border: 3px solid #0d1030; border-radius: 999px; padding: 5px 14px 5px 8px; display: flex; align-items: center; gap: 8px; font-size: 20px; color: var(--yellow); }
.coin { display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe680, #e0a800); border: 2px solid #8a6300; }
#questBox { background: rgba(0,0,0,.45); border: 3px solid #0d1030; border-radius: 14px; padding: 8px 14px; min-width: 220px; }
#questTitle { color: var(--yellow); font-size: 14px; }
#questProgress { font-size: 15px; }
#questBox.done #questProgress { color: var(--green); }
#killfeed { position: absolute; right: 18px; top: 120px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.feed { background: rgba(0,0,0,.5); border-radius: 10px; padding: 5px 10px; font-size: 14px; animation: feedin .25s ease-out; }
.feed b { color: var(--yellow); }
.feed.me { background: rgba(45,127,249,.75); }
@keyframes feedin { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%,-50%); }
#crosshair div { position: absolute; inset: 0; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.6); }
#crosshair::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; background: #fff; border-radius: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 0 1px #000; }
#hitmarker { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%,-50%) rotate(45deg); opacity: 0; }
#hitmarker::before, #hitmarker::after { content: ''; position: absolute; background: #fff; box-shadow: 0 0 0 1px #000; }
#hitmarker::before { left: 50%; top: 0; width: 3px; height: 100%; transform: translateX(-50%); }
#hitmarker::after { top: 50%; left: 0; height: 3px; width: 100%; transform: translateY(-50%); }
#hitmarker.show { animation: hm .22s ease-out; }
#hitmarker.head::before, #hitmarker.head::after { background: var(--red); }
@keyframes hm { 0% { opacity: 1; transform: translate(-50%,-50%) rotate(45deg) scale(1.4); } 100% { opacity: 0; transform: translate(-50%,-50%) rotate(45deg) scale(.9); } }
#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(255,0,40,0); transition: box-shadow .35s; }
#vignette.hurt { box-shadow: inset 0 0 160px rgba(255,0,40,.75); transition: none; }
#labels { position: absolute; inset: 0; overflow: hidden; }
.label { position: absolute; transform: translate(-50%, -100%); text-align: center; white-space: nowrap; will-change: transform; }
.label .nm { font-size: 13px; background: rgba(0,0,0,.5); padding: 2px 8px; border-radius: 8px; }
.label .nm.npc { background: rgba(255,204,51,.9); color: var(--ink); }
.label .nm.npc.q { box-shadow: 0 0 0 2px var(--red); }
.label .hp { height: 5px; width: 54px; margin: 3px auto 0; background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden; }
.label .hp i { display: block; height: 100%; background: var(--green); }
.label .bub { position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -6px); background: #fff; color: var(--ink); border-radius: 12px; padding: 6px 10px; font-size: 13px; max-width: 220px; white-space: normal; width: max-content; box-shadow: 0 3px 0 rgba(0,0,0,.3); animation: pop .2s ease-out; }
.label .bub::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
@keyframes pop { from { transform: translate(-50%,-6px) scale(.6); } to { transform: translate(-50%,-6px) scale(1); } }
#prompt { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: rgba(0,0,0,.6); border: 2px solid rgba(255,255,255,.5); border-radius: 12px; padding: 8px 14px; font-size: 16px; }
#prompt b { color: var(--yellow); background: rgba(255,255,255,.15); padding: 1px 7px; border-radius: 6px; margin-right: 6px; }
#toast { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toastmsg { background: var(--yellow); color: var(--ink); border: 3px solid #0d1030; border-radius: 14px; padding: 8px 18px; font-size: 20px; box-shadow: 0 5px 0 rgba(0,0,0,.3); animation: toastin .25s ease-out; }
.toastmsg.red { background: var(--red); color: #fff; }
.toastmsg.blue { background: var(--blue); color: #fff; }
@keyframes toastin { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
#bottom { position: absolute; left: 18px; right: 18px; bottom: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
#chat { width: 360px; display: flex; flex-direction: column; gap: 4px; }
#chatLog { max-height: 160px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; font-size: 14px; }
#chatLog div { background: rgba(0,0,0,.4); border-radius: 8px; padding: 3px 8px; width: fit-content; max-width: 100%; word-break: break-word; }
#chatLog .sys { color: #cfe3ff; font-style: italic; }
#chatLog b { color: var(--yellow); }
#chatInput { pointer-events: auto; font-size: 15px; padding: 8px 10px; }
#chatHint { font-size: 12px; opacity: .6; }
#hotbarWrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#ammoBox { display: flex; gap: 12px; align-items: baseline; }
#ammoText { font-size: 28px; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
#ammoText.reloading { color: var(--yellow); animation: blink .4s infinite alternate; }
@keyframes blink { to { opacity: .4; } }
#weaponName { font-size: 15px; opacity: .85; }
#hotbar { display: flex; gap: 6px; }
.slot { width: 62px; height: 62px; border-radius: 14px; background: rgba(0,0,0,.45); border: 3px solid rgba(255,255,255,.25); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; position: relative; text-align: center; line-height: 1.1; padding: 4px; }
.slot .ico { font-size: 22px; }
.slot .n { position: absolute; left: 5px; top: 2px; font-size: 11px; opacity: .7; }
.slot.active { border-color: var(--yellow); background: rgba(255,204,51,.3); transform: translateY(-4px); }
.slot.empty { opacity: .35; }
.slot.temp::after { content: 'temp'; position: absolute; right: 4px; top: 2px; font-size: 9px; color: var(--yellow); }
#emoteHint { font-size: 12px; opacity: .55; width: 360px; text-align: right; }
#scoreboard { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); background: rgba(10,14,35,.9); border: 3px solid #0d1030; border-radius: 18px; padding: 14px 20px; min-width: 420px; }
#scoreboard h3 { margin: 0 0 8px; color: var(--yellow); }
#scoreboard table { width: 100%; border-collapse: collapse; font-size: 15px; }
#scoreboard th { text-align: left; opacity: .6; font-weight: 600; padding: 4px 8px; }
#scoreboard td { padding: 5px 8px; border-top: 1px solid rgba(255,255,255,.1); }
#scoreboard tr.me td { color: var(--yellow); }
#deathScreen { position: absolute; inset: 0; background: rgba(120, 0, 30, .45); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.death-title { font-size: 64px; font-weight: 700; color: #fff; -webkit-text-stroke: 2px #0d1030; text-shadow: 0 6px 0 rgba(0,0,0,.4); transform: rotate(-3deg); }
#deathBy { font-size: 20px; }
#deathLine { font-size: 17px; opacity: .9; font-style: italic; }
#deathTimer { font-size: 48px; color: var(--yellow); }

/* Shop */
.coinline { font-size: 18px; color: var(--yellow); display: flex; gap: 6px; align-items: center; }
.shop-tabs { display: flex; gap: 8px; }
.shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; overflow: auto; max-height: 48vh; padding: 2px; }
.item { background: var(--navy-2); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; border: 3px solid transparent; }
.item.owned { border-color: var(--green); }
.item.equipped { border-color: var(--yellow); }
.item .nm { font-size: 16px; }
.item .desc { font-size: 12px; opacity: .7; min-height: 30px; }
.item .price { color: var(--yellow); font-size: 14px; display: flex; align-items: center; gap: 4px; }
.item .price .coin { width: 14px; height: 14px; }
.qtitle { font-size: 20px; color: var(--yellow); }
.reward { color: var(--yellow); font-weight: 700; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 15px; }
.keys b { display: inline-block; min-width: 76px; color: var(--yellow); }

/* Screen edge warning for small screens */
@media (max-width: 820px) {
  .menu-body { flex-direction: column; align-items: center; }
  .look-panel, .rooms-panel { width: min(420px, 94vw); }
  .preview-gap { display: none; }
  #chat { width: 240px; }
  #emoteHint { display: none; }
}
