html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    touch-action: manipulation;
    font-family: Arial, sans-serif;
}

a {
    color: inherit;
}

#map {
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

.map-links {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
}

.map-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    text-decoration: none;
    background: rgba(15, 23, 42, 0.84);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
    backdrop-filter: blur(14px);
}

.map-links a:hover {
    background: rgba(30, 41, 59, 0.92);
}

.mark-popup-image {
    display: block;
    margin-top: 8px;
    max-width: 220px;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.admin-page {
    overflow: auto;
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, rgba(56, 189, 248, 0.22), transparent 32%),
        radial-gradient(circle at 90% 5%, rgba(34, 197, 94, 0.18), transparent 26%),
        linear-gradient(180deg, #05131f 0%, #0f172a 100%);
    color: #e2e8f0;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.admin-card {
    width: min(560px, 100%);
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.86);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 26px 72px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(14px);
    padding: 22px;
    display: grid;
    gap: 14px;
}

.admin-header h1 {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.2rem);
}

.admin-header p {
    margin: 8px 0 0;
    color: #cbd5e1;
}

.admin-eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
    color: #22d3ee;
}

.admin-form {
    display: grid;
    gap: 10px;
}

.admin-form label {
    font-size: 0.9rem;
    color: #cbd5e1;
}

.admin-form input,
.admin-form button {
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
    font-size: 1rem;
}

.admin-form input {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.72);
    color: #f8fafc;
    padding: 12px 14px;
}

.admin-file-row {
    display: flex;
    align-items: center;
}

.admin-form button {
    border: 0;
    padding: 12px 14px;
    font-weight: 700;
    background: #22d3ee;
    color: #082f49;
    cursor: pointer;
}

.admin-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-image-preview {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.admin-status {
    margin: 0;
    color: #cbd5e1;
}

.admin-status-error {
    color: #fca5a5;
}

.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-links a {
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.6);
}

.position-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    background: rgba(2, 6, 23, 0.68);
    padding: 16px;
    box-sizing: border-box;
}

.position-preview-modal[hidden] {
    display: none;
}

.position-preview-card {
    width: min(780px, 100%);
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 24px 72px rgba(2, 6, 23, 0.42);
    display: grid;
    gap: 10px;
}

.position-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.position-preview-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.position-preview-close {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(30, 41, 59, 0.84);
    color: #f8fafc;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
}

.position-preview-map {
    width: 100%;
    height: min(64vh, 480px);
    border-radius: 12px;
    overflow: hidden;
}

.scan-page {
    background: #0f172a;
}

.scan-page #map {
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 0;
}

.scan-page #map[hidden] {
    display: none;
}

.scan-panel {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(92vw, 360px);
    z-index: 3000;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(14px);
}

.scan-form {
    display: grid;
    gap: 12px;
    padding: 20px;
}

.scan-form h1 {
    margin: 0;
    font-size: 1.2rem;
}

.scan-form p {
    margin: 0;
    color: #cbd5e1;
    line-height: 1.45;
}

.scan-form label {
    font-size: 0.9rem;
    color: #cbd5e1;
}

.scan-form input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.72);
    color: #f8fafc;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 1rem;
}

.scan-form input::placeholder {
    color: #94a3b8;
}

.scan-form button {
    border: 0;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 1rem;
    font-weight: 700;
    background: #38bdf8;
    color: #082f49;
    cursor: pointer;
}

.scan-form input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(148, 163, 184, 0.18);
    color: #64748b;
}

.scan-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.scan-form button:not(:disabled):hover {
    background: #7dd3fc;
}

.scan-form button.scan-secondary-button {
    background: transparent;
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.scan-form button.scan-secondary-button:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

.leaderboard-page {
    overflow: auto;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.22), transparent 32%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.18), transparent 24%),
        linear-gradient(180deg, #07111f 0%, #0f172a 45%, #111827 100%);
    color: #e2e8f0;
}

.leaderboard-shell {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
    display: grid;
    gap: 20px;
}

.leaderboard-hero,
.board-card,
.stat-card {
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 24px 64px rgba(2, 6, 23, 0.24);
    backdrop-filter: blur(14px);
}

