/* Tekken 3 WebArcade Styling */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Teko:wght@600;700&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    --bg-dark: #0a0b10;
    --bg-panel: rgba(18, 20, 29, 0.92);
    --bg-card: rgba(28, 31, 46, 0.85);
    --border-color: #ff3e3e;
    --border-gold: #ffb703;
    --tekken-red: #e63946;
    --tekken-gold: #ffb703;
    --tekken-blue: #00b4d8;
    --text-main: #f1faee;
    --text-muted: #8d99ae;
    --accent-glow: rgba(230, 57, 70, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(230, 57, 70, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 80% 80%, rgba(0, 180, 216, 0.08) 0%, transparent 50%),
        linear-gradient(rgba(10, 11, 16, 0.95), rgba(10, 11, 16, 0.95)),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.25) 3px, rgba(0, 0, 0, 0.25) 4px);
    color: var(--text-main);
    font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
header {
    background: linear-gradient(180deg, rgba(20, 15, 25, 0.95) 0%, rgba(10, 11, 16, 0.8) 100%);
    border-bottom: 2px solid var(--tekken-red);
    box-shadow: 0 4px 20px var(--accent-glow);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-title {
    font-family: 'Teko', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 3px;
    line-height: 1;
    background: linear-gradient(180deg, #fff 0%, var(--tekken-gold) 45%, var(--tekken-red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 15px rgba(230, 57, 70, 0.6);
    text-transform: uppercase;
}

.logo-sub {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: var(--tekken-gold);
    letter-spacing: 2px;
    display: block;
    margin-top: -2px;
    text-shadow: 0 0 5px var(--tekken-gold);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.95rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #2ec4b6;
    box-shadow: 0 0 8px #2ec4b6;
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background-color: #e63946;
    box-shadow: 0 0 8px #e63946;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* Main Container */
main {
    flex: 1;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Arcade Cabinet Screen Wrapper */
#arcade-screen-container {
    background: #000;
    border: 3px solid var(--border-gold);
    border-radius: 8px;
    box-shadow: 
        0 0 30px rgba(255, 183, 3, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.9);
    width: 100%;
    max-width: 100vw;
    aspect-ratio: 4 / 3;
    max-height: 720px;
    position: relative;
    overflow: hidden;
    display: none;
    flex-direction: column !important;
    margin: 0 auto;
    contain: layout paint size;
}

#game {
    width: 100%;
    height: 100%;
    transform: translateZ(0);
    will-change: transform;
    contain: strict;
}

#game canvas,
.ejs_canvas {
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: smooth;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    filter: contrast(1.04) saturate(1.08);
}

/* Crisp HD Mode (DuckStation-Style Clean 3D Rendering) */
.canvas-crisp-hd canvas,
.canvas-crisp-hd .ejs_canvas,
.canvas-crisp-hd #game canvas,
#game.canvas-crisp-hd canvas {
    image-rendering: auto !important;
    image-rendering: smooth !important;
    filter: contrast(1.05) saturate(1.10) drop-shadow(0 0 1px rgba(0,0,0,0.4)) !important;
}

/* Retro Pixelated Mode */
.canvas-pixelated canvas,
.canvas-pixelated .ejs_canvas,
.canvas-pixelated #game canvas,
#game.canvas-pixelated canvas {
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: pixelated !important;
    filter: none !important;
}

/* CRT Overlay Effect - Disabled for maximum 60 FPS performance */
.crt-overlay {
    display: none;
}

/* Lobby View */
#lobby-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

.arcade-panel {
    background: var(--bg-panel);
    border: 1px solid rgba(230, 57, 70, 0.3);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.arcade-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--tekken-red), var(--tekken-gold), var(--tekken-blue));
}

.panel-title {
    font-family: 'Teko', sans-serif;
    font-size: 2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--tekken-gold);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Match Actions */
.btn-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-arcade {
    background: linear-gradient(135deg, #1f2438 0%, #161826 100%);
    border: 2px solid var(--tekken-red);
    color: #fff;
    padding: 1.1rem 1.5rem;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.2);
}

