/* ================================
   SPACE INVADERS - MODERN REDESIGN
   Futuristic HUD-style layout
   ================================ */

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

html {
    scroll-behavior: smooth;
}

:root {
    /* Light Mode Colors */
    --primary-color: #ff0033;
    --secondary-color: #0066ff;
    --accent-color: #00ffff;
    --bg-primary: #0a0e1a;
    --bg-secondary: #151a2e;
    --bg-panel: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #b0b8cc;
    --border-color: rgba(255, 0, 51, 0.3);
    --glow-primary: rgba(255, 0, 51, 0.5);
    --glow-secondary: rgba(0, 102, 255, 0.5);
    --success-color: #00ff88;
    --warning-color: #ffaa00;
    --danger-color: #ff0033;
}

body.night-mode {
    --primary-color: #ff00ff;
    --secondary-color: #8800ff;
    --accent-color: #00ffff;
    --border-color: rgba(255, 0, 255, 0.4);
    --glow-primary: rgba(255, 0, 255, 0.6);
    --glow-secondary: rgba(136, 0, 255, 0.5);
}

body {
    font-family: 'Rajdhani', 'Orbitron', 'Segoe UI', sans-serif;
    background: 
        radial-gradient(ellipse at top, var(--bg-secondary) 0%, var(--bg-primary) 100%),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 0, 51, 0.03) 3px);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Animated Background Grid */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
    animation: gridScroll 20s linear infinite;
}

@keyframes gridScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(50px); }
}

/* Starfield Background */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 90%, white, transparent);
    background-size: 200% 200%;
    background-position: 0% 0%;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
    animation: starfield 200s linear infinite;
}

@keyframes starfield {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

/* ================================
   COCKPIT HUD HEADER
   ================================ */

.cockpit-hud {
    position: relative;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    gap: clamp(0.25rem, 1vw, 0.5rem);
    padding: clamp(0.2rem, 0.5vh, 0.3rem) clamp(0.4rem, 1.5vw, 0.75rem);
    background: linear-gradient(180deg, var(--bg-secondary) 0%, transparent 100%);
    border-bottom: 2px solid var(--border-color);
    box-shadow: 
        0 4px 20px var(--glow-primary),
        inset 0 -1px 0 var(--glow-primary);
}

/* HUD Left Section */
.hud-left {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: var(--primary-color);
    color: var(--text-primary);
    box-shadow: 0 0 15px var(--glow-primary);
    transform: translateX(-2px);
}

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

.night-mode-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.night-mode-btn:hover {
    box-shadow: 0 0 15px var(--glow-secondary);
    transform: scale(1.05);
}

.mode-icon {
    font-size: 1.5rem;
}

/* HUD Center - Title */
.hud-center {
    display: flex;
    justify-content: center;
}

.title-display {
    text-align: center;
}

.title-main {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    font-weight: 900;
    letter-spacing: 3px;
    color: var(--primary-color);
    text-shadow: 
        0 0 20px var(--glow-primary),
        0 0 40px var(--glow-primary);
    line-height: 1;
    margin-bottom: 0.2rem;
}

.title-sub {
    font-size: clamp(0.5rem, 1vw, 0.7rem);
    letter-spacing: 2px;
    color: var(--accent-color);
    text-transform: uppercase;
    opacity: 0.8;
}

/* HUD Right - Stats */
.hud-right {
    display: flex;
    justify-content: flex-end;
}

.stat-cluster {
    display: flex;
    gap: 0.75rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: clamp(0.15rem, 0.5vw, 0.4rem);
    padding: clamp(0.2rem, 0.5vh, 0.4rem) clamp(0.3rem, 1vw, 0.75rem);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
}

.stat-item.critical {
    border-color: var(--danger-color);
    animation: pulseCritical 2s ease-in-out infinite;
}

@keyframes pulseCritical {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 0, 51, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 0, 51, 0.8); }
}

.stat-icon {
    font-size: clamp(0.65rem, 1.5vw, 1.25rem);
    filter: drop-shadow(0 0 5px var(--glow-primary));
    flex-shrink: 0;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    overflow: hidden;
}

.stat-label {
    font-size: clamp(0.35rem, 0.8vw, 0.6rem);
    letter-spacing: clamp(0.3px, 0.15vw, 1px);
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: clamp(0.55rem, 1.5vw, 1.1rem);
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--glow-primary);
    font-family: 'Orbitron', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ================================
   MAIN GAME CONTAINER
   ================================ */

