:root {
    --bg: #070b12;
    --panel: rgba(13, 18, 28, 0.9);
    --panel-strong: rgba(17, 24, 36, 0.96);
    --panel-soft: rgba(255, 255, 255, 0.045);
    --line: rgba(177, 207, 255, 0.16);
    --line-strong: rgba(127, 231, 214, 0.36);
    --text: #f3f7ff;
    --muted: #a8b5c8;
    --dim: #6f7e91;
    --primary: #58d8d2;
    --blue: #6fa8ff;
    --magenta: #ff5aa5;
    --amber: #ffbf57;
    --green: #77e36f;
    --danger: #ff6262;
    --ink: #090d14;
    --shadow: 0 22px 52px rgba(0, 0, 0, 0.42);
    --radius-lg: 8px;
    --radius-md: 8px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    background-image:
        linear-gradient(135deg, rgba(88, 216, 210, 0.1) 0%, transparent 34%, rgba(255, 90, 165, 0.08) 69%, transparent 100%),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 52px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.026) 0 1px, transparent 1px 52px),
        linear-gradient(180deg, #080b12 0%, #10131b 54%, #090b10 100%);
    color: var(--text);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.02), transparent 14%, transparent 86%, rgba(255,255,255,0.025)),
        linear-gradient(180deg, rgba(255,255,255,0.05), transparent 160px);
    mix-blend-mode: screen;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.shell {
    width: min(1500px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.landing-page, .auth-page, .build-page, .table-page, .main-page, .codex-page { display: grid; gap: 18px; }

.glass-card {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), transparent 120px),
        var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    border-top: 1px solid rgba(255,255,255,0.18);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    font-weight: 800;
}

.subtle,
.hero-copy,
.log-item,
.card-meta,
.character-meta,
.empty-state,
.tooltip-bubble,
.note-box p {
    color: var(--muted);
}

.hero, .auth-card, .panel-header, .character-panel, .card-panel, .table-topbar, .state-panel, .board-panel, .side-panel { padding: 22px; }
.hero, .auth-card { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; }
.auth-form { display: grid; gap: 18px; }
.account-panel, .mode-panel { padding: 22px; display: grid; gap: 18px; }
.hero h1, .auth-card h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.05; }
.panel-header h1, .table-topbar h1 { font-size: clamp(28px, 3vw, 44px); line-height: 1.05; }

.panel-header,
.table-topbar,
.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.combat-topbar,
.build-command {
    overflow: hidden;
    min-height: 78px;
}

.combat-topbar::after,
.build-command::after {
    content: '';
    position: absolute;
    right: 22px;
    bottom: -28px;
    width: min(38vw, 520px);
    height: 82px;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0 12%, rgba(88,216,210,0.42) 12% 13%, transparent 13% 25%, rgba(255,90,165,0.35) 25% 26%, transparent 26% 100%),
        linear-gradient(180deg, transparent, rgba(111,168,255,0.12));
    transform: skewX(-24deg);
}

.build-command {
    min-height: 76px;
    padding: 14px 22px;
    display: grid;
    grid-template-columns: minmax(190px, auto) minmax(260px, 1fr) auto;
    align-items: center;
    gap: 18px;
}

.build-command-title {
    display: grid;
    gap: 4px;
}

.build-command-copy {
    max-width: 560px;
    justify-self: center;
    text-align: center;
}

.section-title-row.compact { margin-top: 18px; margin-bottom: 12px; }
.section-title-row h2 { font-size: 18px; letter-spacing: 0.02em; }

.hero-actions, .header-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.immersive-btn {
    display: none;
}

@media (hover: none), (pointer: coarse) {
    .immersive-btn:not([hidden]) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

.combat-hud {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 0;
    width: min(760px, 58vw);
}

.combat-hud span {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    font-size: 16px;
    font-weight: 900;
}

.hud-die img,
.hud-dice img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.hud-dice b {
    min-width: 1ch;
    text-align: center;
}

.primary-btn,
.secondary-btn,
.icon-btn,
.hand-card button {
    min-height: 42px;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    border: 1px solid transparent;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
    color: #071016;
    font-weight: 800;
    box-shadow: 0 12px 30px rgba(88, 216, 210, 0.22);
}

.danger-btn {
    background: linear-gradient(135deg, var(--danger), var(--magenta));
    color: #fff7fb;
    box-shadow: 0 12px 30px rgba(255, 98, 98, 0.2);
}

.secondary-btn,
.icon-btn,
.hand-card button {
    background: rgba(255,255,255,0.065);
    color: var(--text);
    border-color: rgba(255,255,255,0.12);
}

.primary-btn:hover,
.secondary-btn:hover,
.icon-btn:hover,
.hand-card button:hover,
.character-card:hover,
.build-card:hover {
    transform: translateY(-2px);
}

.icon-btn {
    width: 42px;
    min-width: 42px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    color: var(--primary);
    font-size: 20px;
    font-weight: 1000;
}

.tutorial-help-btn {
    position: relative;
    z-index: 2;
}

.field-label { display: grid; gap: 8px; }
.field-label input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    outline: none;
}
.field-label input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(88,216,210,0.12); }

.note-box,
.hint-box {
    padding: 14px;
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.035));
    border: 1px solid rgba(255,255,255,0.08);
}
.compact-note { min-width: 220px; }
.compact-note strong { display: block; margin-bottom: 6px; }

.mode-grid,
.account-grid {
    display: grid;
    gap: 14px;
}
.mode-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.account-grid { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }

.character-carousel {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(300px, 350px);
    gap: 14px;
    overflow-x: auto;
    padding: 2px 2px 10px;
    scroll-snap-type: x proximity;
}

.character-card,
.build-card,
.hand-card,
.stat-card,
.log-item {
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.1);
}

.character-card,
.build-card {
    position: relative;
    overflow: hidden;
    padding: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.035));
    display: grid;
    gap: 14px;
    min-height: 250px;
    cursor: pointer;
    scroll-snap-align: start;
}

.character-card::before,
.build-card::before,
.hand-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(88,216,210,0.16), transparent 28%),
        linear-gradient(315deg, rgba(255,90,165,0.11), transparent 32%);
    opacity: 0.8;
}

.character-card > *,
.build-card > *,
.hand-card > * { position: relative; }

.character-card.selected,
.build-card.selected {
    border-color: rgba(88, 216, 210, 0.78);
    box-shadow: inset 0 0 0 1px rgba(88, 216, 210, 0.32), 0 18px 40px rgba(88,216,210,0.12);
}

.build-card.locked {
    cursor: default;
}

.build-card.locked .selection-mark {
    background: rgba(255, 191, 87, 0.16);
    border-color: rgba(255, 191, 87, 0.5);
    color: #ffe6a8;
}

.selection-mark {
    position: absolute;
    top: 12px;
    right: 12px;
    display: none;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    background: rgba(88, 216, 210, 0.14);
    border: 1px solid rgba(88, 216, 210, 0.42);
    color: #baf7ef;
    font-size: 12px;
    font-weight: 800;
}
.selected .selection-mark { display: inline-flex; }

.character-portrait {
    height: 112px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        linear-gradient(120deg, rgba(88,216,210,0.24), rgba(255,90,165,0.18)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 18px),
        #0b121d;
    border: 1px solid rgba(255,255,255,0.12);
}
.character-portrait span {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.26);
    background: rgba(5, 10, 18, 0.72);
    color: var(--primary);
    font-size: 30px;
    font-weight: 900;
}

.card-headline { display: grid; gap: 8px; }
.card-headline h2,
.card-headline h3 { line-height: 1.1; }

.character-stats,
.card-grid,
.stats-grid,
.hand-list,
.log-list { display: grid; gap: 10px; }
.character-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.card-tag {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    background: rgba(111,168,255,0.16);
    color: #c9d9ff;
    border: 1px solid rgba(111,168,255,0.22);
    font-size: 12px;
    font-weight: 800;
    width: fit-content;
}

.item-card { isolation: isolate; }
.item-art {
    height: 92px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.12);
    background:
        linear-gradient(135deg, rgba(111,168,255,0.18), transparent 48%),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 12px),
        #0d1420;
}
.item-art.small {
    height: 58px;
    width: 58px;
    float: right;
    margin-left: 10px;
    background:
        radial-gradient(circle at 50% 45%, rgba(255,255,255,0.16), transparent 62%),
        linear-gradient(135deg, rgba(111,168,255,0.18), transparent 48%),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 12px),
        #111a28;
}
.item-sigil {
    width: 42px;
    height: 42px;
    display: block;
    background:
        linear-gradient(45deg, transparent 35%, currentColor 36% 45%, transparent 46%),
        linear-gradient(-45deg, transparent 35%, currentColor 36% 45%, transparent 46%);
    color: var(--primary);
    filter: drop-shadow(0 0 12px currentColor);
}
.item-icon,
.item-icon-img {
    width: 42px;
    height: 42px;
    display: block;
}

.item-icon-img {
    object-fit: contain;
    filter: drop-shadow(0 8px 14px rgba(0,0,0,0.42)) drop-shadow(0 0 10px rgba(255,255,255,0.12));
}

.item-art:not(.small) .item-icon,
.item-art:not(.small) .item-icon-img {
    width: 66px;
    height: 66px;
}

.item-art.small .item-icon,
.item-art.small .item-icon-img {
    width: calc(100% - 8px);
    height: calc(100% - 8px);
}