.btn-arcade:hover {
    background: linear-gradient(135deg, var(--tekken-red) 0%, #a8202b 100%);
    box-shadow: 0 0 25px rgba(230, 57, 70, 0.6);
    transform: translateY(-2px);
    border-color: #fff;
}

.btn-arcade.gold {
    border-color: var(--tekken-gold);
    box-shadow: 0 4px 15px rgba(255, 183, 3, 0.2);
}

.btn-arcade.gold:hover {
    background: linear-gradient(135deg, var(--tekken-gold) 0%, #d49200 100%);
    box-shadow: 0 0 25px rgba(255, 183, 3, 0.6);
    color: #000;
}

.btn-arcade.cyan {
    border-color: var(--tekken-blue);
    box-shadow: 0 4px 15px rgba(0, 180, 216, 0.2);
}

.btn-arcade.cyan:hover {
    background: linear-gradient(135deg, var(--tekken-blue) 0%, #0077b6 100%);
    box-shadow: 0 0 25px rgba(0, 180, 216, 0.6);
    color: #fff;
}

/* Inputs & Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.form-input {
    background: rgba(10, 11, 16, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 0.85rem 1rem;
    border-radius: 6px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--tekken-gold);
    box-shadow: 0 0 10px rgba(255, 183, 3, 0.3);
}

/* Rooms List Table */
.room-list-container {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    background: rgba(10, 11, 16, 0.5);
}

.room-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.room-table th {
    background: rgba(28, 31, 46, 0.8);
    padding: 0.75rem 1rem;
    text-align: left;
    color: var(--tekken-gold);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.room-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.room-table tr:hover td {
    background: rgba(230, 57, 70, 0.1);
}

.empty-rooms {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Controls Guide Table */
.controls-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.key-badge {
    display: inline-block;
    background: #111;
    border: 1px solid #444;
    border-bottom: 3px solid #222;
    border-radius: 4px;
    padding: 0.2rem 0.55rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--tekken-gold);
    font-weight: bold;
    margin: 0.15rem;
}

/* Room Active Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--bg-panel);
    border: 2px solid var(--tekken-gold);
    border-radius: 12px;
    padding: 2.5rem;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 0 40px rgba(255, 183, 3, 0.4);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}

/* Controller Customization Modal */
.modal-content.controls-modal-content {
    max-width: 920px;
    width: 94%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
    padding: 2rem 2.5rem;
    gap: 1.25rem;
}

.modal-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.modal-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
    transition: color 0.2s;
}

.modal-close-icon:hover {
    color: var(--tekken-red);
}

/* Presets Bar */
.preset-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    background: rgba(10, 11, 16, 0.7);
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preset-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tekken-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 0.25rem;
}

.preset-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    border-color: var(--tekken-gold);
    color: var(--tekken-gold);
    background: rgba(255, 183, 3, 0.15);
}

.preset-btn.active {
    border-color: var(--tekken-gold);
    background: linear-gradient(135deg, var(--tekken-gold) 0%, #d49200 100%);
    color: #000;
    font-weight: 700;
}

/* Rebinding Grid */
.rebind-container {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 850px) {
    .rebind-container {
        grid-template-columns: 1fr;
    }
}

.rebind-column {
    background: rgba(10, 11, 16, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rebind-section-title {
    font-family: 'Teko', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 1px;
    color: var(--tekken-gold);
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 183, 3, 0.2);
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
}

.arcade-stick-diagram {
    background: rgba(0, 0, 0, 0.5);
    border: 1px dashed rgba(255, 183, 3, 0.3);
    border-radius: 6px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: center;
}

.stick-row {
    display: flex;
    justify-content: space-around;
}

.stick-btn-hint {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--tekken-gold);
    font-weight: 700;
}

.rebind-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.rebind-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rebind-label-group {
    display: flex;
    flex-direction: column;
}

.rebind-action-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.rebind-sub-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.key-bind-btn {
    background: #141724;
    border: 1.5px solid var(--tekken-gold);
    color: var(--tekken-gold);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    padding: 0.45rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    min-width: 90px;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.key-bind-btn:hover {
    background: rgba(255, 183, 3, 0.2);
    border-color: #fff;
    color: #fff;
    transform: scale(1.05);
}

.key-bind-btn.listening {
    background: var(--tekken-red);
    color: #fff;
    border-color: #fff;
    animation: listening-pulse 0.8s infinite alternate;
}

@keyframes listening-pulse {
    from {
        box-shadow: 0 0 6px #e63946;
        transform: scale(1.02);
    }
    to {
        box-shadow: 0 0 20px #e63946, 0 0 35px var(--tekken-gold);
        transform: scale(1.08);
    }
}

/* In-Game Top Bar */
.in-game-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 11, 16, 0.98);
    padding: 0.35rem 0.75rem;
    border-bottom: 2px solid var(--tekken-gold);
    z-index: 60;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.in-game-title {
    font-family: 'Teko', sans-serif;
    font-size: 1.25rem;
    letter-spacing: 1.5px;
    color: var(--tekken-gold);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: 0 !important;
    flex-shrink: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.in-game-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: nowrap;
    align-items: center;
    min-width: 0 !important;
    flex-shrink: 0 !important;
}

/* Hide desktop-only buttons on touch devices, small screens, and portrait orientation */
@media (pointer: coarse), (max-width: 900px), (orientation: portrait) {
    .desktop-only {
        display: none !important;
    }
}

/* Explicit class-based hiding so that even if layout viewport inflates, portrait mode NEVER shows desktop-only buttons */
.in-portrait-bottom-mode .desktop-only,
.mobile-portrait-mode .desktop-only,
#arcade-screen-container.portrait-bottom-controls .desktop-only,
body.game-running:not(.in-fullscreen-mode) .desktop-only {
    display: none !important;
}

/* Voice Chat UI Styles */
.voice-btn {
    transition: all 0.2s ease;
}

.voice-btn.voice-active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border-color: #34d399 !important;
    color: #fff !important;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4) !important;
}

.voice-btn.voice-speaking {
    animation: voice-pulse 0.9s infinite alternate;
}

.voice-btn.voice-muted {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    border-color: #f87171 !important;
    color: #fff !important;
    opacity: 0.9;
}

@keyframes voice-pulse {
    0% { transform: scale(1); box-shadow: 0 0 6px #10b981; }
    100% { transform: scale(1.06); box-shadow: 0 0 16px #34d399; }
}

.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #1b2838 0%, #0d1b2a 100%);
    border: 1px solid var(--tekken-gold);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.share-link-box {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.4rem;
}

.share-link-input {
    background: transparent;
    border: none;
    color: #fff;
    flex: 1;
    padding: 0.5rem;
    font-family: monospace;
    font-size: 0.95rem;
    outline: none;
}

/* Footer */
footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: rgba(10, 11, 16, 0.9);
}

.footer-highlight {
    color: var(--tekken-gold);
    font-weight: 700;
}

/* ==========================================
   PPSSPP On-Screen Touch Controls (Mobile/Tablet)
   ========================================== */

.touch-overlay {
    position: absolute;
    top: 46px;
    left: 0;
    width: 100%;
    height: calc(100% - 46px);
    pointer-events: none;
    z-index: 50;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.touch-overlay.active {
    display: flex;
}

/* Top bar: L1, Select, Start, R1 */
.touch-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    pointer-events: auto;
}

.touch-btn-shoulder {
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.2) 0%, rgba(25,28,45,0.7) 70%, rgba(10,12,22,0.9) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 0 10px rgba(255,255,255,0.1);
    color: #fff;
    padding: 0.45rem 1.25rem;
    border-radius: 20px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    touch-action: none;
    transition: transform 0.08s, background 0.08s, box-shadow 0.08s;
}

.touch-btn-shoulder:active,
.touch-btn-shoulder.active {
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.45) 0%, rgba(230,57,70,0.8) 70%, rgba(120,20,30,0.95) 100%);
    border-color: #fff;
    box-shadow: 0 0 20px rgba(230,57,70,0.8), inset 0 0 15px rgba(255,255,255,0.4);
    transform: scale(0.92);
}

