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

body {
    font-family: 'Courier New', monospace;
    background: #0a0a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* Main Screen */
.main-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.main-screen.hidden {
    display: none;
}

.main-screen-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(0, 242, 254, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(79, 172, 254, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(245, 87, 108, 0.05) 0%, transparent 60%),
        #0a0a1a;
    animation: bgPulse 6s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(30deg); }
}

.main-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 24px;
    animation: mainIn 0.6s ease;
}

@keyframes mainIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-title {
    font-size: 3.2em;
    font-weight: bold;
    letter-spacing: 6px;
    background: linear-gradient(90deg, #00f2fe, #4facfe, #f093fb, #00f2fe);
    background-size: 300% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
    filter: drop-shadow(0 0 30px rgba(79, 172, 254, 0.4));
}

.main-subtitle {
    color: rgba(79, 172, 254, 0.5);
    font-size: 0.85em;
    letter-spacing: 8px;
    margin-top: 4px;
    margin-bottom: 32px;
}

.main-cube-wrap {
    position: relative;
    height: 64px;
    margin-bottom: 24px;
}

.main-cube {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    border-radius: 6px;
    box-shadow: 0 0 24px rgba(0, 242, 254, 0.5);
    animation: cubeBounce 0.55s ease-in-out infinite alternate, cubeSpin 4s linear infinite;
}

@keyframes cubeBounce {
    from { transform: translateY(0) rotate(0deg); }
    to { transform: translateY(-18px) rotate(90deg); }
}

@keyframes cubeSpin {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(60deg); }
}

.main-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.btn-play {
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    color: #0a0a1a;
    padding: 14px 40px;
    font-size: 1.05em;
}

.btn-play:hover {
    box-shadow: 0 0 30px rgba(79, 172, 254, 0.5);
    transform: scale(1.05);
}

.btn-shop {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 14px 28px;
    font-size: 1.05em;
}

.btn-shop:hover {
    box-shadow: 0 0 24px rgba(245, 87, 108, 0.45);
    transform: scale(1.05);
}

.btn-wave {
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    color: #0a0a1a;
    padding: 14px 28px;
    font-size: 1.05em;
}

.btn-wave:hover {
    box-shadow: 0 0 24px rgba(161, 140, 209, 0.5);
    transform: scale(1.05);
}

#mainScreen .btn-sound {
    margin-bottom: 20px;
}

.main-hint {
    color: rgba(79, 172, 254, 0.35);
    font-size: 0.75em;
}

.btn-menu {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-menu:hover {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.1);
}

.overlay-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

