/* Base Resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: #0f0c29;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Background Glowing Orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: drift 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: #8a2be2;
    top: 10%;
    left: 20%;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: #00d2ff;
    bottom: 10%;
    right: 15%;
    animation-delay: -5s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: #ff007f;
    top: 50%;
    left: 60%;
    animation-delay: -10s;
}

/* Anti-gravity Animations */
@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(30px, -50px) scale(1.1);
    }

    100% {
        transform: translate(-30px, 20px) scale(0.9);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-15px);
    }
}

.float-animation {
    animation: float 6s ease-in-out infinite;
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

/* Glassmorphism Card */
.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border-radius: 24px;
    padding: 10px; /* START MENU PADDING - Change this to adjust internal spacing */
    width: 100%;
    max-width: 600px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: 0 12px 40px 0 rgba(255, 255, 255, 0.1);
}

/* Specific overrides for the setup screen */
#setup-screen {
    max-width: 900px; /* START MENU WIDTH - Change this to make it wider or narrower */
}

.hidden {
    display: none !important;
}

/* Typography & Inputs */
h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 800;
    padding-top: 30px; /* TITLE TOP PADDING - Change this to push the title down */
}

p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

textarea {
    width: 100%;
    height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    resize: none;
    font-size: 1rem;
    outline: none;
}

textarea:focus {
    border-color: rgba(255, 255, 255, 0.5);
}

/* Modern Blur for Hidden Lists */
.blurred-input {
    filter: blur(12px) grayscale(0.5);
    pointer-events: none;
    user-select: none;
    opacity: 0.7 !important;
    transition: filter 0.4s ease, opacity 0.4s ease;
}

/* Neon Buttons */
.neon-btn {
    background: linear-gradient(90deg, #bb00ff, #00d2ff);
    border: none;
    padding: 15px 40px;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
    transition: all 0.3s ease;
}

.neon-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.6);
}

.start-top-btn {
    margin-bottom: 30px;
    width: 100%;
}

.setup-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.neon-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.neon-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

/* Settings Screen */
#settings-screen h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    font-weight: 800;
}

.setting-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-bottom: 20px;
}

.setting-group label {
    font-size: 1.1rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.glass-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.glass-input option {
    background: #24243e;
    color: #fff;
}

.glass-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-group input[type="checkbox"]:checked::after {
    content: "✔";
    color: #00d2ff;
    font-size: 14px;
}

/* Categories Grid */
.categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 5px;
}

/* Base Neon Button adjustment for Category */
.category-btn {
    flex: 1 1 calc(50% - 15px);
    font-size: 1rem;
    padding: 10px 15px;
    min-width: 150px;
    white-space: normal;
    text-align: center;
    transition: all 0.3s ease;
}

.category-selected {
    background: linear-gradient(90deg, #bb00ff, #00d2ff) !important;
    border-color: transparent !important;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4) !important;
}

/* Loading Animation */
.loader {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #00d2ff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Category Image Grid (Responsive) */
.category-image-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin: 20px 0 35px 0;
    width: 100%;
}

.grid-cat-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: white;
    text-transform: capitalize;
    overflow: hidden;
    position: relative;
    aspect-ratio: 0.85 / 1;
}

.grid-cat-btn img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.grid-cat-btn span {
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0.95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.grid-cat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.3);
    border-color: rgba(0, 210, 255, 0.5);
}

.grid-cat-btn:hover img {
    transform: scale(1.08);
}

.grid-cat-btn:active {
    transform: scale(0.96);
}

@media (max-width: 768px) {
    .category-image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .grid-cat-btn {
        aspect-ratio: 0.8 / 1;
        padding: 4px;
        gap: 6px;
    }
    .grid-cat-btn span {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .category-image-grid {
        gap: 10px;
    }
    .grid-cat-btn {
        padding: 3px;
        gap: 4px;
    }
    .grid-cat-btn span {
        font-size: 1.2rem;
    }
}

/* Custom Alert, Instructions, & Review Modal */
#alert-modal,
#instructions-modal {
    position: fixed; /* Changed from absolute for better centering */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 500px;
    width: 90%;
    z-index: 1000;
}

#instructions-modal {
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (max-width: 480px) {
    #instructions-modal {
        width: 95%;
        padding: 20px 15px;
    }
}

#review-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 800px;
    width: 95%;
    z-index: 1000;
}

.instructions-list {
    list-style: none;
    text-align: left;
    margin-bottom: 30px;
}

.instructions-list li {
    font-size: 1.1rem;
    margin-bottom: 15px;
    line-height: 1.5;
    opacity: 0.9;
}

