@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&display=swap');

:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --snake-head: #f59e0b;
    --snake-body: #d97706;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(circle at 50% 50%, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
    user-select: none;
    -webkit-user-select: none;
}

/* ── Header override for this game ── */
.header {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
    flex-shrink: 0;
}

/* ── Main game area ── */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

#game-canvas {
    background: rgba(30, 41, 59, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        inset 0 0 60px rgba(245, 158, 11, 0.03);
    max-width: 100%;
    max-height: calc(100vh - 240px);
    touch-action: none;
}

/* ── Stats panel (top-right) ── */
.stats-panel {
    position: fixed;
    top: 80px;
    right: 1.5rem;
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 140px;
    z-index: 50;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.9rem;
    gap: 1rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* ── Buffer panel (bottom) — "Brzuszek" ── */
.buffer-panel {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    padding: 0.6rem 1.5rem;
    border-radius: 2.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.4rem;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 50;
    min-height: 52px;
}

.buffer-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 0.5rem;
    white-space: nowrap;
}

.buffer-letter {
    width: 34px;
    height: 34px;
    background: var(--accent);
    color: #000;
    font-weight: 800;
    font-size: 0.95rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.buffer-letter.newest {
    background: #10b981;
    color: white;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
    transform: scale(1.1);
}

.buffer-letter.empty {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.15);
    font-weight: 400;
    animation: none;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pop-animation {
    animation: popPulse 0.3s ease-out;
}

@keyframes popPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        color: var(--accent);
    }

    100% {
        transform: scale(1);
    }
}

/* ── Debug status bar ── */
#debug-status {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 18px;
    border-radius: 10px;
    font-size: 12px;
    z-index: 2000;
    pointer-events: none;
    font-family: 'Outfit', monospace;
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

/* ── Overlays (Game Over) ── */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    text-align: center;
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
    font-weight: 800;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Outfit', sans-serif;
}

.btn-primary:hover {
    transform: scale(1.05);
    background: var(--accent-hover);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .stats-panel {
        top: 70px;
        right: 0.75rem;
        min-width: 110px;
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }

    .buffer-panel {
        bottom: 0.75rem;
        padding: 0.4rem 0.8rem;
        gap: 0.3rem;
    }

    .buffer-letter {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .buffer-label {
        font-size: 0.6rem;
    }

    #game-canvas {
        max-height: calc(100vh - 200px);
    }
}

@media (max-width: 380px) {
    .buffer-letter {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }
}

/* ── Login / User Status Box ── */
.login-status-container {
    position: fixed;
    top: 80px;
    left: 1.5rem;
    z-index: 50;
}

.login-prompt-btn {
    background: var(--accent);
    color: #000;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.8rem;
    font-weight: 800;
    text-decoration: none;
    transition: all 0.2s;
    display: block;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.login-prompt-btn:hover {
    transform: scale(1.05);
    background: var(--accent-hover);
}

.user-info-mini {
    background: var(--card-bg);
    padding: 0.4rem 0.8rem;
    border-radius: 0.75rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-name-mini {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.user-dot.online {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .login-status-container {
        top: 70px;
        left: 0.75rem;
    }
}