:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #06b6d4;
    --accent-color: #f472b6;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(51, 65, 85, 0.6);
    --card-hover: rgba(71, 85, 105, 0.8);
    --success-color: #22c55e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; /* Prevent text selection during rapid clicking */
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

header {
    text-align: center;
    width: 100%;
}

h1 {
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
    font-size: 1.5rem;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 12px;
    width: 100%;
    aspect-ratio: 1;
    padding: 10px;
}

.grid-cell {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.grid-cell:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: var(--primary-color);
}

.grid-cell:active {
    transform: scale(0.95);
}

/* State: Completed cell */
.grid-cell.completed {
    background: var(--success-color);
    color: #000;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* State: Wrong click animation using keyframes if needed, or simple shake class */
.grid-cell.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.controls {
    width: 100%;
    display: flex;
    justify-content: center;
}

.current-target-display {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 700;
    letter-spacing: 1px;
    background: rgba(244, 114, 182, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(244, 114, 182, 0.3);
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 100;
    padding: 20px;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.glass-modal {
    background: linear-gradient(135deg, rgba(30, 41, 59, 1) 0%, rgba(15, 23, 42, 1) 100%);
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.2);
}

.modal h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    background: linear-gradient(to right, #06b6d4, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-time {
    font-size: 3rem;
    font-weight: 700;
    margin: 20px 0;
    color: #fff;
}

.result-rank {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--primary-color);
    margin-bottom: 10px;
}

.result-comment {
    color: #94a3b8;
    margin-bottom: 30px;
}

.primary-btn {
    background: var(--primary-color);
    color: #000;
    border: none;
    padding: 12px 32px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
}

@media (max-width: 500px) {
    .timer-display { font-size: 2rem; }
    .game-board { gap: 8px; }
    .grid-cell { font-size: 1.2rem; border-radius: 8px; }
}