.item-icon {
    position: relative;
    border-radius: 10px;
    color: var(--primary);
    filter: drop-shadow(0 0 12px currentColor);
}

.item-icon::before,
.item-icon::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 3px solid currentColor;
}

.item-icon-flame {
    color: var(--danger);
    border-radius: 50% 50% 50% 12%;
    background: linear-gradient(135deg, transparent 30%, currentColor);
    transform: rotate(-45deg);
}
.item-icon-flame::before { inset: 12px; border: 0; border-radius: inherit; background: var(--amber); }
.item-icon-flame::after { display: none; }

.item-icon-dash::before {
    inset: 10px 4px;
    border: 0;
    background: linear-gradient(90deg, currentColor 0 48%, transparent 48% 60%, currentColor 60% 100%);
    clip-path: polygon(0 24%, 70% 24%, 70% 0, 100% 50%, 70% 100%, 70% 76%, 0 76%);
}
.item-icon-dash::after { display: none; }

.item-icon-dice::before {
    border-radius: 8px;
}
.item-icon-dice::after {
    inset: 13px;
    border: 0;
    border-radius: 999px;
    background: currentColor;
    box-shadow: -8px -8px 0 currentColor, 8px 8px 0 currentColor;
}

.item-icon-guard::before {
    inset: 4px 8px;
    border-radius: 12px 12px 18px 18px;
    clip-path: polygon(50% 0, 100% 18%, 88% 78%, 50% 100%, 12% 78%, 0 18%);
}
.item-icon-guard::after {
    inset: 16px 12px;
    border-width: 0 0 3px 3px;
    transform: rotate(-45deg);
}

.item-icon-key::before {
    inset: 7px 19px 7px 7px;
    border-radius: 999px;
}
.item-icon-key::after {
    inset: 18px 3px 18px 20px;
    border: 0;
    background: currentColor;
    box-shadow: 10px 5px 0 -2px currentColor, 17px -5px 0 -2px currentColor;
}

.item-icon-shield::before {
    inset: 3px 8px;
    border-radius: 12px 12px 20px 20px;
    clip-path: polygon(50% 0, 100% 20%, 86% 78%, 50% 100%, 14% 78%, 0 20%);
}
.item-icon-shield::after {
    inset: 11px 18px;
    border-width: 0 3px 0 0;
}

.item-icon-repair::before {
    inset: 18px 6px;
    border: 0;
    background: currentColor;
}
.item-icon-repair::after {
    inset: 6px 18px;
    border: 0;
    background: currentColor;
}

.item-icon-charge::before {
    inset: 4px 12px 4px 14px;
    border: 0;
    background: currentColor;
    clip-path: polygon(46% 0, 100% 0, 68% 40%, 100% 40%, 28% 100%, 46% 55%, 8% 55%);
}
.item-icon-charge::after { display: none; }

.item-icon-scan::before {
    inset: 7px;
    border-radius: 50%;
}
.item-icon-scan::after {
    inset: 20px 5px 18px 20px;
    border: 0;
    background: currentColor;
    transform-origin: left center;
    transform: rotate(35deg);
}
.type-attack .item-sigil { color: var(--danger); }
.type-defense .item-sigil { color: var(--blue); }
.type-utility .item-sigil { color: var(--amber); }
.type-movement .item-sigil { color: var(--green); }
.rarity-epic { border-color: rgba(255,90,165,0.34); }
.rarity-rare { border-color: rgba(111,168,255,0.34); }
.rarity-r { border-color: rgba(111,168,255,0.34); }
.rarity-sr { border-color: rgba(255,90,165,0.4); }
.rarity-ur { border-color: rgba(255,191,87,0.48); }

.build-studio {
    padding: 22px;
    display: grid;
    grid-template-columns: 220px minmax(280px, 340px) minmax(520px, 1fr);
    gap: 18px;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.character-wheel-panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px;
}

.compact-title {
    align-items: flex-start;
}

.compact-title p {
    color: var(--primary);
    font-weight: 900;
}

.character-wheel {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 18px 0 18px 42px;
    touch-action: none;
    user-select: none;
}

.character-wheel::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    z-index: 120;
    transform: translateY(-50%);
    border-top: 18px solid transparent;
    border-bottom: 18px solid transparent;
    border-left: 0;
    border-right: 30px solid var(--primary);
    filter: drop-shadow(0 0 14px rgba(88,216,210,0.5));
    pointer-events: none;
}

.wheel-character {
    --wheel-x: 0px;
    --wheel-y: 0px;
    --wheel-scale: 1;
    --wheel-opacity: 1;
    --wheel-z: 1;
    position: absolute;
    left: 48px;
    top: 50%;
    z-index: var(--wheel-z);
    min-height: 62px;
    width: calc(100% - 58px);
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-weight: 900;
    opacity: var(--wheel-opacity);
    transform: translate(var(--wheel-x), calc(-50% + var(--wheel-y))) scale(var(--wheel-scale));
    transform-origin: left center;
    transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
    will-change: transform, opacity;
}

.wheel-character[hidden] {
    display: none !important;
}

.wheel-character > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wheel-character.active {
    color: var(--text);
    background: rgba(88,216,210,0.12);
    border-color: rgba(88,216,210,0.45);
    box-shadow: inset 0 0 0 1px rgba(88,216,210,0.18), 0 16px 34px rgba(0,0,0,0.26);
}

.wheel-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
}

.wheel-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.character-portrait-stage {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: var(--radius-md);
    background:
        linear-gradient(180deg, rgba(88,216,210,0.1), transparent 46%),
        rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.13);
}

.character-portrait-stage > img {
    width: 100%;
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    object-fit: contain;
    object-position: center center;
    padding: 14px 14px 0;
    display: block;
}

.selected-character-info {
    display: grid;
    gap: 12px;
    padding: 16px;
    background: rgba(7, 11, 18, 0.84);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.selected-character-info .character-stats {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
}

.selected-character-info .stat-card strong {
    font-size: 18px;
}

.build-item-panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
}

.build-item-panel .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    align-content: start;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
}

.table-layout {
    display: grid;
    grid-template-columns: minmax(225px, 276px) minmax(560px, 1fr) minmax(225px, 286px);
    gap: 14px;
    align-items: stretch;
    min-height: 0;
}

.state-panel,
.side-panel {
    min-height: 0;
    overflow: hidden;
}

.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 12px;
}

.stat-card {
    position: relative;
    min-height: 74px;
    padding: 10px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255,255,255,0.062), rgba(255,255,255,0.032));
}
.stat-card span,
.stat-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.stat-card strong {
    display: block;
    margin-top: 6px;
    font-size: 21px;
    line-height: 1.05;
}
.stat-card-compact {
    min-height: 0;
    padding: 10px;
}
.stat-meter {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 10px;
    height: 4px;
    overflow: hidden;
    background: rgba(255,255,255,0.08);
}
.stat-meter i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--amber));
}
.stat-hp .stat-meter i { background: linear-gradient(90deg, var(--green), var(--primary)); }
.stat-boss .stat-meter i { background: linear-gradient(90deg, var(--magenta), var(--danger)); }
.stat-role strong {
    font-size: 21px;
    line-height: 1.05;
}
.stat-role small {
    margin-top: 2px;
    line-height: 1.05;
}

.cta-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin-top: 12px;
    align-items: stretch;
    justify-items: stretch;
}

.dice-readout {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    align-self: center;
    min-width: 92px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text);
    font-size: 18px;
    font-weight: 1000;
    margin: 0;
}

.dice-readout img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.phase-chip {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: rgba(111,168,255,0.14);
    border: 1px solid rgba(111,168,255,0.28);
    color: #d2dfff;
    font-size: 13px;
    font-weight: 900;
}
.phase-victory { background: rgba(119,227,111,0.16); border-color: rgba(119,227,111,0.34); color: #d9ffd6; }
.phase-defeat { background: rgba(255,98,98,0.16); border-color: rgba(255,98,98,0.34); color: #ffd5d5; }
.phase-battle { background: rgba(255,90,165,0.16); border-color: rgba(255,90,165,0.34); color: #ffd7e9; }

.hint-box { margin-top: 14px; }
.hint-box strong,
.note-box strong { display: block; margin-bottom: 7px; }

.state-panel {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    align-content: start;
}

.state-panel .note-box {
    display: none;
}

.state-panel .hint-box {
    display: none;
}

.board-panel {
    min-width: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto auto;
    align-content: start;
    min-height: 0;
}

.board-title-row p {
    color: var(--primary);
    font-weight: 800;
}

.map-stage {
    --map-aspect: 4 / 3;
    --map-aspect-number: 1.333;
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: var(--map-aspect);
    margin-top: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #071019;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 0 0 1px rgba(88,216,210,0.12), 0 28px 60px rgba(0,0,0,0.42);
    align-self: start;
    justify-self: stretch;
    max-height: 100%;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}

.map-stage.dragging {
    cursor: grabbing;
}

.map-stage.drag-ready {
    cursor: grabbing;
}

.map-stage:not(.can-select-target) {
    cursor: default;
}

.map-stage.drag-ready,
.map-stage.dragging {
    cursor: grabbing;
}

.map-stage.touch-target-primed {
    box-shadow: inset 0 0 0 1px rgba(255,191,87,0.18), 0 0 22px rgba(255,191,87,0.14), 0 28px 60px rgba(0,0,0,0.42);
}

.map-stage-inner {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    overflow: visible;
    background: transparent;
    transform-origin: 0 0;
    will-change: transform;
    backface-visibility: hidden;
    contain: layout style paint;
    isolation: isolate;
}

.map-stage-inner.camera-smooth {
    transition: transform 0.42s cubic-bezier(.2,.8,.2,1);
}

.map-stage-inner::before,
.map-stage-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}
.map-stage-inner::before {
    display: none;
}
.map-stage-inner::after {
    border: 1px solid rgba(88,216,210,0.28);
    box-shadow: inset 0 0 60px rgba(0,0,0,0.4);
}

.map-stage img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(1.04) contrast(1.02) brightness(0.78);
}

.codex-shell {
    padding: 22px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 18px;
}

.codex-tabs {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    justify-content: start;
    gap: 8px;
}

.codex-tabs button {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    color: var(--muted);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-weight: 800;
}

.codex-tabs button.active {
    color: var(--text);
    background: rgba(88,216,210,0.22);
    border-color: rgba(88,216,210,0.38);
}

.codex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.codex-card {
    position: relative;
    min-height: 142px;
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 22px 16px 16px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.055);
    border: 1px solid rgba(255,255,255,0.12);
}

