:root {
    --bg-0: #070d10;
    --bg-1: #101b1f;
    --panel: rgba(10, 18, 20, 0.86);
    --panel-border: rgba(204, 176, 114, 0.22);
    --text: #f4ead7;
    --muted: #b8ad96;
    --gold: #d8b76e;
    --gold-strong: #f2d28a;
    --playable: #78d88b;
    --danger: #ff7a7a;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(circle at top, #163135 0%, var(--bg-0) 55%, #040607 100%);
    color: var(--text);
    font-family: Georgia, "Times New Roman", serif;
}

body {
    min-height: 100vh;
    overflow: hidden;
}

.background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 20%, rgba(244, 208, 128, 0.11), transparent 20%),
        radial-gradient(circle at 80% 30%, rgba(120, 216, 139, 0.08), transparent 18%),
        radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0.4), transparent 50%);
    filter: blur(2px);
}

.veil {
    position: fixed;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0.24;
}

.veil-left {
    background: radial-gradient(circle at 18% 18%, rgba(242, 210, 138, 0.22), transparent 24%);
}

.veil-right {
    background: radial-gradient(circle at 82% 20%, rgba(120, 216, 139, 0.14), transparent 24%);
}

.shell {
    width: min(100vw - 8px, 1480px);
    height: calc(100vh - 8px);
    margin: 4px auto;
    display: grid;
    gap: 8px;
    grid-template-rows: auto minmax(0, 1.08fr) minmax(0, 0.92fr);
}

.panel {
    background: linear-gradient(180deg, rgba(17, 27, 30, 0.92), rgba(7, 12, 14, 0.92));
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.topbar {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.24em;
    font-size: 0.7rem;
    color: var(--gold);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(1.45rem, 2.6vw, 2.6rem);
    line-height: 1;
}

h2 {
    font-size: 1.15rem;
}

.topbar-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
    color: var(--muted);
    font-size: 0.95rem;
}

.stat-pill {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
}

.stat-pill-energy {
    color: #fff4d8;
    border-color: rgba(242, 210, 138, 0.34);
    background: linear-gradient(180deg, rgba(242, 210, 138, 0.24), rgba(242, 210, 138, 0.08));
    box-shadow: 0 0 0 1px rgba(242, 210, 138, 0.12), 0 10px 22px rgba(0, 0, 0, 0.18);
    font-weight: 700;
}

.arena {
    padding: 8px 10px;
    display: grid;
    gap: 6px;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.arena-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.enemy-row {
    align-items: stretch;
}

.intent-panel {
    min-width: 160px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(16, 24, 25, 0.72), rgba(7, 11, 12, 0.9));
    display: grid;
    justify-items: center;
    gap: 6px;
    text-align: center;
}

.intent-label {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--gold);
}

.intent-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    color: #fff1dd;
    background: radial-gradient(circle at 35% 35%, rgba(242, 210, 138, 0.34), rgba(242, 210, 138, 0.08));
    border: 1px solid rgba(242, 210, 138, 0.18);
}

.intent-note {
    color: var(--muted);
    font-size: 0.84rem;
}

.zone-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--gold);
}

.zone-note {
    margin-top: 4px;
    color: var(--muted);
    max-width: 520px;
    font-size: 0.88rem;
}

.health-block {
    margin-top: 4px;
    display: grid;
    gap: 5px;
    min-width: min(280px, 42vw);
}

.health-readout {
    font-size: 1rem;
    letter-spacing: 0.04em;
}

.health-track {
    position: relative;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}

.health-fill {
    height: 100%;
    width: 100%;
    border-radius: inherit;
    transition: width 0.36s ease, filter 0.28s ease, transform 0.28s ease;
    position: relative;
}

.health-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 26%, transparent 74%, rgba(255, 255, 255, 0.14));
    mix-blend-mode: screen;
}

