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

body {
    background-color: #0a0a0a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    font-family: 'Press Start 2P', monospace;
}

/* ===== SHARED ===== */
.screen {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
    animation: screenIn 0.5s ease forwards;
    overflow-y: auto;
}

.screen.hiding {
    animation: screenOut 0.5s ease forwards;
    pointer-events: none;
}

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

@keyframes screenOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(1.05); }
}

.big-btn {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 20px auto;
    padding: 16px 0;
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #fff;
    background: #111;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 2px;
    text-transform: lowercase;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.big-btn:hover {
    background: #4CAF50;
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.4), 0 4px 20px rgba(0, 0, 0, 0.4);
    transform: scale(1.03);
}

.big-btn:active { transform: scale(0.97); }

/* ===== TITLE SCREEN ===== */
#title-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

#title-screen.hiding {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

#titleCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#play-btn {
    position: relative;
    z-index: 10;
    padding: 18px 50px;
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    cursor: pointer;
    letter-spacing: 3px;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#play-btn:hover {
    background: rgba(76, 175, 80, 0.85);
    border-color: #4CAF50;
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.5), 0 0 60px rgba(76, 175, 80, 0.2);
    transform: scale(1.08);
}

#play-btn:active { transform: scale(0.95); }

/* ===== INSTRUCTIONS ===== */
.instr-container {
    max-width: 550px;
    width: 90%;
    padding: 30px 20px;
    text-align: left;
}

.instr-header { margin-bottom: 30px; }

.instr-sub {
    display: block;
    font-size: 10px;
    color: #666;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.instr-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(18px, 5vw, 28px);
    color: #fff;
    line-height: 1.4;
}

.instr-sub2 {
    display: inline-block;
    font-size: clamp(14px, 4vw, 20px);
    color: #555;
    margin-top: 4px;
}

.instr-body { margin-bottom: 24px; }

.instr-line {
    font-size: clamp(9px, 2.5vw, 12px);
    color: #bbb;
    line-height: 2.4;
}

.hl-green  { color: #4CAF50; }
.hl-red    { color: #f44336; }
.hl-yellow { color: #FFD600; }
.hl-blue   { color: #42A5F5; text-decoration: underline; text-underline-offset: 3px; }

.sound-note {
    font-size: clamp(10px, 3vw, 14px);
    color: #fff;
    margin-bottom: 28px;
}

.phase-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.phase-btn {
    padding: 10px 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #888;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    text-transform: lowercase;
    letter-spacing: 1px;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.phase-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: #ccc;
}

.phase-btn.selected {
    background: rgba(76, 175, 80, 0.15);
    border-color: #4CAF50;
    color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.15);
}

.phase-btn.completed .phase-check::after {
    content: "✓";
    color: #4CAF50;
    font-size: 10px;
}

.phase-check {
    display: block;
    min-height: 14px;
}

.phase-btn.phase-locked {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: auto;
}

.phase-btn.phase-locked .phase-name {
    text-decoration: line-through;
}

.phase-btn.phase-locked:hover {
    border-color: rgba(255, 255, 255, 0.1);
    color: #888;
}

.phase-desc { text-align: center; min-height: 20px; margin-bottom: 16px; }

#phase-label {
    font-size: 8px;
    color: #666;
    letter-spacing: 0.5px;
}

.hd-link-btn {
    background: rgba(76, 175, 80, 0.15);
    border: 2px solid #4CAF50;
    color: #4CAF50;
    max-width: 280px;
    font-size: 11px;
    margin-top: 8px;
}

.hd-link-btn:hover {
    background: #4CAF50;
    color: #fff;
}

/* ===== GAME ===== */
#game-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas#gameCanvas {
    display: block;
    background-color: #4ec0ca;
    height: 100vh;
    width: auto;
    max-width: 100vw;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

@media (max-aspect-ratio: 9/16) {
    canvas#gameCanvas {
        width: 100vw;
        height: auto;
        max-height: 100vh;
    }
}

/* ===== CHECKPOINT ===== */
#checkpoint-screen {
    z-index: 95;
    flex-direction: column;
    background: #000;
}

.checkpoint-inner {
    width: 90%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.checkpoint-img-wrap {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 4px;
}

.checkpoint-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.checkpoint-text {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(14px, 4vw, 22px);
    color: #f44336;
    text-align: center;
}

/* Slider */
.slider-track {
    position: relative;
    width: 100%;
    max-width: 300px;
    height: 60px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    display: flex;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.slider-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(76, 175, 80, 0.4), rgba(76, 175, 80, 0.7));
    border-radius: 30px;
    z-index: 0;
    transition: width 0.05s linear;
}