.codex-badges {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100% - 20px);
    pointer-events: none;
}

.codex-badges span {
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    background: rgba(88,216,210,0.18);
    border: 1px solid rgba(88,216,210,0.42);
    color: var(--text);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.codex-icon {
    width: 78px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: rgba(6, 12, 20, 0.72);
    border: 1px solid rgba(255,255,255,0.12);
}

.codex-card.rarity-n .codex-icon {
    border-color: rgba(119, 227, 111, 0.82);
    box-shadow: inset 0 0 0 1px rgba(119, 227, 111, 0.2), 0 0 18px rgba(119, 227, 111, 0.14);
}

.codex-card.rarity-r .codex-icon {
    border-color: rgba(111, 168, 255, 0.86);
    box-shadow: inset 0 0 0 1px rgba(111, 168, 255, 0.24), 0 0 18px rgba(111, 168, 255, 0.16);
}

.codex-card.rarity-sr .codex-icon {
    border-color: rgba(184, 119, 255, 0.9);
    box-shadow: inset 0 0 0 1px rgba(184, 119, 255, 0.28), 0 0 20px rgba(184, 119, 255, 0.2);
}

.codex-card.rarity-ur .codex-icon {
    border-color: rgba(255, 191, 87, 0.95);
    box-shadow: inset 0 0 0 1px rgba(255, 191, 87, 0.34), 0 0 22px rgba(255, 191, 87, 0.24);
}

.codex-icon img {
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.codex-icon .map-icon {
    transform: scale(1.9);
}

.codex-copy {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.codex-copy .codex-type {
    color: var(--primary);
    font-size: 13px;
    font-weight: 900;
}

.codex-copy h2 {
    font-size: 24px;
    line-height: 1.08;
}

.codex-copy p {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.45;
}

.map-grid-layer,
.map-range-layer,
.map-preview-layer,
.map-fx-layer,
.map-overlay {
    position: absolute;
    inset: 0;
    overflow: visible;
    backface-visibility: hidden;
}

.map-stage.camera-interacting .map-stage-inner {
    transition: none;
}

.map-stage.camera-interacting .map-stage-inner::after,
.map-stage.camera-interacting .map-cell,
.map-stage.camera-interacting .map-cell::after,
.map-stage.camera-interacting .range-cell,
.map-stage.camera-interacting .preview-dot,
.map-stage.camera-interacting .preview-dot::after,
.map-stage.camera-interacting .preview-block,
.map-stage.camera-interacting .preview-line,
.map-stage.camera-interacting .move-range-outline-segment::after,
.map-stage.camera-interacting .overlay-token,
.map-stage.camera-interacting .token-player,
.map-stage.camera-interacting .token-player::after,
.map-stage.camera-interacting .player-chip {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
}

.map-grid-layer {
    display: block;
    z-index: 2;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(190, 222, 255, 0.2) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(190, 222, 255, 0.18) 1px, transparent 1px);
    background-size: var(--grid-cell-width, 4%) var(--grid-cell-height, 4%);
}

.map-cell {
    position: absolute;
    box-sizing: border-box;
    background: rgba(2, 8, 13, 0.08);
}

.map-cell::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 5px;
    opacity: 0;
    border: 1px solid transparent;
}

.cell-hidden-zone {
    background: rgba(196, 205, 218, 0.26);
    box-shadow: inset 0 0 0 calc(1px / var(--map-zoom, 1)) rgba(255, 255, 255, 0.12);
}

.cell-fog-zone {
    background: #020409;
    box-shadow: inset 0 0 calc(14px / var(--map-zoom, 1)) rgba(0, 0, 0, 0.82);
}

.cell-wall::after,
.cell-door::after,
.cell-portal::after,
.cell-turn_belt::after,
.cell-event::after,
.cell-chest::after,
.cell-boss::after,
.cell-monster::after {
    opacity: 1;
}

.cell-wall {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.1)),
        rgba(223, 233, 248, 0.34);
    border: 0 solid transparent;
}
.cell-wall::after {
    inset: 0;
    border-radius: 0;
    border: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 52%),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.1));
}
.cell-wall.wall-edge-top { border-top-width: calc(1px / var(--map-zoom, 1)); border-top-color: rgba(255, 255, 255, 0.48); }
.cell-wall.wall-edge-right { border-right-width: calc(1px / var(--map-zoom, 1)); border-right-color: rgba(255, 255, 255, 0.4); }
.cell-wall.wall-edge-bottom { border-bottom-width: calc(1px / var(--map-zoom, 1)); border-bottom-color: rgba(194, 213, 238, 0.38); }
.cell-wall.wall-edge-left { border-left-width: calc(1px / var(--map-zoom, 1)); border-left-color: rgba(255, 255, 255, 0.4); }
.cell-door::after { background: rgba(255, 191, 87, 0.16); border-color: rgba(255, 191, 87, 0.44); }
.cell-portal::after { background: rgba(181, 141, 255, 0.14); border-color: rgba(181, 141, 255, 0.48); box-shadow: inset 0 0 16px rgba(181, 141, 255, 0.28); }
.cell-turn_belt::after { background: rgba(111, 168, 255, 0.13); border-color: rgba(111, 168, 255, 0.42); }
.cell-event::after { background: rgba(119, 227, 111, 0.1); border-color: rgba(119, 227, 111, 0.32); }
.cell-chest::after { background: rgba(255, 191, 87, 0.12); border-color: rgba(255, 191, 87, 0.34); }
.cell-boss::after { background: rgba(255, 90, 165, 0.1); border-color: rgba(255, 90, 165, 0.42); }
.cell-monster::after { background: rgba(255, 98, 98, 0.08); border-color: rgba(255, 98, 98, 0.3); }

.map-range-layer {
    z-index: 3;
    pointer-events: none;
}

.range-cell {
    position: absolute;
    display: block;
    background: rgba(255, 98, 98, 0.2);
    border: 1px solid rgba(255, 98, 98, 0.5);
    box-shadow: inset 0 0 20px rgba(255, 98, 98, 0.16), 0 0 16px rgba(255, 98, 98, 0.18);
    animation: rangePulse 1.2s ease-in-out infinite;
}

.identify-range-cell {
    background: rgba(67, 255, 151, 0.17);
    border-color: rgba(67, 255, 151, 0.62);
    box-shadow: inset 0 0 18px rgba(67, 255, 151, 0.18), 0 0 18px rgba(67, 255, 151, 0.22);
}

.preview-threat-range-cell {
    background: rgba(255, 98, 98, 0.08);
    border-color: rgba(255, 98, 98, 0.22);
    box-shadow: inset 0 0 14px rgba(255, 98, 98, 0.08);
    animation: none;
}

.map-preview-layer {
    z-index: 4;
    pointer-events: none;
}

.map-fx-layer {
    z-index: 6;
    pointer-events: none;
}

.map-overlay {
    z-index: 7;
}

.boss-hud {
    position: absolute;
    left: 50%;
    top: 12px;
    width: min(360px, calc(100% - 36px));
    transform: translateX(-50%);
    display: none;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 14px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(10, 6, 16, 0.68);
    border: 1px solid rgba(255, 90, 165, 0.5);
    box-shadow: 0 16px 34px rgba(0,0,0,0.38), 0 0 32px rgba(255,90,165,0.16);
    backdrop-filter: blur(12px);
    z-index: 18;
    pointer-events: none;
}

.boss-hud.active {
    display: grid;
}

.boss-hud span {
    font-weight: 1000;
}

.boss-hud strong {
    color: #ffd7e9;
    font-size: 13px;
}

.boss-hud i {
    grid-column: 1 / -1;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
}

.boss-hud b {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--magenta), var(--danger));
}

.preview-dot,
.preview-block,
.move-ghost {
    position: absolute;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    border-radius: var(--radius-sm);
    font-weight: 900;
}

.preview-dot {
    color: #061016;
    font-size: calc(12px / var(--map-zoom, 1));
    background: linear-gradient(135deg, var(--primary), var(--amber));
    border: calc(1px / var(--map-zoom, 1)) solid rgba(255,255,255,0.72);
    box-shadow: 0 0 0 calc(3px / var(--map-zoom, 1)) rgba(88,216,210,0.14), 0 calc(7px / var(--map-zoom, 1)) calc(18px / var(--map-zoom, 1)) rgba(0,0,0,0.42);
}

