:root {
    color-scheme: dark;
    --bg: #061116;
    --surface: #0c1b22;
    --surface-2: #112630;
    --surface-3: #173440;
    --line: #244653;
    --line-soft: #17333d;
    --text: #f3fbfd;
    --muted: #9bb8c1;
    --cyan: #52d5e8;
    --blue: #4d8ff7;
    --mint: #4ee0a0;
    --gold: #f3c969;
    --coral: #ff8277;
    --violet: #ba9cff;
    --shadow: 0 22px 60px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(82, 213, 232, .15), transparent 28rem),
        radial-gradient(circle at 88% 6%, rgba(77, 143, 247, .13), transparent 32rem),
        linear-gradient(180deg, #0a1c24 0, var(--bg) 34rem);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

button, input, select { font: inherit; }
button, input, select {
    border: 1px solid var(--line);
    color: var(--text);
    background: #09171d;
    outline: none;
}
a { color: inherit; text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(82, 213, 232, .2);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 26px;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(6, 17, 22, .9);
    backdrop-filter: blur(18px);
}

.brand, .top-actions, .profile-card { display: flex; align-items: center; gap: 12px; }
.brand-mark, .profile-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--cyan), var(--blue));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), 0 10px 30px rgba(52, 156, 210, .2);
    font-size: 23px;
}
.brand strong { display: block; font-size: 18px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.player-badge, .secondary-link {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(12, 27, 34, .85);
    font-size: 12px;
    font-weight: 800;
}
.secondary-link:hover { color: var(--text); border-color: var(--cyan); }

.app-shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 74px;
    height: calc(100vh - 74px);
    padding: 22px 18px;
    border-right: 1px solid var(--line-soft);
    background: rgba(6, 17, 22, .75);
    overflow-y: auto;
}
.profile-card {
    align-items: flex-start;
    padding: 15px;
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(17, 38, 48, .95), rgba(8, 24, 30, .95));
}
.profile-icon { width: 42px; height: 42px; border-radius: 12px; font-size: 19px; }
.eyebrow {
    margin: 0 0 5px;
    color: var(--cyan);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .11em;
    text-transform: uppercase;
}
.profile-card h1 { margin: 0; font-size: 16px; }
.profile-card p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.side-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 16px; }
.side-nav button {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-radius: 10px;
    color: #bed0d6;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
}
.side-nav button:hover, .side-nav button.is-active {
    border-color: rgba(82, 213, 232, .65);
    color: var(--text);
    background: rgba(82, 213, 232, .12);
}
.side-nav button span { font-size: 16px; }
.sidebar-tip { margin: 16px 4px 0; color: var(--muted); font-size: 12px; }
.sidebar-tip strong { color: var(--gold); }

.main-content { min-width: 0; padding: 28px; }
.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    min-height: 160px;
    padding: 28px;
    border: 1px solid var(--line-soft);
    border-radius: 22px;
    background:
        linear-gradient(110deg, rgba(12, 36, 46, .96), rgba(9, 24, 31, .92)),
        radial-gradient(circle at 90% 0, rgba(82, 213, 232, .25), transparent 50%);
    box-shadow: var(--shadow);
}
.hero h2 { margin: 0; font-size: clamp(25px, 3vw, 40px); letter-spacing: -.035em; }
.hero p:last-child { max-width: 720px; margin: 9px 0 0; color: var(--muted); }
.summary-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.summary-stat {
    min-width: 104px;
    padding: 11px 13px;
    border: 1px solid rgba(82, 213, 232, .2);
    border-radius: 12px;
    background: rgba(5, 17, 22, .62);
}
.summary-stat strong { display: block; font-size: 18px; }
.summary-stat span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(145px, 190px));
    gap: 10px;
    margin-top: 18px;
    padding: 13px;
    border: 1px solid var(--line-soft);
    border-radius: 15px;
    background: rgba(12, 27, 34, .86);
}
.search-box { position: relative; }
.search-box span { position: absolute; left: 13px; top: 9px; color: var(--muted); font-size: 20px; }
.toolbar input, .toolbar select { width: 100%; height: 42px; border-radius: 10px; padding: 0 12px; }
.toolbar input { padding-left: 39px; }

