/* Shared sizing and touch layouts, loaded after the desktop styles. */
body { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
.screen, .selection-stage > *, .mode-panel > *, .hud-data { min-width: 0; }
.arena-top { flex-wrap: wrap; }
.arena-screen #gameCanvas { display: block; width: 100%; height: auto; min-height: 0; aspect-ratio: 16 / 9; }
.touch-controls { display: none; gap: 10px; margin-top: 12px; }
.touch-tip { grid-column: 1 / -1; margin: 0; color: #a9bdd6; font-size: 11px; text-align: center; line-height: 1.5; }
.touch-player { min-width: 0; container-type: inline-size; margin: 0; padding: 8px 12px 12px; border: 1px solid #794751; border-radius: 12px; background: #111a2a; }
.touch-player[hidden] { display: none !important; }
.touch-player[data-touch-player="1"] { border-color: #426b9e; }
.touch-player legend { padding: 0 7px; color: #f2a5af; font-size: 10px; font-weight: 800; }
.touch-player[data-touch-player="1"] legend { color: #8dc4ff; }
.touch-player-buttons { display: grid; grid-template-columns: 144px 164px; justify-content: space-between; gap: 12px; }
.touch-movement, .touch-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, 46px); gap: 5px; }
.touch-button { min-width: 0; min-height: 44px; padding: 4px; border: 1px solid #69819e; border-radius: 10px; background: linear-gradient(#2c415c, #16263c); color: #fff; font: 700 11px Arial, sans-serif; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.touch-button.is-held, .touch-button:active { border-color: #ffe0a0; background: #7d5327; box-shadow: inset 0 0 10px #0006; }
.touch-button:focus-visible { outline: 2px solid #ffd589; outline-offset: 2px; }
.touch-movement .touch-action-0 { grid-column: 2; grid-row: 1; font-size: 23px; }
.touch-movement .touch-action-1 { grid-column: 1; grid-row: 2; font-size: 23px; }
.touch-movement .touch-action-2 { grid-column: 2; grid-row: 2; font-size: 10px; }
.touch-movement .touch-action-3 { grid-column: 3; grid-row: 2; font-size: 23px; }
.touch-actions .touch-action-4 { background: linear-gradient(#914b42, #562f31); border-color: #e29a7f; }
.touch-actions .touch-action-5, .touch-actions .touch-action-6 { background: linear-gradient(#485681, #2e3554); }
.touch-actions .touch-action-7 { grid-column: 2; }
.touch-actions .touch-action-8 { grid-column: 3; }
@container (max-width: 330px) {
    .touch-player-buttons { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .touch-movement { width: 144px; justify-self: center; }
    .touch-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: 46px; }
    .touch-actions .touch-action-7, .touch-actions .touch-action-8 { grid-column: auto; }
}
@media (any-pointer: coarse), (max-width: 900px) {
    .touch-controls { display: grid; grid-template-columns: minmax(0, 1fr); }
    .choice-btn, .target-btn, .back-btn, .random-character-btn, .music-controls button, .result-actions button, .selection-settings summary, .battle-controls summary { min-height: 44px; }
    .arcade-select .franchise-tabs button { min-height: 44px; padding: 9px 12px; }
    .arcade-select .char-card { min-height: 50px; }
    .player-lives-setting select, .setting-group select { min-height: 44px; }
}
@media (min-width: 760px) {
    .touch-controls[data-two-player="true"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .screen.arena-screen { width: calc(100% - 24px); padding-top: 15px; padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
    .arena-top { gap: 10px; margin-bottom: 12px; }
    .arena-top h1 { font-size: 30px; }
    .arena-top .eyebrow { font-size: 8px; }
    .arena-screen .music-controls { gap: 9px; padding: 9px 11px; }
    .arena-screen .music-controls [data-music-status] { margin-left: auto; width: auto; font-size: 10px; }
    .arcade-select .fighter-heading { flex-wrap: wrap; gap: 10px; }
    .selection-settings .mode-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
    .selection-settings .setting-group select { width: 100%; min-width: 0; max-width: 100%; }
    .selection-settings .arena-setting { grid-column: 1 / -1; }
    .selection-settings .button-row { flex-wrap: wrap; }
    .result-panel { width: min(100%, 650px); max-height: calc(100dvh - 32px); overflow-y: auto; }
    .result-stats-grid { gap: 10px; }
}
@media (max-width: 600px) {
    .selection-screen .topbar { align-items: flex-start; }
    .selection-screen .subtitle { line-height: 1.6; }
    .arcade-select .roster-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .arcade-select .char-card > span { font-size: 9px; }
    .selection-settings summary span { display: block; margin: 6px 0 0 15px; line-height: 1.5; }
    .setting-group select, .player-lives-setting select { font-size: 16px; }
    .music-controls { flex-wrap: wrap; }
    .music-controls input { width: min(120px, 34vw); min-height: 36px; }
    .music-controls [data-music-status] { flex-basis: 100%; margin-left: 0; }
    .arena-screen .music-controls [data-music-status] { flex-basis: 100%; }
    .arena-top .back-btn { padding: 9px; font-size: 10px; }
    .result-actions { display: grid; grid-template-columns: 1fr; }
    .result-actions button { width: 100%; }
    .result-panel h2, .result-stats-grid h3 { overflow-wrap: anywhere; }
    .battle-controls p, .combat-help, .arena-note { overflow-wrap: anywhere; }
    .hud-detail-row { flex-wrap: wrap; gap: 1px; }
    .hud-detail-row small { font-size: 9px; }
    .hud-detail-row .throw-ammo { font-size: 7px; }
    .hud-detail-row [id$="-hud-stats"] { font-size: 0; }
    .hud-detail-row [id$="-hud-stats"]::after { content: attr(data-compact); font-size: 10px; }
    .hud-super > span { font-size: 8px; }
    .hud-name-row .hud-role { display: none; }
}
@media (max-width: 400px) {
    .touch-player-buttons { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .touch-movement { width: 144px; justify-self: center; }
    .touch-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: 46px; }
    .touch-actions .touch-action-7, .touch-actions .touch-action-8 { grid-column: auto; }
    .selection-settings .mode-panel { grid-template-columns: minmax(0, 1fr); }
    .arena-top h1 { font-size: 24px; }
    .hud-detail-row small { font-size: 9px; }
    .hud-detail-row [id$="-hud-stats"] { font-size: 0; }
    .hud-detail-row .throw-ammo { font-size: 7px; }
}
@media (max-height: 520px) and (orientation: landscape) and (max-width: 1100px) {
    .screen.arena-screen { width: min(100% - 20px, 850px); padding-top: 6px; }
    .arena-top { margin-bottom: 6px; }
    .arena-top h1 { font-size: 20px; margin: 0; }
    .arena-top .eyebrow, .arena-screen .music-controls [data-music-status], .touch-tip { display: none; }
    .arena-screen .music-controls { margin: 6px 0; padding: 4px 8px; }
    .arena-screen .music-controls button { min-height: 32px; padding: 5px 9px; font-size: 10px; }
    .arena-screen .game-frame { width: min(100%, calc((100dvh - 200px) * 16 / 9)); min-width: min(100%, 320px); margin-inline: auto; }
    .touch-player { padding-top: 3px; padding-bottom: 6px; }
    .touch-controls { margin-top: 6px; }
    .touch-movement, .touch-actions { grid-template-rows: repeat(2, 44px); }
}
