:root {
    --bg: #f8fafc;
    --bg-2: #eef2f7;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #0ea5e9;
    --accent-2: #38bdf8;
    --card: rgba(255, 255, 255, 0.82);
    --card-border: rgba(15, 23, 42, 0.08);
    --pipe: #e2e8f0;
    --pipe-border: #cbd5e1;
    --ground: #f1f5f9;
    --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
    --shadow-strong: 0 24px 80px rgba(15, 23, 42, 0.14);
    --radius: 24px;
    --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #020617;
        --bg-2: #0f172a;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --accent: #38bdf8;
        --accent-2: #0ea5e9;
        --card: rgba(15, 23, 42, 0.78);
        --card-border: rgba(255, 255, 255, 0.08);
        --pipe: #1e293b;
        --pipe-border: #334155;
        --ground: #0f172a;
        --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
        --shadow-strong: 0 24px 80px rgba(0, 0, 0, 0.6);
    }
}

[data-theme="light"] {
    --bg: #f8fafc;
    --bg-2: #eef2f7;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #0ea5e9;
    --accent-2: #38bdf8;
    --card: rgba(255, 255, 255, 0.82);
    --card-border: rgba(15, 23, 42, 0.08);
    --pipe: #e2e8f0;
    --pipe-border: #cbd5e1;
    --ground: #f1f5f9;
    --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
    --shadow-strong: 0 24px 80px rgba(15, 23, 42, 0.14);
}

[data-theme="dark"] {
    --bg: #020617;
    --bg-2: #0f172a;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-2: #0ea5e9;
    --card: rgba(15, 23, 42, 0.78);
    --card-border: rgba(255, 255, 255, 0.08);
    --pipe: #1e293b;
    --pipe-border: #334155;
    --ground: #0f172a;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 24px 80px rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, var(--bg-2), var(--bg));
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.4s, color 0.3s;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
}

.topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 20;
    backdrop-filter: blur(12px);
    background: linear-gradient(to bottom, var(--card), transparent);
    border-bottom: 1px solid var(--card-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--text);
    color: var(--bg);
    display: grid;
    place-items: center;
    font-size: 18px;
}

.brand span {
    font-size: 15px;
}

.brand small {
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 6px;
    font-size: 12px;
}

.top-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card);
    backdrop-filter: blur(12px);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.icon-btn:active {
    transform: scale(0.96);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

#gameWrap {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 9/16;
    max-height: min(82vh, 800px);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
    box-shadow: var(--shadow-strong);
    border: 1px solid var(--card-border);
    margin-top: 24px;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

.hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.hud-score {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 64px;
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 1;
    color: var(--text);
    text-shadow: 0 2px 0 var(--card), 0 8px 24px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s;
}

.hud-score.pop {
    transform: translateX(-50%) scale(1.18);
}

.hud-top-right {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.hud-bottom {
    position: absolute;
    bottom: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.pill {
    background: var(--card);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-pill);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow);
}

.pill strong {
    font-weight: 800;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(600px 400px at 50% 0%, var(--card), transparent 70%);
    backdrop-filter: blur(2px);
    transition: opacity 0.3s, transform 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}

.card {
    width: 100%;
    max-width: 340px;
    background: var(--card);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-strong);
    text-align: center;
    animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card h1 {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 0.95;
    margin-bottom: 8px;
}

.card h1 span {
    color: var(--accent);
}

.card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 18px;
}

.bird-preview {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 20px;
    background: var(--bg-2);
    display: grid;
    place-items: center;
    position: relative;
    border: 1px solid var(--card-border);
}

.bird-preview::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 24px;
    border: 1px dashed var(--card-border);
    opacity: 0.6;
}

.btn {
    width: 100%;
    height: 48px;
    border-radius: 14px;
    border: 0;
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--card-border);
    margin-top: 10px;
}

.btn-ghost:hover {
    background: var(--bg-2);
}

.row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.row .btn {
    flex: 1;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.stat {
    background: var(--bg-2);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px;
}

.stat label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat strong {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.settings-grid {
    display: grid;
    gap: 12px;
    text-align: left;
    margin: 16px 0;
}

.setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-2);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 14px;
}

.setting span {
    font-size: 13px;
    font-weight: 600;
}

.setting small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.toggle {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: var(--card-border);
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    border: 0;
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s;
}

.toggle.on {
    background: var(--text);
}

.toggle.on::after {
    transform: translateX(18px);
}

.skins {
    display: flex;
    gap: 8px;
}

.skin-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.skin-dot.active {
    border-color: var(--text);
    transform: scale(1.15);
    box-shadow: 0 0 0 3px var(--card), 0 4px 12px rgba(0, 0, 0, 0.12);
}

.difficulty {
    display: flex;
    gap: 6px;
}

.diff-btn {
    flex: 1;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--bg);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.diff-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--bg-2);
    border: 1px solid var(--card-border);
    border-bottom-width: 2px;
    font-size: 11px;
    font-weight: 700;
}

.footer {
    margin-top: 16px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed;
}

.shake {
    animation: shake 0.12s linear 2;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-2px)
    }

    75% {
        transform: translateX(2px)
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-4px)
    }
}

@media (max-width: 520px) {
    #gameWrap {
        max-width: 100%;
        border-radius: 20px;
        margin-top: 56px;
        max-height: calc(100vh - 88px);
    }

    .topbar {
        height: 52px;
        padding: 0 14px;
    }

    .hud-score {
        font-size: 56px;
        top: 14px;
    }
}

@media (min-width: 900px) {
    #gameWrap {
        aspect-ratio: 4/5;
        max-height: 78vh;
    }
}