/* CSS Variables */
:root {
    --bg-dark: #0a0a1a;
    --bg-medium: #12122a;
    --bg-elevated: #1a1a3a;
    --grid-line: #1a1a3a;
    --neon-cyan: #00ffff;
    --neon-magenta: #ff00ff;
    --neon-yellow: #ffff00;
    --neon-red: #ff3366;
    --neon-green: #00ff66;
    --neon-blue: #3366ff;
    --neon-orange: #ff9933;
    --neon-purple: #9933ff;
    --text-primary: #ffffff;
    --text-secondary: #88ccff;
    --text-muted: #667788;
    --glow-intensity: 0.8;
    
    /* iOS-style timing functions */
    --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    touch-action: manipulation;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    height: 100%;
    max-width: 500px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
}

/* ==================== SCREENS & TRANSITIONS ==================== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    padding: env(safe-area-inset-top, 20px) 20px env(safe-area-inset-bottom, 20px);
    opacity: 0;
    will-change: transform, opacity;
}

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

/* iOS-style slide animations */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0.8; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-30%); opacity: 0.5; }
}

@keyframes slideInLeft {
    from { transform: translateX(-30%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}

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

/* ==================== MAIN MENU ==================== */
#main-menu {
    justify-content: center;
    align-items: center;
    position: relative;
}

.menu-content {
    z-index: 1;
    text-align: center;
}

.game-title {
    font-size: 3rem;
    font-weight: 200;
    letter-spacing: 0.3em;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.title-light {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
    animation: pulse-glow 2s ease-in-out infinite;
}

.title-cycle {
    color: var(--neon-magenta);
    text-shadow: 0 0 10px var(--neon-magenta), 0 0 20px var(--neon-magenta), 0 0 40px var(--neon-magenta);
    animation: pulse-glow 2s ease-in-out infinite 0.5s;
}

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

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    margin-bottom: 50px;
    opacity: 0.8;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 260px;
}

/* Grid Background Animation */
.grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.3;
    animation: grid-move 20s linear infinite;
}

@keyframes grid-move {
    0% { transform: perspective(500px) rotateX(60deg) translateY(0); }
    100% { transform: perspective(500px) rotateX(60deg) translateY(40px); }
}

/* ==================== BUTTONS ==================== */
.neon-button {
    padding: 16px 32px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s var(--spring-smooth);
    text-transform: uppercase;
    border-radius: 8px;
}

.neon-button:hover, .neon-button:active {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4), inset 0 0 20px rgba(0, 255, 255, 0.05);
    transform: scale(0.98);
}

.neon-button.primary {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.neon-button.primary:hover, .neon-button.primary:active {
    background: rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.5);
}

.neon-button.danger {
    border-color: var(--neon-red);
    color: var(--neon-red);
}

.neon-button.danger:hover, .neon-button.danger:active {
    background: rgba(255, 51, 102, 0.15);
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.4);
}

/* ==================== SCREEN HEADER ==================== */
.screen-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0 25px;
}

.screen-header h2 {
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
}

.back-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--spring-smooth);
    border-radius: 12px;
}

.back-btn:hover, .back-btn:active {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
    transform: scale(0.95);
}

/* ==================== LEVEL SELECT ==================== */
.level-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 10px 5px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.level-grid::-webkit-scrollbar {
    display: none;
}

.level-tile {
    aspect-ratio: 1;
    background: rgba(0, 255, 255, 0.05);
    border: 2px solid var(--grid-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--spring-smooth);
    position: relative;
    border-radius: 12px;
    padding: 8px;
}

.level-tile:active {
    transform: scale(0.95);
}

.level-tile:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.25);
}

.level-tile.completed {
    border-color: var(--neon-green);
    background: rgba(0, 255, 102, 0.08);
}

.level-tile.completed:hover {
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.3);
}

.level-tile.locked {
    opacity: 0.35;
    cursor: not-allowed;
}

.level-tile.locked:active {
    transform: none;
}

.level-tile .level-number {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.level-tile .level-name {
    font-size: 0.55rem;
    color: rgba(0, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
    text-align: center;
}

.level-tile.completed .level-name {
    color: rgba(0, 255, 102, 0.7);
}

.level-tile.locked .level-name {
    color: rgba(100, 100, 100, 0.4);
}

.level-tile .level-stars {
    font-size: 0.7rem;
    margin-top: 4px;
    color: var(--neon-yellow);
}

/* Level Pack Tiles */
.level-tile.level-pack {
    border-width: 3px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.1) 100%);
    position: relative;
    overflow: hidden;
}

.level-tile.level-pack::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--pack-color, #00ffff) 0%, transparent 70%);
    opacity: 0.1;
    pointer-events: none;
}

