/* ====================================
   PARKOREEN - Global Styles
   A multiplayer parkour game
   ==================================== */

/* Custom Fonts */
@font-face {
    font-family: 'Parkoreen Game';
    src: url('/parkoreen/assets/ttf/jersey10.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Tektur';
    src: url('/parkoreen/assets/ttf/tektur.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* CSS Variables */
:root {
    /* Colors */
    --primary: #2d5a27;
    --primary-light: #4a8c3f;
    --primary-dark: #1e3d1a;
    --secondary: #f4a261;
    --secondary-light: #f7c59f;
    --accent: #e76f51;
    --accent-dark: #c45a3f;
    
    /* Neutrals */
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --surface: #252540;
    --surface-light: #353555;
    --text-primary: #eaeaea;
    --text-secondary: #b8b8b8;
    --text-muted: #787878;
    
    /* Game specific */
    --block-default: #787878;
    --spike-default: #c45a3f;
    --text-default: #000000;
    
    /* UI */
    --border-radius: 8px;
    --border-radius-lg: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Z-index layers */
    --z-game: 1;
    --z-editor-ui: 100;
    --z-toolbar: 200;
    --z-panel: 300;
    --z-popup: 400;
    --z-modal: 500;
    --z-toast: 600;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Tektur', 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Ensure all form elements inherit fonts */
input, textarea, select, button {
    font-family: inherit;
}

/* Prevent zoom on mobile */
body.game-active {
    touch-action: manipulation;
}

/* Mobile-specific styles when touch controls are active */
body.touch-active {
    /* Prevent all touch actions on body (scrolling, zooming) */
    touch-action: none;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    /* Prevent text selection */
    -webkit-user-select: none;
    user-select: none;
    /* Prevent callouts (long-press menus) */
    -webkit-touch-callout: none;
}

/* Prevent double-tap zoom on interactive elements */
body.touch-active button,
body.touch-active .touch-btn,
body.touch-active .touch-joystick-base,
body.touch-active canvas {
    touch-action: manipulation;
}

/* Ensure canvas fills viewport on mobile */
@media (max-width: 1024px) {
    #game-canvas {
        touch-action: none;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

a {
    color: var(--secondary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--secondary-light);
}

/* ====================================
   BUTTONS
   ==================================== */
.btn {
    display: inline-flex;
    align-items: center;
    font-family: inherit;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--primary);
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-accent:hover {
    background: var(--accent-dark);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

.btn-icon .material-symbols-outlined {
    font-size: 24px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

.btn-icon.btn-sm .material-symbols-outlined {
    font-size: 18px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ====================================
   FORMS
   ==================================== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--surface);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.3);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.875rem;
}

/* Range slider */
.form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--bg-dark);
    border: 1px solid var(--surface-light);
    border-radius: 4px;
    outline: none;
    margin: 10px 0; /* Add vertical margin for thumb overflow */
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: -5px; /* Center thumb on track */
}

.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background var(--transition);
}

.form-range::-webkit-slider-thumb:hover,
.form-range::-moz-range-thumb:hover {
    background: var(--primary-light);
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

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

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    border: 1px solid var(--surface-light);
    border-radius: 28px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(24px);
    background: white;
}

/* Select / Dropdown */
.form-select {
    appearance: none;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    padding-right: 40px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23b8b8b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center;
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    outline: none;
}

.form-select:focus {
    border-color: var(--primary);
}

/* ====================================
   CARDS & PANELS
   ==================================== */
.card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--surface-light);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.panel {
    position: fixed;
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-panel);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface);
    border-bottom: 1px solid var(--surface-light);
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
}

.panel-body {
    padding: var(--spacing-md);
    max-height: 60vh;
    overflow-y: auto;
}