.touch-sub-label {
    font-size: 0.75rem;
    color: var(--tekken-gold);
    font-weight: bold;
}

.touch-system-group {
    display: flex;
    gap: 0.8rem;
}

.touch-btn-pill {
    background: rgba(20, 22, 35, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.85);
    padding: 0.35rem 0.95rem;
    border-radius: 14px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    cursor: pointer;
    touch-action: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.08s, background 0.08s;
}

.touch-btn-pill:active,
.touch-btn-pill.active {
    background: var(--tekken-gold);
    color: #000;
    border-color: #fff;
    transform: scale(0.92);
    box-shadow: 0 0 15px var(--tekken-gold);
}

/* Bottom Area: D-Pad & Diamond Buttons */
.touch-bottom-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 1rem 1.5rem 1.5rem 1.5rem;
    pointer-events: none;
}

/* PPSSPP D-Pad Container */
.touch-dpad-container {
    width: 170px;
    height: 170px;
    position: relative;
    pointer-events: auto;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20,24,38,0.5) 0%, rgba(10,12,20,0.65) 70%, transparent 100%);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    touch-action: none;
}

.touch-dpad-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(15,18,30,0.8) 100%);
    border: 1px solid rgba(255,255,255,0.2);
    pointer-events: none;
}

.touch-dpad-btn {
    position: absolute;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(20,24,40,0.6) 80%, rgba(10,12,25,0.85) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    cursor: pointer;
    touch-action: none;
    transition: transform 0.08s, background 0.08s, color 0.08s, box-shadow 0.08s;
}

