:root {
  --bg: #0d0a14;
  --panel: rgba(24, 18, 38, 0.92);
  --line: #3b2f5c;
  --ink: #f4efff;
  --mute: #a99fc4;
  --acc: #ffb347;
  --good: #5ee08a;
  --void: #b07cff;
  --font: 'Pixelify Sans', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); overflow: hidden; }
#screen { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; transition: filter .4s; }
#screen.dim { filter: brightness(.55) saturate(.9); }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; overflow-y: auto; padding: 24px 16px 40px; display: flex; flex-direction: column; align-items: center; }
.logo { text-align: center; margin: 4px 0 18px; }
.logo h1 {
  margin: 0; font-size: clamp(44px, 8vw, 92px); letter-spacing: 4px; color: #ffe680;
  text-shadow: 4px 4px 0 #c0392b, 8px 8px 0 #120c1c;
}
.logo p { margin: 6px 0 0; color: #fff; font-size: 18px; text-shadow: 2px 2px 0 #120c1c; }

.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; width: 100%; max-width: 1240px; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; max-width: 560px; } }
.panel {
  background: var(--panel); border: 3px solid var(--line); padding: 16px;
  box-shadow: 0 0 0 3px #120c1c, 6px 6px 0 3px rgba(0,0,0,.45);
}
.panel h2 { margin: 0 0 12px; font-size: 24px; color: var(--acc); }
.panel h3 { margin: 16px 0 6px; font-size: 16px; color: var(--mute); font-weight: 600; }
.panel p { line-height: 1.4; margin: 8px 0; color: #e6e0f5; }
.help b.v { color: var(--void); } .help b.o { color: var(--acc); }

input {
  font: inherit; font-size: 18px; color: var(--ink); background: #120c1c; border: 3px solid var(--line);
  padding: 8px 10px; outline: none; width: 100%;
}
input:focus { border-color: var(--acc); }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--mute); margin-bottom: 12px; }
button {
  font: inherit; font-size: 18px; color: #120c1c; background: var(--acc); border: 0; padding: 10px 14px; cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.25), inset 3px 3px 0 rgba(255,255,255,.35), 0 0 0 3px #120c1c;
  margin: 3px;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(2px); }
button:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }
button.big { width: calc(100% - 6px); font-size: 24px; padding: 14px; background: var(--good); }
button.ghost { background: #4a3f68; color: var(--ink); }
button.on { background: var(--good); }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.row input { flex: 1; text-transform: uppercase; letter-spacing: 4px; }
.check { display: flex; gap: 6px; align-items: center; color: var(--mute); white-space: nowrap; }
.check input { width: auto; }

.list { display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; }
.empty { color: var(--mute); font-size: 15px; padding: 6px 0; }
.room-row { display: grid; grid-template-columns: 70px 1fr 50px 110px; gap: 6px; align-items: center; text-align: left; background: #2c2440; color: var(--ink); font-size: 16px; padding: 8px 10px; }
.room-row .code { color: var(--acc); letter-spacing: 2px; }
.room-row .st { color: var(--mute); font-size: 14px; text-align: right; }
.lb-row { display: grid; grid-template-columns: 30px 70px 1fr; gap: 6px; font-size: 16px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.lb-row .h { color: #ffe680; }
.lb-row .names { color: #d8d0ec; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#classes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.class-card { display: flex; flex-direction: column; align-items: center; gap: 4px; background: #2c2440; color: var(--ink); padding: 8px 4px; border-bottom: 4px solid var(--acc); }
.class-card.sel { background: #4a3a70; outline: 3px solid var(--acc); }
.class-card .cn { font-size: 15px; font-weight: 700; }
.class-card .cr { font-size: 11px; color: var(--mute); text-align: center; line-height: 1.1; }
.sprite { image-rendering: pixelated; }
#class-detail { display: flex; gap: 12px; margin: 12px 0; padding: 10px; background: #1a1329; border-left: 4px solid var(--acc); }
#class-detail .preview { display: flex; align-items: center; }
#class-detail h3 { margin: 0 0 4px; color: var(--acc); font-size: 20px; }
#class-detail p { font-size: 15px; margin: 6px 0; }
#class-detail .cd { color: var(--mute); }
.key { display: inline-block; min-width: 24px; text-align: center; padding: 1px 6px; margin: 0 2px; background: #ffe680; color: #120c1c; font-weight: 700; box-shadow: 0 2px 0 #b38f2a; font-size: 14px; }
#colors { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { width: 34px; height: 34px; padding: 0; }
.swatch.sel { outline: 3px solid #fff; }
.keys { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 7px; font-size: 15px; }

.code { color: #ffe680; letter-spacing: 6px; }
#players { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.player-row { display: flex; align-items: center; gap: 10px; background: #2c2440; padding: 4px 10px; min-height: 46px; }
.player-row.me { outline: 2px solid var(--acc); }
.player-row.empty { color: #5f557a; justify-content: center; background: #1a1329; }
.player-row .pn { font-weight: 700; font-size: 18px; }
.player-row .pc { color: var(--mute); font-size: 14px; flex: 1; }
.tag { font-size: 12px; padding: 2px 6px; background: #4a3f68; }
.tag.host { background: #c0392b; } .tag.ready { background: var(--good); color: #120c1c; } .tag.wait { color: var(--mute); }
.note { color: var(--mute) !important; font-size: 15px; }

.chat-panel { display: flex; flex-direction: column; }
.chat { flex: 1; min-height: 240px; max-height: 50vh; overflow-y: auto; background: #120c1c; padding: 8px; font-size: 15px; margin-bottom: 8px; }
.chat .line, #chatlog .line { margin: 2px 0; word-wrap: break-word; }
.line.sys { color: #ffe680; font-style: italic; }

#ingame { position: fixed; left: 12px; bottom: 12px; width: min(440px, 60vw); pointer-events: none; }
#chatlog { display: flex; flex-direction: column; font-size: 16px; text-shadow: 2px 2px 0 #120c1c, -1px -1px 0 #120c1c; margin-bottom: 6px; max-height: 30vh; overflow: hidden; justify-content: flex-end; margin-bottom: 120px; }
#chatlog .line { transition: opacity 1.5s; }
#chatlog .line.fade { opacity: 0; }
#chat-input { pointer-events: auto; position: fixed; left: 12px; bottom: 12px; width: min(440px, 60vw); }

.over-panel { max-width: 720px; width: 100%; text-align: center; margin-top: 6vh; }
.over-h { font-size: 72px; color: #ffe680; text-shadow: 4px 4px 0 #c0392b, 7px 7px 0 #120c1c; }
.rank { font-size: 22px; color: var(--good); margin: 6px 0; }
#over-table { margin: 14px 0; }
.orow { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr 1fr 1.2fr 1fr; gap: 4px; padding: 6px; background: #2c2440; margin: 2px 0; font-size: 15px; }
.orow.hdr { background: transparent; color: var(--mute); font-size: 13px; }

#status { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: #c0392b; padding: 8px 14px; z-index: 20; box-shadow: 0 0 0 3px #120c1c; }
#toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #120c1c; border: 3px solid var(--acc); padding: 10px 16px; z-index: 20; font-size: 18px; }
#ping { position: fixed; right: 8px; bottom: 4px; font-size: 12px; color: #6f6590; z-index: 5; }