.preview-start {
    background: #ffffff;
}

.preview-intercept {
    background: linear-gradient(135deg, #b58dff, var(--magenta));
    color: #ffffff;
}

.preview-dot[data-turn]::after {
    content: attr(data-turn);
    position: absolute;
    right: calc(-13px / var(--map-zoom, 1));
    top: calc(-13px / var(--map-zoom, 1));
    width: calc(20px / var(--map-zoom, 1));
    height: calc(20px / var(--map-zoom, 1));
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(7, 14, 22, 0.95);
    color: var(--primary);
    border: calc(1px / var(--map-zoom, 1)) solid rgba(88,216,210,0.48);
    font-size: calc(13px / var(--map-zoom, 1));
}

.preview-block {
    color: #ffffff;
    font-size: calc(16px / var(--map-zoom, 1));
    background: rgba(255, 98, 98, 0.86);
    border: calc(1px / var(--map-zoom, 1)) solid rgba(255,255,255,0.52);
    box-shadow: 0 0 0 calc(5px / var(--map-zoom, 1)) rgba(255,98,98,0.12);
}

.preview-line {
    position: absolute;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(88,216,210,0.26), rgba(255,191,87,0.86));
    box-shadow: 0 0 14px rgba(88,216,210,0.42);
}

.preview-line-horizontal {
    height: calc(4px / var(--map-zoom, 1));
    transform: translateY(-50%);
}

.preview-line-vertical {
    width: calc(4px / var(--map-zoom, 1));
    transform: translateX(-50%);
}

.move-range-outline-segment {
    position: absolute;
    pointer-events: none;
}

.move-range-outline-segment::after {
    content: '';
    position: absolute;
    background: rgba(88, 216, 210, 0.95);
    box-shadow: 0 0 calc(12px / var(--map-zoom, 1)) rgba(88,216,210,0.62);
}

.outline-top::after,
.outline-bottom::after {
    left: 0;
    width: 100%;
    height: calc(2px / var(--map-zoom, 1));
}

.outline-top::after { top: 0; }
.outline-bottom::after { bottom: 0; }

.outline-left::after,
.outline-right::after {
    top: 0;
    width: calc(2px / var(--map-zoom, 1));
    height: 100%;
}

.outline-left::after { left: 0; }
.outline-right::after { right: 0; }

.identify-flash-cell {
    position: absolute;
    border-radius: 6px;
    border: 1px solid rgba(111, 255, 175, 0.86);
    background: rgba(67, 255, 151, 0.18);
    box-shadow: none;
    animation: identifyFlash 0.52s ease-out both;
}

@keyframes identifyFlash {
    0% { opacity: 0; transform: scale(0.7); }
    32% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.12); }
}

.move-ghost {
    left: 0;
    top: 0;
    background: rgba(4, 18, 28, 0.94);
    border: calc(2px / var(--map-zoom, 1)) solid rgba(255, 255, 255, 0.76);
    box-shadow: none;
    pointer-events: none;
    transition: transform 128ms linear, opacity 0.08s linear;
    will-change: transform;
    overflow: hidden;
}

.move-ghost img,
.move-ghost .map-icon {
    width: 84%;
    height: 84%;
    object-fit: contain;
    border-radius: 6px;
}

.move-ghost.fade {
    opacity: 0;
}

.move-intent-arrow {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    pointer-events: none;
    transform-origin: 50% 50%;
    transition-property: transform, opacity;
    transition-timing-function: cubic-bezier(0.18, 0.82, 0.24, 1);
    will-change: transform, opacity;
    z-index: 12;
}

.move-intent-arrow::before {
    content: '';
    position: absolute;
    inset: 18% 0;
    background: linear-gradient(90deg, rgba(88,216,210,0.1), var(--primary) 42%, var(--amber));
    clip-path: polygon(0 36%, 60% 36%, 60% 10%, 100% 50%, 60% 90%, 60% 64%, 0 64%);
}

.move-intent-arrow.active {
    opacity: 0.96;
}

.move-intent-arrow.exit {
    opacity: 0;
}

.item-cast-effect {
    --item-cast-intro-duration: 620ms;
    --item-cast-exit-duration: 360ms;
    --item-cast-fly-y: -420px;
    --item-cast-fly-y-visible: -386px;
    --item-cast-fly-y-step: -76px;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 142px;
    height: 142px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 18;
    overflow: visible;
    contain: layout style;
}

.item-cast-aura,
.item-cast-light,
.item-cast-card,
.item-cast-orb {
    position: absolute;
    left: 50%;
    top: 50%;
    pointer-events: none;
}

.item-cast-aura {
    width: 390px;
    height: 390px;
    border-radius: 999px;
    background:
        radial-gradient(circle, rgba(255,255,255,0.7) 0 4%, rgba(88,216,210,0.44) 13%, rgba(255,191,87,0.2) 36%, transparent 70%),
        conic-gradient(from 20deg, transparent, rgba(88,216,210,0.62), transparent, rgba(255,191,87,0.56), transparent);
    filter: blur(1px);
    mix-blend-mode: screen;
    animation: itemCastAuraGather var(--item-cast-intro-duration) cubic-bezier(0.2, 0.78, 0.2, 1) both;
}

.item-cast-light {
    width: 244px;
    height: 244px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,0.72);
    box-shadow:
        0 0 34px rgba(88,216,210,0.58),
        inset 0 0 28px rgba(255,191,87,0.2);
    animation: itemCastLightGather var(--item-cast-intro-duration) cubic-bezier(0.18, 0.86, 0.18, 1) both;
}

.item-cast-card {
    width: 116px;
    height: 116px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.03)),
        rgba(8, 18, 30, 0.96);
    border: 1px solid rgba(255,255,255,0.72);
    box-shadow:
        0 0 28px rgba(88,216,210,0.46),
        0 18px 40px rgba(0,0,0,0.42);
    overflow: hidden;
    animation: itemCastCardIn var(--item-cast-intro-duration) ease both;
}

.item-cast-card::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 12px;
    border: 1px solid rgba(88,216,210,0.7);
    box-shadow: inset 0 0 22px rgba(88,216,210,0.38);
    animation: itemCastEdgeGlow var(--item-cast-intro-duration) ease both;
}

.item-cast-card .item-icon-img,
.item-cast-card .item-icon {
    width: 72%;
    height: 72%;
}

.item-cast-card .item-icon-img {
    object-fit: contain;
}

.item-cast-orb {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background:
        radial-gradient(circle at 35% 32%, #ffffff 0 16%, #e8fffb 17% 26%, var(--primary) 40%, rgba(255,191,87,0.8) 70%, transparent 72%);
    box-shadow:
        0 0 22px rgba(88,216,210,0.86),
        0 0 46px rgba(255,191,87,0.5);
    animation: itemCastOrbCharge var(--item-cast-intro-duration) cubic-bezier(0.18, 0.86, 0.24, 1) both;
}

.item-cast-effect.is-holding .item-cast-aura {
    animation: itemCastAuraHold 1.2s ease-in-out infinite;
}

.item-cast-effect.is-holding .item-cast-light {
    animation: itemCastLightHold 1.05s ease-in-out infinite;
}

.item-cast-effect.is-holding .item-cast-card {
    animation: itemCastCardHold 1.28s ease-in-out infinite;
}

.item-cast-effect.is-holding .item-cast-orb {
    animation: itemCastOrbHold 0.95s ease-in-out infinite;
}

.item-cast-effect.is-exiting .item-cast-aura,
.item-cast-effect.is-exiting .item-cast-light {
    animation: itemCastGlowExit 140ms ease-in both;
}

.item-cast-effect.is-exiting .item-cast-card {
    animation: itemCastCardExit 150ms ease-in both;
}

.item-cast-effect.is-exiting .item-cast-orb {
    animation: itemCastOrbExit var(--item-cast-exit-duration) cubic-bezier(0.12, 0.9, 0.22, 1) both;
}

@keyframes itemCastAuraGather {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(1.82); }
    18% { opacity: 0.8; transform: translate(-50%, -50%) scale(2.04); }
    72% { opacity: 0.94; transform: translate(-50%, -50%) scale(0.34); }
    100% { opacity: 0.54; transform: translate(-50%, -50%) scale(0.46); }
}

@keyframes itemCastLightGather {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(1.36); }
    18% { opacity: 0.9; transform: translate(-50%, -50%) scale(1.08); }
    76% { opacity: 0.92; transform: translate(-50%, -50%) scale(0.34); }
    100% { opacity: 0.72; transform: translate(-50%, -50%) scale(0.48); }
}

@keyframes itemCastCardIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); filter: brightness(1); }
    22% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); filter: brightness(1.12); }
    72% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); filter: brightness(1.36); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1.18); }
}

@keyframes itemCastEdgeGlow {
    0% { opacity: 0; }
    20% { opacity: 0.75; }
    62% { opacity: 1; }
    100% { opacity: 0.82; }
}

@keyframes itemCastOrbCharge {
    0%, 62% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    86% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0.82; transform: translate(-50%, -50%) scale(0.82); }
}

@keyframes itemCastAuraHold {
    0%, 100% { opacity: 0.44; transform: translate(-50%, -50%) scale(0.44); }
    50% { opacity: 0.68; transform: translate(-50%, -50%) scale(0.54); }
}

