@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;800;900&family=Rajdhani:wght@500;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Rajdhani', sans-serif;
    background-color: #0b0f19;
    color: #f0f4f8;
}

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 1;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

#ui-container > .screen {
    pointer-events: auto;
}

/* Preloader / Entry Gate */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.95) 0%, rgba(5, 7, 12, 1) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-inner {
    width: min(420px, 84vw);
    text-align: center;
}

.preloader-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 50%, #00c6ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 242, 254, 0.4);
    margin-bottom: 30px;
}

.preloader-track {
    width: 100%;
    height: 12px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
}

.preloader-bar {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #00f2fe 0%, #4facfe 100%);
    box-shadow: 0 0 16px rgba(0, 242, 254, 0.6);
    transition: width 0.2s ease;
}

.preloader-status {
    margin-top: 14px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: #cbd5e1;
}

.preloader-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #64748b;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.85) 0%, rgba(5, 7, 12, 0.95) 100%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 20;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Typography & Banner */
.menu-banner {
    text-align: center;
    margin-bottom: 40px;
}

.menu-banner h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 50%, #00c6ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 242, 254, 0.4);
    margin-bottom: 10px;
}

.menu-banner p {
    font-size: 1.1rem;
    color: #94a3b8;
    letter-spacing: 2px;
}

h2 {
    font-family: 'Orbitron', sans-serif;
    color: #e2e8f0;
    margin-bottom: 18px;
    letter-spacing: 1px;
}

/* Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 300px;
}

.menu-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.menu-btn.primary {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: #0b0f19;
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.3);
}

.menu-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 242, 254, 0.5);
}

.menu-btn.primary.ready-active {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.35);
    color: #042f2e;
}

.menu-btn.secondary {
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-btn.secondary:hover:not(:disabled) {
    background: rgba(51, 65, 85, 0.9);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.back-btn {
    margin-top: 25px;
    width: 200px;
}

/* Level Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    max-width: 850px;
    margin-bottom: 15px;
    padding: 0 20px;
}

.level-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.level-card:hover {
    border-color: #00f2fe;
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 242, 254, 0.2);
}

.level-card h3 {
    font-family: 'Orbitron', sans-serif;
    color: #00f2fe;
    margin-bottom: 8px;
}

.level-card p {
    color: #94a3b8;
    font-size: 0.85rem;
}

/* Lobby Layout */
.lobby-header {
    width: 90%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 12px;
    gap: 16px;
}

.lobby-header h2 {
    margin-bottom: 0;
}

.lobby-header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.conn-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 1px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    text-transform: uppercase;
}

.conn-badge.online {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(52, 211, 153, 0.35);
}

.conn-badge.offline {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(248, 113, 113, 0.3);
}

.lobby-status-text {
    color: #94a3b8;
    font-size: 0.9rem;
}

.error-banner {
    width: 90%;
    max-width: 1000px;
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(127, 29, 29, 0.55);
    border: 1px solid rgba(248, 113, 113, 0.45);
    color: #fecaca;
    font-weight: 600;
}

.lobby-layout {
    display: flex;
    width: 90%;
    max-width: 1000px;
    height: 68vh;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
}