.stats-text {
    font-size: 1.2rem;
    color: #00d2ff;
    margin-top: 15px;
    margin-bottom: 30px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-text span {
    font-size: 1rem;
    color: #fff;
    opacity: 0.9;
}

/* Review Lists */
.review-lists {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
    max-height: 40vh;
    overflow-y: auto;
    text-align: left;
}

.review-column {
    flex: 1;
}

.review-column h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 800;
}

.correct-text {
    color: #00e676;
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
}

.skip-text {
    color: #ff4b4b;
    text-shadow: 0 0 10px rgba(255, 75, 75, 0.4);
}

.word-list {
    list-style: none;
    padding-left: 0;
}

.word-list li {
    font-size: 1rem;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Gameplay Screen (Landscape Optimized) */
#play-screen-wrapper {
    height: calc(100vh - 40px);
    /* Fill screen minus body padding */
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    /* Essential for absolute centering of children */
}

#play-screen {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    width: 95vw;
    /* Stable viewport-based width */
    margin: 0 auto;
    flex: 1;
    /* Stretch to fill available space */
    padding: 10px;
    gap: 15px;
    position: relative;
}

.word-display-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    /* Prevent overflow jitters */
    align-self: stretch;
    padding: 0 40px;
    /* Gap from buttons */
    min-width: 0;
    /* Crucial for flex child scrollWidth measurement */
}

#timer {
    font-size: 1.5rem;
    /* Shrunk to fit beside slider */
    font-weight: 800;
    color: #00d2ff;
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.4);
    margin-bottom: 0;
    /* Reset since it's now in the flex row */
    white-space: nowrap;
}

.word-animator {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#past-word {
    font-size: 1.5rem;
    font-weight: 600;
    opacity: 0.4;
    margin: 0 0 20px 0;
    /* Creates the padding below the previous word */
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#current-word {
    font-size: 8rem;
    font-weight: 800;
    margin: 0;
    text-align: center;
    width: 100%;
    line-height: 1.1;
    transition: transform 0.3s ease, opacity 0.3s ease;
    word-wrap: break-word;
    /* Final fallback */
}

.timer-warning {
    animation: flash-red-text 0.5s infinite alternate;
    /* Sped up the flash */
}

/* Animations */
.roll-in {
    animation: rollIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.transition-up {
    transform: translateY(-40px) scale(0.4);
    opacity: 0.4;
}

.roll-out-reverse {
    animation: rollOutReverse 0.3s ease-in forwards;
}

@keyframes flash-red-text {
    0% {
        opacity: 1;
        color: #ffffff;
        text-shadow: 0 0 25px rgba(255, 255, 255, 1);
    }

    100% {
        opacity: 0.8;
        color: #ffbaba;
        /* light red */
        text-shadow: 0 0 15px rgba(255, 75, 75, 0.8);
    }
}

@keyframes rollIn {
    0% {
        transform: translateY(40px) scale(0.8);
        opacity: 0;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes rollOutReverse {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(40px) scale(0.8);
        opacity: 0;
    }
}

#instruction-text {
    font-size: 1.2rem;
    opacity: 0.8;
    transition: opacity 0.5s ease;
    margin-top: 10px;
    /* Snug up to the main phrase */
    text-align: center;
}

/* Go Back Button */
.go-back-btn {
    background: rgba(255, 204, 0, 0.2);
    border: 1px solid #ffcc00;
    color: #ffcc00;
    padding: 12px 24px;
    border-radius: 20px;
    /* Reduced to match the UI blockiness */
    font-size: 1.25rem;
    /* Large font */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(255, 204, 0, 0.2);
    white-space: nowrap;
    width: 100%;
    height: 100%;
}

.go-back-btn:hover {
    background: rgba(255, 204, 0, 0.3);
    box-shadow: 0 6px 20px rgba(255, 204, 0, 0.4);
    transform: translateY(-2px);
}

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

/* Side Fallback Buttons */
.side-btn {
    width: 150px;
    /* Fixed width */
    flex-shrink: 0;
    /* Prevent shrinking */
    align-self: stretch;
    /* Make it fill the height */
    min-height: 100%;
    border-radius: 20px;
    z-index: 10;
    /* Keep buttons above any scaling text if overlap happens */
    border: 3px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.skip-btn {
    border-color: #ff4b4b;
}

.skip-btn:active,
.flash-red {
    background: rgba(255, 75, 75, 0.4) !important;
    box-shadow: 0 0 30px #ff4b4b;
}

.correct-btn {
    border-color: #00e676;
}

.correct-btn:active,
.flash-green {
    background: rgba(0, 230, 118, 0.4) !important;
    box-shadow: 0 0 30px #00e676;
}

.flash-yellow {
    background: rgba(255, 204, 0, 0.4) !important;
    box-shadow: 0 0 30px #ffcc00;
}

/* Responsive adjustments for phones */
@media (max-width: 768px),
(orientation: portrait) {
    .app-container {
        flex-direction: column;
    }

    #current-word {
        font-size: 2.5rem;
    }

    .review-lists {
        flex-direction: column;
        max-height: 50vh;
    }
}

/* Fix for Short Landscape Screens (Low Res Phones) */
@media (max-height: 600px) and (orientation: landscape) {
    .app-container {
        padding: 5px;
        /* Reduce outer padding */
    }

    #play-screen-wrapper {
        gap: 5px !important;
        height: 100%;
        min-height: 90vh;
        /* Stretch the whole wrapper */
    }

    #play-screen {
        flex: 1;
        /* Automatically fill remaining vertical space */
        padding: 5px 10px;
        align-items: stretch;
        /* Allow children to stretch */
    }

    #timer {
        font-size: 1.25rem;
        margin-bottom: 0;
    }

    #current-word {
        font-size: 2.2rem;
    }

    .word-animator {
        min-height: 80px;
        /* Ensure enough height for large text to center within */
    }

    #past-word {
        font-size: 1rem;
        margin: 0 0 5px 0;
        /* Scaled down padding */
    }

    #instruction-text {
        font-size: 0.9rem;
        margin-bottom: 0px;
    }

    .go-back-btn {
        padding: 4px 12px;
        font-size: 0.85rem;
        margin-bottom: 5px;
    }

    .side-btn {
        font-size: 1.1rem;
        min-height: auto;
        /* Let it dictate its height via align-self */
    }

    #pause-slider-area {
        padding: 10px !important;
    }

    #pause-slider-area p {
        margin-bottom: 5px !important;
        font-size: 0.9rem;
    }

    .custom-slider {
        height: 30px;
    }
}

