:root {
  --fg: #e9e2cf; --dim: #8d8574; --accent: #ff7a1a; --danger: #ff4d4d; --term: #5dff9a; --bg: #0b0b0d; --panel: rgba(16, 14, 12, 0.88);
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --bg: #0b0b0d; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font-family: 'VT323', monospace; font-size: 20px; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; font-size: 20px; background: #2a241d; color: var(--fg); border: 2px solid #5a4a38; padding: 6px 14px; cursor: pointer; }
button:hover { background: var(--accent); color: #111; border-color: var(--accent); }
button.big { font-size: 26px; padding: 10px 18px; width: 100%; margin: 6px 0; }
button.tiny { font-size: 16px; padding: 0 8px; float: right; }
button.sel { background: var(--accent); color: #111; }
input { font-family: inherit; font-size: 20px; background: #111; color: var(--fg); border: 2px solid #5a4a38; padding: 6px 8px; }
input[type=range] { width: 100%; padding: 0; }
label { display: block; margin: 8px 0; color: var(--dim); }
label input:not([type=range]) { width: 100%; color: var(--fg); }

#grain { position: fixed; inset: -50%; pointer-events: none; opacity: 0.07; z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.4s steps(4) infinite; }
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-5%, 3%); } 50% { transform: translate(4%, -6%); } 75% { transform: translate(-3%, 5%); } }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.75) 100%); }
#dmg { position: fixed; inset: 0; pointer-events: none; z-index: 3; background: radial-gradient(ellipse at center, transparent 30%, rgba(200, 0, 0, 0.7) 100%); opacity: 0; transition: opacity 0.4s; }
#fade { position: fixed; inset: 0; background: #000; pointer-events: none; z-index: 20; opacity: 0; transition: opacity 0.25s; }