/* Cube Shop */
.shop-screen {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 15, 0.92);
    backdrop-filter: blur(6px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.shop-screen.hidden {
    display: none;
}

.shop-panel {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(79, 172, 254, 0.3);
    border-radius: 16px;
    padding: 24px;
    max-width: 520px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.shop-title {
    font-size: 1.6em;
    color: #4facfe;
    letter-spacing: 3px;
}

.shop-coins {
    color: #ffd700;
    font-size: 1.2em;
    font-weight: bold;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 8px;
    padding: 6px 14px;
}

.cube-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.cube-card {
    background: rgba(79, 172, 254, 0.06);
    border: 2px solid rgba(79, 172, 254, 0.2);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cube-card:hover {
    border-color: rgba(79, 172, 254, 0.5);
    transform: translateY(-2px);
}

.cube-card.equipped {
    border-color: #00f2fe;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.25);
}

.cube-card.locked {
    opacity: 0.75;
}

.cube-preview {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 14px rgba(0, 242, 254, 0.35);
}

.cube-name {
    color: #fff;
    font-size: 0.85em;
    font-weight: bold;
    margin-bottom: 6px;
}

.cube-action {
    font-size: 0.75em;
    letter-spacing: 1px;
}

.cube-action.equipped { color: #00f2fe; }
.cube-action.buy { color: #ffd700; }
.cube-action.free { color: rgba(255, 255, 255, 0.5); }

.shop-panel > .btn-menu {
    width: 100%;
}

/* Color Palette */
.palette-section {
    border-top: 1px solid rgba(79, 172, 254, 0.2);
    padding-top: 18px;
    margin-bottom: 16px;
}

.palette-title {
    color: rgba(79, 172, 254, 0.8);
    font-size: 0.75em;
    letter-spacing: 3px;
    text-align: center;
    margin-bottom: 12px;
}

.palette-slots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.palette-slot {
    flex: 1;
    max-width: 140px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid rgba(79, 172, 254, 0.25);
    background: rgba(79, 172, 254, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Courier New', monospace;
    font-size: 0.75em;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.palette-slot.active {
    border-color: #00f2fe;
    color: #00f2fe;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.2);
}

.palette-preview-cube {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 18px rgba(0, 242, 254, 0.35);
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.palette-swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.palette-swatch:hover {
    transform: scale(1.12);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.25);
}

.palette-swatch.selected-primary {
    border-color: #fff;
    box-shadow: 0 0 0 2px #00f2fe;
}

.palette-swatch.selected-secondary {
    border-color: #fff;
    box-shadow: 0 0 0 2px #f5576c;
}

.palette-reset {
    font-size: 0.8em;
    padding: 8px;
    margin-bottom: 0;
}

.game-container {
    background: transparent;
    border-radius: 0;
    padding: 12px;
    box-shadow: none;
    max-width: 900px;
    width: 95%;
}

.game-container.hidden {
    display: none;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.title {
    font-size: 1.8em;
    font-weight: bold;
    background: linear-gradient(90deg, #00f2fe, #4facfe, #00f2fe);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.stats-row {
    display: flex;
    gap: 12px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(79, 172, 254, 0.08);
    border: 1px solid rgba(79, 172, 254, 0.2);
    border-radius: 8px;
    padding: 4px 16px;
}

.stat-label {
    color: rgba(79, 172, 254, 0.6);
    font-size: 0.65em;
    letter-spacing: 2px;
}

.stat-value {
    color: #fff;
    font-size: 1.3em;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

.level-name {
    text-align: center;
    color: rgba(0, 242, 254, 0.65);
    font-size: 0.8em;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.complete-all {
    color: #ffd700 !important;
    font-size: 1.05em !important;
    margin: 8px 0 12px !important;
}

.canvas-wrap {
    position: relative;
}

#gameCanvas {
    width: 100%;
    height: 420px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: block;
    cursor: pointer;
}

.controls {
    margin-top: 14px;
    text-align: center;
}

.control-info {
    color: rgba(79, 172, 254, 0.5);
    font-size: 0.8em;
    margin-bottom: 10px;
}

.key {
    background: rgba(79, 172, 254, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(79, 172, 254, 0.25);
    color: rgba(79, 172, 254, 0.7);
    font-size: 0.85em;
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn {
    padding: 10px 28px;
    font-size: 0.95em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.btn-start {
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    color: #0a0a1a;
}

.btn-start:hover {
    box-shadow: 0 0 20px rgba(79, 172, 254, 0.4);
}

.btn-restart {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.btn-restart:hover {
    box-shadow: 0 0 20px rgba(245, 87, 108, 0.4);
}

.btn-sound {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-sound:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-sound.active {
    color: #00f2fe;
    border-color: rgba(0, 242, 254, 0.3);
}

/* Overlays */
.overlay {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(5, 5, 15, 0.96);
    padding: 40px 50px;
    border-radius: 16px;
    text-align: center;
    z-index: 100;
    border: 2px solid rgba(79, 172, 254, 0.3);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
    animation: overlayIn 0.3s ease;
}

@keyframes overlayIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.overlay-title {
    font-size: 2.2em;
    color: #4facfe;
    margin-bottom: 16px;
    letter-spacing: 3px;
}

.overlay-title.complete {
    color: #00f2fe;
    text-shadow: 0 0 30px rgba(0, 242, 254, 0.6);
}

.overlay-title.dead {
    color: #f5576c;
    text-shadow: 0 0 30px rgba(245, 87, 108, 0.5);
}

.overlay-rick {
    color: rgba(0, 242, 254, 0.7);
    font-size: 0.95em;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.overlay-stat {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1em;
    margin: 6px 0;
}

.hl {
    color: #fff;
    font-weight: bold;
}

.attempt-line {
    margin-top: 12px;
    color: rgba(79, 172, 254, 0.4);
    font-size: 0.9em;
}

.wave-stat .hl {
    color: #f093fb;
}

/* Score popup */
.score-popup {
    position: fixed;
    color: #00f2fe;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1em;
    pointer-events: none;
    z-index: 200;
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
    animation: popUp 0.8s ease forwards;
}

@keyframes popUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(1.3); }
}

/* Mobile */
@media (max-width: 600px) {
    .main-title { font-size: 2em; letter-spacing: 3px; }
    .main-subtitle { letter-spacing: 4px; font-size: 0.75em; }
    .main-stats { gap: 12px; }
    .main-stat { padding: 6px 16px; min-width: 80px; }
    .btn-play { padding: 12px 28px; font-size: 1em; }
    .btn-wave { padding: 12px 18px; font-size: 0.9em; }
    .btn-shop { padding: 12px 20px; font-size: 0.9em; }
    .cube-grid { grid-template-columns: repeat(2, 1fr); }
    .palette-grid { grid-template-columns: repeat(4, 1fr); }
    .shop-panel { padding: 16px; }
    .game-container { padding: 12px; }
    .title { font-size: 1.2em; }
    #gameCanvas { height: 300px; }
    .header { flex-direction: column; gap: 8px; }
    .btn { padding: 8px 18px; font-size: 0.85em; }
}
