* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: "Space Grotesk", sans-serif;
    background: #050505;
    color: white;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}
.bg-glow {
    position: fixed;
    width: 700px;
    height: 700px;
    background: #00ff8840;
    filter: blur(180px);
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: -2;
}
#particles-js {
    position: fixed;
    inset: 0;
    z-index: -3;
}
.cursor-glow {
    position: fixed;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle,rgba(0, 255, 136, 0.18) 0%,transparent 70%);
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: -1;
}
.container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.card {
    position: relative;
    overflow: hidden;
    width: 520px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    padding: 45px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.08);
    transition: box-shadow 0.2s ease;
}
.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 20%;
    width: 60%;
    height: 2px;
    background: #00ff88;
    filter: blur(4px);
}
.card-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
h1 {
    font-size: 3rem;
    margin-bottom: 12px;
}
.subtitle {
    color: #b3b3b3;
    margin-bottom: 35px;
}
button {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    background: linear-gradient(135deg,#00ff88,#00d26a);
    color: black;
    font-weight: bold;
    font-size: 18px;
    transition: 0.25s;
}
button:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.55);
}
button:active {
    transform: scale(0.96);
}
#gameArea {
    margin-top: 28px;
    height: 250px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg,#1b1b1b,#111);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    transition:background 0.25s,transform 0.25s,box-shadow 0.25s;
    user-select: none;
    cursor: pointer;
}
.stats {
    margin-top: 30px;
}
.stats span {
    color: #999;
}
#result {
    margin-top: 8px;
    font-size: 52px;
    color: #00ff88;
}
@keyframes pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    70% {
        transform: scale(1.12);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
.pop {
    animation: pop 0.45s ease;
}

/* Leaderboard Toggle */
.leaderboard-toggle {
    position: absolute;
    right: 0;
    top: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #999;
    font-size: 14px;
    transition: 0.25s;
}
.leaderboard-toggle:hover {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    border-color: rgba(0, 255, 136, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
}

/* Result sub-strip — fixed height, always present, never grows the card */
.result-sub {
    height: 40px;
    margin-top: 14px;
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
}

/* Inline name input row (first-time / change-name) */
.inline-name-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    height: 40px;
    animation: fadeSlideIn 0.25s ease;
}
.inline-name-row input {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: white;
    font-family: "Space Grotesk", sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.inline-name-row input:focus {
    border-color: rgba(0, 255, 136, 0.45);
}
.inline-name-row input::placeholder {
    color: #555;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-5px); }
    75%       { transform: translateX(5px); }
}
.inline-name-row input.input-error {
    border-color: rgba(255, 68, 68, 0.65) !important;
    animation: shake 0.3s ease;
}
.submit-btn-inline {
    width: 68px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.submit-btn-inline:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Status row (shown after auto-submit or first-time submit) */
.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    gap: 10px;
    animation: fadeSlideIn 0.25s ease;
}
.submit-message {
    flex: 1;
    font-size: 13px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.submit-message.success { color: #00ff88; }
.submit-message.error   { color: #ff4444; }
.change-name-btn {
    width: auto;
    flex-shrink: 0;
    padding: 6px 12px;
    height: 30px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #666;
    border-radius: 8px;
    line-height: 1;
}
.change-name-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #999;
    transform: none;
    box-shadow: none;
}

/* Leaderboard View */
.leaderboard-view {
    text-align: left;
}
.leaderboard-view h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.4rem;
    color: #00ff88;
}
.leaderboard-state {
    text-align: center;
    padding: 40px 0;
    color: #666;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: #00ff88;
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.retry-btn {
    width: auto;
    padding: 10px 24px;
    font-size: 14px;
    margin-top: 12px;
}
.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 360px;
    overflow-y: auto;
}
.leaderboard-list::-webkit-scrollbar {
    width: 4px;
}
.leaderboard-list::-webkit-scrollbar-track {
    background: transparent;
}
.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 136, 0.2);
    border-radius: 4px;
}
.leaderboard-list li {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 6px;
    transition: background 0.2s;
    animation: fadeSlideIn 0.35s ease both;
}
.leaderboard-list li:nth-child(1) {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.2);
}
.leaderboard-list li:nth-child(2) {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.leaderboard-list li:nth-child(3) {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}
.leaderboard-list li:hover {
    background: rgba(255, 255, 255, 0.06);
}
.rank {
    width: 32px;
    font-weight: 700;
    font-size: 16px;
    color: #555;
    flex-shrink: 0;
}
.leaderboard-list li:nth-child(1) .rank {
    color: #00ff88;
}
.leaderboard-list li:nth-child(2) .rank {
    color: #c0c0c0;
}
.leaderboard-list li:nth-child(3) .rank {
    color: #cd7f32;
}
.player-name {
    flex: 1;
    font-weight: 500;
    font-size: 15px;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.player-time {
    font-weight: 700;
    font-size: 16px;
    color: #00ff88;
    margin-left: 12px;
    flex-shrink: 0;
}
.back-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
}
.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

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

/* Utility */
.hidden {
    display: none !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive Design
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
    .card {
        width: 90%;
        max-width: 520px;
        padding: 30px 20px;
    }
    h1 {
        font-size: 2.2rem;
    }
    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 25px;
    }
    #gameArea {
        height: 200px;
        font-size: 24px;
    }
    #result {
        font-size: 42px;
    }
    .bg-glow {
        width: 100vw;
        height: 100vw;
        filter: blur(100px);
    }
    .cursor-glow {
        display: none; /* Disable cursor glow on touch devices */
    }
}

@media (max-width: 390px) {
    .card {
        padding: 25px 15px;
    }
    h1 {
        font-size: 1.8rem;
    }
    #gameArea {
        height: 160px;
        font-size: 20px;
    }
    .inline-name-row {
        gap: 6px;
    }
    .inline-name-row input {
        padding: 0 10px;
        font-size: 13px;
    }
    .submit-btn-inline {
        width: 58px;
        font-size: 12px;
    }
    .status-row {
        gap: 6px;
    }
    .submit-message {
        font-size: 11px;
    }
    .change-name-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
}
