/* Second review: stable terrain, readable action chronology, touch layouts. */
.arena-welcome .arena-modes [aria-pressed=true]{transform:translateY(2px);box-shadow:inset 0 0 0 3px #675381,inset 0 4px #ffffff50;filter:saturate(1.15);font-weight:700}
.arena-welcome .arena-modes [aria-pressed=true]::after{content:' ✓';font-family:Arial,sans-serif;font-size:15px}
.arena-impossible::after{content:'';position:fixed;inset:0;z-index:15;box-shadow:inset 0 0 70px 18px #a019384b;pointer-events:none}
.arena-impossible .arena-main{animation:arena-inferno .12s linear infinite alternate}
@keyframes arena-inferno{from{translate:-.5px 0}to{translate:.5px .5px}}
.arena-battle{--arena-controls:254px;grid-template-rows:minmax(0,1fr) var(--arena-controls);gap:8px;padding-bottom:8px}
.arena-battle[data-mode=HARD],.arena-battle[data-mode=IMPOSSIBLE]{--arena-controls:400px}
.arena-battle>.arena-challenge{padding:10px 10px 40px}
.arena-challenge .arena-interaction,.arena-challenge .arena-interaction:has(.pixel-keyboard:not([hidden])){width:100%;justify-content:start;gap:6px}
.arena-interaction>h2,.arena-question-head{min-height:27px;height:27px;flex:none;margin:0;display:grid;place-items:center}
.arena-interaction>h2,.arena-question-head h2{font-size:21px!important;line-height:1.1;margin:0}
.arena-question-head h2[data-reading-kind]{font-weight:700;white-space:nowrap!important}
.arena-question-head h2[data-reading-kind=on]{color:#285dba}
.arena-question-head h2[data-reading-kind=kun]{color:#b6334a}
.arena-timing{height:24px;min-height:24px;display:flex;gap:8px;align-items:center;flex:none}
.arena-timebar{flex:1;height:14px;overflow:hidden;background:#eee4f6}
.arena-timebar span{display:block;height:100%;background:#9c86c7;transform-origin:left center}
.arena-timing.for-selection .arena-timebar span{background:#75bba6}
.arena-team-row{grid-template-columns:repeat(auto-fit,minmax(70px,1fr));height:auto;min-height:0;flex:1}
.arena-team-card{min-height:0;max-height:144px}.arena-team-card .arena-native-creature{max-width:104px}
.arena-answer-content{display:flex;flex-direction:column;min-height:0;flex:1;gap:6px}
.arena-answers{height:100%;width:100%;min-height:0;max-height:none;flex:1;margin:0;gap:8px}
.arena-answers .arena-button{min-height:48px;padding:4px 8px}
.arena-arrival-message{margin:auto;text-align:center;font-size:25px}
.arena-wait{display:none}
.arena-nameplate{flex-wrap:nowrap;width:100%;min-height:30px;gap:6px;align-items:center;padding:4px 6px}
.arena-nameplate strong{min-width:0;flex:1;white-space:nowrap;overflow-wrap:normal;text-align:left;font-size:15px}
.arena-nameplate [data-arena-hp]{flex:none;line-height:0}
.arena-nameplate.hearts-only{width:max-content;align-self:center;justify-content:center;padding:6px 10px}
.arena-hearts{gap:2px}.arena-hearts>img{width:16px;height:16px}
.arena-pote-comment{position:absolute;top:auto;bottom:8px;left:50%;width:min(420px,calc(100% - 44px));padding:5px 10px;font-size:18px;line-height:1.15;border-width:3px;max-height:70px}
.arena-battle .arena-fighter .arena-actor{width:min(38vw,172px);height:min(38vw,172px)}
.arena-battle .arena-fighter.you{bottom:3%;left:3%}.arena-battle .arena-fighter.opponent{top:4%;right:3%}
.arena-story{font-size:25px;margin:0}
.arena-interaction>[data-keyboard-slot]{display:flex!important;align-items:end;justify-content:center;width:100%;height:270px;min-height:270px;flex:none}
.arena-battle[data-mode=NORMAL] .arena-interaction>[data-keyboard-slot],.arena-battle:not([data-phase=CHALLENGE]) .arena-interaction>[data-keyboard-slot]{display:none!important}
.arena-answer-form{height:40px;min-height:40px;display:flex;gap:6px;flex:none}
.arena-answer-form input{min-width:0;min-height:40px;height:40px;padding:4px 8px;flex:1}
.arena-answer-form .arena-button{min-height:40px;height:40px;padding:4px 12px}
.arena-challenge .arena-interaction .arena-answer-form input,.arena-challenge .arena-interaction .arena-answer-form [data-arena-submit]{height:40px;min-height:40px;padding:4px 8px}
.arena-challenge .pixel-keyboard{--key-size:30px;padding:3px;width:100%;max-width:620px;margin:0}
html body .arena-challenge .pixel-keyboard-row button{font-family:'Noto Sans JP','Yu Gothic',Meiryo,sans-serif;font-weight:500;-webkit-text-stroke:0;text-shadow:none}
.arena-result{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;gap:10px;position:relative;overflow:hidden}
.arena-result>h2{font:700 38px/1.1 PixelUI;color:#fff;-webkit-text-stroke:4px #815572;paint-order:stroke fill;margin:0}
.arena-result[data-result=PLAYER_A_WIN]>h2{-webkit-text-stroke-color:#407760}
.arena-xp-gain{width:min(360px,100%);text-align:center;flex:none;opacity:0}
.is-celebrating .arena-xp-gain{animation:arena-xp-enter .45s ease-out forwards}
@keyframes arena-xp-enter{from{transform:translateX(70%);opacity:0}to{transform:none;opacity:1}}
.arena-xp-gain .home-status{position:relative!important;inset:auto!important;transform:none!important;width:100%!important;display:grid!important;grid-template-columns:1fr auto;gap:6px;padding:12px 16px;border:0;border-image:url('/assets/interface-v2/pastel-ui/lavender-normal.png') var(--native-frame-slice,4) fill / var(--native-frame-corner,8px) / 0 repeat;border-image-width:var(--native-frame-corner,8px);background:none;box-shadow:none;color:#604479;image-rendering:pixelated;image-rendering:crisp-edges;}
.arena-xp-gain h3{font:700 25px/1 PixelUI;margin:0;min-width:0}.arena-xp-level{font-size:19px;align-self:center}
.arena-xp-gain .home-progress{grid-column:1/-1;position:relative;height:24px;background:#e6dcef;border:2px solid #87709f;border-radius:5px;overflow:hidden;width:100%;margin:0}
.arena-xp-fill{display:block;height:100%;background:#a384ce;transition:none}.arena-xp-text{position:absolute;inset:0;display:grid;place-items:center;color:#463457;font-size:17px;line-height:1}
.arena-xp-gain>p{font-size:22px;color:#6e4b91;margin:4px 0 0}
.arena-end-actions{display:flex;gap:10px;width:100%;justify-content:center;flex:none}.arena-end-actions .arena-button{min-height:44px;flex:1;max-width:220px;font-size:23px}
.arena-rest-team{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;width:100%;margin-top:auto;min-height:0;flex:1}
.arena-rest-team .arena-roster-item{gap:2px;font-size:14px;justify-content:center}
.arena-rest-team canvas{width:min(100%,112px);height:auto;aspect-ratio:1;max-height:112px;object-fit:contain}
.arena-rest-team small{color:#a34354;font-size:19px;white-space:nowrap}.arena-rest-team .study-text{white-space:nowrap;font-size:13px}

.arena-battle:has(.is-celebrating) .arena-interaction{height:100%}
.arena-confetti{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.arena-confetti i{position:absolute;left:var(--x);top:-12px;width:7px;height:12px;background:var(--c);opacity:0}
.is-celebrating .arena-confetti i{animation:arena-confetti 2.4s calc(var(--n)*.025s) ease-in 1}
@keyframes arena-confetti{0%{opacity:1;transform:translate(0,-20px) rotate(0)}90%{opacity:1}100%{opacity:0;transform:translate(24px,480px) rotate(420deg)}}
@media(orientation:portrait) and (min-width:700px){.arena-battle{--arena-controls:300px;padding-inline:12px}.arena-battle[data-mode=HARD],.arena-battle[data-mode=IMPOSSIBLE]{--arena-controls:440px}.arena-battle .arena-fighter .arena-actor{width:270px;height:270px}.arena-nameplate strong{font-size:23px}.arena-hearts>img{width:24px;height:24px}.arena-challenge .pixel-keyboard{--key-size:34px}.arena-interaction>[data-keyboard-slot]{height:302px;min-height:302px}.arena-pote-comment{font-size:22px}.arena-team-card{max-height:180px}.arena-team-card .arena-native-creature{max-width:140px}}
@media(orientation:portrait) and (max-height:740px){.arena-battle{--arena-controls:228px}.arena-battle[data-mode=HARD],.arena-battle[data-mode=IMPOSSIBLE]{--arena-controls:350px}.arena-interaction>[data-keyboard-slot]{height:228px;min-height:228px}.arena-challenge .pixel-keyboard{--key-size:24px}.arena-battle .arena-fighter .arena-actor{width:116px;height:116px}.arena-team-card .arena-native-creature{max-width:82px}.arena-story{font-size:22px}}
@media(orientation:landscape){.arena-battle{display:block}.arena-battle>.arena-challenge{width:min(680px,56vw);height:330px;max-height:44%;padding-bottom:40px}.arena-battle[data-mode=HARD]>.arena-challenge,.arena-battle[data-mode=IMPOSSIBLE]>.arena-challenge{height:440px;max-height:49%}.arena-battle .arena-fighter .arena-actor{width:clamp(170px,29vh,320px);height:clamp(170px,29vh,320px)}.arena-battle .arena-fighter.you{left:17%;bottom:45%}.arena-battle .arena-fighter.opponent{right:17%;top:14%}.arena-nameplate strong{font-size:22px}.arena-hearts>img{width:22px;height:22px}.arena-pote-comment{bottom:18px;top:auto;font-size:20px}.arena-interaction>[data-keyboard-slot]{height:270px;min-height:270px}}
@media(orientation:landscape) and (max-height:600px){.arena-battle>.arena-challenge,.arena-battle[data-mode=HARD]>.arena-challenge,.arena-battle[data-mode=IMPOSSIBLE]>.arena-challenge{height:calc(100% - 70px);max-height:none;bottom:8px;padding:6px 8px 28px;width:52vw}.arena-battle .arena-fighter.you{left:12%;bottom:12%}.arena-battle .arena-fighter.opponent{right:12%;top:24%}.arena-battle .arena-fighter .arena-actor{width:140px;height:140px}.arena-nameplate strong{font-size:14px}.arena-hearts>img{width:14px;height:14px}.arena-question-head h2,.arena-interaction>h2{font-size:17px!important}.arena-interaction>h2,.arena-question-head{height:20px;min-height:20px}.arena-interaction{gap:3px}.arena-timing{height:18px;min-height:18px}.arena-interaction>[data-keyboard-slot]{height:190px;min-height:190px}.arena-challenge .pixel-keyboard{--key-size:20px}.arena-answer-form,.arena-answer-form input,.arena-answer-form .arena-button{height:32px;min-height:32px}.arena-pote-comment{bottom:8px;width:46%;font-size:16px;padding:3px 6px}.arena-result{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:40px 1fr 42px;gap:8px 14px}.arena-result>h2{grid-column:1;font-size:29px}.arena-xp-gain{grid-column:1;grid-row:2}.arena-rest-team{grid-column:2;grid-row:1/4;height:100%;align-items:center}.arena-end-actions{grid-column:1;grid-row:3}.arena-end-actions .arena-button{font-size:19px;min-height:36px}}
@media(prefers-reduced-motion:reduce){.arena-impossible .arena-main,.is-celebrating .arena-confetti i{animation:none}.is-celebrating .arena-xp-gain{animation:none;opacity:1}}
@media(orientation:portrait){.arena-battle[data-mode=HARD]{--arena-controls:350px}.arena-battle[data-mode=HARD] .arena-interaction>[data-keyboard-slot]{height:190px;min-height:190px}}
@media(orientation:portrait) and (min-width:700px){.arena-battle[data-mode=HARD]{--arena-controls:360px}.arena-battle[data-mode=HARD] .arena-interaction>[data-keyboard-slot]{height:222px;min-height:222px}}
@media(orientation:portrait) and (max-height:740px){.arena-battle[data-mode=HARD]{--arena-controls:324px}.arena-battle[data-mode=HARD] .arena-interaction>[data-keyboard-slot]{height:168px;min-height:168px}}
@media(orientation:landscape) and (max-height:600px){.arena-challenge .arena-interaction,.arena-challenge .arena-interaction:has(.pixel-keyboard:not([hidden])){gap:3px}.arena-challenge .arena-interaction .arena-answer-form input,.arena-challenge .arena-interaction .arena-answer-form [data-arena-submit]{height:32px;min-height:32px}}
/* Reuse the room's native identity panel and compact XP bar. */
.arena-xp-gain .home-status{border-image-source:url('/assets/interface-v2/identity-xp/identity-frame.png');border-image-slice:6 fill;border-image-width:12px;padding:12px;gap:4px 8px}
.arena-xp-gain h3{white-space:nowrap;font-size:22px;text-align:left}.arena-xp-level{font-size:18px;white-space:nowrap}
.arena-xp-gain .home-progress{height:20px;border:0;border-radius:0;overflow:visible;background:none;isolation:isolate}
.arena-xp-gain .home-progress::before,.arena-xp-fill{content:'';position:absolute;inset:0;width:100%!important;height:100%;box-sizing:border-box;border:6px solid transparent;border-image:url('/assets/interface-v2/room-hud/xp-empty-compact.png') 3 fill stretch;border-image-width:6px;background:none;image-rendering:pixelated}
.arena-xp-fill{border-image-source:url('/assets/interface-v2/room-hud/xp-filled-compact.png');clip-path:inset(0 var(--xp-unfilled,100%) 0 0)}
.arena-xp-text{color:#fff;font:700 16px/1 PixelUI;-webkit-text-stroke:2px #655079;paint-order:stroke fill}
/* A keyboard must never overlap the field that opens it. Reserve the form,
   then give the keyboard the remaining space, even while it is folded. */
.arena-battle:is([data-mode=HARD],[data-mode=IMPOSSIBLE]) .arena-answer-content{flex:0 0 40px}
.arena-battle:is([data-mode=HARD],[data-mode=IMPOSSIBLE]) .arena-interaction>[data-keyboard-slot]{flex:1;min-height:0;height:auto}
.arena-battle .arena-challenge .arena-interaction:has(.pixel-keyboard) .arena-answer-form :is(input,[data-arena-submit]){height:40px;min-height:40px}
@media(orientation:portrait) and (max-width:699px) and (min-height:741px){.arena-battle[data-mode=IMPOSSIBLE] .pixel-keyboard{--key-size:28px}}
@media(orientation:portrait) and (max-height:740px){.arena-battle[data-mode=IMPOSSIBLE]{--arena-controls:380px}}
@media(orientation:landscape) and (max-height:600px){.arena-battle:is([data-mode=HARD],[data-mode=IMPOSSIBLE]) .arena-answer-content{flex-basis:32px}.arena-battle .arena-challenge .arena-interaction:has(.pixel-keyboard) .arena-answer-form :is(input,[data-arena-submit]){height:32px;min-height:32px}}
