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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    transition: background 0.5s ease;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: white;
    overflow: hidden;
}

body.light-mode {
    background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 50%, #bcccdc 100%);
    color: #1a202c;
}

body.light-mode .header { background: rgba(255, 255, 255, 0.95); border-color: #cbd5e0; }
body.light-mode .title { color: #1a202c; }
body.light-mode .level-card { background: rgba(255, 255, 255, 0.9); border-color: #cbd5e0; }
body.light-mode .stat-box { background: rgba(255, 255, 255, 0.95); color: #1a202c; }
body.light-mode .game-area { background: #f7fafc; border-color: rgba(139, 92, 246, 0.5); }
body.light-mode .control-btn { background: rgba(203, 213, 224, 0.9); color: #1a202c; }
body.light-mode .sidebar { background: rgba(255, 255, 255, 0.95); border-color: #cbd5e0; }
body.light-mode .sidebar-item { background: rgba(243, 244, 246, 0.9); border-color: #e5e7eb; }

.header {
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(15px);
    border-bottom: 2px solid #374151;
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.header h1 {
    font-size: 22px;
    color: #a855f7;
    text-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
}

.header-right {
    display: flex;
    gap: 10px;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(168, 85, 247, 0.6);
    background: rgba(55, 65, 81, 0.9);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.15) rotate(5deg);
    border-color: #a855f7;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
}

.main-container {
    display: flex;
    height: calc(100vh - 66px);
}

.content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: rgba(168, 85, 247, 0.6); border-radius: 10px; }

.sidebar {
    width: 280px;
    background: rgba(31, 41, 55, 0.95);
    border-left: 2px solid #374151;
    padding: 20px;
    overflow-y: auto;
}

.sidebar-title {
    font-size: 18px;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 15px;
    text-align: center;
}

.sidebar-item {
    background: rgba(55, 65, 81, 0.8);
    border: 2px solid #374151;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.sidebar-item:hover {
    border-color: #a855f7;
    transform: translateX(-3px);
}

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

.sidebar-item-level {
    font-size: 13px;
    font-weight: bold;
    color: #a855f7;
}

.sidebar-item-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.status-unlocked {
    background: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.status-locked {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.sidebar-item-score {
    font-size: 20px;
    font-weight: bold;
    color: white;
}

.sidebar-item-score.no-score {
    font-size: 14px;
    color: #9ca3af;
}

.menu-screen {
    text-align: center;
    animation: fadeIn 0.6s ease;
}

.title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 8px;
    text-shadow: 0 0 40px rgba(168, 85, 247, 0.9);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.subtitle {
    font-size: 18px;
    color: #d1d5db;
    margin-bottom: 25px;
    opacity: 0.9;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.level-card {
    background: rgba(31, 41, 55, 0.8);
    border: 2px solid #374151;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(168, 85, 247, 0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.5s;
}

.level-card:hover::before {
    left: 100%;
}

.level-card:hover {
    border-color: #a855f7;
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-card.locked:hover {
    transform: none;
    box-shadow: none;
    border-color: #374151;
}

.level-card.locked::before {
    display: none;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    border-radius: 10px;
}

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

.level-title {
    font-size: 15px;
    font-weight: bold;
}

.level-number {
    background: rgba(168, 85, 247, 0.3);
    color: #a855f7;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
}

.level-description {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 5px;
}

.level-best {
    font-size: 11px;
    color: #fbbf24;
    margin-bottom: 10px;
}

.play-button {
    width: 100%;
    padding: 8px;
    background: linear-gradient(135deg, #a855f7, #9333ea);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(168, 85, 247, 0.5);
}

.play-button:disabled {
    background: #4b5563;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.how-to-play {
    background: rgba(31, 41, 55, 0.6);
    border: 2px solid #374151;
    border-radius: 12px;
    padding: 15px;
    margin: 0 auto 15px;
    max-width: 800px;
}

.how-to-play h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #fbbf24;
}

.instructions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 13px;
}

.instruction-item strong {
    color: #a855f7;
    display: block;
    margin-bottom: 3px;
}

.game-screen {
    animation: fadeIn 0.5s ease;
}

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

.game-stats {
    display: flex;
    gap: 10px;
}

.stat-box {
    background: rgba(31, 41, 55, 0.9);
    border: 2px solid #374151;
    border-radius: 10px;
    padding: 6px 14px;
    min-width: 80px;
    transition: all 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(168, 85, 247, 0.3);
}

.stat-label {
    font-size: 10px;
    color: #9ca3af;
    margin-bottom: 3px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
}

.stat-value.purple {
    color: #a855f7;
}

.menu-btn {
    padding: 8px 18px;
    background: rgba(31, 41, 55, 0.9);
    border: 2px solid #374151;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-btn:hover {
    border-color: #a855f7;
    transform: scale(1.05);
}

.game-area {
    position: relative;
    width: 700px;
    height: 500px;
    margin: 0 auto 12px;
    background: #0a0a0a;
    border: 4px solid rgba(168, 85, 247, 0.5);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(168, 85, 247, 0.4);
}

.game-hint {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

.game-hint span {
    color: #a855f7;
    font-weight: bold;
}

.player {
    position: absolute;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    border-radius: 3px;
    box-shadow: 0 0 25px rgba(6, 182, 212, 1);
    transition: none;
    animation: playerGlow 1s ease-in-out infinite;
}

@keyframes playerGlow {
    0%, 100% { box-shadow: 0 0 25px rgba(6, 182, 212, 1); }
    50% { box-shadow: 0 0 35px rgba(6, 182, 212, 1), 0 0 50px rgba(6, 182, 212, 0.5); }
}

.ghost {
    position: absolute;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.8), rgba(147, 51, 234, 0.8));
    border-radius: 3px;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.8);
    transition: none;
    animation: ghostFloat 0.8s ease-in-out infinite;
}

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

.obstacle {
    position: absolute;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
    border-radius: 4px;
    transition: none;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

.gameover-screen {
    text-align: center;
    max-width: 450px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.gameover-box {
    background: rgba(31, 41, 55, 0.95);
    border: 2px solid #374151;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.gameover-icon {
    font-size: 60px;
    margin-bottom: 12px;
    animation: bounce 0.6s ease;
}

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

.gameover-title {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 6px;
}

.gameover-subtitle {
    font-size: 14px;
    color: #9ca3af;
    margin-bottom: 20px;
}

.time-display {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.time-label {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 4px;
}

.time-value {
    font-size: 46px;
    font-weight: bold;
    color: #a855f7;
}

.new-record {
    font-size: 12px;
    color: #fbbf24;
    margin-top: 6px;
    animation: pulse 1s ease-in-out infinite;
}

.level-unlocked {
    font-size: 14px;
    color: #10b981;
    margin-top: 8px;
    font-weight: bold;
}

.gameover-buttons {
    display: flex;
    gap: 8px;
}

.gameover-btn {
    flex: 1;
    padding: 11px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn {
    background: linear-gradient(135deg, #a855f7, #9333ea);
    color: white;
}

.retry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(168, 85, 247, 0.5);
}

.next-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.next-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.5);
}

.next-btn:disabled {
    background: #4b5563;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.menu-btn-gameover {
    background: rgba(31, 41, 55, 0.9);
    border: 2px solid #374151;
    color: white;
}

.menu-btn-gameover:hover {
    border-color: #a855f7;
}

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

.hidden {
    display: none !important;
}

@media (max-width: 1100px) {
    .sidebar { width: 220px; }
}

@media (max-width: 900px) {
    .sidebar { display: none; }
}

@media (max-width: 768px) {
    .title { font-size: 36px; }
    .levels-grid { grid-template-columns: 1fr; }
    .game-area { width: 100%; height: 400px; }
}
