/* style.css - Vocab Invaders styling */

:root {
    --bg-dark: #0a0a1a;
    --primary: #00f0ff;
    /* Cyan neon */
    --secondary: #ff003c;
    /* Red neon */
    --accent: #7000ff;
    /* Purple neon */
    --text-main: #e0e0e0;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Parallax Star Background --- */
#stars,
#stars2,
#stars3 {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: transparent;
}

/* A simple CSS representation of a starry background. 
   In production you'd use a box-shadow generator for multiple stars, 
   but we'll keep it simple or let Canvas draw stars. 
   Let's make a subtle gradient for now. */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, #1a1a3a 0%, #050510 100%);
    z-index: -2;
}

/* Utilities */
.hidden {
    display: none !important;
}

.visually-disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: #333 !important;
}

.visually-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* --- Layout --- */
.game-wrapper {
    width: 100%;
    max-width: 1400px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 10, 30, 0.7);
    padding: 15px 25px;
    border-radius: 12px;
    border: 1px solid rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.1);
    backdrop-filter: blur(10px);
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.8rem;
    margin: 0;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.controls-area {
    display: flex;
    gap: 15px;
}

/* --- UI Controls --- */
.styled-select {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid var(--accent);
    padding: 10px 15px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.styled-select:focus,
.styled-select:hover {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.btn-primary {
    background: linear-gradient(45deg, var(--accent), var(--primary));
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover:not([disabled]) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 240, 255, 0.4);
}

.btn-primary[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    background: #333;
}

.customizer-arrow {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.1s;
    padding: 0 5px;
}

.customizer-arrow:hover {
    color: var(--primary);
    transform: scale(1.2);
}

/* --- Game Canvas Area --- */
.game-container {
    position: relative;
    width: 100%;
    height: 70vh;
    min-height: 500px;
    margin: 0 auto;
    background-color: #000;
    border: 2px solid var(--accent);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(112, 0, 255, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.8);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- HUD Overlay --- */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    /* Let clicks pass to canvas */
    z-index: 10;
}

.hud.hidden {
    display: none;
}

.hud-left,
.hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.hud-right {
    text-align: right;
}

.score-box {
    color: var(--primary);
}

.multiplier-box {
    color: #ffff00;
    font-size: 0.9rem;
}

.wave-box {
    color: var(--text-main);
}

.lives-box i {
    color: var(--secondary);
    margin-left: 5px;
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.8);
}

.lives-box i.lost {
    color: #333;
    text-shadow: none;
}

.hud-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    margin: 0 20px;
}

.target-panel {
    background: rgba(10, 10, 30, 0.85);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 10px 20px;
    text-align: center;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
    pointer-events: auto;
    /* Allow interaction if needed */
    max-width: 400px;
    width: 100%;
}

.target-label {
    font-size: 0.75rem;
    color: var(--primary);
    letter-spacing: 2px;
    margin-bottom: 5px;
    font-family: var(--font-heading);
}

.target-text {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: white;
}

/* --- Overlay Screens (Start, GameOver, Victory) --- */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    z-index: 20;
    padding: 20px;
    overflow-y: auto;
}

.overlay-screen> :first-child {
    margin-top: auto;
}

.overlay-screen> :last-child {
    margin-bottom: auto;
}

.start-screen-content {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
}

.start-main {
    flex: 1;
}

.overlay-screen.hidden {
    display: none;
}

.overlay-screen h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 15px;
    text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
}

.game-over-title {
    color: var(--secondary) !important;
    text-shadow: 0 0 15px rgba(255, 0, 60, 0.6) !important;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    font-size: 1.1rem;
}

.text-success {
    color: #00ff00;
}

.text-danger {
    color: #ff003c;
}

/* Leaderboard */
#leaderboard-container {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 20px;
    width: 300px;
    box-shadow: 0 0 15px rgba(112, 0, 255, 0.3);
}

#leaderboard-container h3 {
    margin: 0 0 10px 0;
    color: var(--accent);
    font-size: 1.2rem;
    text-transform: uppercase;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    text-align: left;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.2);
}

#leaderboard-list li span.lb-score {
    color: var(--primary);
    font-weight: bold;
}

/* Save Score Form */
.save-score-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.save-score-form input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--accent);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-family: 'Outfit', sans-serif;
    outline: none;
}

