/* ==========================================================================
   SOKOBAN MASTER - 100% RESPONSIVE ULTIMATE DESIGN SYSTEM
   Supports Desktop, Tablets, Mobile Portrait/Landscape & IFrame Embeds
   ========================================================================== */

/* 1. CSS CUSTOM PROPERTIES & TOKENS */
:root {
    /* Color Palette */
    --bg-dark: #0f172a;
    --bg-surface: rgba(30, 41, 59, 0.85);
    --bg-surface-hover: rgba(51, 65, 85, 0.95);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    
    /* Primary Accents */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.5);
    
    /* Secondary & Functional Colors */
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.5);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.5);
    --accent-rose: #f43f5e;
    --accent-violet: #8b5cf6;
    
    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    /* Fonts & Radii */
    --font-heading: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 2. BASE & RESET */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: clamp(13px, 1.4vw, 16px);
    line-height: 1.4;
    touch-action: manipulation;
}

/* 3. APPLICATION CONTAINER */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Background Particle Canvas */
.bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* 4. APP HEADER */
.app-header {
    position: relative;
    z-index: 10;
    height: clamp(44px, 7vh, 56px);
    padding: 0 clamp(0.75rem, 2vw, 1.5rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform var(--transition-bounce);
}

.header-logo:hover {
    transform: scale(1.04);
}

.logo-icon {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6));
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text small {
    font-size: 0.7em;
    color: var(--accent-amber);
    background: none;
    -webkit-text-fill-color: var(--accent-amber);
    letter-spacing: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Icon Button */
.icon-btn {
    width: clamp(34px, 5vh, 40px);
    height: clamp(34px, 5vh, 40px);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-size: clamp(1rem, 2vw, 1.2rem);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

/* 5. MAIN CONTENT SCREENS */
.main-content {
    position: relative;
    z-index: 5;
    flex: 1 1 0%;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    flex-direction: column;
    padding: clamp(0.5rem, 2vw, 1.25rem);
    overflow: hidden;
    transition: opacity 0.25s ease-in-out;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* 6. SCREEN 1: MENU HERO */
#screen-menu {
    justify-content: center;
    align-items: center;
    gap: clamp(1rem, 3vh, 2.5rem);
    text-align: center;
    overflow-y: auto;
}

.menu-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-badge {
    padding: 0.25rem 0.8rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--accent-amber);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: clamp(0.85rem, 2vw, 1.05rem);
    margin-top: 0.4rem;
    max-width: 440px;
}

.hero-character-preview {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hero-img {
    width: clamp(50px, 10vw, 80px);
    height: clamp(50px, 10vw, 80px);
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}

.pulse-anim {
    animation: pulseFloat 3s ease-in-out infinite;
}

@keyframes pulseFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.hero-crate-stack {
    display: flex;
    gap: 0.4rem;
}

.crate-img {
    width: clamp(40px, 8vw, 64px);
    height: clamp(40px, 8vw, 64px);
    object-fit: contain;
}

.glow-target {
    filter: drop-shadow(0 0 12px var(--accent-emerald));
}

/* Menu Buttons */
.menu-nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 380px;
}

.btn-group-row {
    display: flex;
    gap: 0.6rem;
    width: 100%;
}

.btn-group-row .btn {
    flex: 1;
}

/* 7. BUTTON STYLES */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: clamp(0.6rem, 1.5vh, 0.85rem) clamp(1rem, 2vw, 1.4rem);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(0.85rem, 1.8vw, 1rem);
    border: none;
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: #ffffff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa 0%, var(--primary) 100%);
}

.glow-effect {
    box-shadow: 0 0 24px var(--primary-glow);
}

.glow-effect:hover {
    box-shadow: 0 0 32px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-tertiary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.btn-tertiary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, #047857 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-amber) 0%, #b45309 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-rose) 0%, #be123c 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, var(--accent-violet) 0%, #6d28d9 100%);
    color: white;
}

