:root {
    --bg: #10161d;
    --bg-soft: #151e27;
    --card: rgba(24, 34, 44, 0.94);
    --card-strong: #202c38;
    --border: rgba(255, 255, 255, 0.09);
    --text: #eef3f7;
    --muted: #a9b5c0;
    --orange: #f7931e;
    --orange-dark: #c96908;
    --danger: #e05757;
    --success: #44c67a;
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color: var(--text); }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 20% 0%, rgba(247, 147, 30, 0.14), transparent 33rem),
        linear-gradient(135deg, #0e141b 0%, #111b25 54%, #0c1117 100%);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.app-shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 20px 0; position: sticky; top: 0; z-index: 20;
    background: linear-gradient(180deg, rgba(16, 22, 29, 0.96), rgba(16, 22, 29, 0.72));
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: 0.02em; }
.brand-mark {
    display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
    color: #141c22; background: linear-gradient(135deg, #ffb35c, var(--orange)); box-shadow: 0 0 24px rgba(247, 147, 30, 0.28);
}
.topnav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topnav a:not(.btn) { color: var(--muted); padding: 10px 12px; border-radius: 12px; }
.topnav a:not(.btn):hover { color: var(--text); background: rgba(255,255,255,0.05); }

.page { padding: 26px 0 80px; }
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px;
}
.alert-card { max-width: 760px; margin: 80px auto; }
.hero-section { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 28px; align-items: center; min-height: 68vh; }
.hero-copy h1, .page-heading h1 { font-size: clamp(2.2rem, 5vw, 5.5rem); line-height: 0.95; margin: 8px 0 18px; letter-spacing: -0.06em; }
.hero-copy .lead { color: var(--muted); font-size: 1.18rem; max-width: 760px; line-height: 1.7; }
.eyebrow { color: var(--orange); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 800; font-size: 0.78rem; }
.action-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn {
    border: 0; border-radius: 13px; padding: 10px 15px; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center; gap: 8px; font-weight: 800; transition: 160ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-large { padding: 14px 20px; }
.btn-primary { background: linear-gradient(135deg, #ffad54, var(--orange)); color: #111820; }
.btn-secondary { background: rgba(247, 147, 30, 0.14); color: #ffd0a1; border: 1px solid rgba(247, 147, 30, 0.26); }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text); }
.btn-danger { background: rgba(224, 87, 87, 0.15); color: #ffb6b6; border: 1px solid rgba(224, 87, 87, 0.28); }
.btn-disabled { background: rgba(255,255,255,0.07); color: var(--muted); cursor: not-allowed; }
.full-width { width: 100%; }
.timeline-list { color: var(--muted); line-height: 2; padding-left: 22px; }

.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 28px));
    pointer-events: none;
}
.toast {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: 11px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(20, 28, 36, 0.97);
    box-shadow: 0 18px 45px rgba(0,0,0,0.42);
    padding: 12px 12px;
    transform: translateX(18px);
    opacity: 0;
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: auto;
    overflow: hidden;
}
.toast.is-visible { transform: translateX(0); opacity: 1; }
.toast.is-hiding { transform: translateX(18px); opacity: 0; }
.toast::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--orange);
}
.toast p { margin: 0; color: var(--text); font-weight: 850; line-height: 1.35; }
.toast-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--orange); box-shadow: 0 0 16px rgba(247,147,30,0.55); }
.toast-close { border: 0; background: rgba(255,255,255,0.07); color: var(--muted); width: 26px; height: 26px; border-radius: 9px; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.toast-close:hover { color: var(--text); background: rgba(255,255,255,0.12); }
.toast-success { border-color: rgba(68,198,122,0.35); }
.toast-success::before, .toast-success .toast-dot { background: var(--success); box-shadow: 0 0 16px rgba(68,198,122,0.55); }
.toast-error { border-color: rgba(224,87,87,0.42); }
.toast-error::before, .toast-error .toast-dot { background: var(--danger); box-shadow: 0 0 16px rgba(224,87,87,0.55); }
.toast-warning { border-color: rgba(247,147,30,0.46); }
.toast-info { border-color: rgba(255,255,255,0.14); }

kbd {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.07);
    color: #ffd0a1;
    font-weight: 900;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.35);
}


