:root {
    --bg-color: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.7);
    --primary-color: #58a6ff;
    --accent-color: #238636;
    --text-main: #c9d1d9;
    --text-dim: #8b949e;
    --tile-off: rgba(255, 255, 255, 0.05);
    --tile-on: #3fb950;
    --tile-on-glow: 0 0 20px #3fb950, 0 0 40px #3fb950;

    --font-main: 'Inter', system-ui, sans-serif;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Background Effects */
.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: #1f6feb;
    top: 10%;
    left: 20%;
    animation: float 10s infinite alternate;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: #d2a8ff;
    bottom: 10%;
    right: 20%;
    animation: float 12s infinite alternate-reverse;
}

@keyframes float {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(30px, -50px);
    }
}

#app {
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: 900px;
    padding: 20px;
    position: relative;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
}

/* Typography */
.title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -2px;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, white, #58a6ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(88, 166, 255, 0.3);
}

/* Cards & UI */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h2 {
    margin-bottom: 20px;
    text-align: center;
    color: white;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Inputs & Buttons */
select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

select:focus {
    border-color: var(--primary-color);
}

.level-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.level-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-dim);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.level-btn.active,
.level-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
    padding: 0 10px;
}

.cta-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #238636, #2ea043);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

.cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(46, 160, 67, 0.4);
}

.cta-btn:active {
    transform: translateY(0);
}

.cta-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 15px;
}

.cta-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Game Grid */
.hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
    padding: 0 10px;
}

.hud-item {
    text-align: center;
    background: rgba(22, 27, 34, 0.8);
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-item .label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.hud-item .value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: monospace;
}

.hud-item #timer {
    color: var(--primary-color);
}

.hud-item #score {
    color: var(--accent-color);
}

.grid-container {
    display: grid;
    gap: 8px;
    width: 100%;
    /* Grid columns will be set by JS based on count */
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
}

.tile {
    aspect-ratio: 1;
    background: var(--tile-off);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.1s ease;
    position: relative;
    overflow: hidden;
}

.tile.active {
    background: white;
    /* Base flash */
    animation: flash 0.5s forwards;
}

/* Dynamic styling for active state to support custom colors/speed if needed */
.tile.active {
    background: var(--tile-on);
    box-shadow: var(--tile-on-glow);
    border-color: #fff;
    transform: scale(0.95);
}

.tile:active {
    transform: scale(0.9);
}

@keyframes flash {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Result Styles */
.final-score-container {
    text-align: center;
    margin: 30px 0;
}

.final-score-container .value {
    display: block;
    font-size: 4rem;
    font-weight: 900;
    color: var(--primary-color);
}

.missed-container {
    text-align: center;
    margin-bottom: 30px;
    padding: 10px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 0, 0, 0.2);
}

.missed-container .label {
    display: block;
    font-size: 0.8rem;
    color: #ff6b6b;
    text-transform: uppercase;
}

.missed-container .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ff6b6b;
}