.btn-xl {
    padding: clamp(0.85rem, 2vh, 1.1rem) clamp(1.4rem, 3vw, 2rem);
    font-size: clamp(1.05rem, 2.2vw, 1.25rem);
    letter-spacing: 0.5px;
}

.btn-large {
    padding: clamp(0.75rem, 1.8vh, 1rem) clamp(1.2rem, 2.5vw, 1.75rem);
    font-size: clamp(0.95rem, 2vw, 1.1rem);
}

.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon-only {
    padding: 0;
    width: clamp(34px, 5vh, 44px);
    height: clamp(34px, 5vh, 44px);
    border-radius: var(--radius-sm);
}

/* 8. SCREEN 2: LEVEL SELECT */
.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.screen-title {
    font-family: var(--font-heading);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.level-progress-summary {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    color: var(--accent-amber);
}

/* Pack Tabs */
.pack-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(0.78rem, 1.6vw, 0.9rem);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.tab-btn.active, .tab-btn:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
}

/* Level Grid */
.level-grid-wrapper {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(80px, 14vw, 110px), 1fr));
    gap: clamp(0.5rem, 1.5vw, 0.9rem);
}

.level-card {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition-bounce);
    backdrop-filter: blur(10px);
}

.level-card:hover:not(.locked) {
    transform: translateY(-3px) scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.level-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(15, 23, 42, 0.6);
}

.level-num {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(1rem, 2.2vw, 1.3rem);
    color: var(--text-main);
}

.level-stars {
    display: flex;
    gap: 0.1rem;
    font-size: clamp(0.7rem, 1.5vw, 0.85rem);
}

.star-empty {
    opacity: 0.25;
    filter: grayscale(1);
}

.level-best {
    font-size: clamp(0.65rem, 1.2vw, 0.75rem);
    color: var(--text-muted);
}

.lock-icon {
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    margin: auto;
}

/* 9. SCREEN 3: GAMEPLAY VIEW */
#screen-gameplay {
    padding: clamp(0.35rem, 1vh, 0.75rem);
    gap: clamp(0.35rem, 1vh, 0.6rem);
    overflow: hidden;
    height: 100%;
}

.game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.8rem;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hud-info {
    display: flex;
    flex-direction: column;
}

.hud-title {
    font-family: var(--font-heading);
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    font-weight: 800;
    line-height: 1.1;
}

.badge {
    font-size: 0.65rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    font-weight: 700;
    width: fit-content;
}

.hud-center {
    display: flex;
    gap: clamp(0.6rem, 2vw, 1.5rem);
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: clamp(1rem, 2.2vw, 1.25rem);
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.stat-target {
    font-size: 0.7em;
    color: var(--accent-amber);
    display: inline;
}

/* Action Controls Bar */
.game-action-bar {
    display: flex;
    justify-content: center;
    gap: clamp(0.35rem, 1.2vw, 0.75rem);
    flex-shrink: 0;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(0.75rem, 1.5vw, 0.85rem);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Canvas Container */
.game-canvas-container {
    position: relative;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    box-shadow: inset 0 0 32px rgba(0, 0, 0, 0.6);
}

#game-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
}

.hint-overlay {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(139, 92, 246, 0.95);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: clamp(0.75rem, 1.6vw, 0.85rem);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.5);
    white-space: nowrap;
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Virtual Mobile D-Pad */
.virtual-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
    padding: 0.2rem 0;
}

.dpad-row {
    display: flex;
    gap: 0.2rem;
}

.dpad-btn {
    width: clamp(38px, 6vh, 46px);
    height: clamp(38px, 6vh, 46px);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.9rem, 2vh, 1.1rem);
    color: white;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.1s;
}

.dpad-btn:active {
    background: var(--primary);
}

.dpad-center {
    width: clamp(38px, 6vh, 46px);
    height: clamp(38px, 6vh, 46px);
}

/* 10. SCREEN 4: LEVEL EDITOR */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.editor-header-actions {
    display: flex;
    gap: 0.4rem;
}