.touch-dpad-btn svg {
    width: 26px;
    height: 26px;
    pointer-events: none;
}

.touch-dpad-btn.dpad-up {
    top: 4px;
    left: 59px;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.touch-dpad-btn.dpad-down {
    bottom: 4px;
    left: 59px;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.touch-dpad-btn.dpad-left {
    top: 59px;
    left: 4px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.touch-dpad-btn.dpad-right {
    top: 59px;
    right: 4px;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.touch-dpad-btn:active,
.touch-dpad-btn.active {
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,183,3,0.7) 70%, rgba(180,120,0,0.9) 100%);
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 20px rgba(255,183,3,0.7), inset 0 0 10px rgba(255,255,255,0.4);
    transform: scale(0.92);
}

/* Diagonal hit zones for smooth rolling */
.dpad-diag {
    position: absolute;
    width: 44px;
    height: 44px;
    z-index: 2;
    cursor: pointer;
    touch-action: none;
}
.diag-ul { top: 12px; left: 12px; }
.diag-ur { top: 12px; right: 12px; }
.diag-dl { bottom: 12px; left: 12px; }
.diag-dr { bottom: 12px; right: 12px; }

/* Action Buttons Diamond Layout (PPSSPP Style) */
.touch-action-diamond {
    width: 190px;
    height: 190px;
    position: relative;
    pointer-events: auto;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20,24,38,0.4) 0%, rgba(10,12,20,0.55) 70%, transparent 100%);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    touch-action: none;
}

.touch-action-btn {
    position: absolute;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.18) 0%, rgba(22,26,42,0.7) 65%, rgba(10,12,22,0.92) 100%);
    border: 2px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 15px rgba(0,0,0,0.6), inset 0 0 12px rgba(255,255,255,0.1);
    cursor: pointer;
    touch-action: none;
    transition: transform 0.08s, background 0.08s, box-shadow 0.08s, border-color 0.08s;
}

.ps-symbol {
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 0 8px currentColor;
    pointer-events: none;
}

.action-sub-hint {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1;
    margin-top: 1px;
    pointer-events: none;
}

/* Triangle △ - Top (RP / 2) */
.action-triangle {
    top: 4px;
    left: 66px;
    border-color: rgba(0, 230, 118, 0.5);
}
.action-triangle .triangle-sym { color: #00e676; }
.action-triangle:active,
.action-triangle.active {
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(0,230,118,0.75) 60%, rgba(0,150,75,0.95) 100%);
    border-color: #fff;
    box-shadow: 0 0 25px rgba(0,230,118,0.8), inset 0 0 15px rgba(255,255,255,0.5);
    transform: scale(0.92);
}

/* Square □ - Left (LP / 1) */
.action-square {
    top: 66px;
    left: 4px;
    border-color: rgba(255, 64, 129, 0.5);
}
.action-square .square-sym { color: #ff4081; }
.action-square:active,
.action-square.active {
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,64,129,0.75) 60%, rgba(180,30,80,0.95) 100%);
    border-color: #fff;
    box-shadow: 0 0 25px rgba(255,64,129,0.8), inset 0 0 15px rgba(255,255,255,0.5);
    transform: scale(0.92);
}