/* ====================================
   MODAL
   ==================================== */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    z-index: var(--z-toast);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-title {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

/* ====================================
   OBJECT EDIT POPUP
   ==================================== */
.object-edit-popup {
    z-index: var(--z-modal);
}

.object-edit-panel {
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    max-width: 380px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
}

.object-edit-popup.active .object-edit-panel {
    transform: scale(1);
}

.object-edit-panel .panel-header {
    position: sticky;
    top: 0;
    z-index: 1;
}

.object-edit-panel .panel-body {
    max-height: none;
}

.object-edit-panel .color-picker-option {
    display: flex;
    gap: 8px;
    align-items: center;
}

.object-edit-panel .color-preview {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid var(--surface-light);
}

/* ====================================
   TELEPORTAL CONFIG
   ==================================== */
.teleportal-section {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
}

.teleportal-connection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.teleportal-connection-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    background: var(--surface);
    border-left: 4px solid #f87171;
    transition: border-color var(--transition), background var(--transition);
}

.teleportal-connection-item.connected {
    border-left-color: #4ade80;
}

.teleportal-connection-item select {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    background: var(--bg-medium);
    border: 1px solid var(--surface-light);
    border-radius: var(--border-radius);
    color: var(--text-primary);
}

.teleportal-connection-item .remove-connection {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background var(--transition), color var(--transition);
}

