:root {
    --bg: #06121f;
    --bg-deep: #020711;
    --panel: rgba(8, 19, 32, 0.78);
    --panel-strong: rgba(11, 27, 44, 0.92);
    --text: #f4fbff;
    --muted: #a9b8c8;
    --line: rgba(255, 255, 255, 0.14);
    --cyan: #19d3ff;
    --magenta: #ff4fbf;
    --amber: #ffd166;
    --green: #06d6a0;
    --danger: #ff6b6b;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
    --radius: 8px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg-deep);
    scroll-behavior: smooth;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
    background: var(--bg);
    overflow-x: hidden;
}

body,
input,
button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.motion-field {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(25, 211, 255, 0.12), transparent 28%),
        linear-gradient(35deg, rgba(255, 79, 191, 0.12), transparent 34%),
        linear-gradient(180deg, #06121f 0%, #09192a 54%, #020711 100%);
}

.motion-field::before {
    content: "";
    position: absolute;
    inset: -18%;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 42px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 42px),
        linear-gradient(115deg, transparent 0%, rgba(25, 211, 255, 0.12) 22%, transparent 36%, rgba(6, 214, 160, 0.1) 54%, transparent 70%, rgba(255, 209, 102, 0.1) 100%);
    opacity: 0.84;
    transform: translate3d(0, calc(var(--scroll-y, 0) * -0.05px), 0) rotate(0.001deg);
    animation: gridDrift 18s ease-in-out infinite alternate;
}

.field-layer {
    position: absolute;
    left: -20%;
    right: -20%;
    height: 28%;
    transform: translate3d(0, calc(var(--scroll-y, 0) * -0.08px), 0) rotate(-12deg);
    filter: blur(2px);
    opacity: 0.58;
}

.layer-one {
    top: 12%;
    background: linear-gradient(90deg, transparent 0%, rgba(25, 211, 255, 0.32) 38%, rgba(255, 255, 255, 0.16) 48%, transparent 66%);
    animation: bandSweep 12s ease-in-out infinite;
}

.layer-two {
    bottom: 4%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 79, 191, 0.24) 32%, rgba(255, 209, 102, 0.16) 52%, transparent 76%);
    animation: bandSweep 14s ease-in-out infinite reverse;
}

.scan-line {
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 120px;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    animation: scanMove 8s linear infinite;
}

.mobile-shell {
    width: min(100%, 480px);
    min-height: 100svh;
    margin: 0 auto;
    padding: calc(18px + env(safe-area-inset-top)) 16px calc(30px + env(safe-area-inset-bottom));
}

.register-shell,
.counter-shell,
.dashboard-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-panel,
.dashboard-head {
    padding: 50px 2px 8px;
}

.hero-panel h1,
.dashboard-head h1,
.state-panel h1 {
    margin: 4px 0 10px;
    color: var(--text);
    font-size: 2.75rem;
    line-height: 0.95;
    font-weight: 850;
    letter-spacing: 0;
    text-shadow: 0 0 28px rgba(25, 211, 255, 0.32);
}

