:root {
    color-scheme: dark;
    --bg: var(--game-bg-deep, #091321);
    --panel: var(--game-surface, #112338);
    --panel-2: var(--game-surface-high, #19304a);
    --line: var(--game-line-muted, #34536d);
    --text: var(--game-text-primary, #f0f6fc);
    --muted: var(--game-text-muted, #a8bacb);
    --accent: var(--game-glow-cyan, #2ad7d0);
    --accent-ink: #06241f;
    --danger: var(--game-danger, #fc6c76);
    --ok: #8ef0c4;
    --info: var(--game-glow-blue, #4c9bff);
    --amber: var(--game-signal-amber, #f6b64a);
    --common: var(--game-rarity-common, #b6c2cd);
    --uncommon: var(--game-rarity-uncommon, #45cd99);
    --rare: var(--game-rarity-rare, #5e9cfa);
    --epic: var(--game-rarity-epic, #b786f6);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --hud-h: 56px;
    --nav-h: 56px;
    --control-h: 44px;
    --radius: 12px;
    --title: 22px;
    --section: 17px;
    --stat: 20px;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.4 "Segoe UI", Roboto, sans-serif;
}

body.has-nav {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

a { color: var(--accent); }

img { max-width: 100%; }

.skip {
    position: absolute;
    left: var(--space-3);
    top: -3rem;
    background: var(--accent);
    color: var(--accent-ink);
    padding: var(--space-2) var(--space-3);
    z-index: 5;
}

.skip:focus { top: var(--space-2); }

.hud {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-height: var(--hud-h);
    padding: env(safe-area-inset-top) var(--space-3) 0;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--text);
    font-weight: 750;
    letter-spacing: 0.02em;
    text-decoration: none;
    font-size: 15px;
}

.hud-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.hud-qr,
.hud-credits,
.hud-profile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-h);
    min-width: var(--control-h);
    border-radius: 999px;
    text-decoration: none;
    font-weight: 750;
}

.hud-qr {
    padding: 0 12px;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    font-size: 13px;
}

.hud-credits {
    padding: 0 12px;
    background: color-mix(in srgb, var(--accent) 16%, var(--panel));
    color: var(--accent);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.hud-profile {
    width: var(--control-h);
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
}

.flash {
    margin: var(--space-3) var(--space-3) 0;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    font-size: 14px;
}

.flash-error { color: var(--danger); }
.flash-ok { color: var(--ok); }
.flash-info { color: var(--info); }

main {
    width: min(640px, 100%);
    margin: 0 auto;
    padding: var(--space-3) var(--space-3) var(--space-5);
}

h1, .page-title {
    margin: 0;
    font-size: var(--title);
    line-height: 1.2;
}

h2, .section-title {
    margin: 0 0 var(--space-2);
    font-size: var(--section);
    line-height: 1.25;
}

h3 { margin: 0; font-size: 15px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.page-kicker {
    margin: 0 0 var(--space-1);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.bv {
    text-align: right;
}

.bv strong {
    display: block;
    font-size: 24px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.bv span, .muted, .hint, .lead { color: var(--muted); }
.hint, .lead { margin: 0; font-size: 13px; }
.lead { margin-bottom: var(--space-3); font-size: 14px; }

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.pill.is-locked, .state.is-locked { color: var(--amber); }
.pill.is-ready { color: var(--ok); }

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
}

.stat {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.stat strong {
    display: block;
    margin-top: 2px;
    font-size: var(--stat);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.quick {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0 0 var(--space-4);
}

.quick a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-h);
    padding: 6px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    text-align: center;
    text-decoration: none;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.15;
}

.button, button.button, a.button, summary.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-h);
    min-width: var(--control-h);
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.button-quiet {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.button-block { width: 100%; }

button:disabled, .button:disabled { opacity: 0.45; cursor: not-allowed; }

label { display: grid; gap: var(--space-1); font-size: 13px; font-weight: 700; }

input, select, textarea {
    width: 100%;
    min-height: var(--control-h);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0b1626;
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

.fold, .panel, .item-row, .offer, .product, .job, .slot-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.panel, .job, .slot-card, .offer, .product {
    padding: var(--space-3);
    margin: 0 0 var(--space-3);
}

.stack, .actions, .hub { display: grid; gap: var(--space-3); }
.stack { margin: var(--space-3) 0; }

.item-list { display: grid; gap: var(--space-2); margin: 0 0 var(--space-4); }

.item-row.skill-card { grid-template-columns: minmax(0, 1fr) auto; }

.item-row {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
    min-height: 72px;
    padding: var(--space-2);
}

.product {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
    min-height: 118px;
}

.thumb, .item-row img, .product img, .slot-thumb {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 8px;
    background: #0b1626;
}

.item-copy { min-width: 0; }

.item-copy strong, .product strong, .offer strong {
    display: block;
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.price {
    font-size: 16px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.quality {
    color: var(--crate, var(--common));
    font-size: 12px;
    font-weight: 750;
}

.quality-common { --crate: var(--common); }
.quality-uncommon { --crate: var(--uncommon); }
.quality-rare { --crate: var(--rare); }
.quality-epic { --crate: var(--epic); }
.quality-credits { --crate: var(--accent); }

.rarity-edge { box-shadow: inset 3px 0 0 var(--crate, var(--line)); }

progress.hp, progress.meter {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 6px;
    border: 0;
    border-radius: 99px;
    overflow: hidden;
    appearance: none;
    background: #0b1626;
}

progress.hp::-webkit-progress-bar, progress.meter::-webkit-progress-bar { background: #0b1626; }
progress.hp::-webkit-progress-value, progress.meter::-webkit-progress-value { background: var(--ok); }
progress.hp::-moz-progress-bar, progress.meter::-moz-progress-bar { background: var(--ok); }

.robot-layout {
    display: grid;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.robot-stage {
    position: relative;
    width: min(100%, 260px);
    height: 210px;
    margin: 0 auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 62%),
        var(--panel);
    overflow: hidden;
}

.robot-stage img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
}

.more-stats { margin: 0 0 var(--space-3); }
.more-stats summary {
    min-height: var(--control-h);
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.seg {
    display: flex;
    gap: var(--space-1);
    margin: 0 0 var(--space-3);
    padding: 3px;
    border-radius: 12px;
    background: #0b1626;
    border: 1px solid var(--line);
    overflow-x: auto;
}

.seg a, .seg button {
    flex: 1 0 auto;
    min-height: var(--control-h);
    min-width: var(--control-h);
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}

.seg img { width: 18px; height: 18px; vertical-align: -4px; object-fit: contain; }

.item-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    margin: 0 0 8px;
}

.item-stats div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.item-stats dt { color: var(--muted); }
.item-stats dd { margin: 0; font-variant-numeric: tabular-nums; }

.seg a[aria-current="true"], .seg button[aria-selected="true"], .seg a.is-on {
    background: var(--panel-2);
    color: var(--text);
}

html.js [data-panel] { display: none; }
html.js [data-panel].is-on { display: block; }

.choice-row, .chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
}

.choice-row .button, .chip-row .button { flex: 1 1 auto; }

fieldset {
    margin: 0 0 var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

fieldset label {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    min-height: var(--control-h);
    font-weight: 650;
}

.duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.fight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }

.fight-grid button {
    display: grid;
    gap: 2px;
    width: 100%;
    min-height: 92px;
    padding: var(--space-2);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.fight-grid strong { font-size: 15px; }
.fight-grid span { color: var(--muted); font-size: 12px; }
.fight-grid b { font-size: 16px; font-variant-numeric: tabular-nums; }

.scene-banner, .boss-art {
    display: block;
    width: 100%;
    max-height: 180px;
    margin: 0 0 var(--space-3);
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--panel);
}

.boss-art { width: min(100%, 180px); height: auto; margin-inline: auto; object-fit: contain; }

.skill-row {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
    padding: 0;
}

.skill-row a, .skill-row li {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-height: var(--control-h);
    color: var(--muted);
    font-size: 11px;
    text-decoration: none;
    text-align: center;
}

.skill-row img { width: 36px; height: 36px; object-fit: contain; }

.skill-card.is-locked { opacity: 0.72; }
.skill-card.is-ready { border-color: var(--amber); }
.skill-card.is-unlocked, .skill-card.is-active { border-color: var(--accent); }

.ledger, .odds, .log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-1);
}

.ledger li, .odds li, .log li {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 36px;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.ledger strong, .odds strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

.log { max-height: 220px; overflow: auto; }

.fold > summary {
    min-height: var(--control-h);
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 750;
}

.fold { padding: 0 var(--space-3); margin-bottom: var(--space-2); }
.fold[open] { padding-bottom: var(--space-3); }

.sheet {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    max-width: none;
    max-height: none;
}

.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }

.sheet-body {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    max-height: min(70vh, 520px);
    overflow: auto;
    padding: var(--space-3);
    border-radius: 16px 16px 0 0;
    background: var(--panel-2);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.quality-counts, .crate-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
    padding: 0;
    list-style: none;
}

.crate-grid a, .quality-counts li {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: var(--space-2);
    align-items: center;
    min-height: 72px;
    padding: var(--space-2);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
}

.crate-grid img, .chest-row img { width: 48px; height: 48px; object-fit: contain; }
.crate-large { width: min(100%, 160px); height: auto; display: block; margin: 0 auto var(--space-3); }

.chest-list { display: grid; gap: var(--space-2); padding: 0; list-style: none; }
.chest-row {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: var(--space-2);
    align-items: center;
    min-height: 64px;
    padding: var(--space-2);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    background: var(--panel);
}

.strip-window {
    position: relative;
    overflow: hidden;
    margin: var(--space-3) 0 var(--space-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #0b1626;
    height: 108px;
}

.strip-marker {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
    transform: translateX(-1px);
    z-index: 1;
}

.chest-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-2);
    width: max-content;
    min-width: 100%;
    height: 100%;
    align-items: center;
    padding-left: 50%;
    padding-right: 50%;
}

.strip-card {
    flex: 0 0 116px;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2);
    border-radius: 10px;
    background: color-mix(in srgb, var(--crate, #9aa4b2) 28%, #121a2b);
    border: 2px solid var(--crate, #9aa4b2);
    font-size: 13px;
    font-weight: 750;
}

.js #combat-result[data-conceal="1"],
.js #combat-log[data-conceal="1"],
.js #combat-log-title[data-conceal="1"],
.js #chest-reward[data-conceal="1"],
.js #omega-result[data-conceal="1"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.reward-panel {
    margin-top: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: var(--panel);
    text-align: center;
}

.reward-panel .item-name { font-size: 22px; margin: var(--space-2) 0; }

.admin-jump {
    position: sticky;
    top: var(--hud-h);
    z-index: 3;
    margin-bottom: var(--space-3);
}

.admin-table, .catalog-form {
    display: grid;
    gap: var(--space-2);
}

.hub-card {
    display: grid;
    gap: 2px;
    min-height: 64px;
    padding: var(--space-3);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
}

.hub-card span { color: var(--muted); font-size: 13px; }
.hub-card.is-waiting { opacity: 0.55; }

.tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #10192a;
    border-top: 1px solid var(--line);
}

.tabs a {
    min-height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 750;
}

.tabs a[aria-current="page"] { color: var(--accent); }

.empty {
    padding: var(--space-4) 0;
    color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
    .chest-strip { transition: none; }
}

@media (min-width: 768px) {
    .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .crate-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .robot-stage { height: 280px; width: min(100%, 320px); }
}

@media (min-width: 1100px) {
    body.has-nav {
        display: grid;
        grid-template-columns: 200px minmax(0, 1fr);
        grid-template-rows: var(--hud-h) 1fr;
        padding-bottom: 0;
    }

    .hud { grid-column: 1 / -1; }

    .tabs {
        position: sticky;
        top: var(--hud-h);
        grid-row: 2;
        grid-column: 1;
        height: calc(100vh - var(--hud-h));
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding: var(--space-3);
        border-top: 0;
        border-right: 1px solid var(--line);
    }

    .tabs a { justify-content: flex-start; padding: 0 var(--space-3); border-radius: 10px; }

    main {
        grid-row: 2;
        grid-column: 2;
        width: min(960px, 100%);
        padding: var(--space-5);
    }

    .flash { grid-column: 2; width: min(960px, calc(100% - 48px)); margin-left: var(--space-5); }

    .robot-layout { grid-template-columns: 320px minmax(0, 1fr); align-items: center; }
    .sheet-body { left: 200px; max-width: 640px; }
}
