
:root {
    --bg-color: #020617;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-color: #ffffff;
    --text-muted: #94a3b8;
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --success-color: #22c55e;
    --header-bg: rgba(15, 23, 42, 0.8);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Tajawal', sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Header */
.game-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--header-bg);
    backdrop-filter: blur(8px);
    z-index: 20;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.back-btn:hover {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.game-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-blue {
    color: var(--primary-color);
}

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

.timer-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: bold;
}

.timer-value {
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: #60a5fa; /* lighter blue */
}

/* Main Game Area */
.main-area {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.click-box {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1/1;
    background-color: var(--surface-color);
    border-radius: 1.5rem;
    border: 4px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}

.click-box:hover {
    border-color: var(--primary-color);
}

.click-box:active {
    transform: scale(0.98);
}

/* Overlay */
.overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.8);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.bounce-icon {
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: white;
    animation: bounce 1s infinite;
}

.bounce-icon i {
    width: 2.5rem;
    height: 2.5rem;
}

@keyframes bounce {
    0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
    50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

.overlay h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.overlay p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Counter */
.counter-container {
    text-align: center;
    z-index: 0;
    pointer-events: none;
    transition: transform 0.1s;
}

.click-box:active .counter-container {
    transform: scale(0.95);
}

#click-count {
    font-size: 6rem;
    font-weight: 900;
    color: #e2e8f0;
    line-height: 1;
}

.counter-container .label {
    color: #64748b;
    font-weight: 700;
    margin-top: 0.5rem;
}

/* Ripples */
.ripples-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.4);
    transform: scale(0);
    animation: ripple-anim 0.6s linear;
    pointer-events: none;
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-right: -50px; /* RTL adjustment */
}

@keyframes ripple-anim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-content {
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: fadeUp 0.3s ease-out;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.trophy-icon {
    width: 4rem;
    height: 4rem;
    background-color: rgba(59, 130, 246, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    color: var(--primary-color);
}

.trophy-icon i {
    width: 2rem;
    height: 2rem;
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--surface-color);
    padding: 0.75rem;
    border-radius: 0.75rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 900;
}

.stat-value.text-blue {
    color: #60a5fa;
}

.best-score-card {
    background-color: rgba(30, 41, 59, 0.5);
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(51, 65, 85, 0.5);
    margin-bottom: 1.5rem;
}

.best-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.best-label {
    color: var(--text-muted);
}

.best-val {
    font-weight: 700;
    color: var(--success-color);
}

.retry-btn {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.retry-btn:hover {
    background-color: var(--primary-dark);
}

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