/* ─── TOKENS ─────────────────────────── */
:root {
    --c-bg:       #0d0d0d;
    --c-surface:  #161616;
    --c-surface2: #1f1f1f;
    --c-border:   #2a2a2a;
    --c-border2:  #383838;
    --c-text:     #efefef;
    --c-muted:    #777;
    --c-green:    #3a8c32;
    --c-green-hi: #7ee870;
    --c-gold:     #c49a00;
    --c-gold-hi:  #f5c800;
    --c-red:      #8c3232;
    --c-red-hi:   #e05555;
    --r:          8px;
    --topbar-h:   52px;
}

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

body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: 'Barlow', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 1rem;
    padding: 1.5rem 1rem;
    padding-top: calc(var(--topbar-h) + 1.5rem);
}

/* ─── TOP BAR ────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: linear-gradient(180deg, #1a1a1a 0%, var(--c-surface) 100%);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    gap: 1.5rem;
    z-index: 10;
}
.topbar-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.35rem;
    letter-spacing: 5px;
    color: var(--c-text);
    flex-shrink: 0;
    opacity: 0.9;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.row-counter {
    font-size: 0.78rem;
    color: var(--c-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-right: 0.25rem;
}
.row-counter span { color: var(--c-text); font-weight: 600; }
.row-counter.warning span:first-child { color: var(--c-gold-hi); }
.row-counter.danger  span:first-child { color: var(--c-red-hi); }

.auth-btn {
    padding: 6px 16px;
    font-size: 0.77rem;
    font-weight: 600;
    font-family: 'Barlow', sans-serif;
    background: var(--c-surface2);
    border: 1px solid var(--c-border2);
    border-radius: var(--r);
    cursor: pointer;
    color: var(--c-text);
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.auth-btn:hover { background: #272727; border-color: #555; }
.auth-btn.logged-in { border-color: var(--c-green); color: var(--c-green-hi); }

.topbar-premium {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 0.5rem;
    border-right: 1px solid var(--c-border);
}
.premium-btn {
    padding: 6px 13px;
    font-size: 0.74rem;
    font-weight: 600;
    font-family: 'Barlow', sans-serif;
    background: transparent;
    border: 1px solid var(--c-border2);
    border-radius: var(--r);
    cursor: pointer;
    color: var(--c-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.premium-btn:hover { background: var(--c-surface2); border-color: #555; color: var(--c-text); }
.premium-btn .lock { font-size: 0.62rem; opacity: 0.5; }
.premium-btn.unlocked { border-color: var(--c-gold); color: var(--c-gold-hi); }
.premium-btn.unlocked:hover { background: rgba(196,154,0,0.08); }
.premium-btn.unlocked .lock { display: none; }

@media (max-width: 680px) {
    .topbar { padding: 0 1rem; gap: 0.5rem; }
    .topbar-title { display: none; }
    .topbar-premium { padding-right: 0.35rem; gap: 0.35rem; }
    .auth-btn { padding: 5px 11px; }
    .premium-btn { padding: 5px 9px; }
}

/* ─── MAIN LAYOUT ────────────────────── */
.hero { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }

h1 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3.8rem;
    letter-spacing: 8px;
    line-height: 1;
}

.desc {
    color: var(--c-muted);
    text-align: center;
    font-size: 0.86rem;
    max-width: 400px;
    line-height: 1.7;
}
.desc strong { color: var(--c-text); font-weight: 600; }

.indicator {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--c-green-hi);
    box-shadow: 0 0 10px var(--c-green-hi);
    transition: opacity 0.06s;
    flex-shrink: 0;
}
.indicator.dim { opacity: 0.1; }

/* ─── GRID (wymiary bez zmian — używane przez JS) ── */
.viewport-wrap { display: contents; }

