:root {
    --bg: #07080c;
    --bg-2: #0c0f16;
    --ink: #f4f6fb;
    --muted: #9aa3b8;
    --line: rgba(255, 255, 255, 0.08);
    --cell: rgba(16, 20, 30, 0.88);
    --cell-hover: rgba(22, 28, 42, 0.96);
    --emerald: #34f5a0;
    --emerald-dim: #1bd489;
    --gold: #e7c56a;
    --danger: #ff5d73;
    --glow: 0 0 0 1px rgba(52, 245, 160, 0.18), 0 18px 50px rgba(52, 245, 160, 0.08);
    --radius: 22px;
}

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

html,
body {
    min-height: 100%;
}

body {
    font-family: Outfit, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    overflow-x: hidden;
}

.atmosphere {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(1200px 700px at 12% -10%, rgba(52, 245, 160, 0.12), transparent 55%),
        radial-gradient(900px 600px at 110% 10%, rgba(88, 116, 255, 0.16), transparent 50%),
        radial-gradient(800px 500px at 50% 120%, rgba(231, 197, 106, 0.08), transparent 55%),
        var(--bg);
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.55;
    animation: drift 18s ease-in-out infinite;
}

.orb-a {
    width: 340px;
    height: 340px;
    left: -80px;
    top: 18%;
    background: rgba(52, 245, 160, 0.18);
}

.orb-b {
    width: 420px;
    height: 420px;
    right: -120px;
    top: -80px;
    background: rgba(79, 108, 255, 0.22);
    animation-delay: -6s;
}

.orb-c {
    width: 280px;
    height: 280px;
    right: 18%;
    bottom: -90px;
    background: rgba(231, 197, 106, 0.12);
    animation-delay: -11s;
}

.grain {
    position: absolute;
    inset: 0;
    opacity: 0.18;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.stage {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    padding: 28px 20px 36px;
    width: min(1080px, 100%);
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mark {
    width: 44px;
    height: 44px;
    color: var(--emerald);
    display: grid;
    place-items: center;
    filter: drop-shadow(0 0 18px rgba(52, 245, 160, 0.35));
}

.mark svg {
    width: 44px;
    height: 44px;
}

.brand-copy h1 {
    font-family: Syne, Outfit, sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.brand-copy p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.progress {
    min-width: 180px;
    display: grid;
    gap: 8px;
    justify-items: end;
}

.progress.compact {
    min-width: 120px;
}

.progress-label {
    font-family: Syne, Outfit, sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--emerald);
}

.progress-track {
    width: 180px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.progress-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--emerald-dim), var(--emerald));
    box-shadow: 0 0 16px rgba(52, 245, 160, 0.55);
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.board {
    padding: 14px;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--line);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(22px);
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.cell {
    --i: 0;
    position: relative;
    min-height: clamp(128px, 18vh, 176px);
    padding: 22px 18px 18px;
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 42%),
        var(--cell);
    border: 1px solid var(--line);
    overflow: hidden;
    isolation: isolate;
    animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i) * 35ms);
}

.cell::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(120px 80px at 20% 0%, rgba(255, 255, 255, 0.07), transparent 70%);
    pointer-events: none;
}

.cell-index {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    color: rgba(244, 246, 251, 0.28);
    z-index: 1;
}

.cell-text {
    position: relative;
    z-index: 1;
    max-width: 92%;
    font-size: clamp(0.92rem, 1.45vw, 1.12rem);
    font-weight: 500;
    line-height: 1.38;
    letter-spacing: -0.01em;
    white-space: pre-wrap;
    word-break: break-word;
    transition: opacity 0.3s ease, color 0.3s ease, filter 0.3s ease;
}

.stamp {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--emerald);
    opacity: 0;
    transform: scale(0.62) rotate(-12deg);
    pointer-events: none;
    z-index: 2;
    filter: drop-shadow(0 0 18px rgba(52, 245, 160, 0.45));
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.stamp svg {
    width: min(72%, 118px);
    height: min(72%, 118px);
}

.stamp circle {
    stroke: currentColor;
    stroke-width: 3.5;
    opacity: 0.28;
}

.stamp path {
    fill: none;
    stroke: currentColor;
    stroke-width: 7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cell.is-checked {
    border-color: rgba(52, 245, 160, 0.38);
    background:
        linear-gradient(180deg, rgba(52, 245, 160, 0.12), rgba(16, 20, 30, 0.92)),
        var(--cell);
    box-shadow: var(--glow);
}

.cell.is-checked .stamp {
    opacity: 0.95;
    transform: scale(1) rotate(-8deg);
}

.cell.is-checked .cell-text,
.cell.is-checked .cell-input {
    color: #d7ffe9;
    opacity: 0.72;
}

.cell.just-checked .stamp {
    animation: stamp-in 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.admin-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.save-status {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    padding: 8px 12px;
    border-radius: 999px;
}

.save-status.is-saving {
    color: var(--gold);
    border-color: rgba(231, 197, 106, 0.28);
}

.save-status.is-error {
    color: #fff;
    background: var(--danger);
    border-color: transparent;
}

.public-link {
    color: #07080c;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--emerald);
    padding: 10px 14px;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(52, 245, 160, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.public-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(52, 245, 160, 0.32);
}

.admin-cell {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 28px 14px 14px;
}

.cell-input {
    width: 100%;
    flex: 1;
    resize: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: clamp(0.86rem, 1.3vw, 1.02rem);
    line-height: 1.35;
    color: var(--ink);
    z-index: 1;
}

.cell-input:focus {
    outline: none;
}

.admin-cell:focus-within {
    border-color: rgba(52, 245, 160, 0.42);
    box-shadow: var(--glow);
}

.toggle-btn {
    align-self: flex-start;
    z-index: 3;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.toggle-btn:hover {
    border-color: rgba(52, 245, 160, 0.4);
    color: var(--emerald);
}

.admin-cell.is-checked .toggle-btn {
    background: rgba(52, 245, 160, 0.14);
    border-color: rgba(52, 245, 160, 0.35);
    color: var(--emerald);
}

.admin-hint {
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

@keyframes drift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(30px, -24px, 0) scale(1.08); }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes stamp-in {
    0% { opacity: 0; transform: scale(1.35) rotate(-18deg); }
    60% { opacity: 1; transform: scale(0.94) rotate(-6deg); }
    100% { opacity: 0.95; transform: scale(1) rotate(-8deg); }
}

@media (max-width: 860px) {
    .stage {
        justify-content: flex-start;
        padding-top: 18px;
    }

    .topbar,
    .admin-tools {
        width: 100%;
    }

    .progress-track {
        width: 140px;
    }
}

@media (max-width: 720px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cell {
        min-height: 132px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-tools {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .grid {
        gap: 8px;
    }

    .board {
        padding: 8px;
        border-radius: 18px;
    }

    .cell-text,
    .cell-input {
        font-size: 0.84rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