.editor-palette {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    background: var(--bg-surface);
    padding: 0.4rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    margin-bottom: 0.5rem;
    overflow-x: auto;
    flex-shrink: 0;
}

.palette-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.palette-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.palette-item.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.tile-icon {
    font-size: 1.2rem;
}

.tile-label {
    font-size: 0.65rem;
    font-weight: 700;
    margin-top: 0.1rem;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.editor-toolbar select {
    background: var(--bg-surface);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    outline: none;
}

.editor-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.status-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-amber);
}

.status-valid {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
}

/* 11. SCREEN 5: STATS & ACHIEVEMENTS */
#screen-stats {
    overflow-y: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    backdrop-filter: blur(10px);
}

.stat-card-icon {
    font-size: 1.6rem;
    margin-bottom: 0.2rem;
}

.stat-card-value {
    font-family: var(--font-heading);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 900;
    color: var(--text-main);
}

.stat-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.section-subtitle {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

.achievement-card.locked {
    opacity: 0.45;
    filter: grayscale(0.8);
}

.ach-icon {
    font-size: 1.8rem;
}

.ach-info h4 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
}

.ach-info p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* 12. MODALS & POPUPS */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    position: relative;
    width: min(92vw, 440px);
    max-height: 88dvh;
    overflow-y: auto;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: clamp(1rem, 3vw, 1.75rem);
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-large {
    width: min(94vw, 560px);
}

.pop-anim {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

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

.modal-title {
    font-family: var(--font-heading);
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    font-weight: 800;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: white;
}

.modal-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Victory Popup Special Styling */
.victory-card {
    text-align: center;
    align-items: center;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
    border: 2px solid rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 50px rgba(245, 158, 11, 0.2);
}

.victory-banner {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(1.3rem, 3vw, 1.7rem);
    color: var(--accent-amber);
    letter-spacing: 1px;
}

.stars-display {
    display: flex;
    gap: 0.4rem;
    font-size: clamp(2.2rem, 5vw, 3rem);
    margin: 0.25rem 0;
}

.star {
    animation: starPop 0.5s ease forwards;
}

@keyframes starPop {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

.victory-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
    border-radius: var(--radius-md);
}

.v-stat {
    display: flex;
    flex-direction: column;
}

.v-label {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.v-val {
    font-family: var(--font-heading);
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 800;
}

.highscore-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: var(--accent-rose);
    color: white;
    font-weight: 800;
    font-size: 0.8rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
}

/* Settings Form Controls */
.settings-group {
    margin-bottom: 1rem;
}

.group-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-amber);
    margin-bottom: 0.5rem;
}

.skin-selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.skin-picker label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.skin-picker select {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-body);
    font-size: 0.8rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-emerald);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* How to play tutorial steps */
.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tutorial-step {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.7rem;
    border-radius: var(--radius-md);
}

.t-step-icon {
    font-size: 1.5rem;
}

.t-step-info h4 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
}

.t-step-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

kbd {
    background: #334155;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.7rem;
    color: white;
}

/* Editor XSB Modal */
#editor-xsb-code {
    width: 100%;
    background: #0f172a;
    color: #38bdf8;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    font-family: monospace;
    font-size: 0.8rem;
    margin-top: 0.4rem;
    outline: none;
}

.modal-btn-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.modal-btn-row .btn {
    flex: 1;
}

/* 13. RESPONSIVE BREAKPOINTS & IFRAME COMPATIBILITY */
@media (max-width: 640px) {
    .skin-selector-grid { grid-template-columns: 1fr; }
    .action-btn .action-text { display: none; }
    .action-btn { padding: 0.35rem 0.5rem; }
    .hud-info .badge { display: none; }
}

@media (max-height: 500px) {
    .app-header { height: 40px; }
    .game-hud { padding: 0.25rem 0.5rem; }
    .virtual-dpad { display: none !important; }
}
