:root {
    --sp-primary: #2563eb;
    --sp-primary-dark: #1d4ed8;
    --sp-ink: #101827;
    --sp-muted: #64748b;
    --sp-line: #e2e8f0;
    --sp-bg: #f7fbff;
    --sp-card: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Sarabun", sans-serif;
    color: var(--sp-ink);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .14), transparent 22rem),
        linear-gradient(180deg, #f8fbff, #eef6ff);
}

a {
    color: inherit;
}

.sp-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--sp-line);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
    backdrop-filter: blur(14px);
}

.sp-nav {
    min-height: 64px;
    max-width: 1280px;
    margin: 0 auto;
    padding: .5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sp-brand {
    font-size: 1.15rem;
    font-weight: 800;
    white-space: nowrap;
    text-decoration: none;
}

.sp-menu {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .2rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.sp-menu a {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .6rem .55rem;
    border-radius: .7rem;
    color: #111827;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.sp-menu a:hover,
.sp-menu a.active {
    background: #eff6ff;
    color: var(--sp-primary-dark);
}

.sp-login {
    background: var(--sp-primary);
    color: #fff;
    text-decoration: none;
    border-radius: .65rem;
    padding: .7rem 1.2rem;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .25);
    white-space: nowrap;
}

.sp-main {
    max-width: 1240px;
    margin: 0 auto;
    padding: 1.25rem;
}

.sp-hero {
    position: relative;
    overflow: hidden;
    min-height: 320px;
    display: grid;
    align-items: center;
    border-radius: 1.5rem;
    padding: 2.5rem;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(14, 165, 233, .95), rgba(37, 99, 235, .92)),
        radial-gradient(circle at 85% 10%, rgba(255, 255, 255, .55), transparent 18rem);
    box-shadow: 0 24px 70px rgba(37, 99, 235, .22);
}

.sp-hero.compact {
    min-height: 220px;
}

.sp-hero:after {
    content: "";
    position: absolute;
    inset: auto -6rem -8rem auto;
    width: 22rem;
    height: 22rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
}

.sp-hero-text {
    position: relative;
    z-index: 1;
    max-width: 820px;
}

.sp-kicker {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .26);
    padding: .4rem .75rem;
    border-radius: 999px;
    font-weight: 700;
}

.sp-hero h1 {
    font-size: clamp(2rem, 5vw, 4.2rem);
    margin: .8rem 0 .4rem;
    line-height: 1.08;
}

.sp-hero p {
    font-size: 1.18rem;
    line-height: 1.75;
    margin: 0;
    color: #eff6ff;
}

.sp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.sp-stat,
.sp-link-card,
.sp-card {
    background: var(--sp-card);
    border: 1px solid rgba(148, 163, 184, .26);
    border-radius: 1.2rem;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .07);
}

.sp-stat {
    padding: 1.15rem;
}

.sp-stat span {
    color: var(--sp-muted);
    font-size: .92rem;
}

.sp-stat strong {
    display: block;
    font-size: 2rem;
    margin-top: .15rem;
}

.sp-link-card {
    display: block;
    text-decoration: none;
    padding: 1.2rem;
    transition: transform .16s ease, box-shadow .16s ease;
}

.sp-link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 42px rgba(37, 99, 235, .13);
}

.sp-link-card i {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 14px;
    background: #eff6ff;
    color: var(--sp-primary);
    margin-bottom: .75rem;
}

.sp-link-card strong {
    display: block;
    font-size: 1.1rem;
}

.sp-link-card span {
    display: block;
    color: var(--sp-muted);
    line-height: 1.65;
    margin-top: .25rem;
}

.sp-card {
    margin-top: 1.25rem;
    padding: 1.25rem;
}

.sp-card-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.sp-card h2 {
    margin: 0;
    font-size: 1.35rem;
}

.sp-card p {
    margin: .25rem 0 0;
    color: var(--sp-muted);
}

.sp-search {
    display: flex;
    gap: .5rem;
    min-width: min(100%, 430px);
}

.sp-search input {
    flex: 1;
    border: 1px solid var(--sp-line);
    border-radius: .75rem;
    padding: .75rem .9rem;
    font-family: inherit;
}

.sp-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(220px, 1fr) auto;
    gap: .85rem;
    align-items: end;
}

.sp-filter-grid label {
    display: grid;
    gap: .35rem;
    color: var(--sp-muted);
    font-weight: 700;
}

.sp-filter-grid select {
    width: 100%;
    border: 1px solid var(--sp-line);
    border-radius: .85rem;
    padding: .78rem .9rem;
    background: #fff;
    font-family: inherit;
    font-weight: 700;
    color: var(--sp-ink);
}