@keyframes itemCastLightHold {
    0%, 100% { opacity: 0.64; transform: translate(-50%, -50%) scale(0.46); }
    50% { opacity: 0.92; transform: translate(-50%, -50%) scale(0.58); }
}

@keyframes itemCastCardHold {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1.12); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.035); filter: brightness(1.28); }
}

@keyframes itemCastOrbHold {
    0%, 100% { opacity: 0.72; transform: translate(-50%, -50%) scale(0.74); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(0.98); }
}

@keyframes itemCastGlowExit {
    0% { opacity: 0.86; transform: translate(-50%, -50%) scale(0.52); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.12); }
}

@keyframes itemCastCardExit {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1.3); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.34); filter: brightness(1.8); }
}

@keyframes itemCastOrbExit {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    22% { opacity: 1; transform: translate(-50%, -50%) translateY(var(--item-cast-fly-y-step)) scale(0.86); }
    86% { opacity: 1; transform: translate(-50%, -50%) translateY(var(--item-cast-fly-y-visible)) scale(0.36); }
    100% { opacity: 1; transform: translate(-50%, -50%) translateY(var(--item-cast-fly-y)) scale(0.36); }
}

.map-stage.move-animating .token-player.is-moving-origin {
    opacity: 0;
}

.map-stage.move-animating .token-player::after {
    animation: none;
}

.overlay-token {
    position: absolute;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    background: rgba(5, 11, 18, 0.88);
    border: calc(1px / var(--map-zoom, 1)) solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    z-index: 2;
    box-shadow: 0 calc(7px / var(--map-zoom, 1)) calc(16px / var(--map-zoom, 1)) rgba(0,0,0,0.35);
    overflow: hidden;
}
.overlay-token:hover { z-index: 8; border-color: var(--primary); }
.overlay-token:hover .tooltip-bubble { opacity: 1; pointer-events: auto; transform: translate(-50%, -8px); }
.overlay-token.is-route-blocked {
    cursor: not-allowed;
    border-color: rgba(255, 98, 98, 0.72);
    box-shadow: 0 12px 22px rgba(0,0,0,0.35), 0 0 0 3px rgba(255,98,98,0.12);
}

.overlay-token.is-route-blocked:hover,
.overlay-token.is-route-blocked:focus-visible {
    border-color: rgba(255, 98, 98, 0.92);
}

.tooltip-bubble {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translate(-50%, 0);
    min-width: 210px;
    max-width: 270px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(6, 10, 16, 0.96);
    border: 1px solid rgba(88,216,210,0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    text-align: left;
    white-space: normal;
    z-index: 9;
}
.tooltip-bottom .tooltip-bubble { top: calc(100% + 10px); bottom: auto; }
.tooltip-bottom:hover .tooltip-bubble { transform: translate(-50%, 8px); }
.tooltip-left .tooltip-bubble { left: 0; transform: translate(0, 0); }
.tooltip-left:hover .tooltip-bubble { transform: translate(0, -8px); }
.tooltip-left.tooltip-bottom:hover .tooltip-bubble { transform: translate(0, 8px); }
.tooltip-right .tooltip-bubble { left: auto; right: 0; transform: translate(0, 0); }
.tooltip-right:hover .tooltip-bubble { transform: translate(0, -8px); }
.tooltip-right.tooltip-bottom:hover .tooltip-bubble { transform: translate(0, 8px); }

.map-icon {
    width: 68%;
    height: 68%;
    display: inline-block;
    border-radius: 50%;
    position: relative;
}
.map-icon-img {
    width: 78%;
    height: 78%;
    max-width: 78%;
    max-height: 78%;
    display: block;
    object-fit: contain;
}
.icon-player { background: linear-gradient(180deg, #ffffff, var(--primary) 50%, #25a9ff); box-shadow: 0 0 18px rgba(88, 216, 210, 0.85); }
.icon-monster { background: linear-gradient(180deg, #ffc2c2, var(--danger)); clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); }
.icon-boss { background: linear-gradient(180deg, #ff9ad0, var(--magenta)); clip-path: polygon(50% 0, 64% 30%, 100% 30%, 72% 54%, 84% 100%, 50% 72%, 16% 100%, 28% 54%, 0 30%, 36% 30%); }
.icon-chest {
    background:
        linear-gradient(90deg, transparent 46%, rgba(40, 27, 12, 0.72) 47% 53%, transparent 54%),
        linear-gradient(180deg, #ffe58a, var(--amber));
    border-radius: 5px;
    box-shadow: inset 0 0 0 2px rgba(55, 37, 14, 0.35);
}
.icon-portal { background: transparent; border: 4px solid #b58dff; box-shadow: inset 0 0 10px #b58dff, 0 0 14px #b58dff; }
.icon-door {
    width: 58%;
    height: 28%;
    border-radius: 999px;
    background: #ff4bea;
    box-shadow: 0 0 14px rgba(255,75,234,0.68), inset 0 0 0 2px rgba(255,255,255,0.18);
}
.icon-wall { background: #596579; border-radius: 3px; }
.icon-event { background: linear-gradient(180deg, #d3ff98, var(--green)); }
.icon-desk {
    width: 72%;
    height: 44%;
    border-radius: 3px;
    background:
        linear-gradient(90deg, rgba(56,43,30,0.28), transparent 18% 82%, rgba(56,43,30,0.28)),
        #d9cab8;
    border: calc(2px / var(--map-zoom, 1)) solid rgba(74,58,43,0.55);
    transform: rotate(-8deg);
}

.token-safe .icon-chest {
    width: 72%;
    height: 72%;
    border-radius: 6px;
    background:
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.85) 0 2px, transparent 3px),
        linear-gradient(135deg, transparent 44%, rgba(60,45,20,0.6) 45% 55%, transparent 56%),
        linear-gradient(180deg, #ffd875, #ba8728);
}
.icon-turn_belt {
    background: #7dafff;
    border-radius: 5px;
    overflow: hidden;
}
.icon-turn_belt::after {
    content: '';
    position: absolute;
    left: 14%;
    top: 23%;
    width: 72%;
    height: 54%;
    background: #08111f;
    clip-path: polygon(0 25%, 58% 25%, 58% 0, 100% 50%, 58% 100%, 58% 75%, 0 75%);
    transform-origin: 50% 50%;
}

.token-turn_belt[data-direction="right"] .icon-turn_belt::after { transform: rotate(0deg); }
.token-turn_belt[data-direction="down"] .icon-turn_belt::after { transform: rotate(90deg); }
.token-turn_belt[data-direction="left"] .icon-turn_belt::after { transform: rotate(180deg); }
.token-turn_belt[data-direction="up"] .icon-turn_belt::after { transform: rotate(-90deg); }

.token-player {
    background: rgba(4, 18, 28, 0.96);
    border: calc(2px / var(--map-zoom, 1)) solid rgba(88, 216, 210, 0.92);
    box-shadow: 0 0 0 calc(3px / var(--map-zoom, 1)) rgba(88,216,210,0.16), 0 0 calc(22px / var(--map-zoom, 1)) rgba(88,216,210,0.52);
    z-index: 5;
    overflow: visible;
}

.token-player .map-icon-img {
    width: 84%;
    height: 84%;
    max-width: 84%;
    max-height: 84%;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,0.08);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12);
}

.token-portal .map-icon-img {
    width: 84%;
    height: 84%;
    max-width: 84%;
    max-height: 84%;
}

.token-boss .map-icon-img {
    width: 84%;
    height: 84%;
    object-fit: contain;
    filter: drop-shadow(0 0 18px rgba(255,90,165,0.45));
}
.token-boss_tile {
    width: 36px;
    height: 36px;
    z-index: 1;
    background: rgba(255, 90, 165, 0.08);
    border-color: rgba(255, 90, 165, 0.22);
}
.token-boss_tile .map-icon {
    transform: scale(0.72);
    opacity: 0.7;
}
.token-boss {
    background: rgba(12, 5, 18, 0.82);
    border-color: rgba(255, 90, 165, 0.56);
    box-shadow: inset 0 0 42px rgba(255,90,165,0.12), 0 0 34px rgba(255,90,165,0.22);
}

.token-boss .map-icon {
    width: 58%;
    height: 58%;
}

.token-boss .tooltip-bubble {
    bottom: calc(100% + 8px);
}
.token-player::after {
    content: '';
    position: absolute;
    inset: calc(-6px / var(--map-zoom, 1));
    border-radius: var(--radius-sm);
    border: calc(2px / var(--map-zoom, 1)) solid rgba(88,216,210,0.34);
    animation: playerPulse 1.8s ease-in-out infinite;
}
.player-chip {
    position: absolute;
    top: calc(-8px / var(--map-zoom, 1));
    right: calc(-8px / var(--map-zoom, 1));
    min-width: calc(22px / var(--map-zoom, 1));
    height: calc(22px / var(--map-zoom, 1));
    padding: 0 calc(5px / var(--map-zoom, 1));
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--amber));
    color: #061016;
    font-size: calc(12px / var(--map-zoom, 1));
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 calc(7px / var(--map-zoom, 1)) calc(14px / var(--map-zoom, 1)) rgba(0,0,0,0.32);
}

@keyframes playerPulse {
    0% { transform: scale(0.94); opacity: 0.8; }
    72% { transform: scale(1.08); opacity: 0.2; }
    100% { transform: scale(1.14); opacity: 0; }
}

@keyframes rangePulse {
    0%, 100% { opacity: 0.62; }
    50% { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hand-card,
.log-item {
    background: rgba(255,255,255,0.045);
    padding: 11px;
}
.hand-card {
    position: relative;
    overflow: hidden;
    display: block;
}
.hand-card .card-headline { margin-bottom: 8px; }
.hand-card button {
    width: 100%;
    margin-top: 10px;
}

.item-tool {
    width: 100%;
    min-height: 0;
    padding: 0;
    overflow: visible;
    background: transparent;
    border: 0;
}

.item-tool::before {
    display: none;
}

.item-tool-button {
    width: 100%;
    min-height: 74px;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px;
    border-radius: var(--radius-md);
    background:
        linear-gradient(90deg, rgba(111,168,255,0.12), transparent 72%),
        rgba(255,255,255,0.055);
    border: 1px solid rgba(255,255,255,0.12);
}

.item-tool .item-tool-button {
    margin-top: 0;
}

.item-tool-button:hover,
.item-tool-button:focus-visible {
    border-color: rgba(88,216,210,0.58);
    transform: translateY(-1px);
}

.item-tool-button.is-loading {
    position: relative;
    opacity: 0.82;
    cursor: progress;
}

.item-tool-button.is-loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 10px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(88,216,210,0.22);
    border-top-color: var(--primary);
    animation: spin 0.76s linear infinite;
}

body.action-locked .map-stage {
    cursor: progress;
}

body.action-locked .map-stage,
body.action-locked .hand-list {
    pointer-events: none;
}

.item-tool-button .item-art.small {
    float: none;
    margin: 0;
    width: 62px;
    height: 62px;
}

.item-stack {
    justify-self: center;
    align-self: center;
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 191, 87, 0.18);
    border: 1px solid rgba(255, 191, 87, 0.44);
    color: #ffe7ad;
    font-size: 12px;
    font-weight: 900;
}

.item-tooltip {
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    width: min(280px, 42vw);
    padding: 12px;
    display: grid;
    gap: 10px;
    border-radius: var(--radius-md);
    background: rgba(6, 10, 16, 0.97);
    border: 1px solid rgba(88,216,210,0.28);
    box-shadow: 0 18px 46px rgba(0,0,0,0.42);
    opacity: 0;
    pointer-events: none;
    transform: translate(8px, -50%);
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 16;
}

.item-floating-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, calc(100vw - 24px));
    padding: 14px;
    display: grid;
    gap: 10px;
    border-radius: var(--radius-md);
    background: rgba(6, 10, 16, 0.98);
    border: 1px solid rgba(88,216,210,0.34);
    box-shadow: 0 22px 56px rgba(0,0,0,0.52);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 80;
}

.item-floating-tooltip.open {
    opacity: 1;
    transform: translateY(0);
}

.map-floating-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    width: min(360px, calc(100vw - 24px));
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(4, 10, 16, 0.96);
    border: 1px solid rgba(88,216,210,0.38);
    color: var(--text);
    box-shadow: 0 18px 38px rgba(0,0,0,0.44), 0 0 24px rgba(88,216,210,0.13);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 95;
    font-size: 15px;
    line-height: 1.45;
}

.map-floating-tooltip.open {
    opacity: 1;
    transform: translateY(0);
}

.map-tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.map-tooltip-tag {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    background: rgba(67, 255, 151, 0.14);
    border: 1px solid rgba(67, 255, 151, 0.34);
    color: #b9ffd2;
    font-size: 12px;
    font-weight: 900;
}

.item-tool:hover .item-tooltip,
.item-tool:focus-within .item-tooltip {
    opacity: 1;
    transform: translate(0, -50%);
}

.item-stack-detail {
    color: var(--amber);
    font-size: 12px;
    font-weight: 800;
}

.side-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    overflow: visible;
}

.side-title-row {
    align-items: flex-start;
}

.side-title-row > div:first-child {
    display: grid;
    gap: 4px;
}

.side-title-row p {
    color: var(--muted);
    font-weight: 700;
}

.side-toggle {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(46px, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.055);
    border: 1px solid rgba(255,255,255,0.1);
}

.side-toggle button {
    min-height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.side-toggle button.active {
    background: rgba(88,216,210,0.18);
    color: var(--text);
}

.map-zoom-control {
    display: grid;
    gap: 7px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.1);
}

.map-zoom-control span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.map-zoom-control input {
    width: 100%;
    accent-color: var(--primary);
}

.buff-panel {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.1);
}

.buff-panel span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.buff-panel strong {
    color: var(--text);
    font-size: 13px;
    line-height: 1.3;
}

.identification-panel {
    display: grid;
    gap: 9px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.1);
}

.combo-readout {
    width: fit-content;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255,191,87,0.12);
    border: 1px solid rgba(255,191,87,0.22);
    color: #ffe2aa;
    font-size: 13px;
    font-weight: 1000;
}