.teleportal-connection-item .remove-connection:hover {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

.teleportal-connection-empty {
    padding: 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

.teleportal-connection-item .toggle-connection {
    width: 28px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #f87171;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background var(--transition), color var(--transition);
}

.teleportal-connection-item .toggle-connection.enabled {
    color: #4ade80;
}

.teleportal-connection-item .toggle-connection:hover {
    background: rgba(255, 255, 255, 0.1);
}

.teleportal-connection-item.disabled {
    opacity: 0.5;
    border-left-color: #666 !important;
}

.teleportal-connection-item.disabled select {
    pointer-events: none;
    opacity: 0.6;
}

/* ====================================
   INSPECT BOX (Test Mode)
   ==================================== */
.inspect-box-container {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.inspect-box-container.hidden {
    transform: translateX(calc(-100% + 48px));
}

.inspect-box-container.hidden .inspect-box {
    opacity: 0;
    pointer-events: none;
}

.inspect-box {
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 12px 16px;
    min-width: 200px;
    max-width: 350px;
    font-size: 12px;
    color: #e0e0e0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

.inspect-box-title {
    font-weight: 600;
    font-size: 13px;
    color: #4ade80;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.inspect-box-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inspect-box-row {
    display: flex;
    gap: 8px;
}

.inspect-box-key {
    color: #888;
    min-width: 80px;
    flex-shrink: 0;
}

.inspect-box-value {
    color: #fff;
    word-break: break-word;
}

.inspect-box-empty {
    color: #666;
    font-style: italic;
}

.inspect-toggle-btn {
    position: absolute;
    top: 50%;
    right: -44px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.inspect-toggle-btn:hover {
    background: rgba(40, 40, 50, 0.95);
    color: #fff;
}

.inspect-box-container.hidden .inspect-toggle-btn {
    transform: translateY(-50%) rotate(180deg);
    background: rgba(74, 222, 128, 0.9);
    color: #000;
    border-color: rgba(74, 222, 128, 1);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(74, 222, 128, 0.5);
    right: -52px;
}

.inspect-box-container.hidden .inspect-toggle-btn:hover {
    background: rgba(74, 222, 128, 1);
    box-shadow: 0 3px 16px rgba(74, 222, 128, 0.7);
    transform: translateY(-50%) rotate(180deg) scale(1.1);
}

/* ====================================
   ZONE POPUPS
   ==================================== */
.zone-name-panel,
.zone-edit-panel {
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    max-width: 350px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
}

#zone-name-popup.active .zone-name-panel,
#zone-edit-popup.active .zone-edit-panel {
    transform: scale(1);
}

.zone-adjust-stop {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    display: none;
    gap: 8px;
    align-items: center;
    padding: 12px 20px;
    font-size: 14px;
}

.modal-actions .btn {
    min-width: 120px;
}

/* ====================================
   TOAST NOTIFICATIONS
   ==================================== */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid var(--primary);
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.warning {
    border-left: 4px solid var(--secondary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ====================================
   GAME CANVAS CONTAINER
   ==================================== */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #87CEEB;
}

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Game background */
.game-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

.game-bg.sky {
    background-image: url('/parkoreen/assets/png/bg_sky.png');
}

.game-bg.galaxy {
    background-image: url('/parkoreen/assets/png/bg_galaxy.png');
}

/* ====================================
   EDITOR UI
   ==================================== */
.editor-ui {
    position: fixed;
    z-index: var(--z-editor-ui);
    pointer-events: none;
}

.editor-ui > * {
    pointer-events: auto;
}

/* Corner buttons */
.editor-btn-corner {
    position: fixed;
    z-index: var(--z-editor-ui);
}

.editor-btn-tl { top: var(--spacing-md); left: var(--spacing-md); }
.editor-btn-tr { top: var(--spacing-md); right: var(--spacing-md); }
.editor-btn-bl { bottom: var(--spacing-md); left: var(--spacing-md); }
.editor-btn-br { bottom: var(--spacing-md); right: var(--spacing-md); }

/* Toolbar */
.toolbar {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--spacing-xs);
    background: var(--surface);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-toolbar);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toolbar.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    min-width: 60px;
}

.toolbar-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
    transform: translateY(-2px);
}

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

.toolbar-btn.active {
    background: var(--primary);
    color: white;
}

.toolbar-btn .material-symbols-outlined {
    font-size: 24px;
}

.toolbar-btn-label {
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toolbar-divider {
    width: 1px;
    background: var(--surface-light);
    margin: var(--spacing-xs) var(--spacing-sm);
}

.toolbar-extra {
    display: flex;
    gap: var(--spacing-xs);
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                margin 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
}

.toolbar-extra.expanded {
    max-width: 500px;
    opacity: 1;
    margin-left: var(--spacing-xs);
}

.toolbar-expand-btn {
    padding: var(--spacing-sm) var(--spacing-xs) !important;
    min-width: 32px !important;
    margin-left: var(--spacing-xs);
    transition: background 0.15s ease, transform 0.15s ease;
}

.toolbar-expand-icon {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 20px !important;
}

.toolbar-expand-btn.expanded .toolbar-expand-icon {
    transform: rotate(180deg);
}

/* Selection Toolbar */
.selection-toolbar {
    bottom: var(--spacing-lg);
}

.selection-mouse-toolbar {
    bottom: calc(var(--spacing-lg) + 80px);
}

.sel-toolbar-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.sel-toolbar-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    writing-mode: vertical-lr;
    text-orientation: mixed;
    padding: 0 2px;
}

.sel-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 var(--spacing-sm);
    white-space: nowrap;
    min-width: 70px;
    text-align: center;
}

.sel-cancel-btn {
    background: var(--danger) !important;
    border-color: var(--danger) !important;
}

.sel-done-btn {
    background: #2e7d32 !important;
    border-color: #2e7d32 !important;
    color: #fff !important;
}

.sel-done-btn:hover {
    background: #388e3c !important;
    border-color: #388e3c !important;
}

/* MIXED overlay for multi-edit booleans/selects */
.multi-mixed-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: var(--border-radius);
    cursor: pointer;
    z-index: 2;
    transition: background var(--transition);
}

.multi-mixed-overlay:hover {
    background: rgba(0, 0, 0, 0.4);
}

.multi-mixed-select {
    top: auto;
    bottom: 0;
    height: 36px;
    border-radius: var(--border-radius);
}

/* ====================================
   LAYERS PANEL
   ==================================== */
.layers-panel {
    position: fixed;
    right: var(--spacing-md);
    top: 80px;
    bottom: 80px;
    width: 360px;
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-panel);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.layers-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-xs);
    cursor: grab;
    transition: background var(--transition), transform 0.15s ease, box-shadow 0.15s ease;
}