.game-container {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(220px, 15vw) 1fr minmax(250px, 17vw);
    gap: clamp(0.3rem, 1vw, 0.75rem);
    padding: clamp(0.25rem, 0.5vh, 0.5rem) clamp(0.4rem, 1vw, 0.75rem);
    max-width: 1920px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 1;
    max-height: calc(100vh - clamp(45px, 8vh, 70px));
    overflow: hidden;
}

/* ================================
   LEFT UPGRADES PANEL
   ================================ */

.left-panel {
    position: relative;
}

.panel-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: clamp(0.3rem, 0.8vh, 0.6rem);
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.section-header {
    display: flex;
    align-items: center;
    gap: clamp(0.25rem, 0.7vw, 0.5rem);
    margin-bottom: clamp(0.4rem, 1.2vh, 1rem);
    padding-bottom: clamp(0.35rem, 0.9vh, 0.75rem);
    border-bottom: 1px solid var(--border-color);
}

.section-icon {
    font-size: clamp(1rem, 2vw, 1.5rem);
    filter: drop-shadow(0 0 5px var(--glow-primary));
}

.section-title {
    font-size: clamp(0.65rem, 1.2vw, 0.875rem);
    font-weight: 700;
    letter-spacing: clamp(0.5px, 0.3vw, 2px);
    color: var(--primary-color);
    text-transform: uppercase;
}

.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(0.25rem, 0.7vh, 0.5rem);
    margin-bottom: clamp(0.2rem, 0.5vh, 0.4rem);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    background: rgba(0, 0, 0, 0.4);
    border-left-color: var(--accent-color);
    transform: translateX(3px);
}

.stat-card:last-child {
    margin-bottom: 0;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
    font-family: 'Orbitron', monospace;
    text-shadow: 0 0 10px var(--glow-secondary);
}

/* ================================
   MAIN GAME AREA
   ================================ */

.game-main {
    display: flex;
    flex-direction: column;
    position: relative;
}

.canvas-wrapper {
    position: relative;
    background: #000;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 
        0 0 30px var(--glow-primary),
        0 0 60px var(--glow-primary),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
    max-height: calc(100vh - 90px);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 100px);
    background: linear-gradient(180deg, #000428 0%, #004e92 100%);
}

body.night-mode #gameCanvas {
    background: linear-gradient(180deg, #0d001a 0%, #2d0052 100%);
}

/* Pause Button */
.pause-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--danger-color), var(--primary-color));
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.5),
        0 0 20px var(--glow-primary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-btn:hover {
    transform: scale(1.05);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.6),
        0 0 25px var(--glow-primary);
}

.pause-btn:active {
    transform: scale(0.95);
}

/* Touch Controls */
.touch-controls {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 15px;
    pointer-events: none;
}

.touch-control-btn {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.9), rgba(0, 51, 204, 0.9));
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    color: white;
    font-size: 28px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.5),
        0 0 20px var(--glow-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.touch-control-btn:active {
    transform: scale(0.95);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.5),
        0 0 30px var(--glow-secondary);
}

@media (hover: none) and (pointer: coarse) {
    .touch-controls {
        display: flex;
    }
}

/* Overlay Screens */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(10px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
    background: var(--bg-panel);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 0 40px var(--glow-primary);
}

.overlay h2 {
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--glow-primary);
    margin-bottom: 1rem;
}

.overlay p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ================================
   RIGHT UPGRADE PANEL
   ================================ */

.upgrade-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease;
    position: relative;
    max-height: calc(100vh - 90px);
}

.upgrade-panel.collapsed {
    transform: translateX(100%);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
    border-bottom: 2px solid var(--border-color);
}

.header-icon {
    font-size: 1.25rem;
    filter: drop-shadow(0 0 5px var(--glow-primary));
}

.header-title {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--primary-color);
    text-transform: uppercase;
}

.panel-toggle {
    width: 32px;
    height: 32px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: none;
    align-items: center;
    justify-content: center;
}

.panel-toggle:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px var(--glow-primary);
}

/* Prestige Stats Display */
.prestige-stats-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(0.25rem, 0.7vw, 0.5rem);
    padding: clamp(0.4rem, 1vh, 0.75rem);
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
    border-bottom: 1px solid var(--border-color);
}