/* Circle ○ - Right (RK / 4) */
.action-circle {
    top: 66px;
    right: 4px;
    border-color: rgba(255, 23, 68, 0.5);
}
.action-circle .circle-sym { color: #ff1744; }
.action-circle:active,
.action-circle.active {
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,23,68,0.75) 60%, rgba(180,10,40,0.95) 100%);
    border-color: #fff;
    box-shadow: 0 0 25px rgba(255,23,68,0.8), inset 0 0 15px rgba(255,255,255,0.5);
    transform: scale(0.92);
}

/* Cross ✕ - Bottom (LK / 3) */
.action-cross {
    bottom: 4px;
    left: 66px;
    border-color: rgba(0, 176, 255, 0.5);
}
.action-cross .cross-sym { color: #00b0ff; }
.action-cross:active,
.action-cross.active {
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(0,176,255,0.75) 60%, rgba(0,110,180,0.95) 100%);
    border-color: #fff;
    box-shadow: 0 0 25px rgba(0,176,255,0.8), inset 0 0 15px rgba(255,255,255,0.5);
    transform: scale(0.92);
}

/* Combo Shortcut Buttons (1+2, 3+4) */
.touch-combo-btn {
    position: absolute;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(30, 35, 55, 0.85);
    border: 1px solid var(--tekken-gold);
    color: var(--tekken-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    cursor: pointer;
    touch-action: none;
    transition: transform 0.08s, background 0.08s;
}

.combo-lp-rp {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -92%);
}

.combo-lk-rk {
    top: 50%;
    left: 50%;
    transform: translate(-50%, 28%);
}

.touch-combo-btn:active,
.touch-combo-btn.active {
    background: var(--tekken-gold);
    color: #000;
    transform: translate(-50%, -92%) scale(0.9);
    box-shadow: 0 0 15px var(--tekken-gold);
}

.combo-lk-rk:active,
.combo-lk-rk.active {
    transform: translate(-50%, 28%) scale(0.9);
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 900px) {
    main {
        padding: 0.5rem;
        gap: 1rem;
    }
    #arcade-screen-container {
        border-width: 2px;
        max-height: 80vh;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .touch-bottom-area {
        padding: 0.5rem 0.5rem 0.75rem 0.5rem;
    }
    .touch-dpad-container {
        width: 145px;
        height: 145px;
    }
    .touch-dpad-btn {
        width: 44px;
        height: 44px;
    }
    .touch-dpad-btn.dpad-up { left: 50px; top: 2px; }
    .touch-dpad-btn.dpad-down { left: 50px; bottom: 2px; }
    .touch-dpad-btn.dpad-left { top: 50px; left: 2px; }
    .touch-dpad-btn.dpad-right { top: 50px; right: 2px; }
    .touch-dpad-center { width: 36px; height: 36px; }

    .touch-action-diamond {
        width: 155px;
        height: 155px;
    }
    .touch-action-btn {
        width: 48px;
        height: 48px;
    }
    .action-triangle { left: 53px; top: 2px; }
    .action-square { left: 2px; top: 53px; }
    .action-circle { right: 2px; top: 53px; }
    .action-cross { left: 53px; bottom: 2px; }
    .ps-symbol { font-size: 1.15rem; }
    .touch-combo-btn { width: 30px; height: 30px; font-size: 0.7rem; }

    .touch-btn-shoulder {
        padding: 0.35rem 0.9rem;
        font-size: 0.95rem;
    }
}

/* Landscape Mode on Phones */
@media (max-height: 550px) and (orientation: landscape) {
    header, footer {
        display: none !important;
    }
    main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100vw !important;
        height: 100vh !important;
    }
    #arcade-screen-container {
        max-height: 100vh !important;
        height: 100vh !important;
        border: none !important;
        border-radius: 0 !important;
    }
    .in-game-top-bar {
        padding: 0.25rem 0.75rem;
    }
}