.layer-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Alternating layer colors for groups */
.layer-item.layer-color-light {
    background: rgba(255, 255, 255, 0.08);
}

.layer-item.layer-color-dark {
    background: rgba(0, 0, 0, 0.15);
}

.layer-item.layer-color-light:hover {
    background: rgba(255, 255, 255, 0.12);
}

.layer-item.layer-color-dark:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Group indicator for overlapping objects */
.layer-group-indicator {
    color: #4CAF50;
    font-size: 8px;
    margin-right: -4px;
}

/* Layer item preview */
.layer-item-preview {
    position: relative;
}

.layer-opacity-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    font-weight: bold;
    color: white;
    text-shadow: 
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
    pointer-events: none;
}

/* Hex input wrapper with # prefix */
.hex-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-dark);
    border: 1px solid var(--surface-light);
    border-radius: var(--border-radius);
    padding-left: 8px;
    overflow: hidden;
}

.hex-prefix {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 14px;
    user-select: none;
}

.hex-input-wrapper .hex-input {
    border: none;
    background: transparent;
    padding-left: 4px;
    font-family: monospace;
    text-transform: uppercase;
    width: 70px;
}

.hex-input-wrapper .hex-input:focus {
    outline: none;
    box-shadow: none;
}

.layer-item:hover {
    background: var(--surface-light);
}

.layer-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.layer-item-name {
    flex: 1;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background var(--transition);
}

.layer-item-name:hover {
    background: rgba(255, 255, 255, 0.1);
}

.layer-item-preview {
    cursor: pointer;
}

.layer-item-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.layer-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.layer-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.layer-btn.active {
    color: var(--primary);
}

.layer-btn .material-symbols-outlined {
    font-size: 18px;
}

/* ====================================
   ADD MENU
   ==================================== */
.add-menu {
    position: fixed;
    left: var(--spacing-md);
    bottom: 80px;
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-panel);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.add-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.add-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition), transform 0.15s ease;
    text-align: left;
}

.add-menu-btn:hover {
    background: var(--surface);
    transform: translateX(4px);
}

.add-menu-btn:active {
    transform: translateX(2px);
}

.add-menu-btn .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-secondary);
}

.add-menu-section {
    margin: var(--spacing-xs) 0;
    padding: var(--spacing-xs) 0;
    border-top: 1px solid var(--surface-light);
    border-bottom: 1px solid var(--surface-light);
}

.add-menu-section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 var(--spacing-md);
    margin-bottom: var(--spacing-xs);
}

.add-menu-section-items {
    display: flex;
    flex-direction: column;
}

/* ====================================
   CONFIG PANEL
   ==================================== */
.config-panel {
    position: fixed;
    left: var(--spacing-md);
    top: 80px;
    width: 480px;
    max-height: calc(100vh - 120px);
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-20px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.config-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    display: flex;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    right: var(--spacing-md);
    top: 80px;
    width: 360px;
    max-height: calc(100vh - 120px);
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.settings-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    display: flex;
}

.config-section {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--surface);
}

.config-section:last-child {
    border-bottom: none;
}

/* Collapsible section styles */
.config-section.collapsible {
    padding: 0;
}

.config-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.config-section-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.config-section-arrow {
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

.config-section.collapsible.expanded .config-section-arrow {
    transform: rotate(180deg);
}

.config-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding: 0 var(--spacing-md);
}

.config-section.collapsible.expanded .config-section-content {
    max-height: 1000px;
    padding: 0 var(--spacing-md) var(--spacing-md);
    transition: max-height 0.4s ease-in, padding 0.3s ease-in;
}

.config-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

/* ====================================
   BLOCK PLACEMENT TOOLBAR
   ==================================== */
.placement-toolbar {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    gap: var(--spacing-sm);
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-toolbar);
    flex-wrap: wrap;
    max-width: 90vw;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.placement-toolbar.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Erase Toolbar */