.prestige-stat-card {
    display: flex;
    align-items: center;
    gap: clamp(0.25rem, 0.7vw, 0.5rem);
    padding: clamp(0.25rem, 0.7vh, 0.5rem);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stat-card-icon {
    font-size: clamp(1rem, 2vw, 1.5rem);
    filter: drop-shadow(0 0 8px var(--glow-primary));
}

.stat-card-content {
    flex: 1;
}

.stat-card-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

.stat-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--glow-primary);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

/* Tabs */
.tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(0.25rem, 0.7vw, 0.5rem);
    margin-bottom: clamp(0.35rem, 0.9vh, 0.75rem);
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.1rem, 0.3vh, 0.2rem);
    padding: clamp(0.25rem, 0.7vh, 0.5rem) clamp(0.2rem, 0.6vw, 0.4rem);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.5rem, 0.9vw, 0.7rem);
}

.tab-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--primary-color);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 15px var(--glow-primary);
}

.tab-icon {
    font-size: clamp(0.8rem, 1.7vw, 1.25rem);
}

.tab-label {
    font-size: clamp(0.45rem, 0.85vw, 0.65rem);
    letter-spacing: clamp(0.2px, 0.08vw, 0.5px);
    text-transform: uppercase;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Upgrade Items */
.upgrade-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
    padding: clamp(0.3rem, 0.9vh, 0.65rem);
    margin-bottom: clamp(0.25rem, 0.6vh, 0.5rem);
    transition: all 0.3s ease;
}

.upgrade-item:hover {
    background: rgba(0, 0, 0, 0.4);
    border-left-color: var(--accent-color);
    transform: translateX(3px);
    box-shadow: -3px 0 10px rgba(0, 255, 255, 0.2);
}

.upgrade-info {
    margin-bottom: clamp(0.25rem, 0.6vh, 0.5rem);
}

.upgrade-info strong {
    display: block;
    font-size: clamp(0.65rem, 1.2vw, 0.9rem);
    color: var(--primary-color);
    margin-bottom: clamp(0.2rem, 0.5vh, 0.4rem);
    text-shadow: 0 0 10px var(--glow-primary);
}

.upgrade-info p {
    font-size: clamp(0.55rem, 1vw, 0.8rem);
    color: var(--text-secondary);
    margin-bottom: clamp(0.1rem, 0.3vh, 0.2rem);
}

.upgrade-desc {
    font-size: clamp(0.5rem, 0.9vw, 0.7rem) !important;
    font-style: italic;
    opacity: 0.7;
}

.upgrade-buttons {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: clamp(0.25rem, 0.7vw, 0.5rem);
}

.upgrade-btn {
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--danger-color));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upgrade-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--danger-color), var(--primary-color));
    box-shadow: 0 0 20px var(--glow-primary);
    transform: translateY(-2px);
}

.upgrade-btn:active:not(:disabled) {
    transform: translateY(0);
}

.upgrade-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.upgrade-btn-bulk {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    position: relative;
    transition: all 0.3s ease;
}

.upgrade-btn-bulk:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
    box-shadow: 0 0 20px var(--glow-secondary);
}

.upgrade-btn-bulk.shift-active {
    background: linear-gradient(135deg, #ffaa00, #ff0099);
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.6);
    animation: shiftPulse 1.5s ease-in-out infinite;
}

@keyframes shiftPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(255, 170, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 0, 153, 0.8);
    }
}

.prestige-btn {
    background: linear-gradient(135deg, #ffaa00, #ff6600);
}

.prestige-btn:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.5);
}

.cost {
    display: block;
    font-family: 'Orbitron', monospace;
}

/* Prestige Info */
.prestige-info {
    background: rgba(255, 170, 0, 0.1);
    border: 1px solid rgba(255, 170, 0, 0.3);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.prestige-info strong {
    color: #ffaa00;
    font-size: 1.25rem;
}

.prestige-info-small {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Rebirth Info */
.rebirth-info {
    text-align: center;
    padding: 1rem;
}

.rebirth-info h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--glow-primary);
}