.leaderboard-hero {
    border-radius: 28px;
    padding: 28px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
}

.leaderboard-hero h1,
.board-header h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 0.98;
}

.hero-copy {
    margin: 10px 0 0;
    max-width: 60ch;
    color: #cbd5e1;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: #38bdf8;
}

.leaderboard-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.leaderboard-links a {
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.6);
}

.stat-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
    border-radius: 22px;
    padding: 20px;
    display: grid;
    gap: 8px;
}

.stat-label {
    color: #94a3b8;
    font-size: 0.9rem;
}

.stat-card strong {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    color: #f8fafc;
}

.stat-detail {
    color: #cbd5e1;
    line-height: 1.45;
}

.board-card {
    border-radius: 28px;
    padding: 22px;
}

.board-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.board-header h2 {
    font-size: clamp(1.4rem, 2.8vw, 2.1rem);
}

.leaderboard-search {
    display: grid;
    gap: 8px;
    min-width: min(100%, 420px);
}

.leaderboard-search label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #94a3b8;
}

.leaderboard-search-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.leaderboard-search-row input {
    flex: 1 1 160px;
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(7, 17, 31, 0.72);
    color: #f8fafc;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 0.98rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.leaderboard-search-row input::placeholder {
    color: #64748b;
    letter-spacing: 0.12em;
}

.leaderboard-search-row button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

.leaderboard-search-row button[type="submit"] {
    background: #38bdf8;
    color: #082f49;
}

.leaderboard-search-row button[type="button"] {
    background: rgba(148, 163, 184, 0.16);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.leaderboard-search-row button:hover {
    filter: brightness(1.06);
}

.board-table-wrap {
    overflow-x: auto;
}

.board-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.board-table th,
.board-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.board-table th {
    color: #94a3b8;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.board-table tbody tr:hover {
    background: rgba(56, 189, 248, 0.06);
}

.empty-state {
    padding: 28px 16px;
    text-align: center;
    color: #cbd5e1;
}

@media (max-width: 760px) {
    .leaderboard-shell {
        width: min(100vw - 16px, 1120px);
        padding: 12px 0 24px;
    }

    .leaderboard-hero {
        padding: 20px;
        flex-direction: column;
        align-items: start;
    }

    .leaderboard-hero h1 {
        font-size: 2.2rem;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .board-card {
        padding: 16px;
    }

    .leaderboard-search {
        width: 100%;
        min-width: 0;
    }

    .leaderboard-search-row {
        flex-direction: column;
    }

    .leaderboard-search-row input,
    .leaderboard-search-row button {
        width: 100%;
    }

    .board-table {
        min-width: 0;
    }

    .board-table thead {
        display: none;
    }

    .board-table,
    .board-table tbody,
    .board-table tr,
    .board-table td {
        display: block;
        width: 100%;
    }

    .board-table tr {
        margin-bottom: 12px;
        border: 1px solid rgba(148, 163, 184, 0.18);
        border-radius: 18px;
        overflow: hidden;
        background: rgba(15, 23, 42, 0.55);
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 0;
    }

    .board-table td {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 12px;
        border-bottom: 1px solid rgba(148, 163, 184, 0.12);
        text-align: right;
        min-width: 0;
        font-size: 0.86rem;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .board-table td:nth-child(1),
    .board-table td:nth-child(2),
    .board-table td:nth-child(3) {
        grid-column: span 1;
    }

    .board-table td:nth-child(4),
    .board-table td:nth-child(5) {
        grid-column: 1 / -1;
        font-size: 0.8rem;
        color: #cbd5e1;
    }

    .board-table td::before {
        content: attr(data-label);
        color: #94a3b8;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        text-align: left;
        flex: 0 0 auto;
    }

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

    .board-table td:first-child {
        font-weight: 700;
        color: #f8fafc;
    }

    .board-table td:first-child::before {
        content: attr(data-label);
    }

    .board-table td:nth-child(4)::before,
    .board-table td:nth-child(5)::before {
        color: #7dd3fc;
    }
}