#battleRoom{padding:0;width:min(100%,700px);max-width:100vw;height:100dvh;max-height:100dvh;border:1px solid #4f7187;background:#102030;color:#eaf6ff;overscroll-behavior:contain}#battleRoom::backdrop{background:#000b}#battleRoom *{box-sizing:border-box}#battleRoom button{touch-action:manipulation;min-height:44px}#battleRoom header{height:62px;display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-bottom:1px solid #385267;background:#102030}#battleRoom h2{font-size:20px;margin:0}#battleRoom h3{margin:10px 0}#battleBody{padding:18px;overflow:auto;height:calc(100% - 96px)}#battleError{color:#ffd39a;min-height:30px;padding:4px 16px;font-size:13px}#battleRoom .battle-note{color:#acc3d4;line-height:1.65;font-size:13px}#battleRoom .battle-code{font-size:30px;font-weight:800;letter-spacing:.18em;text-align:center;padding:14px;background:#1d3548;border-radius:12px;margin:12px 0}#battleRoom .battle-list{list-style:none;padding:0}#battleRoom .battle-list li{padding:12px;border-bottom:1px solid #355064;display:flex;justify-content:space-between;gap:12px}#battleRoom .battle-actions{display:flex;gap:10px;flex-wrap:wrap;margin:14px 0}#battleRoom select,#battleRoom input{width:100%;min-height:48px;background:#213c50;color:white;border:1px solid #5c7d92;border-radius:10px;padding:10px;margin:8px 0}#battleRoom .primary{background:linear-gradient(#ffd781,#ffb64e);color:#1b1a16;width:100%;font-weight:bold;padding:13px;border:0;border-radius:12px}#battleRoom .battle-stage{position:relative;height:100%;min-height:450px;isolation:isolate;overflow:hidden;background:#879591}#battleRoom .battle-canvas{position:absolute;width:100%;height:100%;inset:0}#battleRoom .battle-start-ui{position:absolute;inset:0;pointer-events:none;transition:opacity .38s}#battleRoom .battle-start-ui button{pointer-events:auto}#battleRoom .battle-lane{position:absolute;top:15px;left:50%;transform:translateX(-50%);white-space:nowrap;background:#142d42d9;padding:9px 22px;border-radius:24px;letter-spacing:.12em}:is(#battleRoom,#challenge) .battle-signals{position:absolute;top:75px;left:50%;transform:translateX(-50%);display:flex;gap:30px;padding:16px 24px;background:linear-gradient(130deg,#24313a,#111b24);border:3px solid #6d7e8e;border-radius:16px;box-shadow:0 14px 18px #0005}:is(#battleRoom,#challenge) .battle-light{height:64px;width:64px;border-radius:50%;border:7px solid #07121e;background:#210c13}:is(#battleRoom,#challenge) .battle-light.blue{background:#071a35}:is(#battleRoom,#challenge) .battle-light.red.lit{background:#ff2b26;box-shadow:0 0 28px #ff3029}:is(#battleRoom,#challenge) .battle-light.blue.lit{background:#2cbaff;box-shadow:0 0 32px #37c2ff}#battleRoom .battle-instruction{position:absolute;top:195px;width:100%;text-align:center;font-weight:800;font-size:clamp(18px,5vw,29px);text-shadow:0 2px 6px #000}:is(#battleRoom,#challenge) #battleHold{position:absolute;bottom:74px;left:50%;transform:translateX(-50%);width:118px;height:118px;border-radius:50%;background:radial-gradient(at 35% 25%,#30475a,#091423);border:3px solid #5c95af;color:white;font-size:28px;font-weight:900;font-style:italic;box-shadow:0 6px 16px #0005;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}:is(#battleRoom,#challenge) #battleHold:active{border-color:#9cecff}#battleRoom .battle-hint{position:absolute;bottom:34px;width:100%;padding:0 5px;text-align:center;font-size:11px;text-shadow:0 2px 4px #000}#battleRoom .battle-sound{position:absolute;bottom:4px;right:8px;min-height:28px;font-size:12px;padding:3px 10px}#battleRoom .battle-stage.departing canvas,#battleRoom .battle-stage.departing .battle-start-ui{opacity:0;transition:opacity .38s}#battleRoom .battle-replay-head{position:absolute;top:12px;left:12px;right:12px;display:flex;justify-content:space-between;gap:8px;background:#11283bd9;padding:8px;border-radius:10px;font-size:12px}#battleRoom .battle-replay-skip{position:absolute;right:12px;bottom:12px}#battleRoom .battle-result-time{font-size:24px;color:#ffd07c}#battleRoom #battleReplayLegend{position:absolute;bottom:68px;left:12px;right:12px;background:#102030bf;padding:8px;font-size:12px;line-height:1.7}#battleBody.stage-mode{padding:0;overflow:hidden}#battleRoom .battle-back{margin-top:12px}
#battleRoom .battle-standings{position:absolute;top:52px;left:12px;max-width:64%;pointer-events:none;font-size:13px;font-weight:650;line-height:1.85;color:white;text-shadow:0 1px 3px #000}#battleRoom .battle-standing{display:flex;align-items:center;gap:6px;min-height:25px}#battleRoom .battle-standing-text{display:inline-flex;gap:8px;min-width:0}#battleRoom .battle-standing-text>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:180px}#battleRoom .battle-standing b{min-width:27px;font-variant-numeric:tabular-nums}#battleRoom .battle-standing[data-rank="1"] b{color:#ffdc75}#battleRoom .battle-standing small{font-size:9px;color:#bfced8}
#battleRoom .battle-self-marker{position:absolute;width:30px;height:34px;transform:translate(-50%,-100%);pointer-events:none;filter:drop-shadow(0 0 5px #00d9ff) drop-shadow(0 2px 2px #061c33)}#battleRoom .battle-self-marker[hidden]{display:none}#battleRoom .battle-self-marker svg{display:block;width:100%;height:100%}#battleRoom .battle-view-label{position:absolute;top:55px;right:10px;display:flex;align-items:center;gap:4px;font-size:11px}#battleRoom .battle-view-label select{width:74px;min-height:34px;padding:5px;margin:0;background:#18374be6;font-size:12px}