.rebirth-info p {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.rebirth-formula {
    font-size: 0.75rem !important;
    font-style: italic;
    opacity: 0.7;
}

.rebirth-keeps {
    color: var(--success-color) !important;
}

.rebirth-lose {
    color: var(--danger-color) !important;
}

.btn-rebirth {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--danger-color));
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-rebirth:hover:not(:disabled) {
    box-shadow: 0 0 30px var(--glow-primary);
    transform: translateY(-3px);
}

.btn-rebirth:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ================================
   BOTTOM CONTROL BAR
   ================================ */

.control-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(0deg, var(--bg-secondary) 0%, transparent 100%);
    border-top: 2px solid var(--border-color);
    box-shadow: 
        0 -4px 20px var(--glow-primary),
        inset 0 1px 0 var(--glow-primary);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.control-bar.open {
    transform: translateY(0);
}

/* Drawer Toggle Button */
.drawer-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 101;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    border: 2px solid var(--border-color);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.5),
        0 0 20px var(--glow-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.drawer-toggle:hover {
    transform: scale(1.1);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.6),
        0 0 30px var(--glow-secondary);
}

.drawer-toggle:active {
    transform: scale(0.95);
}

.drawer-arrow {
    font-size: 1.5rem;
    color: white;
    transition: transform 0.3s ease;
    line-height: 1;
}

.drawer-toggle.open .drawer-arrow {
    transform: rotate(180deg);
}


.control-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-icon {
    font-size: 1.25rem;
}

.control-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.info-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.info-toggle:hover {
    background: var(--secondary-color);
    color: white;
    box-shadow: 0 0 15px var(--glow-secondary);
}

.btn-wipe-small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--danger-color);
    border-radius: 4px;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.btn-wipe-small:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 0 15px var(--glow-primary);
}

/* ================================
   NUMBER REFERENCE DRAWER
   ================================ */

.number-reference-drawer {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: var(--bg-secondary);
    border-top: 2px solid var(--border-color);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 300;
    overflow-y: auto;
}

.number-reference-drawer.open {
    bottom: 0;
}

.drawer-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.drawer-content h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.5rem;
    text-shadow: 0 0 10px var(--glow-primary);
}

.number-ref-table {
    width: 100%;
    border-collapse: collapse;
}

.number-ref-table th {
    background: var(--bg-panel);
    color: var(--primary-color);
    padding: 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
}

.number-ref-table td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.number-ref-table tr:hover {
    background: var(--bg-panel);
}

/* ================================
   BUTTONS & COMMON ELEMENTS
   ================================ */

.btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--danger-color));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.btn:hover {
    box-shadow: 0 0 20px var(--glow-primary);
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--glow-secondary);
}