/* ==========================================================================
   Suppress EmulatorJS Default Virtual Gamepad & Mobile Elements
   ========================================================================== */
.ejs_virtualGamepad_parent,
.ejs_virtualGamepad_open,
.ejs_virtualGamepad_button,
.ejs_virtualGamepad_top,
.ejs_virtualGamepad_bottom,
.ejs_virtualGamepad_left,
.ejs_virtualGamepad_right,
div.nipple,
.ejs_virtualGamepad_button_down {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    position: absolute !important;
    z-index: -9999 !important;
}

/* ==========================================================================
   Mobile Smartphone Adaptive Layouts: Portrait Bottom Deck vs Fullscreen
   ========================================================================== */

/* While in lobby, arcade screen container is strictly hidden */
body:not(.game-running) #arcade-screen-container {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

/* While game is running on mobile, lock body to viewport to prevent scrolling/jumping */
body.game-running {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    touch-action: none !important;
    overscroll-behavior: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.game-running header,
body.game-running footer,
body.game-running #lobby-view {
    display: none !important;
}

body.game-running main {
    padding: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
}

/* 1. Normal Mode (Portrait): Dedicated Bottom Handheld Controller Deck */
body.game-running #arcade-screen-container.portrait-bottom-controls {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
    contain: strict !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #08090f !important;
    z-index: 99999 !important;
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* Minimal Top Bar in Mobile Portrait (Zero Clutter: only Title, Fullscreen, Exit) */
#arcade-screen-container.portrait-bottom-controls .in-game-top-bar {
    flex: 0 0 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    width: 100vw !important;
    padding: 0 0.5rem !important;
    background: #11131c !important;
    border-bottom: 1px solid rgba(255, 183, 3, 0.25) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    flex-wrap: nowrap !important;
}

#arcade-screen-container.portrait-bottom-controls .in-game-title {
    font-size: 0.9rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    white-space: nowrap !important;
}

#arcade-screen-container.portrait-bottom-controls .in-game-actions {
    display: flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    flex-wrap: nowrap !important;
}

/* Hide all unnecessary desktop buttons on mobile portrait */
#arcade-screen-container.portrait-bottom-controls .in-game-actions button:not(#in-game-fullscreen-btn):not(#in-game-voice-btn):not(#in-game-exit-btn):not(#btn-exit-to-lobby) {
    display: none !important;
}

#arcade-screen-container.portrait-bottom-controls #in-game-fullscreen-btn,
#arcade-screen-container.portrait-bottom-controls #in-game-voice-btn,
#arcade-screen-container.portrait-bottom-controls #in-game-exit-btn,
#arcade-screen-container.portrait-bottom-controls #btn-exit-to-lobby {
    padding: 0.22rem 0.55rem !important;
    font-size: 0.72rem !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
}

/* Game Display: Native 4:3 at top (Unobstructed by fingers/buttons) */
#arcade-screen-container.portrait-bottom-controls #game {
    flex: 0 0 auto !important;
    width: 100vw !important;
    max-height: 38vh !important;
    aspect-ratio: 4 / 3 !important;
    background: #000 !important;
    margin: 0 auto !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.8) !important;
}

#arcade-screen-container.portrait-bottom-controls #game canvas,
#arcade-screen-container.portrait-bottom-controls .ejs_canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-overlay:not(.active) {
    display: none !important;
}

/* Bottom Controller Deck: Takes remaining space without ever scrolling */
#arcade-screen-container.portrait-bottom-controls .touch-overlay.active {
    flex: 1 1 auto !important;
    width: 100vw !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    height: auto !important;
    max-height: calc(100dvh - 36px - 38vh) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 0.2rem 0.4rem 0.6rem 0.4rem !important;
    background: linear-gradient(180deg, #141724 0%, #07080d 100%) !important;
    border-top: 2px solid var(--tekken-red) !important;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.8) !important;
    box-sizing: border-box !important;
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    overflow: hidden !important;
}

