/* Match dungeon.html's battle components; room controls are lesson-only. */
:root {
  color-scheme: dark;
  --bg: #1a1225; --panel: #231830; --panel2: #2d2040;
  --border: #4a3860; --text: #e8dff8; --muted: #9080b0;
  --accent: #a78bfa; --gold: #fbbf24; --ok: #4ade80; --ng: #f87171;
}
* { box-sizing: border-box; font-family: "Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; display: grid; place-items: start center; padding: 20px; }
.app { width: min(700px, 100%); display: flex; flex-direction: column; gap: 12px; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; }
.header-title { font-size: 18px; font-weight: 700; letter-spacing: .08em; color: var(--accent); }
.floor-label, .muted, .eyebrow { font-size: 13px; color: var(--muted); line-height: 1.7; }
.intro h1 { font-size: 22px; color: var(--gold); margin: 6px 0; }
.intro p { font-size: 13px; }
.main-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; min-height: 240px; display: flex; flex-direction: column; gap: 14px; }
button { border: none; border-radius: 10px; padding: 10px 22px; font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity .15s; letter-spacing: .04em; background: var(--accent); color: #fff; }
button:hover { opacity: .85; }
button:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }
button.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
#create, #start { background: var(--gold); color: var(--bg); }
input { width: 100%; font-size: 26px; background: var(--panel2); border: 2px solid var(--border); border-radius: 12px; padding: 10px 14px; color: var(--text); caret-color: var(--accent); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #a78bfa26; }
input:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
form, #hostControls { display: flex; gap: 10px; flex-wrap: wrap; }
.mode-controls { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
select { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 15px; }
.race-choices { display: flex; flex-wrap: wrap; gap: 12px; }
.route-card { flex: 1; min-width: 120px; color: var(--text); cursor: text; }
.route-card:hover { border-color: var(--accent); }
.route-card:nth-child(2) { border-color: var(--gold); }
.race-floor { color: var(--gold); font-weight: bold; font-size: 28px; }
#raceTarget { color: var(--muted); font-size: 16px; }
#raceStandings { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
#raceStandings li { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
#raceStatus { font-size: 13px; margin-top: 8px; }
.bingo-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; margin: 12px 0 20px; }
.bingo-player-card { min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.bingo-player-card[data-self="true"] { border-color: var(--gold); }
.bingo-player-card h4 { margin-bottom: 8px; font-size: 13px; }
.bingo-grid { display: grid; gap: 4px; }
.bingo-cell { min-height: 65px; min-width: 0; padding: 4px; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; display: flex; flex-direction: column; justify-content: center; text-align: center; overflow-wrap: anywhere; font-size: 11px; }
.bingo-cell span { color: var(--muted); font-size: 10px; }
.bingo-cell[data-marked="true"] { background: #14532d; border-color: var(--ok); }
.bingo-pool { display: flex; flex-wrap: wrap; gap: 6px; max-height: 300px; overflow-y: auto; margin: 10px 0; }
.bingo-pool-word { padding: 8px; font-size: 13px; background: var(--panel2); border: 1px solid var(--border); }
.bingo-pool-word[data-used="true"] { text-decoration: line-through; opacity: .4; }
#bingoTurn { margin-bottom: 10px; }
form label { width: 100%; }
.room-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.room-header h2 { font-size: 15px; }
#roomCode { letter-spacing: .1em; color: var(--gold); overflow-wrap: anywhere; }
#role, #connection { font-size: 12px; color: var(--muted); }
.phase { font-size: 13px; font-weight: 700; letter-spacing: .06em; color: var(--accent); }
.scene-visual { position: relative; height: 200px; border-radius: 12px; overflow: hidden; background: #0d0918; flex-shrink: 0; isolation: isolate; }
.arena-background { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.arena::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, #0000001a 40%, var(--panel) 100%); }
.arena[data-phase="attack"] { box-shadow: inset 0 0 0 2px #38bdf8bf; }
.arena[data-phase="guard"] { box-shadow: inset 0 0 0 2px #f87171cc; }
.arena-top { display: flex; justify-content: space-between; gap: 10px; padding: 10px; font-size: 11px; font-weight: bold; text-shadow: 0 1px 3px #000; }
.timer { color: var(--gold); }
.boss-actor { position: absolute; inset: 30px 0 0; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.boss-name { display: none; }
.boss-sprite { image-rendering: pixelated; max-height: 160px; max-width: 100%; width: auto; filter: drop-shadow(0 6px 20px #000000e6); }
.turn-chip { position: absolute; bottom: 10px; left: 10px; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .08em; background: #00000080; color: #7dd3fc; border: 1px solid #7dd3fcbf; }
.arena[data-phase="guard"] .turn-chip { color: #fca5a5; border-color: #fca5a5cc; }
.arena[data-phase="won"] .boss-sprite { opacity: .25; filter: grayscale(1); }
.gauges { display: flex; flex-direction: column; gap: 8px; }
.battle-enemy { display: flex; align-items: center; gap: 14px; background: var(--panel2); border-radius: 12px; padding: 12px 16px; }
.enemy-info { display: flex; flex-direction: column; gap: 4px; }
.enemy-name { font-size: 16px; font-weight: 700; }
.enemy-attr { font-size: 11px; color: var(--gold); }
.stat-block { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.hp-text { font-size: 12px; color: var(--muted); margin-top: 2px; }
progress { display: block; width: 100%; height: 10px; border: 0; border-radius: 999px; overflow: hidden; background: var(--bg); appearance: none; }
progress::-webkit-progress-bar { background: var(--bg); border-radius: 999px; }
progress::-webkit-progress-value { background: #34d399; border-radius: 999px; }
progress::-moz-progress-bar { background: #34d399; border-radius: 999px; }
#bossHp { flex: 1; min-width: 0; max-width: 200px; margin-left: auto; }
#bossHp::-webkit-progress-value { background: var(--ng); }
#bossHp::-moz-progress-bar { background: var(--ng); }
.party { display: flex; flex-wrap: wrap; gap: 8px; }
.party-member { display: flex; align-items: center; gap: 3px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 6px; font-size: 12px; }
.party-member img { width: 28px; height: 38px; object-fit: contain; image-rendering: pixelated; }
.party-member[data-self="true"] { border-color: var(--gold); }
.party-member[data-guarded="true"] { border-color: #38bdf8; box-shadow: 0 0 8px #38bdf866; }
.party-member[data-connected="false"] { opacity: .55; }
.timer-bar-wrap { background: var(--bg); border-radius: 999px; height: 6px; overflow: hidden; }
.timer-bar { height: 100%; width: 0; border-radius: 999px; background: #38bdf8; }
.timer-bar[data-phase="guard"] { background: var(--ng); }
#play { display: flex; flex-direction: column; gap: 14px; }
.battle-phase-label { font-size: 13px; font-weight: 700; color: #7dd3fc; letter-spacing: .06em; }
.battle-card { min-width: 120px; background: var(--panel2); border: 2px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.battle-card.category-attack.active { border-color: #7dd3fc; background: #082f3d; }
.battle-card.qte.active { border-color: var(--ng); background: #3a1010; }
.bc-hand { font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.bc-word { font-size: 22px; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.bc-romaji { font-size: 12px; color: var(--accent); letter-spacing: .08em; font-family: ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }
.input-area { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 12px; color: var(--muted); }
.keyboard-assist { display: flex; flex-direction: column; gap: 8px; }
.keyboard-toggle { align-self: flex-start; padding: 7px 12px; font-size: 12px; }
.keyboard-guide { display: flex; flex-direction: column; gap: 8px; }
.keyboard-hint { min-height: 20px; color: var(--gold); font-size: 13px; font-weight: 700; text-align: center; }
.qwerty-keyboard { display: flex; flex-direction: column; gap: 5px; padding: 10px; background: #171120; border: 1px solid var(--border); border-radius: 12px; }
.keyboard-row { display: flex; justify-content: center; gap: 4px; }
.keyboard-row-offset { margin-left: 4%; margin-right: 4%; }
.keyboard-row-home { margin-left: 8%; margin-right: 8%; }
.keyboard-row kbd { display: grid; flex: 1; min-width: 0; min-height: 34px; place-items: center; border: 1px solid #625174; border-bottom-width: 3px; border-radius: 6px; background: var(--panel2); color: var(--text); font: 600 12px ui-monospace, Menlo, monospace; transition: background-color .12s, border-color .12s, transform .12s, box-shadow .12s; }
.keyboard-row kbd.keyboard-modifier { flex: 1.7; font-size: 10px; }
.keyboard-row kbd.keyboard-space { flex: 5; }
.keyboard-row kbd[data-active="true"] { transform: translateY(-2px); border-color: var(--gold); background: #8a5a08; color: #fff7db; box-shadow: 0 0 12px #fbbf247a; }
.feedback { min-height: 28px; font-size: 15px; font-weight: 700; text-align: center; color: var(--ok); }
.battle-result { background: var(--panel2); border-radius: 12px; padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
#resultTitle { font-size: 20px; color: var(--gold); }
#resultSummary, #lastResult, .battle-result p { font-size: 13px; color: var(--muted); }
#error { color: var(--ng); white-space: pre-wrap; }
#error:empty, #assetStatus:empty { display: none; }
#players { padding: 0; list-style: none; }
#players li { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--border); }
[hidden] { display: none !important; }
@media (max-width: 480px) {
  body { padding: 12px; }
  .main-panel { padding: 14px; }
  .header-title { font-size: 16px; }
  .qwerty-keyboard { gap: 4px; padding: 7px 5px; }
  .keyboard-row { gap: 3px; }
  .keyboard-row kbd { min-height: 30px; font-size: 10px; }
  .keyboard-row kbd.keyboard-modifier { font-size: 8px; }
}