.screen { position: fixed; inset: 0; z-index: 10; overflow-y: auto; background: radial-gradient(ellipse at 50% 20%, #2a1a10 0%, #070605 70%); }
.menu-inner { max-width: 1000px; margin: 0 auto; padding: 24px 16px; }
.title { font-family: 'Rubik Mono One', sans-serif; font-size: clamp(40px, 8vw, 84px); margin: 10px 0 0; line-height: 1; letter-spacing: 2px; text-align: center; color: var(--fg); text-shadow: 0 0 18px rgba(255, 122, 26, 0.35); animation: flick 5s infinite; }
.title .slop { display: block; color: var(--accent); transform: rotate(-3deg); }
@keyframes flick { 0%, 92%, 100% { opacity: 1; } 93% { opacity: 0.3; } 94% { opacity: 1; } 96% { opacity: 0.5; } }
.tag { text-align: center; color: var(--dim); margin-top: 8px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .menu-grid { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 2px solid #3b3128; padding: 14px 16px; box-shadow: 0 0 30px rgba(0, 0, 0, 0.6); }
.panel h3 { margin: 0 0 8px; color: var(--accent); letter-spacing: 2px; font-weight: normal; font-size: 28px; }
.panel h4 { margin: 14px 0 6px; color: var(--dim); font-weight: normal; }
.row { display: flex; gap: 8px; } .row input { flex: 1; min-width: 0; }
#lobbyList .lob { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border: 1px solid #3b3128; margin: 4px 0; cursor: pointer; }
#lobbyList .lob:hover { border-color: var(--accent); }
#menuErr { color: var(--danger); min-height: 1em; margin-top: 6px; }
.howto { margin-top: 14px; color: var(--dim); font-size: 18px; line-height: 1.2; }

/* customizer */
.cust { display: grid; grid-template-columns: 170px 1fr; gap: 10px; }
.cust canvas { width: 170px; height: 230px; background: radial-gradient(#3a2a1c, #0c0a08); border: 1px solid #3b3128; }
.cust .opts { font-size: 17px; }
.cust .opt { margin-bottom: 6px; }
.cust .opt span { color: var(--dim); display: block; }
.cust .chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip { width: 22px; height: 22px; border: 2px solid #222; cursor: pointer; }
.chip.on { border-color: #fff; transform: scale(1.15); }
.cust .pick { display: flex; align-items: center; gap: 4px; }
.cust .pick button { padding: 0 8px; font-size: 18px; }
.cust .pick b { flex: 1; text-align: center; font-weight: normal; color: var(--fg); text-transform: uppercase; }
@media (max-width: 420px) { .cust { grid-template-columns: 1fr; } }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; text-shadow: 0 0 4px #000, 0 0 8px #000; }
#topLeft { position: absolute; top: 12px; left: 16px; }
#clock { font-size: 34px; color: #ffd166; }
#quotaLine { color: var(--fg); font-size: 20px; }
#topRight { position: absolute; top: 12px; right: 16px; text-align: right; max-width: 45vw; }
#lobbyCode { color: var(--dim); }
#lobbyCode b { color: var(--accent); font-size: 26px; letter-spacing: 3px; }
#notes .n { margin-top: 4px; animation: noteIn 0.3s; background: rgba(0, 0, 0, 0.4); padding: 2px 8px; display: inline-block; }
@keyframes noteIn { from { transform: translateX(30px); opacity: 0; } }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255, 255, 255, 0.7); }
#prompt { position: absolute; left: 50%; top: 56%; transform: translateX(-50%); font-size: 24px; white-space: nowrap; }
#vitals { position: absolute; left: 16px; bottom: 150px; width: 220px; }
.bar { height: 16px; background: rgba(0, 0, 0, 0.5); border: 2px solid #5a4a38; margin-bottom: 4px; position: relative; }
.bar span { position: absolute; left: 6px; top: -4px; font-size: 16px; }
#hpBar { height: 100%; background: linear-gradient(#ff6a3d, #b92e10); transition: width 0.2s; }
.bar.stam { height: 6px; } #stBar { height: 100%; background: #e9e2cf; }
#weight { color: var(--dim); font-size: 18px; }
#inv { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.slot { width: 88px; height: 64px; border: 2px solid #5a4a38; background: rgba(0, 0, 0, 0.45); font-size: 15px; padding: 3px 5px; line-height: 1; overflow: hidden; position: relative; }
.slot.on { border-color: var(--accent); box-shadow: 0 0 10px rgba(255, 122, 26, 0.5); }
.slot .k { color: var(--dim); position: absolute; right: 4px; bottom: 2px; }
.slot .v { color: #9f9; }
.slot .bat { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; background: #333; } .slot .bat i { display: block; height: 100%; background: #ff0; }
#chat { position: absolute; left: 16px; bottom: 16px; width: min(420px, 60vw); pointer-events: auto; }
#chatLog { max-height: 120px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 19px; }
#chatLog div { animation: noteIn 0.2s; } #chatLog .ghost { color: #9bb7ff; font-style: italic; }
#chatIn { width: 100%; display: none; margin-top: 4px; background: rgba(0, 0, 0, 0.7); }
#chat.open #chatIn { display: block; }
#bigText { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-family: 'Rubik Mono One', sans-serif; font-size: clamp(28px, 6vw, 64px); opacity: 0; transition: opacity 0.6s; }
#bigText small { display: block; font-family: 'VT323', monospace; font-size: 28px; color: var(--fg); }
#phaseBanner { position: absolute; top: 18%; left: 0; right: 0; text-align: center; font-size: 30px; color: #ffd166; }
#spectate { position: absolute; bottom: 100px; left: 0; right: 0; text-align: center; font-size: 24px; }
#emoteWheel { position: absolute; left: 50%; top: 50%; width: 360px; height: 360px; margin: -180px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); border: 2px solid #5a4a38; pointer-events: auto; }
#emoteWheel button { position: absolute; width: 104px; margin-left: -52px; margin-top: -18px; font-size: 19px; padding: 4px; }
#emoteWheel .mid { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--dim); text-align: center; }
#playerList { position: absolute; top: 20%; left: 50%; transform: translateX(-50%); min-width: 320px; background: var(--panel); border: 2px solid #3b3128; padding: 10px 16px; }
#playerList .dead { color: #f55; text-decoration: line-through; }

.overlay { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); padding: 16px; }
.overlay .panel { width: min(560px, 100%); max-height: 100%; overflow-y: auto; }
.controls { margin: 10px 0; color: var(--dim); font-size: 18px; line-height: 1.3; } .controls b { color: var(--fg); font-weight: normal; }
.crt { width: min(760px, 100%); height: min(560px, 100%); background: #021208; border: 3px solid #1b4a2a; box-shadow: 0 0 40px rgba(93, 255, 154, 0.25), inset 0 0 80px rgba(0, 0, 0, 0.8); color: var(--term); padding: 14px; display: flex; flex-direction: column; text-shadow: 0 0 6px rgba(93, 255, 154, 0.6); position: relative; overflow: hidden; }
.crt::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 2px, transparent 2px 4px); pointer-events: none; }
.crt-head { font-size: 22px; border-bottom: 1px solid #1b4a2a; padding-bottom: 6px; }
.crt button { background: transparent; color: var(--term); border: 1px solid #1b4a2a; }
.crt button:hover, .crt button.on { background: var(--term); color: #021208; }
.tabs { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
#termBody { flex: 1; overflow-y: auto; font-size: 21px; }
#termBody .item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #1b4a2a; }
#termBody .item p { margin: 0; color: #3fae6c; font-size: 18px; }
.wpanel { width: min(520px, 100%); }

#deathScreen { position: fixed; top: 10%; left: 0; right: 0; text-align: center; z-index: 6; pointer-events: none; text-shadow: 0 0 6px #000; }
.dtitle { font-family: 'Rubik Mono One', sans-serif; font-size: clamp(36px, 7vw, 72px); color: var(--danger); }
#deathCause { font-size: 28px; } .dsub { color: var(--dim); }