.hero-copy,
.muted,
.install-note {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    display: block;
    margin: 0 0 6px;
    color: var(--green);
    font-size: 0.77rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.glass-panel,
.stat-card,
.identity-strip,
.share-strip,
.table-wrap,
.empty-state,
.notice,
.segmented-control {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.glass-panel {
    position: relative;
    padding: 16px;
    overflow: hidden;
}

.glass-panel::before,
.stat-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(25, 211, 255, 0.5), transparent 38%, rgba(255, 79, 191, 0.35));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.register-card,
.result-card,
.input-panel,
.state-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-label {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 750;
}

.neon-input,
.url-box {
    width: 100%;
    min-height: 54px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius);
    padding: 0 14px;
    color: var(--text);
    background: rgba(2, 7, 17, 0.68);
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(25, 211, 255, 0.08);
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.url-box {
    min-height: 46px;
    color: var(--green);
    font-size: 0.86rem;
}

.neon-input:focus,
.url-box:focus {
    border-color: rgba(25, 211, 255, 0.78);
    box-shadow: 0 0 0 4px rgba(25, 211, 255, 0.12), inset 0 0 0 1px rgba(25, 211, 255, 0.22);
    transform: translateY(-1px);
}

.primary-button,
.ghost-button,
.icon-text-button,
.nav-link,
.seg-button,
.url-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 0 14px;
    font-weight: 850;
    letter-spacing: 0;
    cursor: pointer;
    text-align: center;
    word-break: break-word;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.primary-button {
    color: #04111b;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    box-shadow: 0 14px 36px rgba(6, 214, 160, 0.22);
}

.ghost-button,
.icon-text-button,
.nav-link,
.seg-button,
.url-chip {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}

.primary-button:hover,
.ghost-button:hover,
.icon-text-button:hover,
.nav-link:hover,
.seg-button:hover,
.url-chip:hover {
    transform: translateY(-2px);
}

.primary-button:active,
.ghost-button:active,
.icon-text-button:active,
.nav-link:active,
.seg-button:active,
.url-chip:active {
    transform: translateY(0);
}

.url-chip {
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--cyan);
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

.action-grid,
.share-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-grid .whatsapp-link {
    grid-column: 1 / -1;
}

.notice {
    padding: 12px 14px;
    font-weight: 750;
}

.notice.success {
    border-color: rgba(6, 214, 160, 0.38);
    color: #cffced;
}

.notice.warning {
    border-color: rgba(255, 209, 102, 0.45);
    color: #fff1c7;
}

.notice.error {
    border-color: rgba(255, 107, 107, 0.45);
    color: #ffd1d1;
}

.user-id {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    border-radius: var(--radius);
    color: var(--amber);
    background: rgba(255, 209, 102, 0.1);
    border: 1px solid rgba(255, 209, 102, 0.24);
    font-size: 1.65rem;
    font-weight: 900;
}

.top-bar,
.identity-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.top-bar {
    position: sticky;
    top: 8px;
    z-index: 5;
    padding: 10px 0;
}

.brand-mark {
    font-size: 1.05rem;
    font-weight: 900;
}

.nav-link {
    min-height: 42px;
    padding-inline: 12px;
    font-size: 0.92rem;
}

.identity-strip {
    padding: 14px;
}

.identity-strip strong {
    display: block;
    color: var(--amber);
    font-size: 1.28rem;
}

.icon-text-button {
    min-height: 42px;
    max-width: 142px;
    font-size: 0.84rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    position: relative;
    min-height: 126px;
    padding: 14px;
    overflow: hidden;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
}

.stat-card strong {
    display: block;
    margin-top: 14px;
    color: var(--text);
    font-size: 1.9rem;
    line-height: 1;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.accent-cyan {
    border-color: rgba(25, 211, 255, 0.32);
}

.accent-magenta {
    border-color: rgba(255, 79, 191, 0.32);
}

.accent-amber {
    border-color: rgba(255, 209, 102, 0.32);
}

.accent-green {
    border-color: rgba(6, 214, 160, 0.32);
}

.input-panel {
    gap: 18px;
}

.count-entry {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.history-section,
.leaderboard-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

.table-wrap {
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 13px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    text-align: left;
    vertical-align: middle;
    word-break: break-word;
}

.data-table th {
    color: var(--green);
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.data-table td {
    color: var(--text);
    font-size: 0.92rem;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.leaderboard-table td:first-child {
    color: var(--amber);
    font-weight: 850;
}

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
}

.empty-state {
    padding: 16px;
    color: var(--muted);
    text-align: center;
}

.segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 6px;
}

.seg-button {
    min-height: 44px;
    font-size: 0.88rem;
}

.seg-button.active {
    color: #04111b;
    background: linear-gradient(135deg, var(--amber), var(--green));
    border-color: transparent;
}

.dashboard-head {
    padding-top: 28px;
}

.dashboard-head h1 {
    font-size: 2.25rem;
}

.state-panel {
    margin-top: 36px;
}

.toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 20;
    width: min(448px, calc(100% - 32px));
    margin: 0 auto;
    padding: 12px 14px;
    border: 1px solid rgba(6, 214, 160, 0.38);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--panel-strong);
    box-shadow: var(--shadow);
    animation: toastIn 220ms ease-out both;
}

.reveal {
    opacity: 0;
    transform: translateY(18px);
    animation: revealIn 700ms ease-out forwards;
}

.reveal:nth-of-type(2) {
    animation-delay: 90ms;
}

.reveal:nth-of-type(3) {
    animation-delay: 160ms;
}

@keyframes gridDrift {
    from {
        transform: translate3d(-1%, calc(var(--scroll-y, 0) * -0.05px), 0) rotate(0.001deg);
    }
    to {
        transform: translate3d(1%, calc(var(--scroll-y, 0) * -0.05px), 0) rotate(0.001deg);
    }
}

@keyframes bandSweep {
    0%, 100% {
        transform: translate3d(-8%, calc(var(--scroll-y, 0) * -0.08px), 0) rotate(-12deg);
    }
    50% {
        transform: translate3d(8%, calc(var(--scroll-y, 0) * -0.08px), 0) rotate(-12deg);
    }
}

@keyframes scanMove {
    from {
        transform: translateY(-140px);
    }
    to {
        transform: translateY(110vh);
    }
}

@keyframes revealIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (max-width: 360px) {
    .mobile-shell {
        padding-inline: 12px;
    }

    .hero-panel h1,
    .dashboard-head h1,
    .state-panel h1 {
        font-size: 2.25rem;
    }

    .stat-card {
        min-height: 118px;
        padding: 12px;
    }

    .stat-card strong {
        font-size: 1.55rem;
    }

    .data-table th,
    .data-table td {
        padding-inline: 7px;
        font-size: 0.82rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}