.combo-readout.combo-fire {
    color: #fff2cf;
    text-shadow:
        0 0 7px rgba(255,214,94,0.95),
        0 -3px 10px rgba(255,98,41,0.78),
        0 3px 14px rgba(255,45,45,0.54);
    animation: comboFire 0.82s ease-in-out infinite alternate;
}

.identification-exp {
    display: grid;
    gap: 7px;
}

.identification-exp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.identification-exp-head span:first-child {
    color: var(--text);
}

.identification-exp-bar {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.identification-exp-bar i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #6be184, #9df2a6);
    box-shadow: 0 0 12px rgba(107,225,132,0.36);
    transition: width 0.22s ease;
}

@keyframes comboFire {
    from { filter: brightness(1); transform: translateY(0); }
    to { filter: brightness(1.24); transform: translateY(-1px); }
}

.side-view {
    display: none;
    min-height: 0;
}

.side-view.active {
    display: grid;
    min-height: 0;
}

#items-side-view.active {
    grid-template-rows: minmax(0, 1fr);
}

#log-side-view.active {
    grid-template-rows: auto minmax(0, 1fr);
}

.hand-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(96px, 104px);
    align-content: start;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.hand-card {
    height: 100%;
}

.item-tool-button {
    height: 100%;
    min-height: 0;
}

.item-tool.touch-primed .item-tool-button {
    border-color: rgba(88,216,210,0.82);
    box-shadow: 0 0 0 3px rgba(88,216,210,0.18), 0 0 24px rgba(88,216,210,0.22);
}

.hand-card .item-art.small {
    width: 66px;
    height: 66px;
}

.hand-card .card-meta {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.log-list {
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
}

.copy-log-btn {
    width: fit-content;
    min-height: 34px;
    padding: 8px 12px;
    margin-bottom: 8px;
    justify-self: start;
    font-size: 12px;
    font-weight: 900;
}

.log-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    line-height: 1.45;
}
.log-item span {
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
}

.empty-state {
    padding: 20px;
    text-align: center;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

button[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.tutorial-modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 18px;
    z-index: 60;
    background: rgba(3, 7, 12, 0.72);
    backdrop-filter: blur(10px);
}

.tutorial-modal.open {
    display: grid;
}

.tutorial-dialog {
    width: min(720px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(88,216,210,0.12), transparent 38%),
        linear-gradient(315deg, rgba(255,191,87,0.1), transparent 46%),
        rgba(9, 14, 22, 0.98);
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: 0 28px 80px rgba(0,0,0,0.58);
}

.tutorial-header,
.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.tutorial-header h2 {
    font-size: 28px;
    line-height: 1.1;
}

.tutorial-progress {
    min-width: 64px;
    text-align: center;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--primary);
    background: rgba(88,216,210,0.11);
    border: 1px solid rgba(88,216,210,0.24);
    font-weight: 900;
}

.tutorial-body {
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
}

.tutorial-copy {
    display: grid;
    gap: 14px;
}

.tutorial-copy h3 {
    font-size: 24px;
    line-height: 1.15;
}

.tutorial-copy p {
    color: var(--muted);
    line-height: 1.7;
}

.tutorial-figure {
    margin: 0;
    min-height: 160px;
    max-height: 280px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: var(--radius-md);
    background:
        radial-gradient(circle at 50% 45%, rgba(255,255,255,0.12), transparent 62%),
        rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.12);
}

.tutorial-figure img {
    width: 100%;
    height: 100%;
    max-height: 280px;
    object-fit: contain;
    display: block;
}

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

.tutorial-link {
    width: fit-content;
}

.tutorial-samples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.tutorial-sample-card {
    min-height: 76px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.055);
    border: 1px solid rgba(255,255,255,0.1);
}

.tutorial-sample-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.055);
    border: 1px solid rgba(255,255,255,0.12);
}

.tutorial-sample-icon .map-icon,
.tutorial-sample-img {
    width: 34px;
    height: 34px;
}

.tutorial-sample-img {
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 8px 14px rgba(0,0,0,0.42));
}

.tutorial-sample-card strong,
.tutorial-sample-card small {
    display: block;
    min-width: 0;
}

.tutorial-sample-card strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tutorial-sample-card small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.tutorial-footer {
    justify-content: flex-end;
}

.event-modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 18px;
    z-index: 34;
    background: rgba(3, 7, 12, 0.68);
    backdrop-filter: blur(10px);
}

.event-modal.open {
    display: grid;
}

.event-dialog {
    width: min(680px, 100%);
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 20px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(88,216,210,0.12), transparent 38%),
        linear-gradient(315deg, rgba(255,191,87,0.12), transparent 46%),
        rgba(9, 14, 22, 0.98);
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: 0 28px 80px rgba(0,0,0,0.58);
}

