:root { color-scheme: dark; --bg: #14161a; --panel: #1e2127; --line: #333842; --fg: #e6e6e6; --dim: #8b92a0; --accent: #ffd54f; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 system-ui, "Noto Sans TC", sans-serif; }
[hidden] { display: none !important; }
.panel { max-width: 320px; margin: 15vh auto; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 0 0 6px; font-size: 13px; color: var(--dim); font-weight: 600; }
input, button { font: inherit; color: inherit; background: #262a31; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
input { width: 100%; margin-bottom: 8px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }
.err { color: #ff8a80; min-height: 1.5em; margin: 8px 0 0; }
.hint { color: var(--dim); font-size: 12px; margin: 6px 0; }

#game { display: grid; grid-template-columns: minmax(0, 800px) 240px; gap: 12px; max-width: 1060px; margin: 12px auto; padding: 0 12px; }
#stage { position: relative; }
#view { width: 100%; height: auto; display: block; background: #000; border: 1px solid var(--line); border-radius: 6px; image-rendering: pixelated; }
#hud { position: absolute; left: 8px; top: 8px; width: 200px; pointer-events: none; }
#lv-text { font-weight: 700; text-shadow: 0 1px 2px #000; }
.bar { position: relative; height: 16px; margin-top: 4px; background: rgba(0,0,0,.55); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; }
#hp-fill { background: #e53935; width: 0; }
#xp-fill { background: #42a5f5; width: 0; }
.bar.xp { height: 8px; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; text-shadow: 0 1px 2px #000; }
#skills { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: none; }
.skill { position: relative; width: 64px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(20,22,26,.8); border: 2px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 12px; line-height: 1.2; }
.skill.ready { border-color: var(--accent); }
.skill.locked { opacity: .55; }
.skill kbd { font: 700 14px system-ui, sans-serif; color: var(--accent); }
.skill .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.65); }
.skill .cd-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; text-shadow: 0 1px 2px #000; }
.skill.locked .cd-text { place-items: end center; padding-bottom: 2px; font-size: 11px; color: var(--accent); }
.skill span { position: relative; }
#overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; background: rgba(0,0,0,.7); border-radius: 6px; }

#side { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
#side section { margin-bottom: 10px; }
#equip { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
#inv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cell { min-height: 44px; padding: 2px; font-size: 12px; line-height: 1.2; white-space: pre-line; }
.cell.empty { opacity: .35; cursor: default; }
#stats { color: var(--dim); font-size: 12px; margin: 6px 0 0; }

#chat { grid-column: 1 / -1; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
#chat-log { height: 130px; overflow-y: auto; margin-bottom: 6px; word-break: break-all; }
#chat-log .who { color: var(--accent); }
#chat-log .whisper { color: #ce93d8; }
#chat-log .sys { color: var(--dim); }
#chat-input { margin: 0; }

@media (max-width: 900px) { #game { grid-template-columns: 1fr; } }