.save-score-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.score-saved-msg {
    color: #00ff00;
    font-weight: bold;
    margin: 10px 0;
}

.key-icon {
    background: #e0e0e0;
    color: #000;
    font-weight: bold;
    font-family: var(--font-heading);
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    box-shadow: 0 4px 0 #999;
}

.key-icon.wide {
    width: 120px;
}

.highlight-text {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.2rem;
}

.font-large {
    font-size: 2rem;
}

.mt-4 {
    margin-top: 25px;
}

.text-white {
    color: white;
    font-weight: bold;
}

.review-section {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #333;
    width: 100%;
    max-width: 500px;
    max-height: 200px;
    overflow-y: auto;
}

.review-section h3 {
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.review-list {
    list-style: none;
    text-align: left;
}

.review-list li {
    padding: 8px 0;
    border-bottom: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.review-list li:last-child {
    border-bottom: none;
}

.review-word {
    font-weight: bold;
    color: var(--secondary);
    margin-bottom: 4px;
}

.review-def {
    font-size: 0.9rem;
    color: #ccc;
}


/* --- Utilities --- */
.game-footer {
    text-align: center;
    margin-top: 10px;
}

.back-link {
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

/* Scrollbar for review box */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #111;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* --- Mobile Responsiveness & Controls --- */
.mobile-controls {
    display: none;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    width: 100%;
    padding: 0 10px;
}

@media (max-width: 1024px),
(pointer: coarse) {
    .mobile-controls {
        display: flex;
        position: fixed;
        bottom: 120px;
        right: 40px;
        width: auto;
        padding: 0;
        z-index: 1000;
    }

    .mobile-controls.hidden {
        display: none;
    }

    .touch-btn {
        background: rgba(0, 0, 0, 0.7);
        border: 3px solid var(--primary);
        color: var(--primary);
        border-radius: 50%;
        width: 80px;
        height: 80px;
        font-size: 36px;
        display: flex;
        justify-content: center;
        align-items: center;
        touch-action: manipulation;
        outline: none;
        -webkit-tap-highlight-color: transparent;
        box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
    }

    .touch-btn-fire {
        border-color: var(--secondary);
        color: var(--secondary);
        width: 90px;
        height: 90px;
        font-size: 42px;
        box-shadow: 0 0 15px rgba(255, 0, 60, 0.4);
    }

    .touch-btn:active {
        background: rgba(255, 255, 255, 0.2);
    }

    .game-container {
        flex: 1;
        min-height: 350px;
    }

    .hud {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 10px;
    }

    .hud-left,
    .hud-right {
        flex-direction: row;
        gap: 20px;
        justify-content: center;
        font-size: 0.9rem;
    }

    .target-panel {
        padding: 5px 10px;
    }

    .target-text {
        font-size: 0.95rem;
    }

    .game-wrapper {
        padding: 0;
        gap: 10px;
        height: 100dvh;
        /* Fill precisely the screen height */
        overflow: hidden;
        /* Avoid any lingering scroll in landscape */
    }

    .game-container {
        flex: 1;
        /* Stretch vertically fully in landscape */
        min-height: 0;
        height: auto;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        flex-shrink: 0;
    }

    .controls-area {
        flex-wrap: wrap;
        justify-content: center;
    }

    .overlay-screen h2 {
        font-size: 1.8rem;
    }

    .start-screen-content {
        flex-direction: column;
        gap: 20px;
    }

    .start-main {
        width: 100%;
    }

    #leaderboard-container {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 1024px) and (orientation: portrait),
(pointer: coarse) and (orientation: portrait) {
    .game-wrapper {
        height: 100dvh;
        overflow-y: hidden;
        /* Prevent page-level scroll */
        justify-content: flex-start;
        padding: 0;
        /* Remove top padding to save space */
    }

    .game-container {
        flex: 1;
        /* Allow container to stretch to the bottom of the screen */
        height: auto;
        min-height: 50vh;
        max-height: none;
    }

    .touch-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .touch-btn-fire {
        width: 70px;
        height: 70px;
        font-size: 32px;
    }

    /* Stack ship customizer items tightly on narrow phones */
    #ship-customizer>div {
        flex-wrap: wrap;
        gap: 10px !important;
    }
}