.erase-toolbar {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: var(--spacing-sm);
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-toolbar);
    flex-wrap: wrap;
    justify-content: center;
}

.erase-toolbar.active {
    display: flex;
}

.placement-option {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 100px;
}

.placement-option-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.placement-option-btns {
    display: flex;
    gap: 2px;
    background: var(--bg-dark);
    padding: 2px;
    border-radius: var(--border-radius);
}

.placement-opt-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all var(--transition);
}

.placement-opt-btn:hover {
    color: var(--text-primary);
}

.placement-opt-btn.active {
    background: var(--primary);
    color: white;
}

/* Color picker option */
.color-picker-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.color-preview {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    border: 2px solid var(--surface-light);
    cursor: pointer;
}

.color-input {
    width: 80px;
    padding: var(--spacing-xs);
    font-size: 0.75rem;
    font-family: monospace;
}

/* ====================================
   COLOR PICKER POPUP
   ==================================== */
.color-picker-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-medium);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-modal) + 10);
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.color-picker-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.color-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.color-picker-title {
    font-size: 1rem;
    font-weight: 600;
}

.color-picker-gradient {
    width: 100%;
    height: 150px;
    background: linear-gradient(to bottom, transparent, black),
                linear-gradient(to right, white, hsl(var(--picker-hue, 0), 100%, 50%));
    border-radius: var(--border-radius);
    cursor: crosshair;
    margin-bottom: var(--spacing-md);
    position: relative;
}

.color-picker-cursor {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.color-picker-hue {
    width: 100%;
    height: 16px;
    background: linear-gradient(to right, 
        #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: var(--spacing-md);
}

.color-picker-preview {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.color-picker-preview-box {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    border: 2px solid var(--surface-light);
}

.color-picker-hex-input {
    flex: 1;
}

/* ====================================
   FONT DROPDOWN
   ==================================== */
.font-dropdown {
    position: relative;
}

.font-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    background: var(--surface);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition);
}

.font-dropdown-trigger:hover {
    border-color: var(--primary);
}

.font-dropdown-menu {
    position: fixed;
    background: var(--bg-medium);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    max-height: 300px;
    width: 200px;
    overflow-y: auto;
    z-index: 99999;
    display: none;
}

.font-dropdown.active .font-dropdown-menu {
    display: block;
}

.font-dropdown-search {
    position: sticky;
    top: 0;
    padding: var(--spacing-sm);
    background: var(--bg-medium);
    border-bottom: 1px solid var(--surface);
}

.font-dropdown-section {
    padding: var(--spacing-sm);
}

.font-dropdown-section-title {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: var(--spacing-xs) var(--spacing-sm);
}

.font-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background var(--transition);
}

.font-dropdown-item:hover {
    background: var(--surface);
}

.font-dropdown-item.font-selected {
    background: var(--primary);
    color: white;
}

.font-dropdown-item-remove {
    opacity: 0;
    transition: opacity var(--transition);
}

.font-dropdown-item:hover .font-dropdown-item-remove {
    opacity: 1;
}

/* ====================================
   TEXTURE DROPDOWN
   ==================================== */
.texture-dropdown {
    position: relative;
}

.texture-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition);
    min-width: 140px;
}

.texture-dropdown-trigger:hover {
    border-color: var(--primary);
}

.texture-dropdown-trigger .material-symbols-outlined {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-muted);
}

.texture-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-medium);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    width: 280px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.texture-dropdown.active .texture-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.texture-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
}

.texture-dropdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;
}

.texture-dropdown-item:hover {
    background: var(--surface);
    transform: scale(1.05);
}

.texture-dropdown-item.selected {
    border-color: var(--primary);
    background: rgba(45, 90, 39, 0.2);
}