.level-tile.level-pack:hover {
    border-color: var(--pack-color, #00ffff);
    box-shadow: 0 0 20px color-mix(in srgb, var(--pack-color, #00ffff) 40%, transparent);
}

.level-tile.level-pack .pack-desc {
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
    text-transform: none;
    letter-spacing: normal;
}

.level-tile.back-button {
    border-color: #666;
    background: rgba(100, 100, 100, 0.1);
}

.level-tile.back-button:hover {
    border-color: #888;
    box-shadow: 0 0 10px rgba(150, 150, 150, 0.2);
}

.level-tile.back-button .level-number {
    font-size: 1.8rem;
}

/* ==================== TUTORIAL / HOW TO PLAY ==================== */
.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
}

.tutorial-step {
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid var(--grid-line);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-radius: 16px;
}

.tutorial-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

.tutorial-step h3 {
    color: var(--neon-cyan);
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 0.08em;
    font-size: 1rem;
}

.tutorial-step p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9rem;
}

/* ==================== SETTINGS ==================== */
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid var(--grid-line);
    border-radius: 12px;
}

.setting-item span {
    font-size: 0.95rem;
}

/* iOS-style Toggle */
.toggle {
    position: relative;
    width: 56px;
    height: 32px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    transition: 0.3s var(--spring-smooth);
    border-radius: 16px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    transition: 0.3s var(--spring-bounce);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toggle input:checked + .toggle-slider {
    background: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

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

/* ==================== GAME SCREEN ==================== */
#game-screen {
    padding-top: env(safe-area-inset-top, 10px);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.level-info {
    text-align: center;
    flex: 1;
}

#current-level-name {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--neon-cyan);
    letter-spacing: 0.1em;
    text-shadow: 0 0 10px var(--neon-cyan);
}

.icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s var(--spring-smooth);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active {
    background: rgba(0, 255, 255, 0.15);
    transform: scale(0.95);
}

#game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    min-height: 0;
}

#game-canvas {
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.1);
}

/* ==================== GAME CONTROLS ==================== */

/* Secondary toolbar - compact icon row */
.secondary-toolbar {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 0 4px;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 255, 255, 0.4);
    background: rgba(0, 20, 40, 0.6);
    color: var(--neon-cyan);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tool-btn:active {
    transform: scale(0.92);
    background: rgba(0, 255, 255, 0.15);
}

.tool-btn .hint-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--neon-cyan);
    color: #000;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 8px;
    min-width: 14px;
}

.tool-btn.active {
    background: rgba(0, 255, 255, 0.25);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.4);
}

#eraser-btn.active {
    background: rgba(255, 100, 100, 0.25);
    border-color: #ff6666;
    box-shadow: 0 0 12px rgba(255, 100, 100, 0.4);
}

#hint-btn.active {
    background: rgba(255, 255, 0, 0.2);
    border-color: #ffff00;
    box-shadow: 0 0 12px rgba(255, 255, 0, 0.4);
}

/* Main game controls */
.game-controls {
    display: flex;
    gap: 12px;
    padding: 8px 0 12px;
    align-items: stretch;
}

.control-btn {
    flex: 1;
    padding: 16px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    cursor: pointer;
    transition: all 0.15s var(--spring-smooth);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.control-btn:active {
    background: rgba(0, 255, 255, 0.1);
    transform: scale(0.97);
}

.control-btn.primary {
    flex: 1.5;
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
    font-size: 1rem;
}

.control-btn.primary:active {
    background: rgba(0, 255, 255, 0.25);
}

.control-btn.primary.running {
    background: rgba(255, 100, 100, 0.2);
    border-color: #ff6666;
    color: #ff6666;
    box-shadow: 0 0 20px rgba(255, 100, 100, 0.3);
}

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

.level-message {
    text-align: center;
    min-height: 24px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 8px 0;
    font-weight: 400;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-medium);
    border: 2px solid var(--neon-cyan);
    padding: 35px 40px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.25);
    animation: modal-appear 0.4s var(--spring-bounce);
    border-radius: 20px;
}

@keyframes modal-appear {
    from {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: var(--neon-cyan);
    font-size: 1.8rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--neon-cyan);
}

.stars {
    font-size: 2.2rem;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.stars .star {
    display: inline-block;
    animation: starPop 0.4s var(--spring-bounce) forwards;
    opacity: 0;
    transform: scale(0);
}

@keyframes starPop {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-buttons .neon-button {
    min-width: 120px;
    padding: 14px 24px;
}

/* ==================== CONFETTI CANVAS ==================== */
#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 20px) + 100px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.85);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s var(--spring-bounce);
    z-index: 2000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
    max-width: 85%;
}

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

/* ==================== CONTEXT MENU ==================== */
.context-menu {
    position: fixed;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid var(--neon-cyan);
    border-radius: 12px;
    padding: 8px 0;
    z-index: 1500;
    min-width: 180px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: contextAppear 0.2s var(--spring-bounce);
}

@keyframes contextAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-item {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.context-item:active {
    background: rgba(0, 255, 255, 0.15);
}

.context-item.danger {
    color: var(--neon-red);
}

/* ==================== CONFIRM DIALOG ==================== */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.2s;
}

.confirm-dialog.active {
    opacity: 1;
}

.confirm-content {
    background: var(--bg-medium);
    border: 2px solid var(--neon-cyan);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    max-width: 85%;
    animation: modal-appear 0.3s var(--spring-bounce);
}

.confirm-content h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 10px;
}