.notice {
    margin-top: 18px;
    padding: 13px 16px;
    border: 1px solid rgba(243, 201, 105, .35);
    border-radius: 12px;
    color: #ffe6a8;
    background: rgba(113, 77, 17, .24);
}
.content-panel { margin-top: 18px; }
.loading, .empty-state {
    display: grid;
    place-items: center;
    min-height: 220px;
    padding: 30px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
}
.loading span { width: 28px; height: 28px; margin-bottom: 10px; border: 3px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.data-card, .guide-card, .mission-card, .achievement-card {
    position: relative;
    overflow: hidden;
    padding: 17px;
    border: 1px solid var(--line-soft);
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(17, 38, 48, .95), rgba(9, 24, 30, .95));
}
.data-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--rarity-color, var(--cyan));
}
.data-card.is-locked-zone,
.data-card.is-locked-mode,
.data-card.is-locked-shop-item {
    --rarity-color: #ff9757;
    border-color: rgba(255, 151, 87, .34);
    background: linear-gradient(145deg, rgba(73, 40, 25, .8), rgba(20, 27, 30, .96));
}
.data-card.is-locked-zone h3,
.data-card.is-locked-mode h3,
.data-card.is-locked-shop-item h3 { color: #ffd0ad; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-icon { font-size: 25px; line-height: 1; }
.data-card h3, .guide-card h3, .mission-card h3, .achievement-card h3 { margin: 0; font-size: 15px; }
.card-id { margin: 4px 0 0; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.card-copy { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.card-status { justify-content: flex-end; margin-top: 0; }
.tag {
    padding: 4px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #c5d6dc;
    background: rgba(5, 17, 22, .55);
    font-size: 10px;
    font-weight: 800;
}
.tag.good { color: #9ff0c7; border-color: rgba(78, 224, 160, .3); }
.tag.gold { color: #ffe19a; border-color: rgba(243, 201, 105, .32); }
.tag.muted { color: #819ba4; }
.tag.locked { color: #ffc28f; border-color: rgba(255, 151, 87, .42); background: rgba(98, 45, 22, .28); }
.status-mark { color: var(--mint); font-size: 20px; }
.status-mark.missing { color: #536b74; }

.command-row-tags,
.command-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.command-row-tags {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
}

.command-tag {
    min-height: 29px;
    padding: 4px 9px;
    border: 1px solid rgba(82, 213, 232, .4);
    border-radius: 8px;
    color: #9beaf5;
    background: rgba(22, 78, 91, .28);
    font: 700 10px ui-monospace, SFMono-Regular, Consolas, monospace;
    white-space: nowrap;
    cursor: pointer;
}

.command-tag::before {
    content: '⧉ ';
    color: var(--cyan);
}

.command-tag:hover {
    border-color: var(--cyan);
    color: var(--text);
    background: rgba(82, 213, 232, .15);
}

.command-tag.is-copied {
    border-color: rgba(78, 224, 160, .65);
    color: #a8f4cd;
    background: rgba(78, 224, 160, .14);
}

.command-tag.is-copied::before { content: ''; }

.section-block { margin-top: 22px; }
.section-block:first-child { margin-top: 0; }
.section-title { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 11px; }
.section-title h3 { margin: 0; font-size: 17px; }
.section-title span { color: var(--muted); font-size: 12px; }

.data-table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 15px; }
.data-table { width: 100%; border-collapse: collapse; background: rgba(9, 24, 30, .88); font-size: 12px; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.data-table th { position: static; color: var(--muted); background: #10242d; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(82, 213, 232, .045); }
.data-table tbody tr.is-undiscovered { background: rgba(92, 47, 27, .13); }
.data-table tbody tr.is-undiscovered:hover { background: rgba(118, 59, 31, .21); }
.data-table tbody tr.is-undiscovered td:first-child { box-shadow: inset 3px 0 rgba(255, 151, 87, .55); }
.undiscovered-mark { color: #ffac75; }
.item-name { color: var(--text); font-weight: 800; }
.item-sub { display: block; color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.data-table .zones-cell {
    width: 290px;
    max-width: 290px;
    white-space: normal;
}
.zones-text {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.data-table .state-cell { min-width: 125px; white-space: nowrap; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 15px;
}
.pagination span { color: var(--muted); font-size: 12px; font-weight: 800; }
.pagination button {
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text);
    background: rgba(17, 49, 60, .75);
    cursor: pointer;
}
.pagination button:hover:not(:disabled) { border-color: var(--cyan); }
.pagination button:disabled { opacity: .4; cursor: default; }

.event-featured { border-color: rgba(243, 201, 105, .4); background: linear-gradient(145deg, rgba(48, 42, 24, .92), rgba(9, 24, 30, .96)); }

.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 13px; }
.guide-card strong { color: var(--gold); }
.command-list { display: grid; gap: 7px; margin-top: 12px; }
.command-row { display: grid; grid-template-columns: minmax(125px, .7fr) 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 12px; }
.command-row code { color: var(--cyan); font-weight: 800; }
.command-row span { color: var(--muted); }

.progress-track { height: 8px; margin-top: 13px; border-radius: 999px; background: #07151b; overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--mint)); }
.progress-label { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 11px; }
.mission-card.is-complete, .achievement-card.is-complete { border-color: rgba(78, 224, 160, .38); }

.ranking-list { display: grid; gap: 9px; }
.ranking-row {
    display: grid;
    grid-template-columns: 52px minmax(160px, 1fr) repeat(4, minmax(90px, 130px));
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border: 1px solid var(--line-soft);
    border-radius: 13px;
    background: rgba(10, 27, 34, .9);
}
.ranking-position { color: var(--gold); font-size: 18px; font-weight: 900; }
.ranking-name strong { display: block; }
.ranking-name span, .ranking-stat span { color: var(--muted); font-size: 10px; }
.ranking-stat strong { display: block; font-size: 13px; }

.menu-button { display: none; }

@media (max-width: 1050px) {
    .app-shell { grid-template-columns: 238px minmax(0, 1fr); }
    .side-nav { grid-template-columns: 1fr; }
    .toolbar { grid-template-columns: 1fr 1fr; }
    .ranking-row { grid-template-columns: 45px minmax(150px, 1fr) repeat(2, minmax(90px, 1fr)); }
    .ranking-stat:nth-last-child(-n+2) { display: none; }
}

@media (max-width: 760px) {
    .topbar { min-height: 64px; padding: 9px 14px; }
    .brand-mark { width: 42px; height: 42px; }
    .player-badge { display: none; }
    .app-shell { display: block; }
    .sidebar {
        position: fixed;
        z-index: 25;
        top: 64px;
        left: 0;
        width: min(310px, 88vw);
        height: calc(100vh - 64px);
        transform: translateX(-105%);
        transition: transform .2s ease;
        background: #07161c;
        box-shadow: var(--shadow);
    }
    body.menu-open .sidebar { transform: translateX(0); }
    .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main-content { padding: 14px; }
    .hero { min-height: 0; display: block; padding: 21px; border-radius: 17px; }
    .summary-stats { justify-content: flex-start; margin-top: 18px; }
    .toolbar { grid-template-columns: 1fr; }
    .menu-button {
        position: fixed;
        z-index: 40;
        right: 15px;
        bottom: 15px;
        display: grid;
        place-items: center;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border-color: rgba(82, 213, 232, .55);
        background: #12313c;
        box-shadow: var(--shadow);
        cursor: pointer;
    }
    .ranking-row { grid-template-columns: 40px minmax(120px, 1fr) 90px; }
    .ranking-stat:nth-last-child(-n+3) { display: none; }
}