.slider-thumb {
    position: absolute;
    left: 4px;
    width: 52px;
    height: 52px;
    background: #fff;
    border-radius: 50%;
    z-index: 3;
    cursor: grab;
    transition: left 0.05s linear;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3), 0 0 20px rgba(76, 175, 80, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-thumb::after {
    content: "▶";
    font-size: 16px;
    color: #4CAF50;
    margin-left: 2px;
}

.slider-thumb:active { cursor: grabbing; }

.slider-label {
    position: absolute;
    width: 100%;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.35);
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0.2) 0%, 
        rgba(255,255,255,0.6) 50%, 
        rgba(255,255,255,0.2) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2.5s ease-in-out infinite;
}

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

/* ===== VIDEO OVERLAY ===== */
#video-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: screenIn 0.3s ease forwards;
}

#video-overlay.hiding {
    animation: screenOut 0.3s ease forwards;
    pointer-events: none;
}

#video-overlay video {
    max-width: 90%;
    max-height: 75vh;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(76, 175, 80, 0.3);
}

#video-close-btn {
    margin-top: 20px;
    padding: 12px 30px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#video-close-btn:hover {
    background: #f44336;
    border-color: #f44336;
}

/* ===== HARD DRIVE ===== */
#harddrive-screen {
    z-index: 90;
    flex-direction: column;
    background: #0a0a0a;
}

.hd-container {
    width: 90%;
    max-width: 480px;
    padding: 30px 16px;
    text-align: center;
}

.hd-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(18px, 5vw, 28px);
    color: #fff;
    margin-bottom: 8px;
}

.hd-sub {
    font-size: 9px;
    color: #666;
    margin-bottom: 30px;
}

/* Grid and card layout */
.hd-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-bottom: 28px;
}

.hd-card {
    width: calc(50% - 7px);
}

/* Rest of the code */
.hd-card-inner {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 14px 14px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 180px;
    justify-content: center;
}

.hd-card-inner.locked { opacity: 0.35; }

.hd-card-inner.unlocked {
    opacity: 1;
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.08);
    cursor: pointer;
}

.hd-card-inner.unlocked:hover {
    background: rgba(76, 175, 80, 0.18);
    transform: scale(1.03);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.2);
}

.hd-card-inner.playing {
    border-color: #4CAF50;
    box-shadow: 0 0 25px rgba(76, 175, 80, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 15px rgba(76, 175, 80, 0.2); }
    50% { box-shadow: 0 0 30px rgba(76, 175, 80, 0.4); }
}

.hd-lock { 
    font-size: 24px; 
    font-family: 'Press Start 2P', monospace;
    opacity: 0.7;
    margin-bottom: 10px;
}

.hd-card-label {
    font-size: 8px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.hd-card-title {
    font-size: 11px;
    color: #fff;
}

.hd-card-cover {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    display: none;
}

.hd-card-inner.locked .hd-card-cover {
    display: none;
}

.hd-card-inner.unlocked .hd-card-cover {
    display: block;
}

/* Hide lock icon when unlocked */
.hd-card-inner.unlocked .hd-lock {
    display: none;
}

/* Hide play arrow when cover exists */
.hd-card-inner.unlocked:has(.hd-card-cover)::before {
    display: none;
}

/* =========================================================
   MODALS (Leaderboard & Highscore)
   ========================================================= */
.modal-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.hs-panel, .lb-inner {
    background: #2a2a2a;
    border: 4px solid #fff;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.hs-title, .lb-header {
    color: #ffd700;
    font-size: 16px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #000;
    line-height: 1.4;
}

.hs-rank {
    font-size: 10px;
    color: #aaa;
}

.hs-input {
    width: 100%;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 14px;
    background: #111;
    color: #4CAF50;
    border: 2px solid #555;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.hs-input:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.lb-list-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
    background: #1a1a1a;
    border: 2px inset #555;
    padding: 10px;
}

.lb-loading {
    text-align: center;
    font-size: 10px;
    padding: 20px;
    color: #888;
}

.lb-row {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 2px dashed #333;
    font-size: 10px;
    color: #ddd;
}
.lb-row:last-child {
    border-bottom: none;
}

.lb-row.top-score {
    color: #ffd700;
    text-shadow: 1px 1px 0 #000;
    background: rgba(255, 215, 0, 0.05);
}

.lb-rank { width: 40px; color: #888; }
.lb-name { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 10px; }
.lb-score { font-weight: bold; color: #4CAF50; }

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}