.confirm-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-buttons .neon-button {
    padding: 12px 24px;
    font-size: 0.85rem;
}

/* ==================== RESPONSIVE ==================== */
@media (max-height: 650px) {
    .game-title {
        font-size: 2.2rem;
    }
    
    .tagline {
        margin-bottom: 30px;
        font-size: 0.85rem;
    }
    
    .menu-buttons {
        gap: 10px;
    }
    
    .neon-button {
        padding: 12px 24px;
    }
    
    .game-controls {
        padding: 8px 0;
    }
    
    .control-btn {
        padding: 12px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 350px) {
    .game-title {
        font-size: 2rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .modal-content {
        padding: 25px 20px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .neon-button {
        width: 100%;
    }
}

/* Large screens / tablets */
@media (min-width: 500px) {
    #game-container {
        border-radius: 20px;
        margin: 20px;
        height: calc(100% - 40px);
        box-shadow: 0 0 50px rgba(0, 255, 255, 0.15);
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== NEW FEATURES ==================== */

/* Timer Display */
.timer-display {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.85rem;
    color: var(--neon-cyan);
    margin-left: 10px;
    opacity: 0.9;
    min-width: 60px;
    text-align: right;
}

.timer-display:empty {
    display: none;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
}

.level-info {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

/* Daily Challenge Tile */
.level-tile.daily-challenge {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(255, 153, 51, 0.2) 100%);
    border-color: var(--neon-orange);
    position: relative;
    overflow: hidden;
}

.level-tile.daily-challenge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 40%, rgba(255, 153, 51, 0.1) 50%, transparent 60%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.level-tile.daily-challenge .level-number {
    font-size: 1.5rem;
}

.level-tile.daily-challenge.completed {
    border-color: var(--neon-green);
}

.level-tile.daily-challenge.completed::before {
    background: linear-gradient(45deg, transparent 40%, rgba(0, 255, 102, 0.1) 50%, transparent 60%);
}

/* Level Time Display */
.level-time {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Settings Section */
.settings-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--grid-line);
}

.settings-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.shortcut-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 5px 0;
    line-height: 1.6;
}

/* Share Button */
#share-level-btn {
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Colorblind Indicator */
.colorblind-label {
    position: absolute;
    font-weight: bold;
    font-size: 10px;
    color: white;
    text-shadow: 0 0 3px black;
    pointer-events: none;
}

/* Streak Fire Effect */
.streak-fire {
    animation: fireGlow 1s ease-in-out infinite alternate;
}

@keyframes fireGlow {
    from { text-shadow: 0 0 5px rgba(255, 153, 51, 0.5); }
    to { text-shadow: 0 0 15px rgba(255, 153, 51, 0.8), 0 0 25px rgba(255, 102, 0, 0.5); }
}

/* ==================== FREE DRAW MODE INDICATOR ==================== */
.draw-mode-indicator {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    z-index: 10;
}

.draw-mode-indicator:active {
    transform: translateY(-50%) scale(0.95);
}

.draw-mode-indicator.auto-path-active {
    background: linear-gradient(135deg, rgba(51, 102, 255, 0.3), rgba(51, 102, 255, 0.1));
    border: 1px solid rgba(51, 102, 255, 0.5);
    color: var(--neon-blue);
}

.draw-mode-indicator.free-draw-active {
    background: linear-gradient(135deg, rgba(0, 255, 102, 0.3), rgba(0, 255, 102, 0.1));
    border: 1px solid rgba(0, 255, 102, 0.5);
    color: var(--neon-green);
    animation: freeDrawPulse 2s ease-in-out infinite;
}

@keyframes freeDrawPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(0, 255, 102, 0.3); }
    50% { box-shadow: 0 0 15px rgba(0, 255, 102, 0.6); }
}