/* ================================
   MODALS
   ================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 
        0 0 60px var(--glow-primary),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h2 {
    color: var(--primary-color);
    font-size: 1.75rem;
    text-shadow: 0 0 20px var(--glow-primary);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-warning {
    font-size: 1.125rem;
    color: var(--warning-color);
    text-align: center;
    margin-bottom: 1rem;
}

.modal-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.modal-keeps {
    color: var(--success-color);
    margin-bottom: 0.5rem;
    padding-left: 1rem;
}

.modal-lose {
    color: var(--danger-color);
    padding-left: 1rem;
}

.modal-question {
    text-align: center;
    font-size: 1.125rem;
    color: var(--accent-color);
    margin-top: 1rem;
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-btn {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.modal-btn-yes {
    background: linear-gradient(135deg, var(--success-color), #00cc66);
    color: white;
}

.modal-btn-yes:hover {
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
    transform: translateY(-2px);
}

.modal-btn-no {
    background: linear-gradient(135deg, var(--danger-color), var(--primary-color));
    color: white;
}

.modal-btn-no:hover {
    box-shadow: 0 0 20px var(--glow-primary);
    transform: translateY(-2px);
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

/* Tablets and below - Stack layout vertically */
@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 0.5rem;
        padding: 0.5rem;
        max-height: calc(100vh - 65px);
    }
    
    /* Left panel becomes horizontal at top */
    .upgrade-panel.left-panel {
        max-height: none;
        order: -1;
    }
    
    /* Game canvas in middle */
    .game-main {
        order: 0;
    }
    
    /* Right panel slides in from side */
    .upgrade-panel.right-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 90%;
        max-width: 400px;
        z-index: 500;
        transform: translateX(100%);
        border-radius: 0;
        max-height: 100vh;
    }
    
    .upgrade-panel.right-panel.active {
        transform: translateX(0);
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    /* Show toggle button for right panel */
    .panel-toggle {
        display: flex !important;
    }
    
    .canvas-wrapper {
        max-height: calc(45vh - 40px);
    }
    
    #gameCanvas {
        max-height: calc(45vh - 45px);
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .cockpit-hud {
        grid-template-columns: auto 1fr auto;
        gap: 0.25rem;
        padding: 0.25rem 0.4rem;
    }
    
    .title-main {
        font-size: 0.8rem;
        letter-spacing: 1px;
    }
    
    .title-sub {
        font-size: 0.35rem;
        letter-spacing: 0.3px;
    }
    
    .stat-cluster {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.2rem;
    }
    
    .stat-item {
        padding: 0.2rem 0.3rem;
        gap: 0.2rem;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .stat-icon {
        font-size: 0.75rem;
        flex-shrink: 0;
    }
    
    .stat-label {
        font-size: 0.4rem;
    }
    
    .stat-value {
        font-size: 0.65rem;
    }
    
    .back-text {
        display: none;
    }
    
    .game-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        padding: 0.25rem;
        gap: 0.5rem;
        max-height: none;
        overflow-y: auto;
    }
    
    /* Game first (spans both columns), then panels side-by-side */
    .game-main {
        order: 1;
        grid-row: 1;
        grid-column: 1 / -1;
    }
    
    .left-panel {
        order: 2;
        grid-row: 2;
        grid-column: 1;
        max-height: none;
        display: flex !important;
    }
    
    .right-panel {
        order: 3;
        grid-row: 2;
        grid-column: 2;
        position: relative !important;
        transform: none !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none;
    }
    
    .canvas-wrapper {
        max-height: 40vh;
    }
    
    #gameCanvas {
        max-height: 40vh;
    }
    
    /* Hide panel toggle on mobile - panels are always visible and stacked */
    .panel-toggle {
        display: none !important;
    }
    
    .control-bar {
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.25rem 0.4rem;
    }
    
    .control-section {
        gap: 0.25rem;
    }
    
    .control-text {
        font-size: 0.6rem;
    }
    
    .control-text strong {
        display: inline;
    }
    
    .tabs {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem;
    }
    
    .tab-btn {
        padding: 0.3rem 0.2rem;
        gap: 0.2rem;
    }
    
    .tab-icon {
        font-size: 0.9rem;
    }
    
    .tab-label {
        font-size: 0.5rem;
    }
    
    .panel-header {
        padding: 0.4rem;
    }
    
    .header-title {
        font-size: 0.75rem;
    }
    
    .panel-content {
        padding: 0.4rem;
        gap: 0.3rem;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .panel-section {
        padding: 0.4rem;
    }
    
    .section-header {
        margin-bottom: 0.4rem;
        gap: 0.3rem;
    }
    
    .section-title {
        font-size: 0.75rem;
    }
    
    .prestige-stats-display {
        grid-template-columns: 1fr;
        gap: 0.3rem;
        padding: 0.4rem;
    }
    
    .prestige-stat-card {
        padding: 0.3rem;
    }
    
    .stat-card {
        padding: 0.3rem;
        margin-bottom: 0.3rem;
    }
    
    .stat-card-label {
        font-size: 0.55rem;
    }
    
    .stat-card-value {
        font-size: 0.9rem;
    }
    
    .pause-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
        top: 5px;
        right: 5px;
    }
    
    .touch-control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .upgrade-item {
        padding: 0.4rem;
        margin-bottom: 0.3rem;
    }
    
    .upgrade-info strong {
        font-size: 0.75rem;
    }
    
    .upgrade-info p {
        font-size: 0.65rem;
        margin: 0.2rem 0;
    }
    
    .upgrade-cost {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }
    
    .buy-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }
    
    .overlay-content {
        padding: 1rem;
        max-width: 280px;
    }
    
    .overlay h2 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .overlay p {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .cockpit-hud {
        padding: 0.2rem 0.3rem;
        gap: 0.2rem;
    }
    
    .hud-left {
        gap: 0.2rem;
    }
    
    .back-btn {
        padding: 0.25rem 0.3rem;
        font-size: 0.6rem;
    }
    
    .night-mode-btn {
        width: 26px;
        height: 26px;
    }
    
    .mode-icon {
        font-size: 0.9rem;
    }
    
    .title-main {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
    }
    
    .title-sub {
        display: none;
    }
    
    .stat-item {
        padding: 0.2rem 0.25rem;
        gap: 0.15rem;
    }
    
    .stat-icon {
        font-size: 0.65rem;
    }
    
    .stat-label {
        font-size: 0.35rem;
    }
    
    .stat-value {
        font-size: 0.55rem;
    }
    
    .game-container {
        padding: 0.2rem;
        gap: 0.4rem;
        max-height: none;
    }
    
    .canvas-wrapper {
        max-height: 35vh;
    }
    
    #gameCanvas {
        max-height: 35vh;
    }
    
    .panel-header {
        padding: 0.3rem;
    }
    
    .header-title {
        font-size: 0.65rem;
    }
    
    .panel-content {
        padding: 0.3rem;
        gap: 0.25rem;
    }
    
    .panel-section {
        padding: 0.3rem;
    }
    
    .section-header {
        margin-bottom: 0.3rem;
    }
    
    .section-title {
        font-size: 0.65rem;
    }
    
    .upgrade-item {
        padding: 0.3rem;
        margin-bottom: 0.25rem;
    }
    
    .upgrade-info strong {
        font-size: 0.65rem;
        margin-bottom: 0.2rem;
    }
    
    .upgrade-info p {
        font-size: 0.55rem;
        margin: 0.15rem 0;
    }
    
    .upgrade-cost {
        font-size: 0.55rem;
        padding: 0.2rem 0.3rem;
    }
    
    .buy-btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.55rem;
    }
    
    .tab-btn {
        padding: 0.25rem 0.15rem;
        gap: 0.15rem;
    }
    
    .tab-icon {
        font-size: 0.8rem;
    }
    
    .tab-label {
        font-size: 0.45rem;
    }
    
    .pause-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
        top: 4px;
        right: 4px;
    }
    
    .touch-control-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .prestige-stat-card {
        padding: 0.25rem;
    }
    
    .stat-card {
        padding: 0.25rem;
        margin-bottom: 0.25rem;
    }
    
    .stat-card-label {
        font-size: 0.5rem;
    }
    
    .stat-card-value {
        font-size: 0.75rem;
    }
    
    .modal-content {
        padding: 0.75rem;
        max-width: 92%;
    }
    
    .modal-title {
        font-size: 1rem;
    }
    
    .modal-message {
        font-size: 0.7rem;
    }
    
    .modal-btn {
        padding: 0.5rem;
        font-size: 0.65rem;
    }
    
    .control-bar {
        padding: 0.2rem 0.3rem;
        gap: 0.2rem;
    }
    
    .control-text {
        font-size: 0.5rem;
    }
    
    .overlay-content {
        padding: 0.75rem;
        max-width: 200px;
    }
    
    .overlay h2 {
        font-size: 1.2rem;
        margin-bottom: 0.4rem;
    }
    
    .overlay p {
        font-size: 0.65rem;
        margin-bottom: 0.5rem;
    }
}

/* Landscape mobile orientation - optimize for short screens */
@media (max-height: 600px) and (orientation: landscape) {
    .cockpit-hud {
        padding: 0.25rem 0.75rem;
    }
    
    .title-main {
        font-size: 1rem;
    }
    
    .title-sub {
        display: none;
    }
    
    .stat-item {
        padding: 0.25rem 0.5rem;
    }
    
    .control-bar {
        padding: 0.25rem 0.75rem;
    }
    
    .game-container {
        max-height: calc(100vh - 60px);
        padding: 0.35rem;
    }
    
    .canvas-wrapper {
        max-height: calc(100vh - 80px);
    }
    
    #gameCanvas {
        max-height: calc(100vh - 85px);
    }
    
    .upgrade-panel {
        max-height: calc(100vh - 70px);
    }
}

/* ================================
   UTILITY CLASSES
   ================================ */

.hidden {
    display: none !important;
}

/* Scrollbar Styling */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-primary);
}

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

*::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

*::-webkit-scrollbar-thumb:hover {
    background: var(--danger-color);
}

/* Text Selection */
::selection {
    background: var(--primary-color);
    color: white;
}

/* Focus States */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