.texture-dropdown-item-preview {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    margin-bottom: 6px;
    border: 1px solid var(--surface-light);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.texture-dropdown-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.texture-dropdown-item-name {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
}

.texture-dropdown-item.selected .texture-dropdown-item-name {
    color: var(--primary-light);
    font-weight: 600;
}

/* ====================================
   TOUCHSCREEN CONTROLS - Multi-touch
   ==================================== */
.touch-controls {
    position: fixed;
    z-index: var(--z-editor-ui);
    display: none;
    pointer-events: none;
    /* Prevent any scrolling/zooming while touch controls are active */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.touch-controls.active {
    display: block;
}

/* Joystick Container - Left side, matching SVG position */
.touch-joystick-container {
    position: fixed;
    left: 5%;
    bottom: 8%;
    pointer-events: auto;
    touch-action: none;
}

.touch-joystick-base {
    width: min(150px, 20vw);
    height: min(150px, 20vw);
    background: rgba(255, 255, 255, 0.12);
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    touch-action: none;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
}

.touch-joystick-base.active {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

.touch-joystick-stick {
    width: min(65px, 9vw);
    height: min(65px, 9vw);
    background: rgba(255, 255, 255, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    transition: transform 0.03s ease-out, background 0.15s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    will-change: transform;
}

.touch-joystick-base.active .touch-joystick-stick {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Action Buttons Container - Right side, diagonal layout matching SVG */
.touch-buttons-right {
    position: fixed;
    right: 3%;
    bottom: 8%;
    display: grid;
    grid-template-columns: repeat(2, auto);
    grid-template-rows: repeat(2, auto);
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    touch-action: none;
}

/* Base button style */
.touch-btn {
    width: min(80px, 12vw);
    height: min(80px, 12vw);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    touch-action: none;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 3px solid;
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn .material-symbols-outlined {
    font-size: min(40px, 6vw);
    pointer-events: none;
}

.touch-btn.active {
    transform: scale(0.92);
}

/* Jump Button - Primary action, larger, positioned bottom-right in grid */
.touch-btn.touch-jump {
    width: min(95px, 14vw);
    height: min(95px, 14vw);
    background: rgba(76, 175, 80, 0.25);
    border-color: rgba(76, 175, 80, 0.5);
    grid-column: 2;
    grid-row: 2;
}

.touch-btn.touch-jump .material-symbols-outlined {
    font-size: min(48px, 7vw);
}

.touch-btn.touch-jump.active {
    background: rgba(76, 175, 80, 0.5);
    border-color: rgba(76, 175, 80, 0.8);
}

/* Attack Button - Red/Orange, positioned bottom-left in grid */
.touch-btn.touch-attack {
    width: min(80px, 12vw);
    height: min(80px, 12vw);
    background: rgba(244, 67, 54, 0.25);
    border-color: rgba(244, 67, 54, 0.5);
    grid-column: 1;
    grid-row: 2;
    align-self: end;
}

.touch-btn.touch-attack.active {
    background: rgba(244, 67, 54, 0.5);
    border-color: rgba(244, 67, 54, 0.8);
}

/* Dash Button - Blue, positioned top-right in grid */
.touch-btn.touch-dash {
    width: min(80px, 12vw);
    height: min(80px, 12vw);
    background: rgba(33, 150, 243, 0.25);
    border-color: rgba(33, 150, 243, 0.5);
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
}

.touch-btn.touch-dash.active {
    background: rgba(33, 150, 243, 0.5);
    border-color: rgba(33, 150, 243, 0.8);
}

/* Heal Button - Pink/Magenta, positioned top-left in grid */
.touch-btn.touch-heal {
    width: min(80px, 12vw);
    height: min(80px, 12vw);
    background: rgba(233, 30, 99, 0.25);
    border-color: rgba(233, 30, 99, 0.5);
    grid-column: 1;
    grid-row: 1;
}

.touch-btn.touch-heal.active {
    background: rgba(233, 30, 99, 0.5);
    border-color: rgba(233, 30, 99, 0.8);
}

/* Landscape orientation - compact layout */
@media (orientation: landscape) and (max-height: 500px) {
    .touch-buttons-right {
        bottom: 5%;
        right: 2%;
        gap: 6px;
    }
    
    .touch-joystick-container {
        left: 3%;
        bottom: 5%;
    }
    
    .touch-joystick-base {
        width: min(120px, 25vh);
        height: min(120px, 25vh);
    }
    
    .touch-joystick-stick {
        width: min(50px, 11vh);
        height: min(50px, 11vh);
    }
    
    .touch-btn {
        width: min(60px, 13vh);
        height: min(60px, 13vh);
    }
    
    .touch-btn .material-symbols-outlined {
        font-size: min(28px, 6vh);
    }
    
    .touch-btn.touch-jump {
        width: min(70px, 15vh);
        height: min(70px, 15vh);
    }
    
    .touch-btn.touch-jump .material-symbols-outlined {
        font-size: min(36px, 8vh);
    }
}

/* Small screens - compact layout */
@media (max-width: 400px) {
    .touch-joystick-container {
        left: 3%;
        bottom: 5%;
    }
    
    .touch-joystick-base {
        width: 100px;
        height: 100px;
    }
    
    .touch-joystick-stick {
        width: 42px;
        height: 42px;
    }
    
    .touch-buttons-right {
        right: 2%;
        bottom: 5%;
        gap: 6px;
    }
    
    .touch-btn {
        width: 55px;
        height: 55px;
    }
    
    .touch-btn .material-symbols-outlined {
        font-size: 26px;
    }
    
    .touch-btn.touch-jump {
        width: 65px;
        height: 65px;
    }
    
    .touch-btn.touch-jump .material-symbols-outlined {
        font-size: 32px;
    }
}

/* ====================================
   GAME HUD
   ==================================== */
.game-hud {
    position: fixed;
    z-index: var(--z-editor-ui);
    pointer-events: none;
}

.game-hud > * {
    pointer-events: auto;
}

.hud-btn {
    font-family: inherit;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    color: white;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background var(--transition);
}

.hud-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Players list */
.players-panel {
    position: fixed;
    right: var(--spacing-md);
    bottom: 80px;
    width: 250px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    backdrop-filter: blur(8px);
    display: none;
}

.players-panel.active {
    display: block;
}

.player-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

.player-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.player-name {
    flex: 1;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat */
.chat-panel {
    position: fixed;
    left: var(--spacing-md);
    bottom: 80px;
    width: 300px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    max-height: 300px;
}

.chat-panel.active {
    display: flex;
}

.chat-messages {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.chat-message {
    font-size: 0.875rem;
}

.chat-message-name {
    font-weight: 600;
}

.chat-input-container {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input {
    flex: 1;
    padding: var(--spacing-sm);
    font-family: inherit;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    outline: none;
}

.chat-send {
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    background: var(--primary);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    cursor: pointer;
}

/* ====================================
   DASHBOARD PAGE
   ==================================== */
.page-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-light) 100%);
    overflow-y: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg) var(--spacing-xl);
    flex-shrink: 0;
}

.page-header-left,
.page-header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.page-title {
    font-family: Parkoreen Game;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-content {
    flex: 1;
    padding: 0 var(--spacing-xl) var(--spacing-xl);
}

/* Map grid */
.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.map-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.map-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.map-card-preview {
    height: 140px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.map-card-body {
    padding: var(--spacing-md);
}

.map-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-card-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.map-card-actions .btn {
    flex: 1;
    padding: var(--spacing-sm);
    font-size: 0.875rem;
}

/* ====================================
   AUTH PAGES
   ==================================== */
.auth-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
    padding: var(--spacing-lg);
}

.auth-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.auth-logo h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: var(--spacing-xs);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.auth-footer {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--surface-light);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ====================================
   JOIN PAGE
   ==================================== */
.join-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
    padding: var(--spacing-lg);
    position: relative;
}

.join-back {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
}

.join-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.join-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

/* ====================================
   SETTINGS PAGE
   ==================================== */
.settings-container {
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
    padding: var(--spacing-lg);
    padding-bottom: 80px; /* Space for footer */
    position: relative;
}

.settings-back {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
}

.settings-card {
    max-width: 600px;
    margin: 60px auto 0;
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
}

.settings-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.settings-section {
    margin-bottom: var(--spacing-xl);
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
}

.settings-row-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.settings-volume {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.settings-volume input[type="range"] {
    width: 150px;
}

.settings-volume input[type="number"] {
    width: 60px;
    text-align: center;
}

/* ====================================
   FOOTER
   ==================================== */
.page-footer {
    padding: var(--spacing-lg) var(--spacing-xl);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.github-link {
    display: inline-flex;
    align-items: center;
    opacity: 0.6;
    transition: opacity var(--transition);
}

.github-link:hover {
    opacity: 1;
}

.github-link img {
    width: 20px;
    height: 20px;
    filter: invert(1);
}

/* ====================================
   PIXEL GAME ELEMENTS
   ==================================== */
.pixel {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.pixel-text {
    font-family: 'Parkoreen Game', 'Courier New', monospace;
}

/* Player cube */
.player {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 2px;
    box-shadow: inset -2px -4px 0 rgba(0, 0, 0, 0.3),
                inset 2px 2px 0 rgba(255, 255, 255, 0.2);
}

.player-name {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    padding-top: 4px;
}

/* Game objects */
.game-block {
    position: absolute;
    box-shadow: inset -2px -4px 0 rgba(0, 0, 0, 0.2),
                inset 2px 2px 0 rgba(255, 255, 255, 0.1);
}

.game-spike {
    position: absolute;
}

.game-checkpoint,
.game-spawnpoint,
.game-endpoint {
    position: absolute;
}

/* Grid overlay for editor */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0.3;
}

/* Selection highlight */
.selection-highlight {
    position: absolute;
    border: 2px dashed var(--secondary);
    pointer-events: none;
    background: rgba(244, 162, 97, 0.1);
}

/* ====================================
   LOADING STATES
   ==================================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====================================
   RESPONSIVE
   ==================================== */
@media (max-width: 768px) {
    .toolbar {
        padding: var(--spacing-xs);
        gap: 2px;
        flex-wrap: wrap;
        max-width: calc(100vw - var(--spacing-lg) * 2);
    }
    
    .toolbar-btn {
        min-width: 50px;
        padding: var(--spacing-xs);
    }
    
    .toolbar-btn-label {
        font-size: 0.5rem;
    }
    
    .placement-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .layers-panel,
    .config-panel,
    .settings-panel {
        width: calc(100vw - var(--spacing-md) * 2);
        left: var(--spacing-md);
        right: var(--spacing-md);
    }
    
    .map-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        gap: var(--spacing-md);
    }
}

/* ====================================
   END GAME SCREEN
   ==================================== */
.end-game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.end-game-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 24px;
    padding: 48px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(255, 215, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.end-game-trophy {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FFD700 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 8px 32px rgba(255, 215, 0, 0.4),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    animation: bounce 1s infinite;
}

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

.end-game-trophy .material-symbols-outlined {
    font-size: 56px;
    color: #1a1a2e;
}

.end-game-title {
    font-family: 'Parkoreen Game', 'Jersey 10', monospace;
    font-size: 2.5rem;
    color: #fff;
    margin: 0 0 24px;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.end-game-time {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 20px 32px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.end-game-time-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.end-game-time-value {
    font-family: 'Parkoreen Game', 'Jersey 10', monospace;
    font-size: 3rem;
    color: #4CAF50;
    text-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
    letter-spacing: 4px;
}

.end-game-player {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.end-game-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.end-game-actions .btn {
    min-width: 160px;
    padding: 14px 24px;
    font-size: 1rem;
}

/* ====================================
   UTILITY CLASSES
   ==================================== */
.hidden { display: none !important; }
.visible { display: block !important; }
.flex { display: flex !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