@media (orientation: portrait) {
    #play-screen {
        flex-direction: column;
        height: 85vh;
        align-items: center;
        /* Override back for portrait */
    }

    #timer {
        font-size: 1.2rem !important;
        white-space: nowrap;
    }

    #timer-wrapper {
        min-width: auto !important;
        padding-right: 10px;
    }

    .go-back-btn {
        padding: 8px 16px;
        font-size: 1rem;
        width: auto;
        height: auto;
        margin-bottom: 10px;
    }

    .side-btn {
        width: 100%;
        max-width: none;
        height: 15vh;
        min-height: auto;
        flex-direction: row;
        gap: 10px;
    }

    .side-btn br {
        display: none;
    }

    #pause-slider-area p {
        font-size: 0.8rem !important;
        margin-bottom: 4px;
        opacity: 0.7;
    }

    .custom-slider {
        max-width: 95% !important;
        flex: 1;
    }
}

.priority-word {
    color: #ed87ff !important;
    text-shadow: 0 0 10px rgba(224, 64, 251, 0.4) !important;
}

/* Custom Slider for Pause */
.custom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 350px;
    height: 40px;
    background: rgba(0, 0, 0, 0.2);
    /* Muted semi-transparent back */
    border-radius: 20px;
    outline: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    cursor: pointer;
    margin: 0 auto;
    display: block;
    padding: 0 3px;
    z-index: 2;
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #00d2ff;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.8), inset 0 0 5px rgba(255, 255, 255, 0.5);
    border: 2px solid white;
    transition: transform 0.2s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.custom-slider::-moz-range-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #00d2ff;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.8), inset 0 0 5px rgba(255, 255, 255, 0.5);
    border: 2px solid white;
}

.custom-slider::-moz-range-progress {
    background: rgba(0, 210, 255, 0.4);
    height: 12px;
    border-radius: 10px;
}

/* Disabled states when paused */
.disabled-game {
    pointer-events: none;
    opacity: 0.5;
    filter: grayscale(100%);
}

/* Pass Screen Overlay */
#pass-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none !important;
    /* Override glass-card */
    max-height: none !important;
    /* Override glass-card */
    z-index: 9999;
    /* Ensure it's on top of everything */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #0f0c29;
    /* Solid opaque background */
    border-radius: 0;
    /* No radius for full-screen */
    animation: fadeIn 0.3s ease-out;
}

#pass-countdown {
    font-size: 6rem;
    font-weight: 800;
    color: #00d2ff;
    text-shadow: 0 0 30px rgba(0, 210, 255, 0.6);
    margin: 20px 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}
/* Footer Styling */
.game-footer {
    text-align: center;
    padding: 20px;
    opacity: 0.5;
    font-size: 0.85rem;
    width: 100%;
    position: relative;
    z-index: 10;
}

.game-footer p {
    margin-bottom: 0;
}