.viewport {
    width: calc(4 * 150px + 3 * 8px);
    height: calc(6 * 64px + 5 * 8px);
    overflow: hidden;
    position: relative;
}
.grid-scroll {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.35s ease;
    will-change: transform;
}
.grid-row {
    display: grid;
    grid-template-columns: repeat(4, 150px);
    gap: 8px;
    flex-shrink: 0;
}
.cell {
    height: 64px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    border: 2px solid transparent;
    text-transform: lowercase;
}
.blank { background: #1c1c1c; border-color: #2e2e2e; }
.cell.active { border-color: #fff !important; box-shadow: 0 0 18px rgba(255,255,255,0.75); }
.blank.active { background: #383838; }
.blank.passed { background: #252525; border-color: #3a3a3a; }
.cell.passed:not(.blank) { opacity: 0.4; }

/* ─── BUTTONS ────────────────────────── */
button {
    padding: 13px 52px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Barlow', sans-serif;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    border: none;
    border-radius: var(--r);
    cursor: pointer;
    background: var(--c-green);
    color: #fff;
    transition: background 0.15s, transform 0.08s;
}
button:hover { background: #44a638; }
button:active { transform: scale(0.97); }
button.running { background: var(--c-red); }
button.running:hover { background: #a63838; }
button:disabled { background: #222; color: #444; cursor: default; transform: none; }

#status {
    font-size: 0.74rem;
    color: #505050;
    min-height: 1.1rem;
    letter-spacing: 0.4px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* ─── MODALS ─────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.overlay.hidden { display: none; }

.modal {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 2rem 1.75rem;
    max-width: 460px;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.modal h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.9rem;
    letter-spacing: 2px;
    font-weight: 400;
    line-height: 1;
}
.modal p { color: var(--c-muted); line-height: 1.65; font-size: 0.88rem; }
.modal p strong { color: var(--c-text); }

.modal-steps { display: flex; flex-direction: column; gap: 0.65rem; }
.modal-step {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    font-size: 0.86rem;
    color: #bbb;
    line-height: 1.5;
}
.modal-step-num {
    width: 21px; height: 21px;
    border-radius: 50%;
    background: var(--c-surface2);
    border: 1px solid var(--c-border2);
    color: var(--c-muted);
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.25rem;
}
.modal-actions button {
    padding: 12px;
    font-size: 0.88rem;
    letter-spacing: 1.5px;
}
.btn-secondary {
    background: var(--c-surface2) !important;
    border: 1px solid var(--c-border) !important;
    color: var(--c-muted) !important;
}
.btn-secondary:hover {
    background: #272727 !important;
    border-color: var(--c-border2) !important;
    color: var(--c-text) !important;
}

.btn-close {
    position: absolute;
    top: 0.9rem; right: 0.9rem;
    background: none !important;
    border: none !important;
    color: #444;
    font-size: 0.95rem;
    padding: 5px 7px !important;
    cursor: pointer;
    letter-spacing: 0;
    min-width: unset;
    border-radius: 5px !important;
    line-height: 1;
    transition: color 0.15s, background 0.15s !important;
}
.btn-close:hover { color: var(--c-text) !important; background: var(--c-surface2) !important; }

/* ─── AUTH ───────────────────────────── */
.auth-input {
    width: 100%;
    padding: 11px 13px;
    background: var(--c-surface2);
    border: 1px solid var(--c-border);
    border-radius: var(--r);
    color: var(--c-text);
    font-size: 0.95rem;
    font-family: 'Barlow', sans-serif;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
}
.auth-input:focus { border-color: var(--c-green); }
.auth-input::placeholder { color: #444; }

.auth-error { color: var(--c-red-hi); font-size: 0.8rem; min-height: 1.1rem; }

.auth-toggle {
    text-align: center;
    color: #4a4a4a;
    font-size: 0.8rem;
    cursor: pointer;
}
.auth-toggle span { color: var(--c-green-hi); text-decoration: underline; }

.limit-badge { font-size: 2.5rem; text-align: center; line-height: 1; }

/* ─── BEAT PICKER ────────────────────── */
.modal-wide { max-width: 540px; }

.beat-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--c-border2) transparent;
}
.beat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.9rem;
    background: var(--c-surface2);
    border: 1px solid var(--c-border);
    border-radius: var(--r);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    gap: 0.75rem;
}
.beat-item:hover { background: #252525; border-color: var(--c-border2); }
.beat-item.selected { border-color: var(--c-gold); background: rgba(196,154,0,0.05); }
.beat-item-title { font-weight: 600; font-size: 0.88rem; }
.beat-item-meta { color: var(--c-muted); font-size: 0.74rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 2px; }
.beat-daily-badge {
    font-size: 0.64rem;
    font-weight: 600;
    background: rgba(58,140,50,0.12);
    border: 1px solid rgba(58,140,50,0.45);
    color: var(--c-green-hi);
    border-radius: 3px;
    padding: 1px 5px;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
.beat-list-empty { color: #444; text-align: center; padding: 2rem; font-size: 0.85rem; }

/* ─── ANIMATIONS ────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes btn-idle {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(58,140,50,0);
        background: var(--c-green);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(58,140,50,0.12), 0 0 32px 6px rgba(58,140,50,0.55);
        background: #44a638;
    }
}

.hero          { animation: fadeUp 0.4s ease both; }
.indicator     { animation: fadeUp 0.4s 0.08s ease both; }
.viewport-wrap { animation: fadeUp 0.4s 0.13s ease both; }
#btn           { animation: fadeUp 0.4s 0.18s ease both; }
#status        { animation: fadeUp 0.4s 0.22s ease both; }
.share-row     { animation: fadeUp 0.4s 0.27s ease both; }

#btn:not(:disabled):not(.running) {
    animation: fadeUp 0.4s 0.18s ease both, btn-idle 2.2s 0.6s ease-in-out infinite;
}

/* ─── SHARE ──────────────────────────── */
.share-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.share-trigger {
    background: none !important;
    border: 1px solid var(--c-border) !important;
    color: var(--c-muted) !important;
    padding: 5px 16px !important;
    font-size: 0.72rem !important;
    letter-spacing: 1px !important;
    border-radius: 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    transition: border-color 0.15s, color 0.15s, background 0.15s !important;
    text-transform: uppercase;
}
.share-trigger:hover {
    border-color: var(--c-border2) !important;
    color: var(--c-text) !important;
    background: var(--c-surface2) !important;
}
.share-panel {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
}
.share-panel.hidden { display: none; }
.share-opt {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 5px 12px !important;
    background: var(--c-surface2) !important;
    border: 1px solid var(--c-border) !important;
    border-radius: 20px !important;
    color: var(--c-muted) !important;
    font-family: 'Barlow', sans-serif !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s !important;
    white-space: nowrap;
}
.share-opt:hover {
    background: #252525 !important;
    border-color: var(--c-border2) !important;
    color: var(--c-text) !important;
}
.share-opt.copied {
    border-color: var(--c-green) !important;
    color: var(--c-green-hi) !important;
}

/* ─── ABOUT + CONTACT ROW ───────────── */
.bottom-row {
    display: flex;
    align-items: flex-start;
    gap: 2.5rem;
    width: 100%;
    max-width: 660px;
    margin-top: 1rem;
}
.about-section { flex: 1; min-width: 0; }
.contact-section { flex: 0 0 190px; }

.about-details { list-style: none; }
.about-summary {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #333;
    cursor: pointer;
    user-select: none;
    list-style: none;
    text-align: center;
    padding: 0.4rem 0;
    transition: color 0.15s;
}
.about-summary::-webkit-details-marker { display: none; }
.about-summary::marker { display: none; }
.about-summary:hover { color: #555; }
.about-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
    margin-top: 0.5rem;
}
.about-block h2 {
    font-family: 'Barlow', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #383838;
    margin-bottom: 0.4rem;
}
.about-block p {
    font-size: 0.82rem;
    color: #404040;
    line-height: 1.75;
}

/* ─── CONTACT SECTION ────────────────── */
.contact-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #333;
    text-align: center;
    padding: 0.4rem 0;
}
.contact-body {
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.contact-by {
    font-size: 0.75rem;
    color: #383838;
    line-height: 1.55;
}
.contact-by strong {
    display: block;
    color: #444;
    font-weight: 600;
}
.contact-email {
    display: inline-block;
    font-size: 0.74rem;
    color: #2e6b28;
    text-decoration: none;
    word-break: break-all;
    line-height: 1.4;
    transition: color 0.15s;
}
.contact-email:hover { color: var(--c-green-hi); }
.contact-hint {
    font-size: 0.72rem;
    color: #2d2d2d;
    line-height: 1.6;
    font-style: italic;
}

@media (max-width: 520px) {
    .bottom-row { flex-direction: column; gap: 0; }
    .about-section, .contact-section { flex: none; width: 100%; }
}

/* ─── MOBILE ─────────────────────────── */
@media (max-width: 680px) {
    body { gap: 0.7rem; padding: 0.75rem; padding-top: calc(var(--topbar-h) + 0.75rem); }

    .topbar-right { gap: 0.35rem; }
    #btnNoAds { display: none; }

    h1 { font-size: 2.6rem; letter-spacing: 5px; }
    .desc { font-size: 0.8rem; }

    /* Scale the game grid to fit without touching JS */
    .viewport-wrap {
        display: block;
        width: calc((4 * 150px + 3 * 8px) * 0.54);
        height: calc((6 * 64px + 5 * 8px) * 0.54);
        overflow: hidden;
        position: relative;
        flex-shrink: 0;
    }
    .viewport-wrap .viewport {
        transform: scale(0.54);
        transform-origin: top left;
        position: absolute;
        top: 0; left: 0;
    }

    button { padding: 12px 36px; font-size: 0.95rem; letter-spacing: 2px; }
    .modal { padding: 1.5rem 1.25rem; gap: 0.75rem; }
    .modal h2 { font-size: 1.6rem; }
}

@media (max-width: 360px) {
    .viewport-wrap {
        width: calc((4 * 150px + 3 * 8px) * 0.48);
        height: calc((6 * 64px + 5 * 8px) * 0.48);
    }
    .viewport-wrap .viewport { transform: scale(0.48); }
    h1 { font-size: 2.2rem; letter-spacing: 4px; }
}

/* ─── LANGUAGE SUGGESTION POPUP ──────── */
/* Deliberately NOT an .overlay — no dimmed backdrop, page/game stay visible behind it */
.lang-suggest-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    width: 88%;
    max-width: 320px;
    padding: 1.4rem 1.25rem;
    gap: 0.65rem;
    box-shadow: 0 16px 44px rgba(0,0,0,0.55);
}
.lang-suggest-popup.hidden { display: none; }
.lang-suggest-popup h2 { font-size: 1.4rem; text-align: center; }
.lang-suggest-popup .limit-badge { font-size: 1.8rem; }
.lang-suggest-popup .modal-actions { margin-top: 0.1rem; }
.lang-suggest-popup .modal-actions button { padding: 10px; font-size: 0.8rem; }

/* ─── LANGUAGE SWITCHER ──────────────── */
.lang-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    color: #333;
    margin-top: 0.5rem;
}
.lang-switch a {
    color: #444;
    text-decoration: none;
    transition: color 0.15s;
}
.lang-switch a:hover { color: var(--c-green-hi); }
.lang-switch .lang-current {
    color: var(--c-muted);
    font-weight: 600;
}