.sp-filter-grid button,
.sp-soft-link {
    border: 0;
    border-radius: .85rem;
    padding: .82rem 1.1rem;
    background: var(--sp-primary);
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.sp-soft-link {
    background: #eff6ff;
    color: var(--sp-primary-dark);
}

.sp-medal-stats .sp-stat {
    position: relative;
    overflow: hidden;
}

.sp-medal-stats .sp-stat:after {
    content: "";
    position: absolute;
    right: -1.5rem;
    bottom: -1.5rem;
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 999px;
    opacity: .22;
}

.sp-medal-stats .medal-gold:after { background: #facc15; }
.sp-medal-stats .medal-silver:after { background: #94a3b8; }
.sp-medal-stats .medal-bronze:after { background: #f97316; }

.sp-criteria-strip {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

.sp-medal-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border: 1px solid var(--sp-line);
    border-radius: 999px;
    padding: .42rem .72rem;
    background: #f8fafc;
    color: #334155;
    font-weight: 800;
    white-space: nowrap;
}

.sp-medal-pill i {
    width: .78rem;
    height: .78rem;
    border-radius: 999px;
    background: #94a3b8;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .65);
}

.sp-medal-pill b {
    color: var(--sp-muted);
    font-size: .82rem;
}

.sp-medal-pill.gold {
    background: #fef9c3;
    border-color: #fde68a;
    color: #854d0e;
}

.sp-medal-pill.gold i { background: #facc15; }

.sp-medal-pill.silver {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.sp-medal-pill.silver i { background: #94a3b8; }

.sp-medal-pill.bronze {
    background: #ffedd5;
    border-color: #fed7aa;
    color: #9a3412;
}

.sp-medal-pill.bronze i { background: #f97316; }

.sp-medal-pill.honorable {
    background: #ecfeff;
    border-color: #a5f3fc;
    color: #155e75;
}

.sp-medal-pill.honorable i { background: #06b6d4; }

.sp-medal-table th,
.sp-medal-table td {
    text-align: center;
}

.sp-medal-table th:nth-child(2),
.sp-medal-table td:nth-child(2) {
    text-align: left;
}

.sp-rank {
    font-size: 1.15rem;
    font-weight: 900;
    color: #1e293b;
}

.sp-school-link {
    display: block;
    font-weight: 900;
    color: #1e3a8a;
    text-decoration: none;
}

.sp-school-link:hover {
    color: var(--sp-primary);
    text-decoration: underline;
}

.sp-table small {
    display: block;
    color: var(--sp-muted);
    margin-top: .2rem;
}

.sp-medal-count a,
.sp-total-weight {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    height: 2.1rem;
    border-radius: .7rem;
    font-weight: 900;
    text-decoration: none;
}

.sp-medal-count span {
    color: #cbd5e1;
    font-weight: 800;
}

.sp-medal-count.gold a {
    background: #fef9c3;
    color: #a16207;
}

.sp-medal-count.silver a {
    background: #f1f5f9;
    color: #475569;
}

.sp-medal-count.bronze a {
    background: #ffedd5;
    color: #c2410c;
}

.sp-medal-count.honorable a {
    background: #ecfeff;
    color: #0e7490;
}

.sp-medal-count.participant a {
    background: #eff6ff;
    color: #1d4ed8;
}

.sp-total-weight {
    background: #e0f2fe;
    color: #075985;
}

.sp-search button,
.sp-pagination a {
    border: 0;
    border-radius: .75rem;
    padding: .75rem .9rem;
    background: var(--sp-primary);
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    text-decoration: none;
}

.sp-tabs {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding-bottom: .5rem;
    margin-bottom: .75rem;
}

.sp-tab {
    border: 1px solid var(--sp-line);
    background: #fff;
    border-radius: 999px;
    padding: .55rem .85rem;
    text-decoration: none;
    color: #334155;
    font-weight: 700;
    white-space: nowrap;
}

.sp-tab.active {
    background: var(--sp-primary);
    border-color: var(--sp-primary);
    color: #fff;
}

.sp-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--sp-line);
    border-radius: 1rem;
}

.sp-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.sp-table th,
.sp-table td {
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--sp-line);
    padding: .85rem;
}

.sp-table th {
    background: #f8fafc;
    color: #475569;
    white-space: nowrap;
}

.sp-table td:first-child,
.sp-table th:first-child {
    width: 70px;
    text-align: center;
}

.sp-table small {
    display: block;
    color: var(--sp-muted);
    margin-top: .25rem;
}

.sp-field-list {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.sp-field-list span {
    border: 1px solid #dbeafe;
    background: #eff6ff;
    border-radius: 999px;
    padding: .28rem .55rem;
    font-size: .9rem;
}

.sp-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding-top: 1rem;
    color: var(--sp-muted);
}

.sp-pagination div {
    display: flex;
    gap: .5rem;
}

.sp-empty {
    padding: 2rem;
    text-align: center;
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    color: var(--sp-muted);
}

.sp-footer {
    max-width: 1240px;
    margin: 1.5rem auto 2rem;
    padding: 0 1.25rem;
    color: var(--sp-muted);
    text-align: center;
}

@media (max-width: 900px) {
    .sp-nav {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .sp-menu {
        order: 3;
        width: 100%;
    }

    .sp-card-head,
    .sp-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .sp-search {
        min-width: 100%;
    }

    .sp-filter-grid {
        grid-template-columns: 1fr;
    }

    .sp-medal-pill {
        white-space: normal;
    }
}