/* Top Shoulder Row: L1 on Left, Select/Start in Center, R1 on Right */
#arcade-screen-container.portrait-bottom-controls .touch-top-bar {
    flex: 0 0 34px !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 0.15rem !important;
    box-sizing: border-box !important;
    pointer-events: auto !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-btn-shoulder {
    padding: 0.22rem 0.75rem !important;
    font-size: 0.85rem !important;
    border-radius: 12px !important;
    background: rgba(28, 32, 48, 0.95) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-system-group {
    display: flex !important;
    gap: 0.35rem !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-btn-pill {
    padding: 0.22rem 0.55rem !important;
    font-size: 0.55rem !important;
    border-radius: 10px !important;
}

/* Main Playing Area: D-Pad on Left, Combos Center, Diamond on Right */
#arcade-screen-container.portrait-bottom-controls .touch-bottom-area {
    flex: 1 1 auto !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 0.1rem !important;
    box-sizing: border-box !important;
    pointer-events: auto !important;
}

/* Calibrated D-Pad (136px - Fits every smartphone perfectly) */
#arcade-screen-container.portrait-bottom-controls .touch-dpad-container {
    width: 136px !important;
    height: 136px !important;
    flex: 0 0 136px !important;
    position: relative !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-dpad-btn {
    width: 42px !important;
    height: 42px !important;
    border-radius: 10px !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-dpad-btn.dpad-up {
    top: 2px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-dpad-btn.dpad-down {
    bottom: 2px !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    transform: translateX(-50%) !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-dpad-btn.dpad-left {
    left: 2px !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-dpad-btn.dpad-right {
    right: 2px !important;
    top: 50% !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-dpad-center {
    width: 32px !important;
    height: 32px !important;
}

/* Calibrated Action Diamond (136px - Centered mathematically) */
#arcade-screen-container.portrait-bottom-controls .touch-action-diamond {
    width: 136px !important;
    height: 136px !important;
    flex: 0 0 136px !important;
    position: relative !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-action-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
}

#arcade-screen-container.portrait-bottom-controls .action-triangle {
    top: 2px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    border-color: rgba(0, 230, 118, 0.7) !important;
}

#arcade-screen-container.portrait-bottom-controls .action-triangle .ps-symbol {
    color: #00e676 !important;
}

#arcade-screen-container.portrait-bottom-controls .action-cross {
    bottom: 2px !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    transform: translateX(-50%) !important;
    border-color: rgba(41, 121, 255, 0.7) !important;
}

#arcade-screen-container.portrait-bottom-controls .action-cross .ps-symbol {
    color: #2979ff !important;
}

#arcade-screen-container.portrait-bottom-controls .action-square {
    left: 2px !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    border-color: rgba(255, 64, 129, 0.7) !important;
}

#arcade-screen-container.portrait-bottom-controls .action-square .ps-symbol {
    color: #ff4081 !important;
}

#arcade-screen-container.portrait-bottom-controls .action-circle {
    right: 2px !important;
    top: 50% !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    border-color: rgba(255, 23, 68, 0.7) !important;
}

#arcade-screen-container.portrait-bottom-controls .action-circle .ps-symbol {
    color: #ff1744 !important;
}

#arcade-screen-container.portrait-bottom-controls .ps-symbol {
    font-size: 1.15rem !important;
}

#arcade-screen-container.portrait-bottom-controls .action-sub-hint {
    font-size: 0.58rem !important;
}

#arcade-screen-container.portrait-bottom-controls .touch-combo-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.7rem !important;
    border-radius: 8px !important;
}

/* 2. Fullscreen Mode: Buttons ON THE SCREEN over the display */
#arcade-screen-container:fullscreen,
#arcade-screen-container:-webkit-full-screen,
#arcade-screen-container.fullscreen-touch-active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    aspect-ratio: auto !important;
    z-index: 99999 !important;
    border: none !important;
    border-radius: 0 !important;
    background: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: hidden !important;
}

#arcade-screen-container:fullscreen #game,
#arcade-screen-container:-webkit-full-screen #game,
#arcade-screen-container.fullscreen-touch-active #game {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
}

#arcade-screen-container:fullscreen #game canvas,
#arcade-screen-container:-webkit-full-screen #game canvas,
#arcade-screen-container.fullscreen-touch-active #game canvas,
#arcade-screen-container.fullscreen-touch-active .ejs_canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