.lobby-sidebar {
    width: 300px;
    padding: 24px;
    background: rgba(10, 15, 30, 0.9);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-hint {
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.4;
    margin-top: 4px;
}

.sidebar-hint strong {
    color: #00f2fe;
}

.lobby-main {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

.lobby-main-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input, .form-group select {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px 12px;
    color: #ffffff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #00f2fe;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 30;
}

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

.modal-content {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 30px;
    width: 380px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal-buttons button {
    flex: 1;
}

/* Waiting Room */
.waiting-header {
    text-align: center;
    margin-bottom: 6px;
}

.waiting-container {
    display: flex;
    width: min(820px, 92vw);
    gap: 20px;
    margin-top: 10px;
}

.players-box {
    flex: 1;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 18px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.players-box h3 {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 10px;
    text-transform: uppercase;
}

#waiting-players-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

#waiting-players-list li {
    background: rgba(30, 41, 59, 0.6);
    padding: 10px 14px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.player-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-name {
    font-weight: 700;
    font-size: 1rem;
    color: #f8fafc;
}

.player-skin {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
}

.player-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.tag {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 0.8px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.tag.host {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(251, 191, 36, 0.35);
}

.tag.you {
    color: #bae6fd;
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(56, 189, 248, 0.35);
}

.tag.ready {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(52, 211, 153, 0.35);
}

.tag.wait {
    color: #cbd5e1;
    background: rgba(100, 116, 139, 0.18);
    border-color: rgba(148, 163, 184, 0.25);
}

.ready-summary {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    font-weight: 600;
}

.room-controls {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.room-meta-block, .host-settings {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px;
}

.meta-line {
    color: #cbd5e1;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.room-id-line code {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: #7dd3fc;
}

.link-btn {
    border: none;
    background: transparent;
    color: #00f2fe;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    margin-left: 6px;
    text-decoration: underline;
}

.room-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.room-toast {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(0, 242, 254, 0.35);
    color: #e0f2fe;
    padding: 8px 14px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 40;
    font-weight: 600;
}

.room-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.badge {
    background: rgba(0, 242, 254, 0.15);
    color: #00f2fe;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Customize Menu */
.customize-layout {
    display: flex;
    gap: 30px;
    width: 800px;
    margin-bottom: 20px;
}

.customize-options {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.skin-section {
    min-height: 0;
}

.skin-section-title {
    color: #94a3b8;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 1.2px;
    margin: 0 0 7px 4px;
    text-transform: uppercase;
}

.skin-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    max-height: 166px;
    overflow-y: auto;
    padding: 4px;
}

.skin-card {
    width: 80px;
    height: 80px;
    background: #1e293b;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    padding: 0;
    appearance: none;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Texture layer shown once ready; fades in over the spinner background */
.skin-card-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.skin-card-img.loaded {
    opacity: 1;
}

.skin-card-label {
    display: none;
}

.skin-card.active, .skin-card:hover {
    border-color: #00f2fe;
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.6);
    z-index: 2;
}

/* Loading Spinner for Texture Cards */
.skin-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #00f2fe;
    border-radius: 50%;
    animation: skin-spin 0.8s linear infinite;
}

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

.customize-preview {
    width: 280px;
    background: rgba(10, 15, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#preview-viewport {
    width: 100%;
    height: 220px;
}

.preview-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 10px;
}

/* Settings & Credits */
.settings-form {
    width: 420px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-item label {
    font-size: 0.9rem;
    color: #94a3b8;
}

.credits-content {
    width: 450px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    line-height: 1.5;
    color: #94a3b8;
    margin-bottom: 20px;
}

.credits-content strong {
    color: #00f2fe;
    font-size: 1.2rem;
    font-family: 'Orbitron', sans-serif;
}

/* In-Game HUD */
.hud-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
}

.hud-layer.active {
    display: block;
}

.hud-top {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
}

.hud-box {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 16px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.hud-label {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
    letter-spacing: 1px;
}

.hud-box span:not(.hud-label) {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #00f2fe;
}

.hud-bottom-right {
    position: absolute;
    bottom: 20px;
    right: 20px;
    pointer-events: auto;
    z-index: 25;
}

/* Pause button — top right corner */
.pause-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    pointer-events: auto;
    z-index: 25;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    font-size: 1.2rem;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
}

.hud-btn {
    font-family: 'Orbitron', sans-serif;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hud-btn:hover {
    background: rgba(0, 242, 254, 0.2);
    border-color: #00f2fe;
}

/* MOBILE TOUCH CONTROLS (Dual Thumbsticks & Jump Button)
   Hidden on desktop — only shown when .mobile class is added */
#touch-controls-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 20;
}

#touch-controls-overlay.mobile {
    display: block;
}

.thumbstick-zone {
    position: absolute;
    bottom: 30px;
    width: 140px;
    height: 140px;
    pointer-events: auto;
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

#thumbstick-left {
    left: 30px;
}

#thumbstick-right-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 140px;
    height: 190px;
    pointer-events: none;
}

#thumbstick-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 140px;
    height: 140px;
    pointer-events: auto;
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.thumbstick-base {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.thumbstick-thumb {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.5);
    position: absolute;
    transform: translate(0px, 0px);
    transition: transform 0.05s linear;
}

/* Smaller button above the right stick, offset to the right */
.jump-touch-btn {
    position: absolute;
    top: 0px;
    right: 5px;
    width: 72px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    border: 2px solid rgba(52, 211, 153, 0.5);
    color: #ffffff;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    pointer-events: auto;
    touch-action: none;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    z-index: 25;
}

.jump-touch-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.victory-content {
    text-align: center;
}

.victory-stats {
    background: rgba(30, 41, 59, 0.6);
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 1.2rem;
}

.victory-stats span {
    font-family: 'Orbitron', sans-serif;
    color: #00f2fe;
}

/* Lobby Item Row */
.lobby-row {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
    transition: border-color 0.15s ease;
}

.lobby-row:hover {
    border-color: rgba(0, 242, 254, 0.25);
}

.lobby-info h4 {
    font-family: 'Orbitron', sans-serif;
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 4px;
}

.lobby-info p {
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 0.75rem;
}

.join-btn {
    width: auto !important;
    min-width: 88px;
    padding: 8px 14px;
    font-size: 0.8rem;
}

.placeholder-text {
    text-align: center;
    color: #64748b;
    margin-top: 40px;
}

@media (max-width: 900px) {
    .lobby-layout {
        flex-direction: column;
        height: auto;
        max-height: 75vh;
    }

    .lobby-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .waiting-container {
        flex-direction: column;
    }

    .room-controls {
        width: 100%;
    }

    .menu-banner h1 {
        font-size: 2.2rem;
    }

    .grid-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .customize-layout {
        flex-direction: column;
        width: 92vw;
        align-items: center;
    }

    .customize-options {
        width: 100%;
        max-width: 420px;
    }

    .skin-grid {
        grid-template-columns: repeat(4, 1fr);
        max-height: 300px;
    }

    .skin-card {
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto;
    }
}

/* ============================================================
   MAP FORGE EDITOR
   ============================================================ */
#map-editor {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #070a12;
    z-index: 25;
    display: none;
    opacity: 1;
    visibility: visible;
    flex-direction: column;
    overflow: hidden;
}
#map-editor.active { display: flex; }

.ed-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 14px;
    background: linear-gradient(180deg, #131a2b 0%, #0d1320 100%);
    border-bottom: 1px solid rgba(0, 242, 254, 0.18);
    box-shadow: 0 2px 14px rgba(0,0,0,0.5);
    flex: 0 0 auto;
    gap: 12px;
}
.ed-top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ed-logo {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    letter-spacing: 2px;
    font-size: 1.05rem;
    color: #00f2fe;
    text-shadow: 0 0 14px rgba(0,242,254,0.45);
    white-space: nowrap;
}
.ed-mapname {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0;
    border-radius: 6px;
    padding: 7px 12px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    width: 220px;
}
.ed-mapname:focus { outline: none; border-color: #00f2fe; }
.ed-top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-tbtn {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(30,41,59,0.7);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.ed-tbtn:hover { border-color: #00f2fe; color: #fff; background: rgba(45,58,82,0.9); }
.ed-tbtn.play { background: linear-gradient(135deg,#34d399,#10b981); color:#042f2e; border:none; }
.ed-tbtn.play:hover { box-shadow: 0 0 16px rgba(16,185,129,0.5); }
.ed-tbtn.danger:hover { border-color:#f87171; color:#fecaca; background: rgba(127,29,29,0.4); }

.ed-body { flex: 1 1 auto; display: grid; grid-template-columns: 64px 230px 1fr 290px; min-height: 0; }

/* Tool rail */
.ed-toolbar {
    background: linear-gradient(180deg,#0e1422 0%,#0a0f1a 100%);
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 0;
}
.ed-tool {
    width: 50px; height: 50px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(30,41,59,0.55);
    color: #cbd5e1;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: all 0.15s ease;
    position: relative;
}
.ed-tool span { font-size: 0.55rem; font-family:'Rajdhani'; letter-spacing:0.5px; margin-top:2px; }
.ed-tool:hover { border-color:#00f2fe; color:#fff; background: rgba(45,58,82,0.8); }
.ed-tool.active {
    border-color:#00f2fe;
    background: linear-gradient(135deg, rgba(0,242,254,0.25), rgba(79,172,254,0.15));
    color:#fff;
    box-shadow: 0 0 12px rgba(0,242,254,0.35) inset;
}
.ed-tool-sep { width: 60%; height: 1px; background: rgba(255,255,255,0.08); margin: 6px 0; }

/* Catalog */
.ed-catalog {
    background: linear-gradient(180deg,#0e1422 0%,#0a0f1a 100%);
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex; flex-direction: column; min-height: 0;
}
.ed-catalog-tabs {
    display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 10px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ed-tab {
    font-family:'Rajdhani'; font-weight:700; font-size: 0.72rem; letter-spacing:0.5px;
    padding: 5px 9px; border-radius: 6px; cursor: pointer;
    background: rgba(30,41,59,0.6); color:#94a3b8; border:1px solid transparent;
    text-transform: uppercase;
}
.ed-tab:hover { color:#e2e8f0; }
.ed-tab.active { background: rgba(0,242,254,0.18); color:#fff; border-color: rgba(0,242,254,0.4); }
.ed-catalog-list { flex:1 1 auto; overflow-y:auto; padding: 10px; display:flex; flex-direction:column; gap:8px; }
.ed-catalog-foot { padding: 8px 10px; border-top:1px solid rgba(255,255,255,0.06); }
.ed-cat-hint { font-size: 0.72rem; color:#64748b; line-height:1.35; }
.ed-undo-row { display:flex; gap:6px; margin-top:8px; }
.ed-mini {
    flex:1; font-family:'Rajdhani'; font-weight:700; font-size:0.78rem;
    padding: 6px; border-radius:6px; cursor:pointer;
    background: rgba(30,41,59,0.7); color:#cbd5e1; border:1px solid rgba(255,255,255,0.1);
}
.ed-mini:hover { color:#fff; border-color:#00f2fe; }
.ed-mini:disabled { opacity:0.4; cursor:default; }

/* Catalog piece cards */
.ed-piece {
    display:flex; align-items:center; gap:10px;
    padding: 9px 10px; border-radius: 9px; cursor: pointer;
    background: rgba(30,41,59,0.5); border:1px solid rgba(255,255,255,0.06);
    transition: all 0.15s ease;
}
.ed-piece:hover { border-color:#00f2fe; background: rgba(45,58,82,0.7); transform: translateX(2px); }
.ed-piece.active { border-color:#00f2fe; box-shadow: 0 0 10px rgba(0,242,254,0.3); }
.ed-piece-ico {
    width: 34px; height: 34px; border-radius: 8px; flex:0 0 auto;
    display:flex; align-items:center; justify-content:center; font-size:1.1rem;
    background: radial-gradient(circle at 30% 30%, rgba(0,242,254,0.25), rgba(30,41,59,0.6));
    border:1px solid rgba(255,255,255,0.1);
}
.ed-piece-meta { min-width:0; }
.ed-piece-name { font-weight:700; font-size:0.85rem; color:#e2e8f0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ed-piece-desc { font-size:0.68rem; color:#64748b; line-height:1.2; }

/* Viewport */
.ed-viewport { position: relative; background:#070a12; overflow:hidden; }
#editor-canvas { display:block; width:100%; height:100%; }
.ed-view-hint {
    position:absolute; top:12px; left:50%; transform:translateX(-50%);
    background: rgba(15,23,42,0.85); border:1px solid rgba(0,242,254,0.3);
    color:#cbeffd; font-size:0.8rem; font-weight:600; letter-spacing:0.3px;
    padding:7px 14px; border-radius:999px; pointer-events:none; opacity:0;
    transition: opacity 0.2s ease; max-width:80%; text-align:center;
}
.ed-view-hint.show { opacity:1; }
.ed-selinfo {
    position:absolute; bottom:12px; left:12px;
    background: rgba(15,23,42,0.85); border:1px solid rgba(255,255,255,0.1);
    color:#cbd5e1; font-size:0.74rem; padding:6px 10px; border-radius:8px;
    pointer-events:none; display:none;
}
.ed-selinfo.show { display:block; }
.ed-axis-legend { position:absolute; top:12px; right:12px; display:flex; gap:6px; pointer-events:none; }
.ed-axis-legend .ax {
    width:20px; height:20px; border-radius:5px; display:flex; align-items:center; justify-content:center;
    font-family:'Orbitron'; font-size:0.65rem; font-weight:700;
}
.ed-axis-legend .x { background:rgba(239,68,68,0.25); color:#fca5a5; }
.ed-axis-legend .y { background:rgba(34,197,94,0.25); color:#86efac; }
.ed-axis-legend .z { background:rgba(59,130,246,0.25); color:#93c5fd; }

/* Properties */
.ed-props {
    background: linear-gradient(180deg,#0e1422 0%,#0a0f1a 100%);
    border-left: 1px solid rgba(255,255,255,0.06);
    display:flex; flex-direction:column; min-height:0;
}
.ed-props-head {
    display:flex; justify-content:space-between; align-items:center;
    padding: 12px 14px; border-bottom:1px solid rgba(255,255,255,0.06);
    font-family:'Orbitron'; font-size:0.85rem; color:#e2e8f0; letter-spacing:0.5px;
}
.ed-props-id { font-family:'Rajdhani'; font-size:0.72rem; color:#00f2fe; }
.ed-props-body { flex:1 1 auto; overflow-y:auto; padding: 12px 14px; }
/* ── Viewport cursors for gizmo handles ──────────────────────── */
.ed-viewport.cursor-grab { cursor: grab; }
.ed-viewport.cursor-grab:active { cursor: grabbing; }

/* ── Properties: Is Solid toggle ─────────────────────────────── */
.ed-solid-field { padding-bottom: 4px; }
.ed-checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    font-weight: 700;
    color: #dbe6f5;
    letter-spacing: 0.02em;
}
.ed-checkline input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 5px;
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    background: rgba(10, 16, 30, 0.85);
    cursor: pointer;
    position: relative;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.ed-checkline input[type="checkbox"]:hover { border-color: rgba(0, 242, 254, 0.55); }
.ed-checkline input[type="checkbox"]:checked {
    background: linear-gradient(145deg, #00f2fe, #22d3ee);
    border-color: #00f2fe;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.45);
}
.ed-checkline input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5.5px; top: 1.5px;
    width: 4px; height: 9px;
    border: solid #04121c;
    border-width: 0 2.4px 2.4px 0;
    transform: rotate(43deg);
}
.ed-hint-sm {
    margin-top: 5px;
    font-size: 0.68rem;
    line-height: 1.35;
    color: #8ea3bd;
    letter-spacing: 0.01em;
}

.ed-empty { color:#64748b; font-size:0.85rem; text-align:center; margin-top: 30px; line-height:1.5; }

.ed-field { margin-bottom: 13px; }
.ed-field > label {
    display:block; font-size:0.72rem; color:#94a3b8; text-transform:uppercase;
    letter-spacing:0.6px; margin-bottom:5px; font-weight:700;
}
.ed-field .row { display:flex; align-items:center; gap:8px; }
.ed-input, .ed-select {
    width:100%; background: rgba(0,0,0,0.35); border:1px solid rgba(255,255,255,0.12);
    color:#e2e8f0; border-radius:6px; padding:7px 9px; font-family:'Rajdhani'; font-size:0.9rem;
}
.ed-input:focus, .ed-select:focus { outline:none; border-color:#00f2fe; }
.ed-range { width:100%; }
.ed-range-val { font-size:0.78rem; color:#7dd3fc; min-width:46px; text-align:right; font-weight:700; }
.ed-color { width:40px; height:30px; padding:0; border:1px solid rgba(255,255,255,0.2); border-radius:6px; background:none; cursor:pointer; }
.ed-check { width:18px; height:18px; accent-color:#00f2fe; cursor:pointer; }
.ed-section-title {
    font-family:'Orbitron'; font-size:0.72rem; color:#00f2fe; letter-spacing:1px;
    text-transform:uppercase; margin: 16px 0 8px; padding-bottom:5px;
    border-bottom:1px solid rgba(0,242,254,0.2);
}
.ed-section-title:first-child { margin-top:0; }

/* Texture & effect chips */
.ed-chip-row { display:flex; flex-wrap:wrap; gap:5px; }
.ed-chip {
    width:34px; height:34px; border-radius:7px; cursor:pointer; position:relative;
    border:1px solid rgba(255,255,255,0.12); background-size:cover; background-position:center;
    overflow:hidden; transition: all 0.12s ease;
}
.ed-chip:hover { border-color:#00f2fe; transform: scale(1.06); }
.ed-chip.active { border-color:#00f2fe; box-shadow:0 0 8px rgba(0,242,254,0.6); }
.ed-chip .swatch { position:absolute; inset:0; }
.ed-chip.none::after { content:'∅'; position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#64748b; font-size:0.9rem; }
.ed-desc { font-size:0.8rem; color:#94a3b8; line-height:1.45; }
.ed-tagrow { display:flex; flex-wrap:wrap; gap:5px; margin-top:8px; }
.ed-tag { font-size:0.66rem; padding:3px 8px; border-radius:999px; background:rgba(0,242,254,0.12); color:#7dd3fc; border:1px solid rgba(0,242,254,0.25); text-transform:uppercase; letter-spacing:0.5px; }
.ed-tooltip-inline { font-size:0.74rem; color:#7dd3fc; background:rgba(0,242,254,0.08); border:1px solid rgba(0,242,254,0.2); border-radius:8px; padding:8px 10px; margin-top:6px; line-height:1.4; }

.ed-btn {
    font-family:'Rajdhani'; font-weight:700; font-size:0.85rem;
    padding:9px 14px; border-radius:7px; cursor:pointer; border:1px solid rgba(255,255,255,0.12);
    background: rgba(30,41,59,0.7); color:#cbd5e1; transition:all 0.15s ease;
}
.ed-btn:hover { color:#fff; border-color:#00f2fe; }
.ed-btn.primary { background: linear-gradient(135deg,#00f2fe,#4facfe); color:#04222b; border:none; }
.ed-btn.primary:hover { box-shadow:0 0 14px rgba(0,242,254,0.5); }
.ed-btn.danger { color:#fecaca; }
.ed-btn.danger:hover { border-color:#f87171; }

/* Status bar */
.ed-statusbar {
    display:flex; align-items:center; gap:18px; height:30px; padding:0 14px;
    background:#0a0f1a; border-top:1px solid rgba(255,255,255,0.06);
    font-size:0.74rem; color:#94a3b8; flex:0 0 auto;
}
.ed-statusbar .ed-st.grow { margin-left:auto; text-align:right; }
.ed-statusbar .ed-st b { color:#7dd3fc; }

/* Modals */
.ed-modal {
    position:absolute; inset:0; background: rgba(3,5,10,0.7);
    display:none; align-items:center; justify-content:center; z-index:40;
    backdrop-filter: blur(3px);
}
.ed-modal.open { display:flex; }
.ed-modal-box {
    width: min(440px, 92vw); max-height: 84vh; overflow:hidden;
    background:#0e1422; border:1px solid rgba(0,242,254,0.25); border-radius:14px;
    display:flex; flex-direction:column; box-shadow:0 20px 60px rgba(0,0,0,0.6);
}
.ed-modal-head {
    display:flex; justify-content:space-between; align-items:center;
    padding:14px 16px; border-bottom:1px solid rgba(255,255,255,0.08);
    font-family:'Orbitron'; font-size:0.95rem; color:#e2e8f0; letter-spacing:0.5px;
}
.ed-x { background:none; border:none; color:#94a3b8; font-size:1rem; cursor:pointer; }
.ed-x:hover { color:#fff; }
.ed-modal-body { padding:16px; overflow-y:auto; }
.ed-modal-foot { display:flex; gap:10px; padding:14px 16px; border-top:1px solid rgba(255,255,255,0.08); }
.ed-modal-foot .ed-btn { flex:1; }

/* File list rows */
.ed-file-row {
    display:flex; align-items:center; gap:10px; padding:9px 11px; margin-bottom:7px;
    background: rgba(30,41,59,0.5); border:1px solid rgba(255,255,255,0.08); border-radius:8px;
}
.ed-file-row .fn { flex:1; font-weight:700; color:#e2e8f0; font-size:0.88rem; }
.ed-file-row .fm { font-size:0.7rem; color:#64748b; }
.ed-file-actions { display:flex; gap:6px; }
.ed-sm { font-size:0.72rem; padding:5px 9px; border-radius:6px; cursor:pointer;
    background: rgba(30,41,59,0.8); border:1px solid rgba(255,255,255,0.12); color:#cbd5e1; }
.ed-sm:hover { color:#fff; border-color:#00f2fe; }

/* Floating tooltip */
.ed-tooltip {
    position:fixed; z-index:60; pointer-events:none; display:none;
    max-width:260px; background: rgba(8,12,22,0.97); border:1px solid rgba(0,242,254,0.4);
    border-radius:9px; padding:10px 12px; box-shadow:0 8px 26px rgba(0,0,0,0.6);
}
.ed-tooltip.show { display:block; }
.ed-tooltip .tt-title { font-family:'Orbitron'; font-size:0.8rem; color:#00f2fe; margin-bottom:5px; letter-spacing:0.5px; }
.ed-tooltip .tt-body { font-size:0.78rem; color:#cbd5e1; line-height:1.4; }
.ed-tooltip .tt-row { font-size:0.72rem; color:#7dd3fc; margin-top:5px; }

/* Gizmo cursor feedback */
.ed-viewport.cursor-place { cursor: copy; }
.ed-viewport.cursor-terrain { cursor: cell; }
.ed-viewport.cursor-zipline { cursor: crosshair; }
.ed-viewport.cursor-grab { cursor: grab; }
.ed-viewport.cursor-grabbing { cursor: grabbing; }

/* Save toast */
.ed-toast {
    position:absolute; bottom:46px; left:50%; transform:translateX(-50%) translateY(8px);
    background: rgba(15,23,42,0.96); border:1px solid rgba(0,242,254,0.4); color:#e0f2fe;
    padding:9px 16px; border-radius:999px; font-weight:700; font-size:0.85rem;
    opacity:0; pointer-events:none; transition: all 0.25s ease; z-index:50;
}
.ed-toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* Scrollbars */
.ed-catalog-list::-webkit-scrollbar, .ed-props-body::-webkit-scrollbar, .ed-modal-body::-webkit-scrollbar { width:8px; }
.ed-catalog-list::-webkit-scrollbar-thumb, .ed-props-body::-webkit-scrollbar-thumb, .ed-modal-body::-webkit-scrollbar-thumb {
    background: rgba(0,242,254,0.25); border-radius:8px;
}

@media (max-width: 1024px) {
    .ed-body { grid-template-columns: 56px 190px 1fr 240px; }
    .ed-mapname { width: 140px; }
    .ed-logo { font-size: 0.85rem; }
}
@media (max-width: 760px) {
    .ed-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .ed-toolbar { flex-direction: row; height:auto; padding:6px; overflow-x:auto; }
    .ed-catalog { border-right:none; border-bottom:1px solid rgba(255,255,255,0.06); max-height:160px; }
    .ed-props { display:none; }
}