.enemy-fill {
    background: linear-gradient(90deg, #5f1214, #af4e4e 55%, #ff8d7b 100%);
}

.player-fill {
    background: linear-gradient(90deg, #0c4f22, #3aa85b 55%, #92f0ac 100%);
}

.damage-hit {
    animation: healthHit 0.42s ease;
}

.hand-hud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.hand-stat {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 0.9rem;
}

.hand-stat-energy {
    color: #fff4d8;
    border-color: rgba(242, 210, 138, 0.34);
    background: linear-gradient(180deg, rgba(242, 210, 138, 0.24), rgba(242, 210, 138, 0.08));
    font-weight: 700;
}

.screen-reset {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
}

.screen-help {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
}

.status-orb {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.08), 0 0 38px rgba(0, 0, 0, 0.3);
}

.portrait-frame {
    width: 86px;
    height: 86px;
    position: relative;
    border-radius: 18px;
    border: 1px solid rgba(242, 210, 138, 0.28);
    overflow: hidden;
    display: grid;
    place-items: center;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: rgba(255, 242, 220, 0.82);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.portrait-core {
    position: relative;
    z-index: 2;
}

.portrait-halo {
    position: absolute;
    inset: -10%;
    border-radius: inherit;
    filter: blur(2px);
}

.enemy-halo {
    background: radial-gradient(circle at 40% 40%, rgba(160, 82, 72, 0.85), rgba(41, 14, 16, 0.15) 55%, transparent 70%);
}

.player-halo {
    background: radial-gradient(circle at 40% 40%, rgba(124, 218, 146, 0.85), rgba(16, 65, 37, 0.15) 55%, transparent 70%);
}

.enemy-orb {
    background: radial-gradient(circle at 35% 35%, #9c6a67, #2e1214 66%, #160709 100%);
}

.player-orb {
    background: radial-gradient(circle at 35% 35%, #74cc8f, #18442b 66%, #07170e 100%);
}

.battlefield {
    position: relative;
    min-height: 150px;
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at center, rgba(216, 183, 110, 0.15), transparent 36%),
        linear-gradient(180deg, rgba(31, 54, 41, 0.34), rgba(7, 10, 10, 0.55));
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.combat-rail {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    padding: 0 4px;
}

.combat-rail.turn-swipe {
    animation: turnSwipe 0.42s ease;
}

.combat-token {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.token-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.08em;
}

.enemy-token .token-icon {
    color: #ffdcd4;
    background: radial-gradient(circle at 35% 35%, #d08179, #4c1618 66%, #180708 100%);
}

.player-token .token-icon {
    color: #dbffe6;
    background: radial-gradient(circle at 35% 35%, #9ff0b9, #1d4f2f 66%, #08180f 100%);
}

.token-label {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.76rem;
    color: var(--gold);
}

.token-sub {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 2px;
}

.combat-vs {
    color: var(--gold-strong);
    font-size: 0.9rem;
    letter-spacing: 0.24em;
    opacity: 0.8;
}

.board-runes {
    position: absolute;
    inset: 16px;
    border-radius: 14px;
    border: 1px solid rgba(242, 210, 138, 0.08);
    background:
        linear-gradient(90deg, transparent 0 24%, rgba(242, 210, 138, 0.04) 24% 25%, transparent 25% 49%, rgba(242, 210, 138, 0.04) 49% 50%, transparent 50% 74%, rgba(242, 210, 138, 0.04) 74% 75%, transparent 75%),
        linear-gradient(180deg, transparent 0 22%, rgba(242, 210, 138, 0.05) 22% 23%, transparent 23% 77%, rgba(242, 210, 138, 0.05) 77% 78%, transparent 78%);
    opacity: 0.45;
}

.battle-glow {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 40%, rgba(255, 223, 168, 0.16), transparent 20%),
        radial-gradient(circle at 50% 60%, rgba(118, 216, 139, 0.08), transparent 28%);
    animation: pulse 8s ease-in-out infinite;
}

.center-plate {
    position: absolute;
    inset: 20% 22%;
    display: grid;
    place-items: center;
    text-align: center;
    gap: 6px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(5, 11, 12, 0.33), rgba(5, 11, 12, 0.18));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 50px rgba(0, 0, 0, 0.16);
}

.center-title {
    font-size: 0.98rem;
    color: var(--gold-strong);
}

.center-subtitle {
    color: var(--muted);
}

.center-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.chip {
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
}

.lower-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
}

.hand-panel,
.inspector,
.placeholders {
    padding: 10px 12px;
}

.hand-panel {
    position: relative;
    display: block;
    min-height: 0;
    padding-right: clamp(220px, 24vw, 300px);
}

.hand-main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 0;
}

.hand-main.game-over,
.hand-panel.game-over .hand-detail:not(.empty-state) {
    filter: saturate(0.35) brightness(0.72);
    pointer-events: none;
}

.hand-main.game-over .hand-stat,
.hand-main.game-over .hand-stat-energy {
    color: rgba(180, 175, 165, 0.85);
    border-color: rgba(120, 120, 120, 0.28);
    background: rgba(80, 80, 80, 0.2);
}

.hand-main.game-over .ghost-button {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: rgba(120, 120, 120, 0.35);
    background: linear-gradient(180deg, rgba(120, 120, 120, 0.2), rgba(60, 60, 60, 0.15));
}

.hand-main.game-over .ghost-button:hover {
    transform: none;
    box-shadow: none;
}

.hand-main.game-over .card {
    border-color: rgba(130, 130, 130, 0.4);
    box-shadow: 0 0 0 1px rgba(100, 100, 100, 0.1), 0 16px 32px rgba(0, 0, 0, 0.35);
    opacity: 0.55;
    cursor: not-allowed;
}

.hand-main.game-over .card.playable {
    border-color: rgba(130, 130, 130, 0.4);
    box-shadow: 0 0 0 1px rgba(100, 100, 100, 0.1), 0 16px 32px rgba(0, 0, 0, 0.35);
}

.hand-main.game-over .card.playable:hover {
    transform: translateX(calc(var(--fan, 0) * var(--fan-spacing, 18px))) translateY(calc(18px - var(--fan-lift, 0px))) rotate(calc(var(--tilt, 0) * 1deg));
    z-index: auto;
}

.hand-panel.drag-active .card {
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.card.morphable {
    cursor: grab;
}

.card.morphable.disabled {
    opacity: 0.8;
    filter: saturate(0.8) brightness(0.9);
}

.hand-panel.drag-active .card.playable,
.hand-panel.drag-active .card.morphable {
    cursor: grabbing;
}

.card.morph-source {
    border-color: rgba(242, 210, 138, 0.82);
    box-shadow: 0 0 0 1px rgba(242, 210, 138, 0.2), 0 18px 34px rgba(0, 0, 0, 0.46);
}

.card.morph-target {
    transform: translateX(calc(var(--fan, 0) * var(--fan-spacing, 18px))) translateY(-18px) rotate(0deg) scale(1.03);
    border-color: rgba(242, 210, 138, 0.88);
    box-shadow: 0 0 0 1px rgba(242, 210, 138, 0.24), 0 0 24px rgba(242, 210, 138, 0.18), 0 20px 40px rgba(0, 0, 0, 0.48);
    z-index: 14;
}

.hand-main.game-over .hand-hint {
    color: rgba(150, 145, 135, 0.7);
}

.ghost-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.hand-detail {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: clamp(220px, 24vw, 300px);
    max-width: none;
}

.hand-panel.drop-ready {
    box-shadow: var(--shadow), 0 0 0 1px rgba(242, 210, 138, 0.14), 0 0 0 2px rgba(242, 210, 138, 0.06) inset;
}

.section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.section-head.compact {
    margin-bottom: 8px;
}

.ghost-button {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(243, 207, 129, 0.16), rgba(243, 207, 129, 0.06));
    color: var(--text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ghost-button:hover {
    transform: translateY(-1px);
    border-color: rgba(242, 210, 138, 0.5);
    box-shadow: 0 0 0 1px rgba(242, 210, 138, 0.12), 0 10px 24px rgba(0, 0, 0, 0.24);
}

.hand-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hand-wrap {
    overflow: hidden;
    padding-top: 2px;
}

.hand {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 0;
    min-height: 0;
    width: 100%;
    padding: 2px 2px 2px;
    --fan-spacing: 15px;
}

.card {
    position: relative;
    width: 136px;
    height: 204px;
    margin-left: -40px;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(180deg, #2a2013, #0d1416 32%, #060b0d 100%);
    border: 1px solid rgba(241, 216, 161, 0.2);
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.42);
    transform-origin: bottom center;
    transform:
        translateX(calc(var(--fan, 0) * var(--fan-spacing, 18px))) translateY(calc(18px - var(--fan-lift, 0px))) rotate(calc(var(--tilt, 0) * 1deg));
    opacity: 0;
    animation: rise 0.45s ease forwards;
    animation-delay: calc(var(--delay, 0) * 70ms);
    cursor: pointer;
    touch-action: none;
}

.card:first-child {
    margin-left: 0;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 22%);
    pointer-events: none;
}

.card::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 12px;
    border: 1px solid rgba(242, 210, 138, 0.08);
    pointer-events: none;
}

.card-glow {
    position: absolute;
    inset: -10%;
    background: radial-gradient(circle at 50% 0%, rgba(242, 210, 138, 0.18), transparent 50%);
    opacity: 0.7;
    pointer-events: none;
}

.card.playable {
    border-color: rgba(120, 216, 139, 0.56);
    box-shadow: 0 0 0 1px rgba(120, 216, 139, 0.14), 0 16px 32px rgba(0, 0, 0, 0.42);
}

.card.playable:hover {
    transform: translateX(calc(var(--fan, 0) * var(--fan-spacing, 18px))) translateY(-14px) rotate(0deg) scale(1.03);
    z-index: 12;
}

.card.disabled {
    border-color: rgba(150, 150, 150, 0.45);
    box-shadow: 0 0 0 1px rgba(120, 120, 120, 0.12), 0 16px 32px rgba(0, 0, 0, 0.42);
    opacity: 0.72;
    filter: saturate(0.65) brightness(0.85);
    cursor: not-allowed;
}

.card-art {
    position: absolute;
    inset: 10px 10px 70px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-art.fallback {
    display: grid;
    place-items: center;
    text-align: center;
    color: rgba(255, 241, 215, 0.9);
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 12px;
    background: linear-gradient(180deg, rgba(215, 178, 102, 0.45), rgba(47, 21, 21, 0.8));
}

.card-frame {
    position: absolute;
    inset: 0;
    border-radius: 18px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.card-title {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 48px;
    font-size: 0.78rem;
    color: var(--text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.card-effect {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 24px;
    font-size: 0.56rem;
    line-height: 1.25;
    color: rgba(242, 230, 206, 0.92);
    max-height: 2.6em;
    overflow: hidden;
}

.card-effect .effect-value {
    color: #fff4d8;
}

.card-effect-summary {
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.5;
}

.damage-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin: 0 1px;
    border-radius: 3px;
    vertical-align: -2px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
}

.damage-icon-img {
    width: 12px;
    height: 12px;
    display: block;
    object-fit: contain;
}

.status-row {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 26px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(242, 210, 138, 0.22);
    background: rgba(13, 24, 27, 0.74);
    color: var(--text);
    font-size: 0.72rem;
}

.status-pill .status-icon-image {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.status-empty {
    color: var(--muted);
    font-size: 0.74rem;
}

.health-track {
    position: relative;
    overflow: visible;
}

.damage-badge {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%) scale(0.85);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(10, 14, 16, 0.88);
    border: 1px solid rgba(242, 210, 138, 0.28);
    opacity: 0;
    pointer-events: none;
}

.damage-badge.visible {
    animation: damageBadgePulse 0.6s ease;
}

.damage-badge-image {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.damage-badge-value {
    font-size: 0.66rem;
    color: #fff4d8;
}

.config-modal {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(2, 8, 10, 0.68);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
}

.config-modal.hidden {
    display: none;
}

.config-modal-card {
    width: min(640px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    padding: 20px;
    display: grid;
    gap: 14px;
    overflow-y: auto;
}

.config-modal-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.config-modal-note {
    color: var(--muted);
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
}

.setup-section {
    display: grid;
    gap: 8px;
    min-height: 0;
}

.setup-section-title {
    margin: 0;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(242, 210, 138, 0.9);
}

.setup-options {
    display: grid;
    gap: 8px;
}

.setup-options-scroll {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.setup-choice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(242, 210, 138, 0.16);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.setup-choice:hover {
    border-color: rgba(242, 210, 138, 0.32);
    background: rgba(255, 255, 255, 0.04);
}

.setup-choice.is-selected {
    border-color: rgba(242, 210, 138, 0.5);
    background: rgba(242, 210, 138, 0.08);
}

.setup-choice input {
    margin-top: 3px;
    accent-color: rgba(242, 210, 138, 0.95);
}

.setup-choice-body {
    display: grid;
    gap: 4px;
}

.setup-choice-title {
    font-weight: 600;
    color: var(--text);
}

.setup-choice-summary {
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.45;
}

.setup-choice-tags {
    font-size: 0.74rem;
    color: rgba(242, 210, 138, 0.75);
}

.setup-agent-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    margin-top: 10px;
}

.setup-agent-info-label {
    margin: 0;
    padding-top: 10px;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(242, 210, 138, 0.92);
    white-space: nowrap;
}

.setup-agent-detail {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(242, 210, 138, 0.12);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.5;
}

.config-detail-panel {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(242, 210, 138, 0.16);
    background: rgba(255, 255, 255, 0.03);
    max-height: 220px;
    overflow-y: auto;
}

.config-detail-description {
    margin: 0 0 10px;
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.55;
}

.config-detail-empty {
    margin: 0;
    font-size: 0.86rem;
    color: var(--muted);
}

.config-detail-stats {
    margin: 0;
    display: grid;
    gap: 6px;
}

.config-detail-stats > div {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    font-size: 0.82rem;
}

.config-detail-stats dt {
    margin: 0;
    color: rgba(242, 210, 138, 0.8);
}

.config-detail-stats dd {
    margin: 0;
    color: var(--text);
}

.setup-deck-picker {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.84rem;
    color: var(--muted);
}

.setup-deck-picker.hidden {
    display: none;
}

.setup-deck-picker select {
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(7, 12, 14, 0.92);
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
}

.config-modal-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.config-start-button {
    min-width: 140px;
}

.mechanics-modal {
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(2, 8, 10, 0.72);
    backdrop-filter: blur(5px);
    display: grid;
    place-items: center;
}

.mechanics-modal.hidden {
    display: none;
}

.mechanics-modal-card {
    width: min(760px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    padding: 20px;
    display: grid;
    gap: 14px;
    grid-template-rows: auto minmax(0, 1fr);
}

.mechanics-modal-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.mechanics-modal-body {
    display: grid;
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
}

.mechanics-section {
    display: grid;
    gap: 8px;
}

.mechanics-section-title {
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(242, 210, 138, 0.92);
}

.mechanics-section p,
.mechanics-section li {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.9rem;
}

.mechanics-list {
    margin: 0;
    padding-left: 1.15rem;
    display: grid;
    gap: 6px;
}

.mechanics-config-list {
    margin: 0;
    padding-left: 1.15rem;
    display: grid;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--muted);
}

.mechanics-legend {
    margin: 0 0 4px;
    font-size: 0.82rem;
    color: var(--muted);
}

.mechanics-legend code {
    font-size: 0.78rem;
}

.mechanics-grid {
    display: grid;
    gap: 10px;
}

.mechanics-item {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(242, 210, 138, 0.16);
    background: rgba(255, 255, 255, 0.03);
}

.mechanics-item-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.mechanics-item-head h3,
.mechanics-item-head h4 {
    margin: 0;
    font-size: 1rem;
}

.mechanics-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex: 0 0 auto;
}

.mechanics-icon-missing {
    width: 20px;
    height: 20px;
    border-style: dashed;
    border-color: rgba(242, 210, 138, 0.45);
    background: rgba(255, 255, 255, 0.06);
}

.mechanics-icon-energy {
    background: linear-gradient(135deg, #f2d28a, #9a7a32);
}

.mechanics-icon-armor {
    background: linear-gradient(135deg, #b8c4d4, #5a6a82);
}

.mechanics-icon-heal {
    background: linear-gradient(135deg, #8fe8a8, #2f8a52);
}

.mechanics-icon-draw,
.mechanics-icon-discard {
    background: linear-gradient(135deg, #9ab6ff, #4a62a8);
}

.mechanics-icon-morph {
    background: linear-gradient(135deg, #c9a0ff, #6b42a8);
}

.mechanics-icon-turn {
    background: linear-gradient(135deg, #ffd49a, #b87830);
}

.mechanics-icon-deterministic {
    background: linear-gradient(135deg, #a8b8c8, #4a5a6a);
}

.mechanics-icon-stochastic {
    background: linear-gradient(135deg, #ffb0e8, #a84888);
}

.mechanics-item .mechanics-config-list {
    margin-top: 8px;
}


.damage-icon-kinetic {
    background: linear-gradient(135deg, #d8c27a, #8f7a3f);
}

.damage-icon-burn {
    background: linear-gradient(135deg, #ff8a4d, #b83218);
}

.damage-icon-poison {
    background: linear-gradient(135deg, #8fd86d, #3f7a2d);
}

.damage-icon-ice {
    background: linear-gradient(135deg, #9adfff, #4f8eb8);
}

.damage-icon-thunder {
    background: linear-gradient(135deg, #f4ef9a, #b7a51f);
}

.damage-flash {
    animation: damageFlash 0.45s ease;
}

.damage-shake {
    animation: damageShake 0.38s ease;
}

.card-cost {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 30% 30%, #f5deb3, #b98d42 56%, #4b3012 100%);
    color: #20150a;
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(255, 236, 195, 0.1);
}

.card-meta {
    position: absolute;
    inset: auto 10px 8px;
    color: var(--muted);
    font-size: 0.76rem;
}

.card-badge {
    display: inline-block;
    padding: 4px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-detail {
    min-height: 0;
    color: var(--text);
    line-height: 1.45;
}

.hand-detail {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: clamp(220px, 24vw, 300px);
    max-width: none;
    min-height: 0;
    padding: 14px;
    background: linear-gradient(180deg, rgba(16, 24, 25, 0.88), rgba(7, 11, 12, 0.94));
    border: 2px solid rgba(150, 150, 150, 0.35);
    border-radius: 18px;
    box-shadow: inset 0 0 0 1px rgba(242, 210, 138, 0.05), 0 14px 30px rgba(0, 0, 0, 0.26);
    z-index: 2;
}

.card-detail-playable {
    border-color: rgba(120, 216, 139, 0.62);
    box-shadow: inset 0 0 0 1px rgba(120, 216, 139, 0.12), 0 14px 30px rgba(0, 0, 0, 0.26);
}

.card-detail-disabled {
    border-color: rgba(150, 150, 150, 0.4);
}

.drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.92;
    transform: none !important;
    margin: 0 !important;
    transition: none !important;
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.4));
}

.hand-panel.drag-active .hand {
    filter: saturate(0.98) brightness(0.92);
}

.hand-panel.drop-ready .hand-main {
    outline: 1px solid rgba(242, 210, 138, 0.12);
    outline-offset: 2px;
}

.hand-panel.drag-active .hand-main {
    filter: saturate(1.03) brightness(0.94);
}

.hand-panel.drag-active .hand-detail {
    border-color: rgba(242, 210, 138, 0.28);
}

.flavor-text {
    margin-top: 8px !important;
    color: rgba(242, 230, 206, 0.9) !important;
    font-style: italic;
    padding: 8px 10px;
    border-left: 2px solid rgba(242, 210, 138, 0.42);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 10px 10px 0;
}

.empty-state {
    color: var(--muted);
    display: grid;
    place-items: center;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.09);
    border-radius: 16px;
    padding: 18px;
}

.hand-hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.8rem;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(46px) rotate(calc(var(--tilt, 0) * 1deg));
    }

    to {
        opacity: 1;
        transform: translateY(0) rotate(calc(var(--tilt, 0) * 1deg));
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

@keyframes turnSwipe {
    0% {
        transform: translateY(0);
        filter: saturate(1);
    }

    35% {
        transform: translateY(-4px);
        filter: saturate(1.12);
    }

    100% {
        transform: translateY(0);
        filter: saturate(1);
    }
}

@keyframes damageFlash {
    0% {
        background-color: rgba(255, 122, 122, 0.18);
        box-shadow: 0 0 0 0 rgba(255, 122, 122, 0.45);
    }

    35% {
        background-color: rgba(255, 122, 122, 0.34);
        box-shadow: 0 0 0 12px rgba(255, 122, 122, 0.12);
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

@keyframes damageShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-4px);
    }

    40% {
        transform: translateX(4px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(2px);
    }
}

@keyframes healthHit {
    0% {
        transform: scaleY(1) scaleX(1);
        filter: brightness(1);
        box-shadow: 0 0 0 0 rgba(255, 122, 122, 0);
    }

    30% {
        transform: scaleY(1.08) scaleX(1.01);
        filter: brightness(1.18);
        box-shadow: 0 0 0 10px rgba(255, 122, 122, 0.14);
    }

    100% {
        transform: scaleY(1) scaleX(1);
        filter: brightness(1);
        box-shadow: none;
    }
}

@keyframes damageBadgePulse {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.82);
    }

    25% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50%) scale(1.05);
    }
}

opacity: 1;
}
}

@media (max-width: 1180px) {
    .lower-grid {
        grid-template-columns: 1fr;
    }

    .hand-panel {
        padding-right: 12px;
    }

    .hand-detail {
        position: static;
        width: 100%;
        margin-top: 10px;
    }
}

@media (max-width: 840px) {
    .shell {
        width: min(100vw - 6px, 1480px);
        height: calc(100vh - 6px);
    }

    .topbar,
    .arena-row,
    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .combat-rail {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .combat-token {
        width: 100%;
        justify-content: center;
    }

    .health-block {
        min-width: 100%;
    }

    .hand {
        overflow-x: auto;
        padding-bottom: 20px;
    }

    .card {
        margin-left: -24px;
    }

    .card:first-child {
        margin-left: 0;
    }

    .portrait-frame {
        width: 76px;
        height: 76px;
    }
}

@media (min-width: 1200px) {
    .hand {
        min-height: 0;
        padding-inline: 6px;
        --fan-spacing: 15px;
    }

    .card {
        margin-left: 0;
    }
}