.event-icon {
    min-height: 180px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background:
        radial-gradient(circle, rgba(88,216,210,0.18), transparent 62%),
        rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.12);
}

.event-icon .map-icon,
.event-icon .map-icon-img {
    width: 92px;
    height: 92px;
}

.event-icon .icon-portal {
    border-width: 10px;
}

.event-copy {
    display: grid;
    gap: 10px;
}

.event-copy h2 {
    font-size: 30px;
    line-height: 1.1;
}

.event-copy p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.65;
    font-size: 15px;
}

.event-dialog .primary-btn {
    grid-column: 2;
    justify-self: start;
}

.battle-modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 18px;
    z-index: 30;
    background: rgba(3, 7, 12, 0.68);
    backdrop-filter: blur(10px);
}

.battle-modal.open {
    display: grid;
}

.battle-dialog {
    width: min(760px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    gap: 18px;
    align-items: stretch;
    padding: 18px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(88,216,210,0.1), transparent 40%),
        linear-gradient(315deg, rgba(255,90,165,0.12), transparent 48%),
        rgba(9, 14, 22, 0.98);
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: 0 28px 80px rgba(0,0,0,0.58);
}

.battle-scene {
    min-height: 250px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.combatant {
    position: relative;
    min-height: 210px;
    display: grid;
    align-content: end;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.14);
    background:
        linear-gradient(180deg, transparent 0 24%, rgba(255,255,255,0.07) 24% 100%),
        rgba(255,255,255,0.04);
}

.hero-combatant {
    box-shadow: inset 0 0 60px rgba(88,216,210,0.1);
}

.enemy-combatant {
    box-shadow: inset 0 0 60px rgba(255,90,165,0.12);
}

.combat-label {
    width: fit-content;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 12px;
    font-weight: 900;
}

.combatant strong {
    font-size: 22px;
    line-height: 1.1;
}

.combatant small {
    color: var(--muted);
}

.versus-mark {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 999px;
    color: #071016;
    background: linear-gradient(135deg, var(--primary), var(--amber));
    font-weight: 1000;
    box-shadow: 0 0 26px rgba(88,216,210,0.32);
}

.battle-hp {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
}

.battle-hp i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--primary));
    transition: width 0.24s ease;
}

.battle-hp.enemy i {
    background: linear-gradient(90deg, var(--magenta), var(--danger));
}

.battle-summary {
    display: grid;
    align-content: center;
    gap: 12px;
}

.battle-summary h2 {
    font-size: 28px;
}

.battle-summary p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.6;
}

.battle-dialog .primary-btn {
    grid-column: 2;
    align-self: end;
}

.damage-pop {
    position: absolute;
    left: 50%;
    top: 34%;
    transform: translate(-50%, 8px) scale(0.9);
    color: #ffffff;
    font-size: 34px;
    font-weight: 1000;
    text-shadow: 0 4px 18px rgba(255, 98, 98, 0.88);
    opacity: 0;
    pointer-events: none;
}

.damage-pop.enemy {
    color: #ffe3ef;
}

.battle-animating .hero-combatant {
    animation: heroClash 0.64s cubic-bezier(.2,.8,.2,1) 0.12s both;
}

.battle-animating .enemy-combatant {
    animation: enemyClash 0.64s cubic-bezier(.2,.8,.2,1) 0.12s both;
}

.battle-animating .versus-mark {
    animation: versusBurst 0.56s ease 0.22s both;
}

.battle-animating .damage-pop:not(:empty) {
    animation: damageFloat 0.82s ease-out 0.58s both;
}

@keyframes heroClash {
    0% { transform: translateX(0); }
    42% { transform: translateX(44px) scale(1.04); filter: brightness(1.25); }
    58% { transform: translateX(28px) scale(0.98); }
    100% { transform: translateX(0); }
}

@keyframes enemyClash {
    0% { transform: translateX(0); }
    42% { transform: translateX(-44px) scale(1.04); filter: brightness(1.25); }
    58% { transform: translateX(-28px) scale(0.98); }
    100% { transform: translateX(0); }
}

@keyframes versusBurst {
    0% { transform: scale(1); }
    45% { transform: scale(1.24); box-shadow: 0 0 42px rgba(255,191,87,0.48); }
    100% { transform: scale(1); }
}

@keyframes damageFloat {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.84); }
    18% { opacity: 1; transform: translate(-50%, -8px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -54px) scale(1); }
}

@supports selector(body:has(.table-page)) {
    body:has(.table-page) {
        overflow: hidden;
    }

    body:has(.table-page) .shell {
        width: calc(100vw - 24px);
        max-width: none;
        height: 100vh;
        padding: 12px 0;
    }

    body:has(.table-page) .table-page {
        height: calc(100vh - 24px);
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        gap: 12px;
        overflow: hidden;
    }

    body:has(.table-page) .combat-topbar {
        min-height: 74px;
        padding: 12px 16px;
    }

    body:has(.table-page) .combat-topbar .subtle {
        display: none;
    }

    body:has(.table-page) .panel-header h1,
    body:has(.table-page) .table-topbar h1 {
        font-size: 28px;
    }
}

@supports selector(body:has(.build-page)) {
    body:has(.build-page) {
        overflow: hidden;
    }

    body:has(.build-page) .shell {
        height: 100vh;
        padding: 8px 0;
    }

    body:has(.build-page) .build-page {
        height: calc(100vh - 16px);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 10px;
        overflow: hidden;
    }
}

@media (max-width: 1180px) {
    .build-studio {
        grid-template-columns: minmax(180px, 0.4fr) minmax(260px, 0.6fr);
    }
    .build-item-panel {
        grid-column: 1 / -1;
    }
    .table-layout { grid-template-columns: 1fr; }
    .state-panel, .side-panel { position: static; }

    @supports selector(body:has(.table-page)) {
        body:has(.table-page) {
            overflow: auto;
        }

        body:has(.table-page) .shell,
        body:has(.table-page) .table-page {
            height: auto;
            min-height: 100vh;
            overflow: visible;
        }
    }
}

@media (max-width: 720px) {
    .shell { width: min(100vw - 20px, 100%); padding-top: 14px; }
    .hero, .auth-card, .panel-header, .character-panel, .card-panel, .table-topbar, .state-panel, .board-panel, .side-panel { padding: 16px; }
    .account-panel, .mode-panel { padding: 16px; }
    .panel-header, .table-topbar, .section-title-row { flex-direction: column; align-items: flex-start; }
    .character-carousel { grid-auto-columns: minmax(250px, 84vw); }
    .account-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .build-studio { grid-template-columns: 1fr; }
    .character-wheel { min-height: 390px; padding-left: 36px; }
    .wheel-character { left: 42px; width: calc(100% - 48px); }
    .character-portrait-stage { min-height: 520px; }
    .map-stage { aspect-ratio: var(--map-aspect, 4 / 3); }
    .tutorial-dialog { padding: 16px; }
    .tutorial-header { align-items: flex-start; }
    .tutorial-samples { grid-template-columns: 1fr; }
    .event-dialog { grid-template-columns: 1fr; }
    .event-dialog .primary-btn { grid-column: auto; }
    .battle-dialog { grid-template-columns: 1fr; }
    .battle-dialog .primary-btn { grid-column: auto; }
    .battle-scene { grid-template-columns: 1fr; }
    .versus-mark { justify-self: center; }
}

