/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --color-dark: #0f172a;
    --color-primary: #d946ef;
    /* Fuchsia-500 */
    --color-secondary: #0ea5e9;
    /* Sky-500 */
    --color-accent: #facc15;
    /* Yellow-400 */
    --color-slate-800: #1e293b;
    --color-slate-700: #334155;
    --color-green-500: #22c55e;
    --color-green-900: #14532d;
    --color-red-500: #ef4444;
    --color-red-900: #7f1d1d;
}

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

body {
    background-color: var(--color-dark);
    color: white;
    font-family: 'Press Start 2P', cursive;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
}

/* Utilities */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-8 {
    margin-top: 2rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.pb-32 {
    padding-bottom: 8rem;
}

.uppercase {
    text-transform: uppercase;
}

.border-2 {
    border-width: 2px;
    border-style: solid;
}

.border-4 {
    border-width: 4px;
    border-style: solid;
}

.border-b-2 {
    border-bottom-width: 2px;
    border-bottom-style: solid;
}

.border-b-4 {
    border-bottom-width: 4px;
    border-bottom-style: solid;
}

.border-b-8 {
    border-bottom-width: 8px;
    border-bottom-style: solid;
}

.border-l-4 {
    border-left-width: 4px;
    border-left-style: solid;
}

.border-dashed {
    border-style: dashed;
}

.shadow-xl {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.overflow-y-auto {
    overflow-y: auto;
}

.flex-1 {
    flex: 1 1 0%;
}

.absolute {
    position: absolute;
}

.bottom-0 {
    bottom: 0;
}

.left-0 {
    left: 0;
}

.right-0 {
    right: 0;
}

.transform {
    transform: var(--tw-transform);
}

.-rotate-2 {
    --tw-rotate: -2deg;
    transform: rotate(var(--tw-rotate));
}

.-rotate-45 {
    --tw-rotate: -45deg;
    transform: rotate(var(--tw-rotate));
}

.rotate-45 {
    --tw-rotate: 45deg;
    transform: rotate(var(--tw-rotate));
}

/* Typography */
.font-dos {
    font-family: 'VT323', monospace;
}

.font-retro {
    font-family: 'Press Start 2P', cursive;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.text-3xl {
    font-size: 1.875rem;
    line-height: 2.25rem;
}

.leading-relaxed {
    line-height: 1.625;
}

.tracking-wider {
    letter-spacing: 0.05em;
}

.tracking-widest {
    letter-spacing: 0.1em;
}

.text-brand-primary {
    color: var(--color-primary);
}

.text-brand-secondary {
    color: var(--color-secondary);
}

.text-accent {
    color: var(--color-accent);
}

.text-red-500 {
    color: var(--color-red-500);
}

.text-green-500 {
    color: var(--color-green-500);
}

.text-slate-300 {
    color: #cbd5e1;
}

.text-slate-400 {
    color: #94a3b8;
}

.text-white {
    color: white;
}

.text-shadow-lg {
    text-shadow: 4px 4px 0px rgba(217, 70, 239, 0.4);
}

/* Components */
.screen {
    width: 100%;
    max-width: 600px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Game Screen - Flexbox Layout (NOT absolute positioning) */
#screen-game {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Progress bar stays at top */
#screen-game > .h-4 {
    flex-shrink: 0;
}

/* Content area scrolls */
#screen-game .game-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Footer with Next button stays at bottom */
#screen-game > div:last-child {
    flex-shrink: 0;
}

.btn-primary {
    background-color: var(--color-primary);
    border: 4px solid var(--color-primary);
    border-bottom: 6px solid #a21caf;
    /* Fuchsia 700 */
    color: #fff;
    padding: 1.5rem;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.1s;
    width: 100%;
    font-size: 1rem;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.2);
}

.btn-primary:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
}

/* Option Buttons */
.btn-option {
    width: 100%;
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    text-align: left;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    line-height: 1.5;
    background-color: var(--color-slate-800);
    border: 2px solid var(--color-slate-700);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
}

.btn-option:hover:not(:disabled) {
    background-color: var(--color-slate-700);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.2);
}

.btn-option:active:not(:disabled) {
    transform: translate(0, 0);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

/* State Classes */
.btn-correct {
    background-color: var(--color-green-900) !important;
    border-color: var(--color-green-500) !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.4) !important;
}

.btn-incorrect {
    background-color: var(--color-red-900) !important;
    border-color: var(--color-red-500) !important;
    color: white !important;
    opacity: 0.8;
}

.bg-slate-700 {
    background-color: var(--color-slate-700);
}

