@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700;900&display=swap');

/* ===== CSS Variables ===== */
:root {
    --primary: #8b5cf6;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Neon Palette */
    --neon-blue: #00f3ff;
    --neon-purple: #bd00ff;
    --neon-pink: #ff0055;

    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.3) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    /* Prevent scrolling during game */
    user-select: none;
}

/* ===== Glassmorphism Utilities ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
}

.glass-dark {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== Screen Management ===== */
.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 2rem;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Start Screen ===== */
#start-screen {
    justify-content: center;
    background: radial-gradient(circle at center, #1e1b4b 0%, #0f172a 100%);
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
    z-index: 10;
}

.logo {
    font-size: 5rem;
    font-weight: 900;
    letter-spacing: -2px;
    background: linear-gradient(to right, var(--neon-blue), var(--neon-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 20px rgba(189, 0, 255, 0.5));
}

.tagline {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* ===== Categories Grid ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 800px;
    padding-bottom: 4rem;
    /* Spacing for scroll */
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.category-card:hover::before {
    transform: translateX(100%);
}

.category-card:active {
    transform: scale(0.95);
}

.category-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.category-name {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.category-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* ===== Game Screen (Landscape Focus) ===== */
#game-screen {
    justify-content: center;
    padding: 0;
    overflow: hidden;
    background: black;
    /* High contrast for game */
}

.game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.timer {
    font-size: 3rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.timer.warning {
    color: var(--warning);
    animation: pulse 1s infinite;
}

.timer.danger {
    color: var(--danger);
    animation: shake 0.5s infinite;
}

.score {
    font-size: 2rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    backdrop-filter: blur(5px);
}

.timer-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
}

.timer-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    box-shadow: 0 0 10px var(--neon-blue);
    transition: width 1s linear;
}

/* Main Card */
.card-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
    width: 100%;
}

#current-card {
    width: 90%;
    height: 80%;
    max-width: 1000px;
    background: linear-gradient(135deg, #2d3748, #1a202c);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

.card-word {
    font-size: min(15vw, 180px);
    /* Massive text that scales */
    font-weight: 900;
    background: linear-gradient(180deg, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    line-height: 1.1;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Tilt Indicators */
.tilt-indicator {
    position: absolute;
    left: 50%;
    /* Center horizontally */
    transform: translateX(-50%);
    font-size: 5rem;
    opacity: 0.2;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    pointer-events: none;
    /* Let clicks pass through */
}

/* Tilt Down = Correct = Bottom of screen */
.tilt-down {
    bottom: 1rem;
    top: auto;
    right: auto;
    color: var(--success);
}

/* Tilt Up = Pass = Top of screen */
.tilt-up {
    top: 1rem;
    bottom: auto;
    left: 50%;
    /* Ensure it stays centered */
    color: var(--warning);
}

.tilt-indicator.active {
    opacity: 1;
    transform: translateX(-50%) scale(1.2);
    /* Keep centered scaling */
    filter: drop-shadow(0 0 20px currentColor);
}

/* Feedback Overlay */
.feedback {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    font-weight: 900;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback.show {
    opacity: 1;
    transform: scale(1);
}

.feedback.correct {
    background: rgba(16, 185, 129, 0.8);
    color: white;
}

.feedback.skip {
    background: rgba(245, 158, 11, 0.8);
    color: white;
}

/* ===== Rotate Overlay ===== */
#rotate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

#rotate-overlay.active {
    display: flex;
}

.rotate-icon {
    font-size: 5rem;
    margin-bottom: 2rem;
    animation: rotate 2s infinite ease-in-out;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-90deg);
    }

    50% {
        transform: rotate(-90deg);
    }

    75% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

/* ===== Keyframes ===== */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

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

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ===== Results Results ===== */
.results-container {
    width: 100%;
    max-width: 600px;
}

.final-score {
    font-size: 8rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 0.5rem;
    background: linear-gradient(to bottom, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.results-list {
    margin: 2rem 0;
    max-height: 40vh;
    overflow-y: auto;
    width: 100%;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.25rem;
}

.result-item.correct {
    color: var(--success);
}

.result-item.skipped {
    color: var(--text-secondary);
    text-decoration: line-through;
}

.btn {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border: none;
    padding: 1rem 3rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

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

/* Debug Info */
#debug-info {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: lime;
    font-family: monospace;
    padding: 10px;
    border-radius: 5px;
    display: none;
    z-index: 999;
    pointer-events: none;
}