#arcade-screen-container:fullscreen .touch-overlay,
#arcade-screen-container:-webkit-full-screen .touch-overlay,
#arcade-screen-container.fullscreen-touch-active .touch-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none !important;
    z-index: 100000 !important;
    background: transparent !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 0.5rem 1rem 1rem 1rem !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

#arcade-screen-container:fullscreen .touch-top-bar,
#arcade-screen-container:-webkit-full-screen .touch-top-bar,
#arcade-screen-container.fullscreen-touch-active .touch-top-bar {
    margin-top: 50px !important;
    padding: 0.5rem 1rem !important;
    pointer-events: auto !important;
}

#arcade-screen-container:fullscreen .in-game-top-bar,
#arcade-screen-container:-webkit-full-screen .in-game-top-bar,
#arcade-screen-container.fullscreen-touch-active .in-game-top-bar {
    position: absolute !important;
    top: 6px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 100001 !important;
    background: rgba(14, 16, 26, 0.8) !important;
    backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 20px !important;
    padding: 0.2rem 0.75rem !important;
    max-width: 90vw !important;
    opacity: 0.85;
    transition: opacity 0.2s;
}
#arcade-screen-container.fullscreen-touch-active .in-game-top-bar:hover {
    opacity: 1;
}

/* Clean up unnecessary details in Mobile Lobby (< 768px) */
@media (max-width: 768px) {
    header {
        padding: 0.6rem 0.8rem !important;
    }
    header .system-status {
        display: none !important;
    }
    .logo-title {
        font-size: 2rem !important;
    }
    .panel-title {
        font-size: 1.5rem !important;
    }
    .arcade-panel {
        padding: 1.25rem 1rem !important;
        gap: 1rem !important;
    }
    /* Hide desktop keybindings table from mobile lobby */
    .arcade-panel:has(#controls-summary-body),
    .controls-card:has(#controls-summary-body) {
        display: none !important;
    }
    #btn-open-controls,
    #btn-gpu-settings {
        font-size: 0.95rem !important;
        padding: 0.75rem 1rem !important;
    }
}

/* Media query fallback: automatically enforce portrait bottom controls on narrow screens when running and not in fullscreen */
@media (max-width: 768px), (orientation: portrait) and (max-width: 900px) {
    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        overflow: hidden !important;
        contain: strict !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #08090f !important;
        z-index: 99999 !important;
        touch-action: none !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container .in-game-top-bar {
        flex: 0 0 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        width: 100vw !important;
        padding: 0 0.5rem !important;
        background: #11131c !important;
        border-bottom: 1px solid rgba(255, 183, 3, 0.25) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
        flex-wrap: nowrap !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container .in-game-actions button:not(#in-game-fullscreen-btn):not(#in-game-voice-btn):not(#in-game-exit-btn):not(#btn-exit-to-lobby) {
        display: none !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container #in-game-fullscreen-btn,
    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container #in-game-voice-btn,
    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container #in-game-exit-btn {
        padding: 0.22rem 0.55rem !important;
        font-size: 0.72rem !important;
        border-radius: 6px !important;
        white-space: nowrap !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container #game {
        flex: 0 0 auto !important;
        width: 100vw !important;
        max-height: 38vh !important;
        aspect-ratio: 4 / 3 !important;
        background: #000 !important;
        margin: 0 auto !important;
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 4px 14px rgba(0,0,0,0.8) !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container #game canvas,
    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container .ejs_canvas {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container .touch-overlay {
        flex: 1 1 auto !important;
        width: 100vw !important;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        height: auto !important;
        max-height: calc(100dvh - 36px - 38vh) !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        padding: 0.2rem 0.4rem 0.6rem 0.4rem !important;
        background: linear-gradient(180deg, #141724 0%, #07080d 100%) !important;
        border-top: 2px solid var(--tekken-red) !important;
        box-shadow: inset 0 2px 10px rgba(0,0,0,0.8) !important;
        box-sizing: border-box !important;
        touch-action: none !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        overflow: hidden !important;
    }

    body.game-running:not(.in-fullscreen-mode) #arcade-screen-container .touch-top-bar {
        flex: 0 0 34px !important;
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0 0.15rem !important;
        box-sizing: border-box !important;
        pointer-events: auto !important;
    }
}