/* Tooltip hint on hover */
.draw-mode-indicator::after {
    content: 'Tap to toggle';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.draw-mode-indicator:hover::after {
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .draw-mode-indicator {
        right: 60px;
        padding: 3px 8px;
        font-size: 0.6rem;
    }
    
    .draw-mode-indicator::after {
        display: none;
    }
}


/* Back Tile - used in level pack view */
.level-tile.back-tile {
    border-color: #666;
    background: linear-gradient(135deg, rgba(100, 100, 100, 0.2) 0%, rgba(50, 50, 50, 0.1) 100%);
}

.level-tile.back-tile:hover {
    border-color: var(--pack-color, #888);
    box-shadow: 0 0 15px color-mix(in srgb, var(--pack-color, #888) 30%, transparent);
}

.level-tile.back-tile .level-number {
    font-size: 1.5rem;
}

.level-tile.back-tile .level-stars {
    color: var(--pack-color, #888);
    font-size: 0.6rem;
}

/* Pack completion badge */
.level-tile.level-pack.completed::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 1rem;
    color: var(--neon-green);
}

/* Enhanced pack tiles with color border */
.level-tile.level-pack {
    border-color: color-mix(in srgb, var(--pack-color, #00ffff) 60%, transparent);
}


/* Cloud Sync Indicator */
.sync-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--neon-cyan);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.8rem;
    display: none;
    align-items: center;
    gap: 5px;
    z-index: 1000;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sync-indicator:hover {
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.sync-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* ==================== CINEMATIC REPLAY ==================== */
#cinema-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 100;
}

#cinema-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.cinema-bars {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.cinema-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 40px;
    background: #000;
    transition: height 0.5s ease;
}

.cinema-bar.top {
    top: 0;
}

.cinema-bar.bottom {
    bottom: 0;
}

#cinema-overlay.active .cinema-bar {
    height: 50px;
}

.cinema-label {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
    opacity: 0;
    animation: cinemaLabelFade 3s ease forwards;
}

@keyframes cinemaLabelFade {
    0% { opacity: 0; }
    10% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

.cinema-skip {
    position: absolute;
    bottom: 8px;
    right: 15px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.7);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.cinema-skip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    color: #fff;
}

/* Replay button in modal */
#replay-btn {
    background: linear-gradient(135deg, #1a1a3a 0%, #0a0a2a 100%);
    border-color: #ff00ff;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

#replay-btn:hover {
    background: linear-gradient(135deg, #2a1a4a 0%, #1a0a3a 100%);
    box-shadow: 0 0 25px rgba(255, 0, 255, 0.5);
}


/* ==================== COMMUNITY LEVELS ==================== */

.community-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 15px;
    flex-wrap: wrap;
}

.community-tab {
    background: transparent;
    border: 1px solid rgba(0, 255, 255, 0.3);
    color: rgba(0, 255, 255, 0.7);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.community-tab:hover {
    border-color: rgba(0, 255, 255, 0.6);
    color: #0ff;
}

.community-tab.active {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 255, 255, 0.1));
    border-color: #0ff;
    color: #0ff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.community-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    margin: 5px 0 10px 0;
    padding: 0 15px;
}

.community-level {
    position: relative;
}

.community-level .creator-name {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

.community-level .level-stats {
    display: block;
    font-size: 0.75rem;
    color: rgba(0, 255, 255, 0.7);
    margin-top: 4px;
}

.loading-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: rgba(0, 255, 255, 0.7);
    font-size: 0.9rem;
}

.empty-community {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
}

.empty-community p {
    margin: 10px 0;
}

/* Publish button styling */
#publish-level-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.3s ease;
}

#publish-level-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ============================================
   THEMES & SKINS SYSTEM
   ============================================ */

.theme-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--grid-line, #1a1a3a);
}

.theme-section h3 {
    color: var(--accent, #00ffff);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px 0;
    font-weight: 600;
}

.theme-picker {
    margin-bottom: 16px;
}

.theme-picker label {
    display: block;
    color: var(--text-secondary, #88ccff);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 500;
}

.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-medium, #12122a);
    border: 2px solid var(--grid-line, #1a1a3a);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 0;
    flex-shrink: 0;
}

.theme-option:hover:not(.locked) {
    border-color: var(--accent, #00ffff);
    background: var(--bg-elevated, #1a1a3a);
    transform: translateY(-1px);
}

.theme-option.selected {
    border-color: var(--accent, #00ffff);
    background: var(--bg-elevated, #1a1a3a);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.theme-option.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.theme-option.locked:hover {
    border-color: var(--grid-line, #1a1a3a);
    transform: none;
}

.theme-icon {
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.theme-name {
    color: var(--text-secondary, #88ccff);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.theme-option.selected .theme-name {
    color: var(--accent, #00ffff);
}

.theme-lock {
    color: var(--text-muted, #667788);
    font-size: 0.65rem;
    white-space: nowrap;
    margin-left: auto;
}

/* Mobile adjustments for theme pickers */
@media (max-width: 480px) {
    .theme-options {
        gap: 6px;
    }
    
    .theme-option {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
    
    .theme-icon {
        font-size: 1rem;
    }
    
    .theme-name {
        font-size: 0.7rem;
    }
}