#battleRoom #battleReplayLegend{bottom:0;left:0;right:0;margin:0}#battleRoom .battle-replay-skip{top:99px;bottom:auto;right:10px}#battleRoom .battle-preview-go{position:absolute;bottom:40px;left:10%;width:80%;background:#17384be6;color:white}

/* Fit the room overview to the viewport; racing keeps its full stage. */
#battleRoom[open]:has(.room-compact){display:flex;flex-direction:column;overflow:hidden}
#battleRoom[open]:has(.room-compact)>header{height:48px;min-height:48px;padding:5px 12px}
#battleRoom[open]:has(.room-compact)>header h2{font-size:18px}
#battleRoom[open]:has(.room-compact)>header button{min-height:36px;padding:4px 12px}
#battleBody.room-compact{height:auto;flex:1;min-height:0;overflow:hidden;padding:10px 12px;display:flex;flex-direction:column;gap:6px}
#battleBody.room-compact>h3{font-size:16px;line-height:1.25;margin:0;flex:none}
#battleBody.room-compact .battle-note{font-size:11px;line-height:1.35;margin:0;flex:none}
#battleBody.room-compact .battle-code{font-size:24px;line-height:1.1;padding:6px;margin:0;flex:none}
#battleBody.room-compact>.battle-list{margin:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 12px;flex:none}
#battleBody.room-compact>.battle-list li{padding:4px 0;font-size:11px;gap:6px;min-width:0}
#battleBody.room-compact>.battle-list li span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#battleBody.room-compact>.battle-course-card{margin:0!important;display:flex;flex-direction:column;flex:1 1 180px;min-height:60px;gap:4px}
#battleBody.room-compact .battle-course-card img{width:100%;height:0!important;min-height:0;flex:1;object-fit:contain}
#battleBody.room-compact button{min-height:36px;padding:6px 9px;font-size:12px;line-height:1.25;margin:0;flex:none}
#battleBody.room-compact .battle-course-card button{margin:0!important;min-height:30px}
#battleBody.room-compact .battle-actions{margin:0;flex:none;justify-content:flex-end}
#battleBody.room-compact label{font-size:11px}
#battleBody.room-compact input,#battleBody.room-compact select{min-height:34px;padding:5px;margin:3px 0}
#battleRoom[open]:has(.room-compact)>#battleError{min-height:0;flex:none;font-size:11px;padding:0 12px 4px}
#battleRoom[open]:has(.room-compact)>#battleError:empty{display:none}
@media(max-height:650px){#battleBody.room-compact{gap:4px;padding:6px 10px}#battleBody.room-compact button{min-height:32px}#battleBody.room-compact .battle-code{font-size:20px;padding:4px}}

/* Anchor the dialog close control independently of global header layouts. */
#battleRoom>header{position:relative;width:100%;flex:none;padding-right:60px}
#battleRoom>header>#battleClose{position:absolute;top:8px;right:10px;bottom:auto;left:auto;width:38px;height:38px;min-height:38px;margin:0;padding:0;display:grid;place-items:center;line-height:1;font-size:22px;transform:none;z-index:2}
#battleRoom[open]:has(.room-compact)>header{padding-right:60px}
#battleRoom[open]:has(.room-compact)>header>#battleClose{top:5px;right:10px;min-height:38px;padding:0}

#battleRoomPicker{display:grid;grid-template-columns:1fr 1fr;gap:6px;padding:5px 10px;background:#102030;flex:none}
#battleRoomPicker[hidden]{display:none}
#battleRoom #battleRoomPicker button{display:flex;flex-direction:column;align-items:flex-start;gap:2px;min-width:0;min-height:42px;padding:4px 8px;font-size:11px;border:1px solid #416078;border-radius:8px;color:#bbd0df;background:#192e40}
#battleRoom #battleRoomPicker button[aria-pressed="true"]{border-color:#64dcf3;background:#244b61;color:white}
#battleRoomPicker span{white-space:nowrap;font-size:10px}
#battleRoom:has(#battleRoomPicker:not([hidden])) #battleBody:not(.room-compact){height:calc(100% - 150px)}

#battleRoom .battle-reveal li{animation:battle-card-enter .38s ease-out var(--reveal-delay,0ms) both;border-left:3px solid #77d7ef;background:#1b3043;margin-bottom:6px}
@keyframes battle-card-enter{from{opacity:0;transform:translateX(24px)}to{opacity:1;transform:translateX(0)}}
@media(prefers-reduced-motion:reduce){#battleRoom .battle-reveal li{animation:none}}