.bg-slate-800 {
    background-color: var(--color-slate-800);
}

.bg-slate-800\/50 {
    background-color: rgba(30, 41, 59, 0.5);
}

.bg-secondary {
    background-color: var(--color-secondary);
}

.bg-red {
    background-color: var(--color-red-500);
}

/* Borders */
.border-accent {
    border-color: var(--color-accent);
}

.border-primary\/50 {
    border-color: rgba(217, 70, 239, 0.5);
}

.border-slate-700 {
    border-color: var(--color-slate-700);
}

.border-slate-900 {
    border-color: #0f172a;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .7;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(-5%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }

    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.animate-bounce {
    animation: bounce 1s infinite;
}

/* Grid Background */
.bg-grid {
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    #screen-game .game-content {
        padding: 1rem;
    }
    
    #screen-game > div:last-child {
        padding: 0.75rem 1rem;
    }
    
    /* Slightly reduce spacing */
    #screen-game .mb-8 {
        margin-bottom: 1.5rem;
    }
    
    /* Keep buttons readable */
    .btn-option {
        padding: 1rem;
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

/* Compact layout for short screens */
@media (max-height: 650px) {
    #screen-game .game-content {
        padding: 0.75rem;
    }
    
    #screen-game > div:last-child {
        padding: 0.5rem 0.75rem;
    }
    
    #screen-game .mb-8 {
        margin-bottom: 1rem;
    }
    
    .btn-option {
        padding: 0.85rem;
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    #question-text {
        font-size: 1.1rem !important;
    }
    
    #next-btn {
        padding: 0.75rem !important;
    }
}

/* Secondary Button */
.btn-secondary {
    background-color: #334155;
    border: 4px solid #334155;
    border-bottom: 6px solid #0f172a;
    color: #fff;
    padding: 1.25rem;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.1s;
    width: 100%;
    font-size: 0.95rem;
}

.btn-secondary:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
}

/* High Scores Board */
.hs-board {
    width: 100%;
    border: 6px double #334155;
    background: rgba(15, 23, 42, 0.85);
    padding: 1rem;
    box-shadow: 0 0 25px rgba(14, 165, 233, 0.15);
}

.hs-row {
    display: grid;
    grid-template-columns: 80px 1fr 140px;
    gap: 0.75rem;
    padding: 0.6rem 0.25rem;
    align-items: center;
    font-family: 'VT323', monospace;
    font-size: 1.75rem;
    letter-spacing: 0.08em;
}

.hs-header {
    border-bottom: 2px dashed #475569;
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 1.6rem;
    color: #facc15;
}

.hs-cell {
    text-align: left;
}

.hs-rank {
    color: #facc15;
}

.hs-score {
    color: #ffffff;
    text-align: center;
}

.hs-initials {
    color: #22c55e;
    text-align: right;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #0f172a;
    border: 6px double #facc15;
    padding: 1.25rem;
    box-shadow: 0 0 35px rgba(217, 70, 239, 0.25);
}

.initials-input {
    width: 100%;
    text-align: center;
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    padding: 0.75rem 0.5rem;
    background: #1e293b;
    color: #ffffff;
    border: 3px solid #0ea5e9;
    outline: none;
    letter-spacing: 0.35em;
}

/* CRT overlay */
.crt {
    position: relative;
}

.crt::before {
    content: "";
    pointer-events: none;
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.035),
        rgba(255, 255, 255, 0.035) 1px,
        rgba(0, 0, 0, 0) 3px,
        rgba(0, 0, 0, 0) 6px
    );
    mix-blend-mode: overlay;
    opacity: 0.35;
    z-index: 100;
}

.crt::after {
    content: "";
    pointer-events: none;
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.55) 100%);
    opacity: 0.55;
    z-index: 101;
}

@keyframes crtFlicker {
    0% { opacity: 0.92; }
    50% { opacity: 0.86; }
    100% { opacity: 0.92; }
}

.crt {
    animation: crtFlicker 4s infinite;
}

/* Mobile Next Button in Header */
.mobile-next-btn-container {
    display: none;
}

.mobile-next-btn {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    transition: all 0.1s;
    white-space: nowrap;
    border-bottom-width: 4px;
    border-style: solid;
}

.mobile-next-btn:not(:disabled) {
    opacity: 1 !important;
    cursor: pointer !important;
}

.mobile-next-btn:active:not(:disabled) {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* Show mobile button only on smaller screens */
@media (max-width: 640px) {
    .mobile-next-btn-container {
        display: block !important;
    }
}

@media (max-height: 750px) {
    .mobile-next-btn-container {
        display: block !important;
    }
}