.flash-message {
    margin: -8px 0 18px;
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-weight: 800;
}
.flash-success { border-color: rgba(68, 198, 122, 0.34); background: rgba(68, 198, 122, 0.12); color: #bff6d4; }
.flash-error { border-color: rgba(224, 87, 87, 0.34); background: rgba(224, 87, 87, 0.12); color: #ffc4c4; }
.inventory-help { margin: 0 0 12px; color: var(--muted); line-height: 1.45; }
.inventory-inline-message {
    min-height: 22px;
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}
.inventory-inline-message[data-type="info"] { color: #ffd0a1; }
.inventory-inline-message[data-type="error"] { color: #ffc4c4; }

.page-heading { margin-bottom: 26px; }
.page-heading p { color: var(--muted); max-width: 850px; line-height: 1.6; }
.shop-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.shop-heading h1 { font-size: clamp(2rem, 4vw, 4rem); }

.menu-grid, .hero-grid, .result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.result-grid { grid-template-columns: 1fr 1fr; }
.menu-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px;
    min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow);
}
.menu-card.primary { background: linear-gradient(135deg, rgba(247,147,30,0.24), rgba(255,255,255,0.06)); border-color: rgba(247,147,30,0.35); }
.menu-card span { font-weight: 900; font-size: 1.35rem; }
.menu-card small, .muted { color: var(--muted); }
.split-card { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }

.hero-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.hero-choice { display: flex; flex-direction: column; gap: 12px; }
.hero-choice p { color: var(--muted); line-height: 1.55; }
.hero-avatar, .profile-avatar-fallback {
    width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; font-weight: 900; font-size: 1.45rem;
    background: rgba(247,147,30,0.14); color: #ffd0a1; border: 1px solid rgba(247,147,30,0.25);
}
.stat-pills, .tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-pills span, .tag-cloud span, .mini-item {
    padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,0.06); color: var(--muted); font-size: 0.82rem; border: 1px solid var(--border);
}
.passive-box { padding: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 14px; }
.passive-box small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.tag-line { font-size: 0.9rem; }

.shop-layout { display: grid; grid-template-columns: 330px minmax(430px, 1fr) 330px; gap: 18px; align-items: start; }
.build-layout { grid-template-columns: minmax(430px, 1fr) 360px; }
.shop-list { display: grid; gap: 12px; }
.shop-item { border: 1px solid var(--border); border-radius: 15px; padding: 14px; background: rgba(255,255,255,0.035); display: grid; gap: 10px; }
.shop-item.is-bought { opacity: 0.55; }
.shop-item-head, .panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shop-item p { margin: 0; color: var(--muted); }
.shop-item small { color: var(--muted); line-height: 1.4; }
.rarity-text { font-weight: 900; font-size: 0.78rem; }
.rarity-common { border-color: rgba(200, 210, 220, 0.25); }
.rarity-uncommon { border-color: rgba(91, 214, 134, 0.45); }
.rarity-rare { border-color: rgba(86, 163, 255, 0.48); }
.rarity-epic { border-color: rgba(174, 99, 255, 0.54); }
.rarity-legendary { border-color: rgba(247, 147, 30, 0.75); box-shadow: 0 0 24px rgba(247, 147, 30, 0.14); }

.inventory-grid-scroll {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 6px;
}
.inventory-grid {
    --slot-size: 48px;
    display: grid;
    grid-template-columns: repeat(var(--grid-w), var(--slot-size));
    grid-template-rows: repeat(var(--grid-h), var(--slot-size));
    gap: 3px;
    width: max-content;
    position: relative;
    touch-action: none;
}
.grid-cell {
    z-index: 1;
    border: 1px dashed rgba(255,255,255,0.04);
    border-radius: 7px;
    background: rgba(0,0,0,0.10);
    opacity: 0.34;
    transition: 120ms ease;
}
.grid-cell.is-unlocked {
    opacity: 1;
    border-color: rgba(247,147,30,0.24);
    background: linear-gradient(135deg, rgba(247,147,30,0.10), rgba(255,255,255,0.035));
}
.grid-cell.is-starter-cell { border-color: rgba(247,147,30,0.30); }
.grid-cell.is-bag-cell { background: linear-gradient(135deg, rgba(125,82,43,0.32), rgba(247,147,30,0.13)); border-color: rgba(247,147,30,0.38); }
.grid-cell:hover { border-color: rgba(247,147,30,0.48); background: rgba(247,147,30,0.08); opacity: 1; }
.grid-cell.is-preview-valid { border-color: rgba(68,198,122,0.78); background: rgba(68,198,122,0.18); opacity: 1; }
.grid-cell.is-preview-invalid { border-color: rgba(224,87,87,0.78); background: rgba(224,87,87,0.16); opacity: 1; }
.grid-cell.is-preview-shape { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.10), 0 0 18px rgba(0,0,0,0.20); }
.inventory-item-cell {
    z-index: 4;
    padding: 4px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.045));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
    cursor: grab;
    user-select: none;
    touch-action: none;
    transition: transform 130ms ease, box-shadow 130ms ease, opacity 130ms ease, border-color 130ms ease;
}
.inventory-item-cell.is-fill-cell {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035));
}
.inventory-item-cell.is-fill-cell::after { content: ''; width: 12px; height: 12px; border-radius: 5px; background: rgba(255,255,255,0.10); }
.inventory-item-cell.is-bag-item {
    z-index: 2;
    background: linear-gradient(135deg, rgba(114,76,39,0.78), rgba(247,147,30,0.22));
    border-color: rgba(247,147,30,0.30);
}
.inventory-item-cell:active { cursor: grabbing; }
.inventory-item-cell.is-selected { outline: 2px solid rgba(247,147,30,0.72); box-shadow: 0 0 0 4px rgba(247,147,30,0.13), 0 14px 32px rgba(0,0,0,0.25); }
.inventory-item-cell.is-dragging { z-index: 8; opacity: 0.58; transform: scale(0.985); }
.inventory-item-cell.is-rotation-preview { outline-color: rgba(255,208,161,0.85); }
.inventory-item-cell[data-draggable="1"]:hover { transform: translateY(-1px); }
.inventory-item-cell strong { font-size: 0.64rem; line-height: 1.05; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.inventory-item-cell small { color: var(--muted); font-size: 0.55rem; line-height: 1.1; }
.item-icon { width: 19px; height: 19px; border-radius: 7px; display: grid; place-items: center; background: rgba(247,147,30,0.16); color: #ffd0a1; font-weight: 900; font-size: 0.74rem; }
.item-sell-form { margin-top: 2px; }
.link-button { background: none; border: 0; padding: 0; color: #ffd0a1; cursor: pointer; font-weight: 800; font-size: 0.78rem; }

.stats-list { display: grid; gap: 10px; margin: 0; }
.stats-list.wide { grid-template-columns: 1fr 1fr; }
.stats-list div { display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; gap: 10px; }
.stats-list dt { color: var(--muted); }
.stats-list dd { margin: 0; font-weight: 900; }
.synergy-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.synergy-list li { background: rgba(247,147,30,0.10); border: 1px solid rgba(247,147,30,0.20); border-radius: 12px; padding: 10px; }
.synergy-list small { display: block; color: var(--muted); margin-top: 4px; }
.spaced-form { margin-top: 18px; }

.success-card { margin-bottom: 18px; border-color: rgba(68,198,122,0.35); background: rgba(68,198,122,0.12); }
.battle-log-card { margin-top: 18px; }
.battle-log { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; max-height: 540px; overflow: auto; }
.battle-log.is-collapsed { max-height: 0; overflow: hidden; margin: 0; }
.battle-log li { display: grid; grid-template-columns: 90px 90px 1fr; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.035); border: 1px solid var(--border); }
.battle-log p { margin: 0; color: var(--muted); }
.log-attack { border-color: rgba(247,147,30,0.24) !important; }
.log-heal { border-color: rgba(68,198,122,0.24) !important; }
.log-debuff { border-color: rgba(224,87,87,0.24) !important; }
.bottom-actions { margin-top: 18px; }

.table-card { padding: 0; overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { text-align: left; padding: 15px 16px; border-bottom: 1px solid var(--border); }
th { color: #ffd0a1; background: rgba(247,147,30,0.08); font-size: 0.84rem; text-transform: uppercase; letter-spacing: 0.08em; }
td { color: var(--text); }
td a { color: #ffd0a1; font-weight: 800; }
.profile-card { text-align: center; }
.profile-card img { width: 110px; height: 110px; object-fit: cover; border-radius: 28px; border: 2px solid rgba(247,147,30,0.25); }
.profile-avatar-fallback { width: 110px; height: 110px; margin: 0 auto; border-radius: 28px; font-size: 2.5rem; }
.item-list-inline { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 1250px) {
    .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .shop-layout, .build-layout { grid-template-columns: 1fr; }
    .shop-panel, .stats-panel { order: initial; }
}
@media (max-width: 860px) {
    .app-shell { width: min(100% - 20px, 1500px); }
    .topbar, .shop-heading, .split-card { align-items: flex-start; flex-direction: column; }
    .hero-section, .menu-grid, .hero-grid, .result-grid { grid-template-columns: 1fr; }
    .inventory-grid { --slot-size: 46px; gap: 3px; }
    .inventory-item-cell { padding: 3px; }
    .inventory-item-cell small { display: none; }
    .stats-list.wide { grid-template-columns: 1fr; }
    .battle-log li { grid-template-columns: 1fr; gap: 4px; }
}


.battle-heading h1 { font-size: clamp(2rem, 4vw, 4rem); }
.battle-stage {
    display: grid;
    grid-template-columns: minmax(290px, 0.95fr) minmax(360px, 1.05fr) minmax(290px, 0.95fr);
    gap: 18px;
    align-items: start;
}
.battle-actor { position: relative; overflow: hidden; }
.battle-actor::after {
    content: "";
    position: absolute;
    inset: auto 18px 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(247,147,30,0.45), transparent);
    opacity: 0;
    transition: opacity 160ms ease;
}
.battle-actor.is-active {
    border-color: rgba(247,147,30,0.38);
    box-shadow: 0 0 0 1px rgba(247,147,30,0.12), var(--shadow);
}
.battle-actor.is-active::after { opacity: 1; }
.battle-actor.is-hit { animation: actor-hit 220ms ease; }
.battle-actor.is-healed { animation: actor-healed 280ms ease; }
@keyframes actor-hit {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(-4px); }
    65% { transform: translateX(4px); }
}
@keyframes actor-healed {
    0%, 100% { transform: translateY(0); }
    45% { transform: translateY(-3px); }
}
.battle-actor-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.battle-actor-head h2 { margin: 2px 0 4px; }
.battle-actor-head span { color: var(--muted); }
.battle-hp-number { white-space: nowrap; color: #ffd0a1; }
.battle-hp-bar, .battle-progress {
    height: 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 14px;
}
.battle-hp-bar span, .battle-progress span {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, rgba(68,198,122,0.95), rgba(247,147,30,0.85));
    transition: width 260ms ease;
}
.battle-progress { height: 8px; margin: 16px 0; }
.battle-progress span { background: linear-gradient(90deg, var(--orange), #ffd0a1); }
.battle-board .inventory-grid { --slot-size: 34px; }
.battle-board .inventory-item-cell { padding: 3px; gap: 1px; cursor: default; }
.battle-board .inventory-item-cell strong { font-size: 0.50rem; }
.battle-board .inventory-item-cell small, .battle-board .item-sell-form, .battle-board .item-icon { display: none; }
.battle-board .item-icon { width: 18px; height: 18px; border-radius: 6px; font-size: 0.72rem; }
.npc-board-placeholder {
    min-height: 260px;
    border: 1px dashed rgba(255,255,255,0.14);
    border-radius: 14px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 20px;
    color: var(--muted);
    background: rgba(0,0,0,0.13);
}
.npc-board-placeholder strong { color: var(--text); font-size: 1.15rem; }
.battle-feed-card { min-height: 500px; }
.battle-tick-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid rgba(247,147,30,0.22);
    background: rgba(247,147,30,0.09);
    border-radius: 15px;
    padding: 12px 14px;
}
.battle-tick-box span { color: var(--muted); font-weight: 800; }
.battle-tick-box strong { font-size: 1.55rem; color: #ffd0a1; }
.battle-current-action {
    margin-top: 14px;
    min-height: 96px;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 16px;
    padding: 18px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    font-size: 1.08rem;
    font-weight: 900;
    line-height: 1.45;
}
.battle-current-action.is-attack { border-color: rgba(247,147,30,0.34); background: rgba(247,147,30,0.10); }
.battle-current-action.is-heal { border-color: rgba(68,198,122,0.30); background: rgba(68,198,122,0.10); }
.battle-current-action.is-debuff { border-color: rgba(224,87,87,0.30); background: rgba(224,87,87,0.10); }
.battle-replay-log {
    max-height: 285px;
    scroll-behavior: smooth;
}
.battle-replay-log li { grid-template-columns: 78px 78px 1fr; }
.battle-replay-log li.is-current {
    border-color: rgba(247,147,30,0.42) !important;
    background: rgba(247,147,30,0.08);
}
.battle-log-full { margin-top: 18px; }
.summary-modal[hidden] { display: none; }
.summary-modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 24px;
}
.summary-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 6, 10, 0.72);
}
.summary-dialog {
    position: relative;
    z-index: 1;
    width: min(860px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    transition: opacity 180ms ease, transform 180ms ease;
}
.summary-modal.is-open .summary-dialog { transform: translateY(0) scale(1); opacity: 1; }
.summary-dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 16px; }
.summary-dialog-head h2 { margin: 4px 0 0; font-size: clamp(1.7rem, 3vw, 2.5rem); }
.summary-close {
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.07);
    color: var(--text);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
}
.summary-result {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 18px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
}
.summary-result strong { font-size: 1.18rem; }
.summary-result span { color: var(--muted); }
.summary-result-success { border-color: rgba(68,198,122,0.35); background: rgba(68,198,122,0.10); }
.summary-result-danger { border-color: rgba(224,87,87,0.35); background: rgba(224,87,87,0.10); }
.summary-result-warning { border-color: rgba(247,147,30,0.35); background: rgba(247,147,30,0.10); }
.summary-grid article {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: rgba(0,0,0,0.12);
}
.summary-actions { margin-top: 18px; justify-content: flex-end; }

@media (max-width: 1180px) {
    .battle-stage { grid-template-columns: 1fr; }
    .battle-board .inventory-grid { --slot-size: 46px; }
}

.life-display {
    display: grid;
    gap: 9px;
    border: 1px solid rgba(247,147,30,0.24);
    background: rgba(247,147,30,0.08);
    border-radius: 15px;
    padding: 12px;
    margin: 0 0 14px;
}
.life-display-compact {
    max-width: 420px;
    margin-top: 10px;
    margin-bottom: 0;
    padding: 10px;
}
.life-display-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-weight: 850;
}
.life-display-head strong { color: #ffd0a1; font-size: 1.05rem; }
.life-pips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
    gap: 6px;
}
.life-pip {
    min-width: 18px;
    height: 18px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.055);
    position: relative;
    overflow: hidden;
}
.life-pip::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 4px;
    background: transparent;
}
.life-pip.is-active {
    border-color: rgba(247,147,30,0.62);
    background: rgba(247,147,30,0.22);
    box-shadow: 0 0 14px rgba(247,147,30,0.18);
}
.life-pip.is-active::after { background: linear-gradient(135deg, #ffb35c, var(--orange)); }
.life-pip.is-empty {
    border-color: rgba(224,87,87,0.25);
    background: rgba(224,87,87,0.08);
}
.life-overflow {
    min-height: 18px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    color: var(--muted);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    font-size: 0.76rem;
    font-weight: 900;
}
.life-display p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.life-display.is-dead {
    border-color: rgba(224,87,87,0.42);
    background: rgba(224,87,87,0.12);
}
.life-display.is-dead .life-display-head strong { color: #ffc4c4; }
.danger-card {
    margin-bottom: 18px;
    border-color: rgba(224,87,87,0.38);
    background: rgba(224,87,87,0.12);
}
.danger-card h2 { margin-top: 0; }
.battle-heading-side {
    display: grid;
    gap: 12px;
    justify-items: end;
    min-width: min(100%, 360px);
}
.battle-heading-side .life-display { width: 100%; }
.active-run-card > div { min-width: 0; }

@media (max-width: 860px) {
    .battle-heading-side { justify-items: stretch; width: 100%; }
    .life-pips { grid-template-columns: repeat(10, minmax(14px, 1fr)); }
}

.inventory-item-cell.is-base-bag {
    z-index: 2;
    background: linear-gradient(135deg, rgba(94,64,35,0.82), rgba(247,147,30,0.16));
    border-color: rgba(247,147,30,0.28);
}
.inventory-item-cell.is-base-bag strong::after {
    content: ' (Basis)';
    color: var(--muted);
    font-weight: 700;
}

/* Phase 6.2: Taschen klarer als Container-Layer darstellen */
.inventory-grid {
    isolation: isolate;
}
.inventory-item-cell.is-bag-item {
    z-index: 2;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(247,147,30,0.18), rgba(122,80,42,0.20)),
        repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0 6px, rgba(0,0,0,0.04) 6px 12px);
    border-color: rgba(247,147,30,0.54);
    border-style: solid;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.20);
}
.inventory-item-cell.is-bag-item.is-fill-cell::after,
.inventory-item-cell.is-bag-item .item-cell-fill {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(247,147,30,0.25);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}
.inventory-item-cell.is-bag-item .bag-cell-mark {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: rgba(247,147,30,0.34);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.12);
}
.inventory-item-cell.is-normal-item {
    z-index: 5;
    background:
        linear-gradient(135deg, rgba(20,28,34,0.96), rgba(33,45,54,0.92)),
        linear-gradient(135deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03));
    border-color: rgba(255,255,255,0.20);
    box-shadow: 0 10px 22px rgba(0,0,0,0.24), inset 0 0 0 1px rgba(255,255,255,0.04);
}
.inventory-item-cell.is-normal-item.is-fill-cell {
    background: linear-gradient(135deg, rgba(23,33,41,0.94), rgba(16,24,31,0.90));
}
.inventory-item-cell.is-normal-item.is-fill-cell::after {
    background: rgba(255,255,255,0.16);
}
.inventory-item-cell.is-drop-denied,
.bag-grip.is-drop-denied {
    animation: aibDropDenied 260ms ease both;
}
@keyframes aibDropDenied {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    55% { transform: translateX(4px); }
    80% { transform: translateX(-2px); }
}
.bag-grip {
    z-index: 14;
    align-self: start;
    justify-self: start;
    transform: translate(-8px, -13px);
    max-width: calc(100% + 18px);
    min-width: 142px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 7px;
    border-radius: 999px;
    border: 1px solid rgba(247,147,30,0.62);
    background: linear-gradient(135deg, rgba(47,35,24,0.98), rgba(111,69,31,0.96));
    box-shadow: 0 10px 24px rgba(0,0,0,0.32), 0 0 0 2px rgba(247,147,30,0.08);
    cursor: grab;
    user-select: none;
    touch-action: none;
    overflow: visible;
}
.bag-grip:active { cursor: grabbing; }
.bag-grip.is-selected,
.bag-grip:focus-visible {
    outline: 2px solid rgba(255,208,161,0.92);
    outline-offset: 2px;
}
.bag-grip.is-dragging {
    opacity: 0.68;
    transform: translate(-8px, -13px) scale(0.98);
}
.bag-grip-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #24160a;
    background: #f7931e;
    font-weight: 950;
    line-height: 1;
}
.bag-grip-text {
    min-width: 0;
    display: grid;
    line-height: 1.05;
}
.bag-grip-text strong {
    color: var(--text);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bag-grip-text small {
    color: #ffd0a1;
    font-size: 0.58rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bag-sell-form {
    margin: 0 0 0 2px;
    display: flex;
}
.bag-sell-button {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(224,87,87,0.78);
    font-weight: 900;
    cursor: pointer;
}
.bag-sell-button:hover { background: rgba(224,87,87,0.98); }
.item-bag-bonus {
    color: #ffd0a1 !important;
    border-radius: 999px;
    padding: 1px 5px;
    background: rgba(247,147,30,0.10);
    border: 1px solid rgba(247,147,30,0.18);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.grid-cell.is-locked {
    background: rgba(0,0,0,0.12);
    border-color: rgba(255,255,255,0.025);
}
.grid-cell.is-bag-cell {
    background: linear-gradient(135deg, rgba(247,147,30,0.09), rgba(125,82,43,0.18));
    border-color: rgba(247,147,30,0.28);
}
@media (max-width: 680px) {
    .bag-grip { min-width: 116px; max-width: 160px; padding: 4px 6px; }
    .bag-grip-text strong { font-size: 0.64rem; }
    .bag-grip-text small { display: none; }
}

/* Battle-/Share-Boards sollen durch Taschen-Griffe nicht voll wirken. */
.battle-board .bag-grip,
.build-share-board .bag-grip {
    min-width: 86px;
    max-width: 116px;
    padding: 3px 5px;
    transform: translate(-5px, -9px);
}
.battle-board .bag-grip-icon,
.build-share-board .bag-grip-icon {
    width: 17px;
    height: 17px;
    font-size: 0.65rem;
}
.battle-board .bag-grip-text small,
.build-share-board .bag-grip-text small {
    display: none;
}
.battle-board .bag-grip-text strong,
.build-share-board .bag-grip-text strong {
    font-size: 0.54rem;
}


/* Phase 6.3: globale Tooltips fuer Items und Taschen */
.aib-tooltip-popover[hidden] { display: none; }
.aib-tooltip-popover {
    position: fixed;
    z-index: 5000;
    width: min(320px, calc(100vw - 24px));
    padding: 12px 13px;
    border-radius: 14px;
    border: 1px solid rgba(247,147,30,0.34);
    background: linear-gradient(135deg, rgba(13,20,26,0.98), rgba(28,38,46,0.98));
    box-shadow: 0 22px 50px rgba(0,0,0,0.46), 0 0 0 1px rgba(255,255,255,0.04) inset;
    color: var(--text);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
}
.aib-tooltip-popover.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.aib-tooltip-popover > strong {
    display: block;
    margin-bottom: 9px;
    color: #ffd0a1;
    font-size: 0.98rem;
    line-height: 1.2;
}
.aib-tooltip-popover dl {
    margin: 0;
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 7px 10px;
}
.aib-tooltip-popover dt {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 850;
}
.aib-tooltip-popover dd {
    margin: 0;
    color: var(--text);
    font-size: 0.78rem;
    line-height: 1.35;
}

/* Ergebnis-Karten und vollstaendiger Log erscheinen erst nach dem Replay. */
.battle-outcome-card.is-revealed,
.battle-log-full.is-revealed {
    animation: aibRevealAfterBattle 180ms ease both;
}
@keyframes aibRevealAfterBattle {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Phase 7: Fullscreen-PC-Game-Layout ohne Browser-/Panel-Scroll */
html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}
body {
    height: 100dvh;
}
.app-shell {
    width: 100%;
    max-width: none;
    height: 100dvh;
    margin: 0;
    padding: 0 28px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.topbar {
    flex: 0 0 80px;
    height: 80px;
    padding: 0;
    position: relative;
    top: auto;
    z-index: 50;
    background: linear-gradient(180deg, rgba(16, 22, 29, 0.99), rgba(16, 22, 29, 0.88));
}
.brand-mark { width: 42px; height: 42px; }
.page {
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100dvh - 104px);
    padding: 18px 0 0;
    overflow: hidden;
}
.page > .game-screen,
.page > .hero-section,
.page > .menu-grid,
.page > .hero-grid,
.page > .result-grid,
.page > .table-card,
.page > .build-layout {
    min-height: 0;
}
.game-screen {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    overflow: hidden;
}
.card {
    min-height: 0;
    overflow: hidden;
}
.page-heading {
    margin: 0 0 16px;
}
.game-screen .page-heading {
    margin: 0;
}
.page-heading h1,
.hero-copy h1 {
    margin: 6px 0 10px;
}
.page-heading p {
    margin-top: 0;
    margin-bottom: 0;
}
.shop-heading h1,
.battle-heading h1 {
    font-size: clamp(2.1rem, 3.4vw, 4.6rem);
    line-height: 0.95;
}
.shop-heading .btn-large,
.battle-heading .btn-large {
    min-width: 168px;
}

/* Shop als fester Game-Screen */
.shop-layout {
    height: 100%;
    min-height: 0;
    align-items: stretch;
    grid-template-columns: minmax(280px, 22vw) minmax(560px, 1fr) minmax(270px, 22vw);
    gap: 18px;
    overflow: hidden;
}
.shop-panel,
.inventory-panel,
.stats-panel {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.shop-panel h2,
.inventory-panel h2,
.stats-panel h2 {
    margin: 0 0 12px;
}
.shop-list {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-rows: repeat(auto-fit, minmax(0, 1fr));
    gap: 10px;
    overflow: hidden;
}
.shop-item {
    min-height: 0;
    padding: 10px 12px;
    gap: 7px;
    align-content: center;
}
.shop-item-head strong {
    font-size: 0.94rem;
    line-height: 1.15;
}
.shop-item p,
.shop-item small {
    font-size: 0.82rem;
    line-height: 1.25;
}
.shop-item .btn {
    min-height: 34px;
    padding: 8px 10px;
}
.inventory-help {
    flex: 0 0 auto;
    margin-bottom: 10px;
    font-size: 0.94rem;
}
.inventory-grid-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    place-items: center;
    max-width: 100%;
    overflow: visible;
    padding: 0;
}
.inventory-panel .inventory-grid {
    --slot-size: clamp(38px, min(4.5vw, 6.1vh), 52px);
}
.stats-panel {
    gap: 10px;
}
.stats-list {
    gap: 8px;
}
.stats-list div {
    padding: 8px 10px;
    min-height: 36px;
}
.stats-panel .life-display {
    flex: 0 0 auto;
    margin-bottom: 4px;
}
.stats-panel h3 {
    margin: 2px 0 0;
    font-size: 1rem;
}
.synergy-list {
    flex: 1 1 auto;
    min-height: 0;
    gap: 7px;
    overflow: hidden;
}
.synergy-list li {
    padding: 8px;
}
.spaced-form {
    flex: 0 0 auto;
    margin-top: auto;
}

/* Battle als fester Game-Screen */
.battle-screen {
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.battle-heading {
    align-items: center;
}
.battle-heading p {
    max-width: 680px;
    font-size: 0.95rem;
}
.battle-heading-side {
    gap: 9px;
}
.battle-heading-side .life-display {
    margin: 0;
}
.battle-stage {
    height: 100%;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
    grid-template-columns: minmax(300px, 0.92fr) minmax(380px, 1fr) minmax(300px, 0.92fr);
}
.battle-actor,
.battle-feed-card {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.battle-board {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: visible;
}
.battle-board .inventory-grid-scroll {
    width: 100%;
    height: 100%;
}
.battle-board .inventory-grid {
    --slot-size: clamp(25px, min(2.35vw, 4.2vh), 38px);
}
.battle-feed-card {
    min-height: 0;
}
.battle-current-action {
    flex: 0 0 auto;
    min-height: 92px;
    margin-top: 12px;
    padding: 14px;
}
.battle-replay-log {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    align-content: end;
}
.battle-replay-log li:nth-last-child(n+8):not([hidden]) {
    display: none;
}
.battle-log-full {
    flex: 0 0 auto;
    margin-top: 0;
    max-height: 156px;
    display: flex;
    flex-direction: column;
}
.battle-log-full .battle-log {
    max-height: none;
    overflow: hidden;
    min-height: 0;
    gap: 6px;
}
.battle-log-full .battle-log li:nth-child(n+5) {
    display: none;
}
.battle-log li {
    padding: 8px 10px;
}
.summary-dialog {
    max-height: calc(100dvh - 48px);
    overflow: hidden;
}

/* Start, Helden, Profil und Scoreboard ebenfalls wie feste PC-Spielseiten */
.hero-section {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.menu-grid {
    height: calc(100% - 116px);
    min-height: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
}
.menu-card {
    min-height: 0;
}
.active-run-card {
    margin-top: 14px;
    max-height: 190px;
}
.hero-grid {
    height: calc(100% - 150px);
    min-height: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
}
.hero-choice {
    min-height: 0;
    gap: 9px;
    padding: 16px;
}
.hero-choice h2,
.hero-choice p {
    margin: 0;
}
.hero-choice p {
    font-size: 0.9rem;
    line-height: 1.35;
}
.passive-box {
    padding: 9px;
}
.table-card {
    height: calc(100% - 150px);
    min-height: 0;
}
.responsive-table {
    height: 100%;
    overflow: hidden;
}
table {
    min-width: 0;
    table-layout: fixed;
    font-size: 0.9rem;
}
th,
td {
    padding: 11px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-grid {
    height: calc(100% - 130px);
    min-height: 0;
    overflow: hidden;
}
.result-grid > .card {
    height: 100%;
}

/* Keine Browser-/Panel-Scrollbars auf Desktop */
.battle-log,
.responsive-table,
.inventory-grid-scroll,
.summary-dialog {
    scrollbar-width: none;
}
.battle-log::-webkit-scrollbar,
.responsive-table::-webkit-scrollbar,
.inventory-grid-scroll::-webkit-scrollbar,
.summary-dialog::-webkit-scrollbar {
    width: 0;
    height: 0;
}

@media (max-width: 1180px) {
    .shop-layout {
        grid-template-columns: 260px minmax(430px, 1fr) 260px;
    }
    .battle-stage {
        grid-template-columns: minmax(260px, 0.9fr) minmax(330px, 1fr) minmax(260px, 0.9fr);
    }
    .hero-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
@media (max-width: 980px), (max-height: 680px) {
    html, body { overflow: hidden; }
    .app-shell { padding: 0 16px 16px; }
    .topbar { height: 64px; flex-basis: 64px; }
    .brand span:last-child { display: none; }
    .page { height: calc(100dvh - 80px); padding-top: 12px; }
    .shop-layout { grid-template-columns: 220px minmax(360px, 1fr) 220px; gap: 10px; }
    .card { padding: 14px; }
    .shop-heading h1, .battle-heading h1 { font-size: 2rem; }
    .shop-item p, .shop-item small { font-size: 0.74rem; }
    .inventory-panel .inventory-grid { --slot-size: clamp(32px, min(4vw, 5.7vh), 42px); }
    .stats-list div { min-height: 30px; padding: 6px 8px; }
    .battle-board .inventory-grid { --slot-size: clamp(22px, min(2.2vw, 3.7vh), 32px); }
    .battle-current-action { min-height: 72px; font-size: 0.94rem; }
    .battle-replay-log li:nth-last-child(n+6):not([hidden]) { display: none; }
}
