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

:root {
    --bg: #0a0a0a;
    --panel: #0f0f23;
    --neon: #00ff41;
    --neon-dim: rgba(0, 255, 65, 0.3);
    --gold: #ffd700;
    --accent: #ff0040;
    --text: #c0c0c0;
    --text-dim: #666;
    --border: #1a1a3e;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Courier New', 'Consolas', monospace;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 65, 0.015) 2px,
            rgba(0, 255, 65, 0.015) 4px
        );
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

header {
    text-align: center;
}

.glitch {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: bold;
    color: var(--neon);
    position: relative;
    text-shadow:
        0 0 10px var(--neon-dim),
        0 0 20px var(--neon-dim);
    letter-spacing: 6px;
    text-transform: uppercase;
    animation: glitch-skew 4s infinite linear;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    color: var(--accent);
    animation: glitch-1 3s infinite linear alternate-reverse;
    clip-path: inset(0 0 70% 0);
}

.glitch::after {
    color: cyan;
    animation: glitch-2 2s infinite linear alternate-reverse;
    clip-path: inset(70% 0 0 0);
}

@keyframes glitch-1 {
    0%, 5% { transform: translate(0); }
    5.5% { transform: translate(-3px, 2px); }
    6%, 100% { transform: translate(0); }
}

@keyframes glitch-2 {
    0%, 10% { transform: translate(0); }
    10.5% { transform: translate(2px, -1px); }
    11%, 100% { transform: translate(0); }
}

@keyframes glitch-skew {
    0%, 10% { transform: skew(0); }
    10.5% { transform: skew(1deg); }
    11%, 100% { transform: skew(0); }
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 4px;
}

.stats-bar {
    display: flex;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 24px;
    width: 100%;
    justify-content: space-around;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 2px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--neon);
    text-shadow: 0 0 8px var(--neon-dim);
}

#timer {
    font-variant-numeric: tabular-nums;
}

#timer.warning {
    color: var(--accent);
    text-shadow: 0 0 8px rgba(255, 0, 64, 0.5);
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 400px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.hole {
    aspect-ratio: 1;
    background: radial-gradient(ellipse at 50% 60%, #0d0d1a 0%, #05050f 100%);
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid #1a1a2e;
    transition: border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.hole::after {
    content: '';
    position: absolute;
    bottom: -8%;
    left: -8%;
    width: 116%;
    height: 30%;
    background: var(--bg);
    border-radius: 50%;
    z-index: 2;
}

.duck {
    position: absolute;
    left: 50%;
    bottom: -60%;
    transform: translateX(-50%);
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    transition: bottom 0.12s ease-out;
    z-index: 1;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

.duck.active {
    bottom: 5%;
}

.duck.hit {
    animation: duck-hit 0.3s ease-out forwards;
}

@keyframes duck-hit {
    0% { transform: translateX(-50%) scale(1); opacity: 1; }
    50% { transform: translateX(-50%) scale(1.3); opacity: 0.7; }
    100% { transform: translateX(-50%) scale(0); opacity: 0; }
}

.duck.miss {
    transition: bottom 0.1s ease-in;
    bottom: -60%;
}

.duck.golden {
    filter: drop-shadow(0 0 12px var(--gold)) drop-shadow(0 0 24px rgba(255, 215, 0, 0.4));
    animation: golden-float 0.6s infinite alternate ease-in-out;
}

@keyframes golden-float {
    from { transform: translateX(-50%) translateY(0); }
    to { transform: translateX(-50%) translateY(-4px); }
}

.hack-log {
    width: 100%;
    max-height: 120px;
    min-height: 60px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    overflow-y: auto;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--neon);
    font-family: 'Courier New', monospace;
}

.hack-log p {
    opacity: 0.8;
    animation: log-fade 0.3s ease;
}

.hack-log p:first-child {
    opacity: 0.4;
}

@keyframes log-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 0.8; transform: translateY(0); }
}

.btn {
    background: transparent;
    color: var(--neon);
    border: 2px solid var(--neon);
    padding: 14px 40px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.25s;
}

.btn:hover {
    background: var(--neon);
    color: var(--bg);
    box-shadow: 0 0 30px var(--neon-dim);
}

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

.footer {
    font-size: 0.7rem;
    color: var(--text-dim);
    opacity: 0.5;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.4s;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 30px;
    animation: overlay-in 0.5s ease;
}

@keyframes overlay-in {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.overlay-content .glitch {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
}

.overlay-message {
    font-size: 1.2rem;
    color: var(--neon);
}

.overlay-message span {
    font-weight: bold;
    font-size: 1.8rem;
}

.overlay-best {
    color: var(--text-dim);
    font-size: 0.9rem;
}

#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-fly 0.6s ease-out forwards;
}

@keyframes particle-fly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); }
}

.score-popup {
    position: fixed;
    pointer-events: none;
    font-weight: bold;
    font-size: 1.5rem;
    color: var(--neon);
    text-shadow: 0 0 10px var(--neon-dim);
    z-index: 60;
    animation: score-float 0.8s ease-out forwards;
}

@keyframes score-float {
    0% { opacity: 1; transform: translateY(0) scale(0.5); }
    50% { opacity: 1; transform: translateY(-30px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

.score-popup.golden {
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

@media (max-width: 400px) {
    .container {
        padding: 12px;
        gap: 14px;
    }

    .stats-bar {
        padding: 10px 14px;
        gap: 8px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .game-board {
        gap: 8px;
        padding: 8px;
    }

    .hack-log {
        max-height: 80px;
        min-height: 40px;
        font-size: 0.65rem;
        padding: 8px 10px;
    }

    .btn {
        padding: 12px 30px;
        font-size: 0.85rem;
    }
}