@media (orientation: landscape) and (max-height: 680px) {
    body:has(.table-page) {
        overflow: hidden;
    }

    body:has(.table-page) .shell {
        width: calc(100vw - 12px);
        height: 100vh;
        padding: 6px 0;
    }

    body:has(.table-page) .table-page {
        height: calc(100vh - 12px);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 6px;
        overflow: hidden;
    }

    body:has(.table-page) .combat-topbar {
        min-height: 52px;
        padding: 8px 10px;
    }

    body:has(.table-page) .combat-topbar .eyebrow {
        display: none;
    }

    body:has(.table-page) .combat-topbar > div:first-child {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    body:has(.table-page) .table-topbar h1 {
        font-size: 22px;
    }

    .combat-hud {
        position: static;
        transform: none;
        margin-top: 0;
        justify-content: flex-start;
    }

    .combat-hud span {
        min-height: 28px;
        padding: 5px 8px;
        font-size: 13px;
    }

    .header-actions {
        gap: 6px;
    }

    .header-actions .primary-btn,
    .header-actions .secondary-btn,
    .header-actions .icon-btn {
        min-height: 38px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .header-actions .icon-btn {
        width: 38px;
        min-width: 38px;
        padding: 0;
    }

    .table-layout {
        grid-template-columns: 198px minmax(400px, 1fr) 176px;
        gap: 6px;
        min-height: 0;
    }

    .state-panel,
    .board-panel,
    .side-panel {
        padding: 10px;
        min-height: 0;
    }

    .section-title-row {
        gap: 8px;
    }

    .section-title-row h2 {
        font-size: 18px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .stat-card {
        min-height: 48px;
        padding: 6px;
    }

    .stat-card strong {
        font-size: 16px;
    }

    .stat-card small {
        display: none;
    }

    .cta-stack {
        gap: 7px;
        margin-top: 8px;
    }

    .dice-readout {
        min-height: 34px;
        min-width: 78px;
        padding: 5px 8px;
    }

    .board-panel {
        grid-template-rows: auto auto;
        align-content: start;
    }

    .map-stage {
        width: min(100%, calc((100vh - 110px) * var(--map-aspect-number, 1.333)));
        margin-top: 6px;
    }

    .side-panel {
        gap: 7px;
    }

    .side-toggle {
        grid-template-columns: repeat(2, minmax(38px, 1fr));
    }

    .side-toggle button {
        min-height: 28px;
        padding: 0 6px;
    }

    .map-zoom-control {
        padding: 7px 8px;
    }

    .hand-list {
        grid-auto-rows: 86px;
        gap: 7px;
    }

    .hand-card {
        height: 86px;
    }

    .hand-card .item-art.small {
        width: 52px;
        height: 52px;
    }
}

@media (orientation: landscape) and (pointer: coarse) {
    body:has(.table-page) {
        overflow: hidden;
        overscroll-behavior: none;
    }

    body:has(.table-page) .shell {
        width: 100vw;
        height: 100dvh;
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    body:has(.table-page) .table-page {
        height: 100dvh;
        gap: 4px;
    }

    body:has(.table-page) .combat-topbar {
        min-height: 40px;
        padding: 4px 8px;
        border-radius: 10px;
    }

    body:has(.table-page) .combat-topbar::after {
        height: 44px;
        bottom: -18px;
        opacity: 0.62;
    }

    body:has(.table-page) .combat-topbar > div:first-child {
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

    body:has(.table-page) .table-topbar h1 {
        display: none;
    }

    body:has(.table-page) .combat-hud {
        position: static;
        width: auto;
        transform: none;
        gap: 4px;
        justify-content: flex-start;
    }

    body:has(.table-page) .combat-hud span {
        min-height: 24px;
        padding: 3px 6px;
        border-radius: 8px;
        font-size: 11px;
        gap: 4px;
    }

    body:has(.table-page) .hud-dice img {
        width: 15px;
        height: 15px;
    }

    body:has(.table-page) .header-actions {
        gap: 4px;
        flex-wrap: nowrap;
        align-items: center;
    }

    body:has(.table-page) .header-actions .primary-btn,
    body:has(.table-page) .header-actions .secondary-btn,
    body:has(.table-page) .header-actions .icon-btn {
        min-height: 30px;
        padding: 5px 8px;
        border-radius: 8px;
        font-size: 12px;
        white-space: nowrap;
    }

    body:has(.table-page) .header-actions .icon-btn {
        width: 30px;
        min-width: 30px;
        padding: 0;
    }

    body:has(.table-page) .table-layout {
        grid-template-columns: minmax(132px, 0.56fr) minmax(0, 2.7fr) minmax(132px, 0.62fr);
        gap: 4px;
    }

    body:has(.table-page) .state-panel,
    body:has(.table-page) .board-panel,
    body:has(.table-page) .side-panel {
        padding: 6px;
        border-radius: 10px;
    }

    body:has(.table-page) .section-title-row {
        gap: 6px;
    }

    body:has(.table-page) .section-title-row h2 {
        font-size: 15px;
        line-height: 1.08;
    }

    body:has(.table-page) .phase-chip {
        padding: 4px 6px;
        border-radius: 7px;
        font-size: 10px;
    }

    body:has(.table-page) .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        margin-top: 5px;
    }

    body:has(.table-page) .stat-card {
        min-height: 38px;
        padding: 5px;
        border-radius: 8px;
    }

    body:has(.table-page) .stat-card span,
    body:has(.table-page) .stat-card small {
        font-size: 9px;
    }

    body:has(.table-page) .stat-card strong,
    body:has(.table-page) .stat-role strong {
        margin-top: 2px;
        font-size: 13px;
    }

    body:has(.table-page) .stat-card small {
        display: none;
    }

    body:has(.table-page) .stat-meter {
        left: 5px;
        right: 5px;
        bottom: 4px;
        height: 3px;
    }

    body:has(.table-page) .cta-stack {
        gap: 5px;
        margin-top: 6px;
    }

    body:has(.table-page) .identification-panel,
    body:has(.table-page) .map-zoom-control,
    body:has(.table-page) .buff-panel {
        padding: 5px 6px;
        gap: 4px;
        border-radius: 8px;
    }

    body:has(.table-page) .combo-readout {
        min-height: 22px;
        padding: 3px 7px;
        border-radius: 7px;
        font-size: 11px;
    }

    body:has(.table-page) .identification-exp {
        gap: 4px;
    }

    body:has(.table-page) .identification-exp-head,
    body:has(.table-page) .map-zoom-control span,
    body:has(.table-page) .buff-panel span {
        font-size: 9px;
        gap: 4px;
    }

    body:has(.table-page) .identification-exp-bar {
        height: 5px;
    }

    body:has(.table-page) .buff-panel strong {
        font-size: 10px;
        line-height: 1.18;
    }

    body:has(.table-page) .board-panel {
        grid-template-rows: auto minmax(0, 1fr);
    }

    body:has(.table-page) .board-title-row {
        align-items: center;
    }

    body:has(.table-page) .board-title-row p {
        font-size: 12px;
    }

    body:has(.table-page) .map-stage {
        width: min(100%, calc((100dvh - 54px) * var(--map-aspect-number, 1.333)));
        margin-top: 3px;
        border-radius: 9px;
        justify-self: center;
    }

    body:has(.table-page) .preview-dot {
        width: calc(16px / var(--map-zoom, 1)) !important;
        height: calc(16px / var(--map-zoom, 1)) !important;
        transform: translate(-50%, -50%);
        font-size: calc(8px / var(--map-zoom, 1));
        line-height: 1;
        box-shadow: 0 0 0 calc(2px / var(--map-zoom, 1)) rgba(88,216,210,0.12), 0 calc(4px / var(--map-zoom, 1)) calc(10px / var(--map-zoom, 1)) rgba(0,0,0,0.34);
    }

    body:has(.table-page) .preview-start {
        width: calc(8px / var(--map-zoom, 1)) !important;
        height: calc(8px / var(--map-zoom, 1)) !important;
    }

    body:has(.table-page) .preview-landing {
        width: calc(20px / var(--map-zoom, 1)) !important;
        height: calc(20px / var(--map-zoom, 1)) !important;
    }

    body:has(.table-page) .preview-dot[data-turn]::after {
        right: calc(-9px / var(--map-zoom, 1));
        top: calc(-9px / var(--map-zoom, 1));
        width: calc(14px / var(--map-zoom, 1));
        height: calc(14px / var(--map-zoom, 1));
        font-size: calc(8px / var(--map-zoom, 1));
    }

    body:has(.table-page) .preview-block {
        width: calc(28px / var(--map-zoom, 1)) !important;
        height: calc(28px / var(--map-zoom, 1)) !important;
        transform: translate(-50%, -50%);
        font-size: calc(14px / var(--map-zoom, 1));
    }

    body:has(.table-page) .preview-line {
        opacity: 0.74;
        box-shadow: 0 0 calc(8px / var(--map-zoom, 1)) rgba(88,216,210,0.34);
    }

    body:has(.table-page) .preview-line-horizontal {
        height: calc(3px / var(--map-zoom, 1));
    }

    body:has(.table-page) .preview-line-vertical {
        width: calc(3px / var(--map-zoom, 1));
    }

    body:has(.table-page) .token-player {
        width: calc(40px / var(--map-zoom, 1)) !important;
        height: calc(40px / var(--map-zoom, 1)) !important;
        box-shadow:
            0 0 0 calc(3px / var(--map-zoom, 1)) rgba(88,216,210,0.34),
            0 0 calc(18px / var(--map-zoom, 1)) rgba(88,216,210,0.78),
            0 0 calc(34px / var(--map-zoom, 1)) rgba(255,191,87,0.26);
    }

    body:has(.table-page) .token-player .map-icon-img {
        width: 92%;
        height: 92%;
        max-width: 92%;
        max-height: 92%;
    }

    body:has(.table-page) .token-player::after {
        inset: calc(-10px / var(--map-zoom, 1));
        border-color: rgba(88,216,210,0.58);
        box-shadow: 0 0 calc(20px / var(--map-zoom, 1)) rgba(88,216,210,0.32);
    }

    body:has(.table-page) .player-chip {
        display: none;
    }

    body:has(.table-page) .side-panel {
        gap: 5px;
    }

    body:has(.table-page) .side-title-row {
        align-items: start;
    }

    body:has(.table-page) .side-title-row p {
        font-size: 11px;
        line-height: 1.2;
    }

    body:has(.table-page) .side-toggle {
        grid-template-columns: repeat(2, minmax(34px, 1fr));
        padding: 3px;
        border-radius: 8px;
    }

    body:has(.table-page) .side-toggle button {
        min-height: 24px;
        padding: 0 5px;
        border-radius: 7px;
        font-size: 10px;
    }

    body:has(.table-page) .hand-list {
        grid-auto-rows: 64px;
        gap: 5px;
    }

    body:has(.table-page) .hand-card {
        height: 64px;
        padding: 5px;
        border-radius: 8px;
    }

    body:has(.table-page) .item-tool {
        height: 64px;
    }

    body:has(.table-page) .item-tool-button {
        height: 100%;
        min-height: 52px;
        padding: 5px;
        border-radius: 8px;
    }

    body:has(.table-page) .hand-card .item-art.small {
        width: 42px;
        height: 42px;
    }

    body:has(.table-page) .item-stack {
        min-width: 18px;
        height: 18px;
        font-size: 10px;
    }
}
