:root {
    color-scheme: dark;
    --bg: #111319;
    --panel: #1b1f28;
    --panel-2: #232936;
    --line: #353d4d;
    --text: #f3efe3;
    --muted: #a9afba;
    --gold: #d6ab58;
    --gold-bright: #f2cc75;
    --red: #c96358;
    --green: #66b58a;
    --blue: #6ca7d9;
    --radius: 14px;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 0, rgba(91, 70, 128, .2), transparent 32rem),
        radial-gradient(circle at 90% 20%, rgba(113, 73, 36, .16), transparent 30rem),
        var(--bg);
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem clamp(1rem, 4vw, 3rem);
    border-bottom: 1px solid var(--line);
    background: rgba(17, 19, 25, .9);
    backdrop-filter: blur(12px);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(1.5rem, 3vw, 2.2rem); }
h2 { margin-bottom: .7rem; font-family: Georgia, serif; }
.eyebrow { margin-bottom: .3rem; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }

main { width: min(1440px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(35, 41, 54, .96), rgba(24, 28, 37, .96)); box-shadow: 0 18px 50px rgba(0, 0, 0, .2); }

.connection { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .9rem; }
.connection__dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(201, 99, 88, .12); }
.connection__dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(102, 181, 138, .12); }

.lobby { display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(2rem, 6vw, 6rem); padding: clamp(1.5rem, 5vw, 4rem); }
.lobby__intro { align-self: center; }
.lobby__intro h2 { max-width: 14ch; font-size: clamp(2rem, 5vw, 4.3rem); line-height: 1.02; }
.lobby__description { max-width: 56ch; color: var(--muted); line-height: 1.65; }
.lobby__form { display: grid; gap: 1rem; padding: 1.4rem; border-radius: 12px; background: rgba(8, 10, 14, .3); }
.account-statistics { max-width: 650px; margin-top: 1.35rem; padding: 1rem; border: 1px solid rgba(214, 171, 88, .38); border-radius: 12px; background: rgba(8, 10, 14, .4); }
.account-statistics__header { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; align-items: center; }
.account-level { display: grid; min-width: 76px; place-items: center; padding: .55rem .75rem; border: 1px solid var(--gold); border-radius: 10px; background: rgba(214, 171, 88, .1); }
.account-level span { color: var(--muted); font-size: .68rem; text-transform: uppercase; }
.account-level strong { color: var(--gold-bright); font: 800 1.75rem/1 Georgia, serif; }
.account-progress { display: grid; gap: .55rem; min-width: 0; }
.account-progress__label { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.account-progress__label strong { color: var(--text); font-size: .9rem; }
.account-progress__label span { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.account-progress__track { height: 9px; overflow: hidden; border: 1px solid #5c4c31; border-radius: 999px; background: #10131a; }
.account-progress__track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b77a2f, var(--gold-bright)); transition: width .35s ease; }
.account-statistics__modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-top: .75rem; }
.account-statistics__modes article { display: grid; gap: .18rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(27, 31, 40, .72); }
.account-statistics__modes article > strong { color: var(--gold-bright); font-size: .8rem; }
.account-statistics__modes article > span { font-size: .82rem; }
.account-statistics__modes article > small { color: var(--muted); font-size: .7rem; line-height: 1.3; }
.account-statistics__note { min-height: 1.2em; margin: .6rem 0 0; color: var(--muted); font-size: .7rem; }
.saved-session-panel { display: grid; gap: .7rem; }
.saved-session-panel__label { display: block; margin-bottom: .2rem; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.saved-sessions { display: grid; gap: .55rem; }
.saved-session { display: grid; grid-template-columns: 1fr auto; gap: .65rem; align-items: center; padding: .7rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(17, 21, 28, .72); }
.saved-session__identity strong, .saved-session__identity span { display: block; }
.saved-session__identity span { margin-top: .2rem; color: var(--muted); font-size: .78rem; }
.saved-session__actions { display: flex; gap: .4rem; }
.saved-session__actions .button { padding: .5rem .65rem; font-size: .78rem; }
label > span, legend { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .85rem; }
label > small { display: block; margin-top: .35rem; color: var(--muted); font-size: .72rem; }
input[type="text"], input:not([type]) { width: 100%; }
input { padding: .8rem .9rem; color: var(--text); border: 1px solid var(--line); border-radius: 8px; outline: none; background: #11151c; }
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 171, 88, .12); }
fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: 0; padding: 0; border: 0; }
.choice { display: flex; gap: .65rem; align-items: center; padding: .75rem; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.choice span { margin: 0; }
.choice strong, .choice small { display: block; }
.choice small { margin-top: .15rem; color: var(--muted); }
.divider { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.button { padding: .72rem 1rem; border: 1px solid #586173; border-radius: 8px; background: #2d3544; cursor: pointer; transition: transform .15s, border-color .15s, opacity .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--gold); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button--primary { color: #18130b; border-color: var(--gold); background: linear-gradient(135deg, var(--gold-bright), #bd893b); font-weight: 800; }
.button--danger { border-color: rgba(201, 99, 88, .6); background: rgba(122, 51, 48, .5); }
.button--quiet { background: transparent; }
.error { min-height: 1.2em; margin: 0; color: #ff9c91; }
.matchmaking-status { min-height: 1.2em; margin: -.45rem 0 0; color: var(--gold-bright); font-size: .82rem; text-align: center; }
.asset-preload { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .7rem; align-items: center; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(17, 21, 28, .72); }
.asset-preload[hidden] { display: none; }
.asset-preload > div { display: flex; min-width: 0; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .72rem; }
.asset-preload strong { color: var(--gold-bright); white-space: nowrap; }
.asset-preload progress { width: 100%; height: .45rem; grid-column: 1 / -1; accent-color: var(--gold); }
.asset-preload .button { grid-column: 1 / -1; }
.asset-preload.ready { border-color: rgba(102, 181, 138, .5); }
.asset-preload.failed { border-color: rgba(201, 99, 88, .65); }

.waiting { max-width: 700px; margin: 5vh auto; padding: 3rem; text-align: center; }
.room-code { display: block; margin: 1.2rem auto .5rem; padding: .5rem 1rem; color: var(--gold-bright); border: 0; background: none; font: 800 clamp(2.6rem, 10vw, 5rem)/1 monospace; letter-spacing: .14em; cursor: pointer; }
.spinner { width: 2.2rem; height: 2.2rem; margin: 2rem auto 1rem; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#game { display: grid; gap: 1rem; }
.match-banner { display: none; padding: 1rem; border: 1px solid var(--gold); border-radius: 10px; color: var(--gold-bright); background: rgba(92, 66, 26, .32); text-align: center; font-size: 1.1rem; font-weight: 800; }
.match-banner.visible { display: block; }
.match-result { padding: clamp(1.2rem, 4vw, 2rem); text-align: center; }
.match-result__header { display: flex; align-items: flex-start; justify-content: center; gap: 1rem; }
.match-result__header > div { flex: 1; }
.match-result__header .button { flex: none; }
.match-result h2 { margin-bottom: .45rem; font-size: clamp(2rem, 5vw, 3.2rem); }
.match-result__reason { color: var(--muted); }
.match-result__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; max-width: 640px; margin: 1.2rem auto; }
.match-result__stats div { padding: .75rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(8, 10, 14, .28); }
.match-result__stats dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.match-result__stats dd { margin: .25rem 0 0; color: var(--gold-bright); font-weight: 800; }
.player-strip { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 1.2rem; padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(27, 31, 40, .88); }
.player-strip strong, .player-strip small { display: block; }
.player-strip small, .label { color: var(--muted); font-size: .78rem; }
.ward { padding: .6rem .8rem; border: 1px solid rgba(214, 171, 88, .45); border-radius: 999px; background: rgba(214, 171, 88, .09); }
button.ward.targetable { outline: 2px solid var(--gold); cursor: crosshair; }
.presence { color: var(--green); font-size: .85rem; }
.presence.offline { color: var(--red); }

.board { overflow-x: auto; padding: 1rem; }
.board__meta { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-bottom: .8rem; color: var(--muted); font-size: .85rem; }
.board__turn { display: flex; min-width: 0; align-items: center; gap: .55rem; }
.board__meta > :last-child { text-align: right; }
.countdown { color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.battlefield { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: .65rem; min-width: 720px; }
.lane { display: grid; grid-template-rows: 1fr auto 1fr; min-height: 235px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: rgba(8, 10, 14, .28); }
.lane__number { padding: .2rem; color: #737b89; text-align: center; font-size: .7rem; }
.slot { position: relative; display: grid; place-items: center; min-height: 96px; padding: .5rem; border: 0; background: transparent; text-align: center; }
button.slot { cursor: default; }
.slot.targetable { cursor: crosshair; background: rgba(214, 171, 88, .11); outline: 2px solid var(--gold); outline-offset: -3px; }
.slot__empty { color: #596170; font-size: .75rem; }
.creature { width: 100%; padding: .55rem; border: 1px solid #596173; border-radius: 8px; background: #293142; }
.creature strong, .creature span { display: block; }
.creature strong { min-height: 2.2em; font-size: .82rem; }
.creature span { margin-top: .35rem; color: var(--muted); font-size: .76rem; }
.creature .creature__statuses { color: #efd58b; font-size: .7rem; }
.creature__art { display: block; width: 56px; height: 56px; margin: 0 auto .45rem; border-radius: 7px; object-fit: cover; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.navi-creature { position: absolute; right: .2rem; bottom: .2rem; width: 72%; padding: .3rem; border: 1px solid #8973b5; border-radius: 8px; background: rgba(39, 25, 57, .88); color: #ded4f4; opacity: .72; pointer-events: none; box-shadow: 0 0 14px rgba(128, 86, 180, .35); }
.navi-creature strong, .navi-creature span { display: block; }
.navi-creature strong { font-size: .7rem; }
.navi-creature span { margin-top: .2rem; color: #b8a8d4; font-size: .64rem; }
.navi-creature__art { display: block; width: 36px; height: 36px; margin: 0 auto .25rem; border-radius: 6px; object-fit: cover; filter: grayscale(.55) saturate(.65); }

.power { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.power__item { padding: .38rem .55rem; border: 1px solid var(--line); border-radius: 6px; font-size: .78rem; background: rgba(0, 0, 0, .18); }
.power__item strong { display: inline; color: var(--gold-bright); }
.power__item--fire { border-color: #d85843; }
.power__item--water { border-color: #4d9bdd; }
.power__item--wind { border-color: #9a75d5; }
.power__item--earth { border-color: #73a94b; }
.power__item--path { border-color: #d6ab58; }
.hand-section { padding-top: .5rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.section-heading h2 { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: .75rem; margin-top: .9rem; }
.card { display: flex; flex-direction: column; min-height: 190px; padding: .9rem; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, #282f3d, #1d222c); }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 171, 88, .12); }
.card.unaffordable { opacity: .58; }
.card__top { display: flex; justify-content: space-between; gap: .5rem; }
.card__school { color: var(--gold); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.card__cost { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; color: var(--gold-bright); background: #10141b; font-weight: 900; }
.card__art { display: block; width: 96px; height: 96px; margin: .7rem auto .1rem; border: 1px solid rgba(214, 171, 88, .25); border-radius: 10px; object-fit: cover; box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.card h3 { margin: .55rem 0 .35rem; font-family: Georgia, serif; font-size: 1.05rem; }
.card p { flex: 1; margin: 0 0 .7rem; color: var(--muted); font-size: .83rem; line-height: 1.4; }
.card__stats { color: var(--text) !important; }
.card .button { width: 100%; }

.lower-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.match-details > summary { cursor: pointer; color: var(--muted); font-size: .8rem; text-align: right; }
.event-panel, .session-panel { padding: 1rem; }
.event-log { display: grid; gap: .4rem; max-height: 210px; margin: 0; padding-left: 1.5rem; overflow-y: auto; color: var(--muted); font-size: .85rem; }
.event-log li:first-child { color: var(--text); }
.event-card-link { --school: var(--gold-bright); color: var(--school); font-weight: 800; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--school) 68%, transparent); text-decoration-style: dotted; text-underline-offset: 2px; cursor: pointer; }
.event-card-link:hover,
.event-card-link:focus-visible { color: #fff; outline: none; text-decoration-style: solid; text-shadow: 0 0 8px var(--school); }
.event-card-link--fire { --school: #ef725d; }
.event-card-link--water { --school: #65b4f1; }
.event-card-link--wind { --school: #b29cec; }
.event-card-link--earth { --school: #8bc766; }
.event-card-link--path { --school: #edc45f; }
.full-event-details { min-height: 0; color: var(--muted); font-size: .76rem; }
.full-event-details > summary { padding-top: .5rem; cursor: pointer; }
.event-log--full { margin-top: .5rem; max-height: 180px; }
.session-panel p { color: var(--muted); }
.activity-panel { display: grid; gap: .7rem; }
.chat-placeholder { display: grid; min-height: 180px; grid-template-rows: auto 1fr auto auto; gap: .55rem; padding: 1rem; }
.chat-placeholder__messages { min-height: 70px; border: 1px solid var(--line); border-radius: 7px; background: rgba(8, 10, 14, .28); }
.chat-placeholder__composer { padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 7px; color: #747b88; background: #11151c; }
.chat-placeholder small { color: var(--muted); }

.button--library { border-color: rgba(214, 171, 88, .72); background: linear-gradient(135deg, rgba(98, 72, 34, .72), rgba(45, 53, 68, .92)); }
.fullscreen-toggle {
    position: fixed;
    top: max(4px, env(safe-area-inset-top));
    right: max(6px, env(safe-area-inset-right));
    z-index: 79;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(214, 171, 88, .75);
    border-radius: 7px;
    background: rgba(17, 20, 27, .88);
    color: var(--gold-bright);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .45);
    font: 700 1.2rem/1 sans-serif;
    cursor: pointer;
}
.fullscreen-toggle:hover,
.fullscreen-toggle:focus-visible { border-color: var(--gold-bright); background: rgba(64, 49, 28, .95); }
.fullscreen-toggle--active { font-size: 1.35rem; }
.fullscreen-prompt {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    z-index: 80;
    display: grid;
    width: min(460px, calc(100vw - 16px));
    margin: auto;
    grid-template-columns: 1fr auto;
    gap: .45rem;
    align-items: center;
    padding: .75rem;
    border: 2px solid var(--gold);
    box-shadow: 0 18px 55px rgba(0, 0, 0, .8);
}
.fullscreen-prompt strong,
.fullscreen-prompt span,
.fullscreen-prompt small { grid-column: 1 / -1; }
.fullscreen-prompt strong { color: var(--gold-bright); font: 700 1.15rem Georgia, serif; }
.fullscreen-prompt span { color: #d9dde5; font-size: .82rem; }
.fullscreen-prompt .button { min-height: 44px; }
.fullscreen-prompt .button--primary { min-width: 220px; }
.fullscreen-prompt .error:empty { display: none; }
body.library-active { --game-card-size: clamp(115px, calc((100vh - 26px) / 6), 175px); min-width: 1200px; height: 100vh; overflow: hidden; }
body.library-active .topbar { display: none; }
body.library-active main { width: 100%; height: 100vh; margin: 0; padding: 0; overflow: hidden; }
.leaderboard { position: fixed; inset: 0; z-index: 100; display: grid; height: 100dvh; grid-template-rows: auto minmax(0, 1fr); background: #111319; }
body.leaderboard-active { height: 100dvh; overflow: hidden; }
body.leaderboard-active .topbar { display: none; }
body.leaderboard-active main { width: 100%; height: 100dvh; margin: 0; padding: 0; overflow: hidden; }
.leaderboard__header { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1rem; border-bottom: 1px solid var(--line); background: rgba(17, 19, 25, .96); }
.leaderboard__header .eyebrow { margin-bottom: .15rem; }
.leaderboard__header h2 { margin: 0; font-size: 1.55rem; }
.leaderboard__content { min-height: 0; padding: clamp(.5rem, 2vw, 1.5rem); overflow: hidden; }
.leaderboard__status { margin: 0 0 .65rem; color: var(--muted); font-size: .85rem; }
.leaderboard__table-wrap { height: calc(100% - 2rem); overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.leaderboard table { width: 100%; min-width: 840px; border-collapse: collapse; background: rgba(24, 28, 37, .96); }
.leaderboard thead { position: sticky; top: 0; z-index: 2; background: #242a36; }
.leaderboard th, .leaderboard td { padding: .75rem .8rem; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.leaderboard thead th { color: var(--gold-bright); font-size: .76rem; text-transform: uppercase; }
.leaderboard__name { max-width: 260px; overflow: hidden; text-align: left !important; text-overflow: ellipsis; }
.leaderboard__rank { color: var(--muted); }
.leaderboard__level { color: var(--gold-bright); font-size: 1.05rem; font-weight: 900; }
.leaderboard tbody tr:nth-child(even) { background: rgba(255, 255, 255, .018); }
.leaderboard tbody tr:hover { background: rgba(214, 171, 88, .08); }
.leaderboard tbody tr.leaderboard__self { background: rgba(102, 181, 138, .13); box-shadow: inset 3px 0 var(--green); }
.card-library { position: fixed; inset: 0; z-index: 100; display: grid; height: 100dvh; grid-template-rows: auto minmax(0, 1fr); background: #111319; }
.card-library__header { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1rem; border-bottom: 1px solid var(--line); background: rgba(17, 19, 25, .96); }
.card-library__header .eyebrow { margin-bottom: .15rem; }
.card-library__header h2 { margin: 0; font-size: 1.55rem; }
.card-library__layout { display: grid; min-height: 0; grid-template-columns: 320px minmax(0, 1fr); gap: .4rem; padding: .4rem; }
.card-library__groups { min-width: 0; min-height: 0; overflow-y: auto; padding: 0 .3rem 1rem 0; scrollbar-color: var(--gold) #171b23; }
.card-library__group { --school: #8b92a0; margin-bottom: .8rem; }
.card-library__group-header { position: sticky; top: 0; z-index: 10; display: flex; min-height: 38px; align-items: center; justify-content: space-between; padding: .35rem .65rem; border-bottom: 3px solid var(--school); background: rgba(17, 19, 25, .96); backdrop-filter: blur(8px); }
.card-library__group-header h3 { margin: 0; color: #fff; font: 700 1.08rem Georgia, serif; }
.card-library__group-header span { color: var(--muted); font-size: .76rem; }
.card-library__grid { display: grid; grid-template-columns: repeat(auto-fill, var(--library-card-size, var(--game-card-size))); justify-content: start; gap: 0; padding-top: .2rem; }

.card-library .library-card { --school: #8b92a0; position: relative; width: var(--library-card-size, var(--game-card-size)); height: var(--library-card-size, var(--game-card-size)); min-width: 0; min-height: 0; padding: 0; overflow: hidden; border: 3px solid var(--school); border-radius: 2px; background: #171b23; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); transition: transform .12s ease, box-shadow .12s ease; }
.card-library .library-card::after { content: ""; position: absolute; inset: 42% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .97)); pointer-events: none; }
.card-library .library-card:hover,
.card-library .library-card:focus-visible,
.card-library .library-card.previewed { z-index: 3; outline: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .58), 0 0 16px color-mix(in srgb, var(--school) 88%, transparent); }
.card-library .library-card:hover { transform: translateY(-3px) scale(1.025); }
.card-library .card__art { width: 100%; height: 100%; margin: 0; border: 0; border-radius: 2px; object-fit: cover; box-shadow: none; }
.card-library .card__cost,
.card-library .card__attack,
.card-library .card__health { position: absolute; z-index: 2; display: grid; width: 1.45rem; height: 1.45rem; place-items: center; border: 1px solid rgba(255, 255, 255, .75); border-radius: 3px; color: #fff; font-size: .78rem; font-weight: 900; text-shadow: 0 1px 2px #000; }
.card-library .card__cost { top: 2px; right: 2px; background: #243e78; }
.card-library .card__attack { bottom: 2px; left: 2px; background: #8a2f28; }
.card-library .card__health { right: 2px; bottom: 2px; background: #316c39; }
.card-library .library-card h3 { position: absolute; right: 3px; bottom: 30px; left: 3px; z-index: 2; display: -webkit-box; max-height: 2.15em; margin: 0; overflow: hidden; color: #fff; font: 700 .75rem/1.05 Georgia, serif; text-align: center; text-shadow: 0 1px 4px #000, 0 0 5px #000; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.library-card-preview { --school: var(--gold); display: grid; width: 100%; height: 100%; min-height: 0; grid-template-rows: minmax(220px, 300px) minmax(0, auto); align-content: start; gap: .55rem; padding: .65rem; overflow: hidden; border: 2px solid var(--school); border-radius: 5px; }
.library-card-preview .card-preview__visual { position: relative; width: min(300px, 100%); height: 100%; aspect-ratio: 1; align-self: center; justify-self: center; }
.library-card-preview .card-preview__art { display: block; width: 100%; height: 100%; border-radius: 3px; object-fit: cover; }
.library-card-preview .card-preview__text { display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; }
.library-card-preview h2 { margin-bottom: .4rem; color: #fff; font-size: 1.55rem; }
.library-card-preview p { margin-bottom: .5rem; overflow: auto; color: #e1e3e8; font-size: .95rem; line-height: 1.4; }
.library-card-preview .card-preview__cost { position: absolute; top: .45rem; right: .45rem; display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border: 2px solid var(--school); border-radius: 50%; background: rgba(5, 8, 12, .9); color: #fff; font-weight: 900; }
.library-card-preview .card-preview__stats { display: flex; margin-top: auto; justify-content: space-between; gap: .5rem; }
.library-card-preview .card-preview__stat { display: flex; min-width: 5.5rem; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem .5rem; border: 1px solid rgba(255, 255, 255, .55); border-radius: 4px; color: #fff; }
.library-card-preview .card-preview__stat--attack { background: rgba(138, 47, 40, .85); }
.library-card-preview .card-preview__stat--health { background: rgba(49, 108, 57, .85); }
.library-card-preview .card-preview__keywords { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.library-card-preview .card-preview__keyword { padding: .28rem .48rem; border: 1px solid color-mix(in srgb, var(--school) 65%, #fff); border-radius: 999px; background: color-mix(in srgb, var(--school) 18%, rgba(8, 11, 17, .92)); color: #f8f5ec; font-size: .72rem; font-weight: 700; line-height: 1; }

.card-library__group--fire,
.card-library .card--fire,
.card-library .card-preview--fire { --school: #d85843; }
.card-library__group--water,
.card-library .card--water,
.card-library .card-preview--water { --school: #4b9fe1; }
.card-library__group--wind,
.card-library .card--wind,
.card-library .card-preview--wind { --school: #9a83db; }
.card-library__group--earth,
.card-library .card--earth,
.card-library .card-preview--earth { --school: #6fa54f; }
.card-library__group--path,
.card-library .card--path,
.card-library .card-preview--path { --school: #d7a942; }

@media (min-width: 0px) {
    body { min-width: 1200px; }
    body.game-active { --game-card-size: clamp(115px, calc((100vh - 26px) / 6), 175px); height: 100vh; overflow: hidden; }
    body.game-active .topbar { display: none; }
    body.game-active main { width: 100%; height: 100vh; margin: 0; padding: .1rem; overflow: hidden; }

    body.game-active #game {
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-columns: 140px 300px minmax(540px, 1fr) 240px;
        grid-template-rows: calc(var(--game-card-size) * 2) minmax(0, 1fr);
        grid-template-areas:
            "opponent board board board"
            "self preview hand activity";
        gap: .1rem;
        overflow: hidden;
        user-select: none;
        -webkit-user-select: none;
    }

    body.game-active .match-result { position: absolute; inset: 4rem 20%; z-index: 20; }
    body.game-active .match-result--collapsed { inset: 3.2rem .7rem auto auto; width: 250px; padding: .45rem .55rem; text-align: left; }
    body.game-active .match-result--collapsed .match-result__header { align-items: center; }
    body.game-active .match-result--collapsed .match-result__header > div { min-width: 0; }
    body.game-active .match-result--collapsed .eyebrow,
    body.game-active .match-result--collapsed .match-result__body { display: none; }
    body.game-active .match-result--collapsed h2 { margin: 0; font-size: 1rem; }
    body.game-active .match-result--collapsed .button { padding: .32rem .45rem; font-size: .68rem; }
    body.game-active .match-banner { flex: none; padding: .08rem .4rem; border-radius: 999px; font-size: .62rem; line-height: 1.25; }
    body.game-active .player-strip { position: relative; display: flex; min-height: 0; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: .35rem; padding: .55rem; border-radius: 5px; }
    body.game-active .player-strip--opponent { grid-area: opponent; }
    body.game-active .player-strip--self { grid-area: self; }
    body.game-active .game-brand { display: grid; gap: .18rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
    body.game-active .game-brand > strong { font-family: Georgia, serif; font-size: .9rem; line-height: 1.05; }
    body.game-active .game-connection { gap: .3rem; color: var(--muted); font-size: .62rem; }
    body.game-active .game-connection .connection__dot { width: .5rem; height: .5rem; }
    body.game-active .player-identity { display: grid; gap: .12rem; }
    body.game-active .player-strip .label { display: none; }
    body.game-active .player-identity strong { font-size: 1rem; line-height: 1.1; }
    body.game-active .player-strip small { font-size: .78rem; }
    body.game-active .ward { width: 100%; margin-top: .1rem; padding: .42rem .3rem; border-radius: 5px; font-size: .78rem; text-align: center; }
    body.game-active .ward strong { display: inline; color: var(--gold-bright); font-size: 1.15rem; }
    body.game-active .presence { font-size: .72rem; }
    body.game-active .keyword-help { position: relative; z-index: 18; margin-top: .1rem; }
    body.game-active .keyword-help > summary { padding: .32rem .42rem; border: 1px solid var(--line); border-radius: 5px; color: var(--gold-bright); background: rgba(17, 21, 28, .92); cursor: pointer; font-size: .7rem; text-align: center; }
    body.game-active .keyword-help__panel { position: absolute; bottom: 0; left: calc(100% + .45rem); width: 330px; padding: .75rem; box-shadow: 0 16px 45px rgba(0, 0, 0, .72); }
    body.game-active .keyword-help__panel h2 { margin-bottom: .45rem; font-size: 1.05rem; }
    body.game-active .keyword-help__panel dl { display: grid; gap: .38rem; margin: 0; }
    body.game-active .keyword-help__panel dl div { display: grid; grid-template-columns: 86px 1fr; gap: .4rem; padding-bottom: .32rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
    body.game-active .keyword-help__panel dt { color: var(--gold-bright); font-size: .76rem; font-weight: 800; }
    body.game-active .keyword-help__panel dd { margin: 0; color: #e2e4e9; font-size: .72rem; line-height: 1.28; }
    body.game-active .power { display: none; }
    body.game-active .opponent-power { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem; }
    body.game-active .opponent-power .power__item { display: grid; min-width: 0; min-height: 1.9rem; place-items: center; padding: .15rem; border-width: 2px; font-size: .9rem; text-align: center; }
    body.game-active .opponent-power .power__item strong { font-size: 1rem; }
    body.game-active .side-match-status { display: grid; height: auto; margin-top: auto; grid-template-columns: 1fr; gap: .28rem; padding-top: .45rem; border-top: 1px solid var(--line); font-size: .66rem; }
    body.game-active .side-match-status .board__turn { display: grid; gap: .2rem; white-space: normal; }
    body.game-active .side-match-status #turn-label,
    body.game-active .side-match-status #target-hint { display: none; }
    body.game-active .side-match-status .match-banner { display: none !important; }
    body.game-active .side-match-status .countdown { color: var(--gold-bright); font-size: .82rem; line-height: 1.15; }
    body.game-active .side-match-status #target-hint { color: var(--muted); line-height: 1.25; }

    body.game-active .board { grid-area: board; min-height: 0; padding: 0; overflow: hidden; border-radius: 5px; }
    body.game-active .battlefield { position: relative; width: 100%; height: 100%; min-width: 0; grid-template-columns: repeat(6, var(--game-card-size)); justify-content: center; align-content: center; gap: 0; background: linear-gradient(to bottom, rgba(48, 62, 82, .08) 0 50%, rgba(84, 62, 38, .07) 50% 100%); }
    body.game-active .lane { min-height: 0; display: grid; grid-template-rows: repeat(2, var(--game-card-size)); align-content: center; gap: 0; border: 0; border-radius: 0; overflow: visible; background: transparent; }
    body.game-active .slot { position: relative; width: var(--game-card-size); height: var(--game-card-size); min-width: 0; min-height: 0; padding: 0; overflow: visible; border: 1px solid #30394a; border-radius: 2px; background: rgba(8, 12, 18, .48); }
    body.game-active .slot[data-friendly="false"] { border-bottom-color: rgba(108, 167, 217, .48); background: rgba(14, 21, 32, .54); }
    body.game-active .slot[data-friendly="true"] { border-top-color: rgba(214, 171, 88, .48); background: rgba(19, 16, 13, .48); }
    body.game-active .slot.targetable { border-color: var(--gold-bright); background: rgba(214, 171, 88, .18); outline: 2px solid rgba(242, 204, 117, .8); outline-offset: 1px; }
    body.game-active .slot__empty { color: #465064; font-size: .58rem; }
    body.game-active .creature { position: relative; width: 100%; height: 100%; min-height: 0; padding: 0; overflow: hidden; border-radius: 3px; background: #202737; cursor: default; }
    body.game-active .creature__art { width: 100%; height: 100%; margin: 0; border-radius: 3px; object-fit: cover; }
    body.game-active .creature .creature__statuses { position: absolute; top: 2px; right: 24px; bottom: auto; left: 2px; z-index: 3; margin: 0; overflow: hidden; padding: 2px; border: 0; background: rgba(0, 0, 0, .78); color: #efd58b; font-size: .46rem; line-height: 1; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
    body.game-active .navi-creature { width: 62%; padding: .15rem; }
    body.game-active .navi-creature__art { display: none; }

    body.game-active .card-preview { --school: var(--gold); grid-area: preview; display: grid; width: 100%; height: 100%; min-height: 0; grid-template-rows: minmax(150px, 270px) minmax(0, auto); align-content: start; gap: .45rem; padding: .55rem; overflow: hidden; border: 2px solid var(--school); border-radius: 5px; }
    body.game-active .card-preview__visual { position: relative; width: min(270px, 100%); height: 100%; aspect-ratio: 1; align-self: center; justify-self: center; }
    body.game-active .card-preview__art { display: block; width: 100%; height: 100%; border-radius: 3px; object-fit: cover; }
    body.game-active .card-preview__text { display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; }
    body.game-active .card-preview h2 { margin-bottom: .3rem; color: #fff; font-size: clamp(1.25rem, 1.4vw, 1.55rem); }
    body.game-active .card-preview p { margin-bottom: .4rem; overflow: auto; color: #e1e3e8; font-size: clamp(.82rem, .92vw, .95rem); line-height: 1.35; }
    body.game-active .card-preview__cost { position: absolute; top: .45rem; right: .45rem; display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border: 2px solid var(--school); border-radius: 50%; background: rgba(5, 8, 12, .9); color: #fff; font-weight: 900; }
    body.game-active .card-preview__stats { display: flex; margin-top: auto; justify-content: space-between; gap: .5rem; }
    body.game-active .card-preview__stat { display: flex; min-width: 5.5rem; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .45rem; border: 1px solid rgba(255, 255, 255, .55); border-radius: 4px; color: #fff; }
    body.game-active .card-preview__stat small { font-size: .72rem; }
    body.game-active .card-preview__stat strong { font-size: 1.1rem; }
    body.game-active .card-preview__stat--attack { background: rgba(138, 47, 40, .85); }
    body.game-active .card-preview__stat--health { background: rgba(49, 108, 57, .85); }
    body.game-active .card-preview__keywords { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .15rem; }
    body.game-active .card-preview__keyword { padding: .28rem .48rem; border: 1px solid color-mix(in srgb, var(--school) 65%, #fff); border-radius: 999px; background: color-mix(in srgb, var(--school) 18%, rgba(8, 11, 17, .92)); color: #f8f5ec; font-size: .72rem; font-weight: 700; line-height: 1; }

    body.game-active .hand-section { grid-area: hand; display: grid; min-height: 0; padding: 0; }
    body.game-active #cancel-selection { display: none !important; }
    body.game-active .hand { min-height: 0; margin: 0; display: grid; grid-template-columns: repeat(5, var(--game-card-size)); justify-content: center; align-content: start; gap: 0; }
    body.game-active .school-column { --school: #8b92a0; display: grid; width: var(--game-card-size); min-width: 0; min-height: 0; grid-template-rows: 20px repeat(4, var(--game-card-size)); gap: 0; }
    body.game-active .school-column__header { display: grid; place-items: center; border-bottom: 3px solid var(--school); }
    body.game-active .school-column__header strong { position: relative; z-index: 4; display: grid; width: 2.05rem; height: 2.05rem; place-items: center; border: 3px solid var(--school); border-radius: 50%; background: #10141b; color: #fff; font-size: 1rem; box-shadow: 0 0 10px color-mix(in srgb, var(--school) 45%, transparent); }
    body.game-active .card { --school: #8b92a0; position: relative; width: var(--game-card-size); height: var(--game-card-size); min-width: 0; min-height: 0; padding: 0; overflow: hidden; border: 3px solid var(--school); border-radius: 2px; background: #171b23; cursor: grab; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
    body.game-active .card::after { content: ""; position: absolute; inset: 42% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .97)); pointer-events: none; }
    body.game-active .card:active { cursor: grabbing; }
    body.game-active .card.card--clickable { cursor: pointer; }
    body.game-active .card.card--clickable:active { cursor: pointer; transform: scale(.98); }
    body.game-active .hand .card:not(.inactive):not(.unaffordable):hover { z-index: 10; transform: translateY(-4px) scale(1.035); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), 0 0 18px color-mix(in srgb, var(--school) 80%, transparent), 0 9px 20px rgba(0, 0, 0, .55); }
    body.game-active .card.previewed { z-index: 6; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .58), 0 0 16px color-mix(in srgb, var(--school) 88%, transparent); }
    body.game-active .card.unaffordable,
    body.game-active .card.inactive { cursor: not-allowed; border-color: color-mix(in srgb, var(--school) 52%, #30343c); }
    body.game-active .card.unaffordable::before,
    body.game-active .card.inactive::before { content: ""; position: absolute; inset: 0; z-index: 1; background: rgba(8, 10, 14, .38); pointer-events: none; }
    body.game-active .card.unaffordable .card__art,
    body.game-active .card.inactive .card__art { filter: grayscale(.62) brightness(.54); opacity: .82; }
    body.game-active .card.inactive:active { cursor: not-allowed; }
    body.game-active .card__art { width: 100%; height: 100%; margin: 0; border: 0; border-radius: 2px; object-fit: cover; box-shadow: none; }
    body.game-active .card__cost,
    body.game-active .card__attack,
    body.game-active .card__health { position: absolute; z-index: 2; display: grid; width: 1.25rem; height: 1.25rem; place-items: center; border: 1px solid rgba(255, 255, 255, .75); border-radius: 3px; color: #fff; font-size: .66rem; font-weight: 900; text-shadow: 0 1px 2px #000; }
    body.game-active .card__cost { top: 2px; right: 2px; background: #243e78; }
    body.game-active .card__attack { bottom: 2px; left: 2px; background: #8a2f28; }
    body.game-active .card__health { right: 2px; bottom: 2px; background: #316c39; }
    body.game-active .card h3 { position: absolute; right: 3px; bottom: 30px; left: 3px; z-index: 2; display: -webkit-box; max-height: 2.15em; margin: 0; overflow: hidden; color: #fff; font: 700 .75rem/1.05 Georgia, serif; text-align: center; text-shadow: 0 1px 4px #000, 0 0 5px #000; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
    body.game-active .card__cost,
    body.game-active .card__attack,
    body.game-active .card__health { width: 1.45rem; height: 1.45rem; font-size: .78rem; }
    body.game-active .slot .card { cursor: default; }
    body.game-active .creature--entering { z-index: 8; animation: creature-entering .45s ease-out; }
    body.game-active .creature--attacking-up { z-index: 8; animation: creature-attack-up .46s ease-in-out; }
    body.game-active .creature--attacking-down { z-index: 8; animation: creature-attack-down .46s ease-in-out; }
    body.game-active .creature--damaged { z-index: 7; animation: creature-damaged .6s ease-out; }
    body.game-active .creature--healed { z-index: 7; animation: creature-healed .6s ease-out; }
    body.game-active .creature--shielded { z-index: 7; animation: creature-shielded .6s ease-out; }
    body.game-active .creature--buffed { z-index: 7; animation: creature-buffed .5s ease-out; }
    body.game-active .creature--weakened { z-index: 7; animation: creature-weakened .5s ease-out; }
    body.game-active .creature--status-ward { z-index: 7; animation: creature-status-ward .65s ease-out; }
    body.game-active .creature--status-poison { z-index: 7; animation: creature-status-poison .65s ease-out; }
    body.game-active .creature--status-frozen { z-index: 7; animation: creature-status-frozen .65s ease-out; }
    body.game-active .creature--status-rooted { z-index: 7; animation: creature-status-rooted .65s ease-out; }
    body.game-active .creature--attack-skipped { z-index: 7; animation: creature-attack-skipped .7s ease-out; }
    body.game-active .creature--dying { z-index: 9; pointer-events: none; animation: creature-dying .36s ease-in forwards; }
    body.game-active .slot--damaged { z-index: 7; animation: creature-damaged .6s ease-out; }
    body.game-active .ward--damaged { animation: ward-damaged .6s ease-out; }
    body.game-active .ward--healed { animation: ward-healed .6s ease-out; }
    body.game-active .ward { position: relative; overflow: visible; }
    body.game-active .combat-float { position: absolute; top: 42%; left: 50%; z-index: 30; min-width: max-content; padding: .18rem .38rem; border: 1px solid currentColor; border-radius: 999px; background: rgba(7, 10, 15, .9); font-size: .82rem; font-weight: 900; line-height: 1; text-shadow: 0 1px 3px #000; pointer-events: none; transform: translate(-50%, -50%); animation: combat-float .65s ease-out forwards; }
    body.game-active .combat-float--damage { color: #ff8175; }
    body.game-active .combat-float--heal { color: #79e89e; }
    body.game-active .combat-float--shield { color: #8fd7ff; }
    body.game-active .combat-float--buff { color: #ffd56f; }
    body.game-active .combat-float--debuff { color: #ff9b75; }
    body.game-active .combat-float--status { color: #d9bcff; }
    body.game-active .combat-float--poison { color: #9de45e; }
    body.game-active .combat-float--frozen { color: #92dfff; }
    body.game-active .combat-float--power { color: #ffe18c; }
    body.game-active .power__item--gained,
    body.game-active .power__item--spent { position: relative; overflow: visible; z-index: 8; }
    body.game-active .power__item--gained { animation: power-gained .5s ease-out; }
    body.game-active .power__item--spent { animation: power-spent .5s ease-out; }

    .spell-cast { --school: var(--gold); position: fixed; z-index: 100; overflow: hidden; border: 2px solid var(--school); border-radius: 5px; background: #111722; pointer-events: none; box-shadow: 0 0 28px color-mix(in srgb, var(--school) 75%, transparent), 0 12px 36px rgba(0, 0, 0, .75); animation: spell-cast 1s ease-in-out both; }
    .spell-cast__art { width: 100%; height: 100%; object-fit: cover; opacity: .72; }
    .spell-cast::after { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .88)); }
    .spell-cast__cost { position: absolute; top: 3px; right: 3px; z-index: 2; display: grid; width: 1.45rem; height: 1.45rem; place-items: center; border: 1px solid #fff; border-radius: 4px; background: #243e78; font-size: .72rem; font-weight: 900; }
    .spell-cast__name { position: absolute; right: 4px; bottom: 5px; left: 4px; z-index: 2; overflow: hidden; font: 700 .62rem/1.05 Georgia, serif; text-align: center; text-overflow: ellipsis; text-shadow: 0 1px 4px #000; white-space: nowrap; }
    .spell-cast--mass,
    .spell-cast--center,
    .spell-cast--summon { border-width: 3px; }
    .spell-cast--summon { box-shadow: 0 0 38px color-mix(in srgb, var(--school) 88%, transparent), 0 16px 44px rgba(0, 0, 0, .82); }

    @keyframes spell-cast {
        0% { opacity: 0; transform: scale(.78) rotate(-2deg); filter: brightness(1.7); }
        14%, 76% { opacity: .78; transform: scale(1) rotate(0); filter: brightness(1.08); }
        100% { opacity: 0; transform: scale(1.08); filter: brightness(1.45); }
    }

    body.game-active .school-column--fire,
    body.game-active .card--fire,
    body.game-active .card-preview--fire { --school: #d85843; }
    body.game-active .school-column--water,
    body.game-active .card--water,
    body.game-active .card-preview--water { --school: #4b9fe1; }
    body.game-active .school-column--wind,
    body.game-active .card--wind,
    body.game-active .card-preview--wind { --school: #9a83db; }
    body.game-active .school-column--earth,
    body.game-active .card--earth,
    body.game-active .card-preview--earth { --school: #6fa54f; }
    body.game-active .school-column--path,
    body.game-active .card--path,
    body.game-active .card-preview--path { --school: #d7a942; }

    body.card-dragging .board { box-shadow: inset 0 0 22px rgba(214, 171, 88, .13); }
    body.game-active .card-drag-preview { position: fixed; z-index: 1000; opacity: .68; pointer-events: none; transform: translate(-50%, -50%) scale(.94) !important; box-shadow: 0 10px 28px rgba(0, 0, 0, .72), 0 0 18px color-mix(in srgb, var(--school) 72%, transparent); will-change: left, top; }

    @keyframes creature-attack-up {
        0%, 100% { transform: translateY(0) scale(1); }
        48% { transform: translateY(-18px) scale(1.035); filter: brightness(1.18); }
    }

    @keyframes creature-entering {
        0% { opacity: 0; transform: scale(.72); filter: brightness(1.7); }
        65% { opacity: 1; transform: scale(1.05); filter: brightness(1.3); }
        100% { opacity: 1; transform: scale(1); filter: brightness(1); }
    }

    @keyframes creature-attack-down {
        0%, 100% { transform: translateY(0) scale(1); }
        48% { transform: translateY(18px) scale(1.035); filter: brightness(1.18); }
    }

    @keyframes creature-damaged {
        0%, 100% { transform: translateX(0); filter: brightness(1); }
        20% { transform: translateX(-5px); filter: brightness(1.65) saturate(.5); }
        45% { transform: translateX(5px); }
        70% { transform: translateX(-3px); }
    }

    @keyframes creature-healed {
        0%, 100% { transform: scale(1); filter: brightness(1); }
        45% { transform: scale(1.035); filter: brightness(1.5) saturate(1.35); box-shadow: 0 0 18px rgba(95, 224, 137, .85); }
    }

    @keyframes creature-shielded {
        0%, 100% { filter: brightness(1); box-shadow: none; }
        45% { filter: brightness(1.35); box-shadow: inset 0 0 0 4px rgba(109, 196, 255, .8), 0 0 20px rgba(109, 196, 255, .9); }
    }

    @keyframes creature-buffed {
        0%, 100% { transform: scale(1); filter: brightness(1); }
        48% { transform: scale(1.04); filter: brightness(1.45) saturate(1.4); box-shadow: 0 0 18px rgba(255, 205, 92, .82); }
    }

    @keyframes creature-weakened {
        0%, 100% { transform: scale(1); filter: brightness(1); }
        45% { transform: scale(.96); filter: brightness(.72) saturate(.55); box-shadow: 0 0 16px rgba(190, 82, 65, .75); }
    }

    @keyframes creature-status-ward {
        0%, 100% { filter: brightness(1); box-shadow: none; }
        50% { filter: brightness(1.38); box-shadow: inset 0 0 0 4px rgba(111, 204, 255, .85), 0 0 22px rgba(111, 204, 255, .72); }
    }

    @keyframes creature-status-poison {
        0%, 100% { filter: hue-rotate(0) brightness(1); }
        50% { filter: hue-rotate(45deg) brightness(1.22) saturate(1.8); box-shadow: inset 0 0 18px rgba(112, 207, 65, .9); }
    }

    @keyframes creature-status-frozen {
        0%, 100% { filter: brightness(1); }
        50% { filter: brightness(1.35) saturate(.42) hue-rotate(165deg); box-shadow: inset 0 0 16px rgba(100, 210, 255, .88); }
    }

    @keyframes creature-status-rooted {
        0%, 100% { transform: translateY(0); filter: brightness(1); }
        45% { transform: translateY(3px) scale(.98); filter: sepia(.55) brightness(.8); box-shadow: inset 0 -8px 15px rgba(119, 82, 42, .9); }
    }

    @keyframes creature-attack-skipped {
        0%, 100% { transform: translateX(0); filter: brightness(1); }
        22% { transform: translateX(-3px); filter: brightness(.68) saturate(.35); }
        48% { transform: translateX(3px); filter: brightness(.72) saturate(.3); }
        74% { transform: translateX(-2px); filter: brightness(.76) saturate(.4); }
    }

    @keyframes creature-dying {
        0% { opacity: 1; transform: scale(1); filter: grayscale(0) brightness(1); }
        55% { opacity: .72; transform: scale(.94); filter: grayscale(.8) brightness(.7); }
        100% { opacity: 0; transform: scale(.68) rotate(-3deg); filter: grayscale(1) brightness(.25); }
    }

    @keyframes ward-damaged {
        0%, 100% { transform: translateX(0); box-shadow: none; }
        25% { transform: translateX(-4px); box-shadow: 0 0 14px rgba(220, 76, 62, .9); }
        55% { transform: translateX(4px); }
        80% { transform: translateX(-2px); }
    }

    @keyframes ward-healed {
        0%, 100% { transform: scale(1); box-shadow: none; }
        45% { transform: scale(1.035); box-shadow: 0 0 16px rgba(95, 224, 137, .8); }
    }

    @keyframes combat-float {
        0% { opacity: 0; transform: translate(-50%, 4px) scale(.82); }
        22% { opacity: 1; transform: translate(-50%, -8px) scale(1.08); }
        100% { opacity: 0; transform: translate(-50%, -34px) scale(.96); }
    }

    @keyframes power-gained {
        0%, 100% { transform: scale(1); filter: brightness(1); }
        50% { transform: scale(1.12); filter: brightness(1.65); box-shadow: 0 0 16px var(--school, var(--gold)); }
    }

    @keyframes power-spent {
        0%, 100% { transform: scale(1); filter: brightness(1); }
        50% { transform: scale(.9); filter: brightness(.68); }
    }

    body.game-active .activity-panel { grid-area: activity; min-width: 0; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; gap: .35rem; }
    body.game-active .side-controls { display: grid; width: 100%; grid-template-columns: 1fr 1fr; gap: .3rem; }
    body.game-active .side-controls .drag-hint { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; line-height: 1.2; }
    body.game-active .side-controls .button { min-width: 0; padding: .5rem .3rem; font-size: .78rem; }
    body.game-active .activity-panel .event-panel,
    body.game-active .chat-placeholder { display: grid; min-width: 0; min-height: 0; padding: .6rem; overflow: hidden; box-shadow: none; }
    body.game-active .activity-panel .event-panel { position: relative; grid-template-rows: auto minmax(0, 1fr) auto; }
    body.game-active .activity-panel h2 { margin-bottom: .35rem; font-size: 1.05rem; }
    body.game-active .activity-panel .event-log { max-height: none; min-height: 0; gap: .35rem; padding-left: 1.2rem; font-size: .84rem; line-height: 1.35; }
    body.game-active .activity-panel .event-log--full { max-height: 180px; }
    body.game-active .full-event-details[open] { position: absolute; right: .6rem; bottom: .6rem; left: .6rem; z-index: 12; max-height: 75%; padding: .5rem; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: rgba(17, 21, 28, .98); box-shadow: 0 10px 30px rgba(0, 0, 0, .65); }
    body.game-active .chat-placeholder { grid-template-rows: auto auto auto; gap: .3rem; }
    body.game-active .chat-placeholder__messages { display: none; }
    body.game-active .chat-placeholder__composer { padding: .55rem .6rem; font-size: .8rem; }
    body.game-active .chat-placeholder small { font-size: .68rem; }

    body.game-active .match-details { position: relative; z-index: 15; margin-top: auto; }
    body.game-active .match-details > summary { padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: .72rem; text-align: center; }
    body.game-active .match-details .session-panel { position: absolute; bottom: calc(100% + .35rem); left: 0; width: min(360px, 90vw); padding: .7rem; box-shadow: 0 16px 45px rgba(0, 0, 0, .55); }
    body.game-active .session-panel h2 { margin-bottom: .35rem; font-size: 1rem; }
}

@media (min-width: 1500px) and (min-height: 850px) {
    body.game-active #game { grid-template-columns: 155px 300px minmax(810px, 1fr) 300px; }
    body.game-active .card-preview__visual { width: min(270px, 100%); }
    body.game-active .card__cost,
    body.game-active .card__attack,
    body.game-active .card__health { width: 1.65rem; height: 1.65rem; font-size: .9rem; }
    body.game-active .card h3 { bottom: 31px; font-size: .78rem; }
    body.game-active .creature .creature__statuses { right: 31px; font-size: .55rem; }
}

@media (max-width: 800px) {
    .lobby { grid-template-columns: 1fr; }
    .lobby__intro h2 { max-width: none; }
    .player-strip { grid-template-columns: 1fr auto; }
    .presence, .power { grid-column: 1 / -1; justify-content: flex-start; }
    .lower-grid { grid-template-columns: 1fr; }
    .section-heading { align-items: stretch; flex-direction: column; }
    .actions { justify-content: flex-start; }
}

@media (max-width: 520px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    fieldset { grid-template-columns: 1fr; }
    .hand { grid-template-columns: 1fr; }
    .actions .button { flex: 1; }
    .match-result__stats { grid-template-columns: 1fr; }
    .saved-session { grid-template-columns: 1fr; }
    .saved-session__actions .button { flex: 1; }
}

/* Compact client: the same markup automatically becomes a no-scroll mobile board. */
@media (max-width: 999px) {
    body { min-width: 320px; }
    body.game-active {
        --mobile-status-width: clamp(72px, 11vw, 96px);
        --mobile-preview-width: clamp(145px, 22vw, 190px);
        --mobile-activity-width: clamp(100px, 15vw, 132px);
        --game-card-size: min(
            calc((100dvh - 16px) / 6.15),
            calc((100vw - var(--mobile-status-width) - var(--mobile-preview-width) - var(--mobile-activity-width) - 8px) / 6)
        );
        width: 100vw;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
        overscroll-behavior: none;
    }
    body.game-active main { width: 100vw; height: 100dvh; padding: 2px; }
    body.game-active #game {
        grid-template-columns: var(--mobile-status-width) minmax(0, 1fr) var(--mobile-preview-width) var(--mobile-activity-width);
        grid-template-rows: calc(var(--game-card-size) * 2) minmax(0, 1fr);
        grid-template-areas:
            "opponent board preview activity"
            "self hand preview activity";
        gap: 2px;
    }

    body.game-active .player-strip { gap: .18rem; padding: .28rem; border-radius: 3px; }
    body.game-active .game-brand { display: flex; align-items: center; justify-content: center; padding: 0 0 .2rem; }
    body.game-active .game-brand > strong { display: none; }
    body.game-active .game-connection { font-size: .54rem; }
    body.game-active .player-identity { gap: 0; text-align: center; }
    body.game-active .player-identity strong { overflow: hidden; font-size: .68rem; line-height: 1.05; text-overflow: ellipsis; white-space: nowrap; }
    body.game-active .player-strip small { font-size: .56rem; }
    body.game-active .ward { margin: 0; padding: .18rem .1rem; font-size: .58rem; }
    body.game-active .ward strong { font-size: .82rem; }
    body.game-active .presence { font-size: .54rem; text-align: center; }
    body.game-active .player-strip .power,
    body.game-active .opponent-power {
        display: grid;
        width: 100%;
        grid-column: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 2px;
        justify-content: stretch;
    }
    body.game-active .player-strip .power__item,
    body.game-active .opponent-power .power__item {
        display: grid;
        min-width: 0;
        min-height: 0;
        place-items: center;
        padding: 1px;
        border-width: 2px;
        border-radius: 3px;
        font-size: 0;
        line-height: 1;
    }
    body.game-active .player-strip .power__item strong,
    body.game-active .opponent-power .power__item strong { font-size: .66rem; }
    body.game-active .side-match-status { gap: .12rem; margin-top: 0; padding-top: .2rem; font-size: .52rem; }
    body.game-active .side-match-status .countdown { font-size: .62rem; }
    body.game-active .keyword-help,
    body.game-active .match-details { margin-top: 0; }
    body.game-active .keyword-help > summary,
    body.game-active .match-details > summary { padding: .18rem .1rem; font-size: .54rem; }
    body.game-active .keyword-help__panel { position: fixed; right: 4px; bottom: 4px; left: calc(var(--mobile-status-width) + 4px); width: auto; max-height: calc(100dvh - 8px); overflow-y: auto; }
    body.game-active .match-details .session-panel { position: fixed; right: 4px; bottom: 4px; left: calc(var(--mobile-status-width) + 4px); width: auto; }

    body.game-active .board { border-radius: 3px; }
    body.game-active .battlefield { align-content: start; }
    body.game-active .hand { grid-template-columns: repeat(5, var(--game-card-size)); align-content: start; }
    body.game-active .school-column { grid-template-rows: 14px repeat(4, var(--game-card-size)); }
    body.game-active .school-column__header { border-bottom-width: 2px; }
    body.game-active .school-column__header strong { width: 1.2rem; height: 1.2rem; border-width: 2px; font-size: .62rem; }
    body.game-active .card { border-width: 2px; }
    body.game-active .card h3 { right: 2px; bottom: 18px; left: 2px; max-height: 2.05em; font-size: clamp(.42rem, 1.45vw, .62rem); }
    body.game-active .card__cost,
    body.game-active .card__attack,
    body.game-active .card__health { width: 1rem; height: 1rem; font-size: .56rem; }
    body.game-active .creature .creature__statuses { right: 18px; font-size: .4rem; }

    body.game-active .card-preview {
        grid-template-rows: minmax(105px, 42%) minmax(0, 1fr);
        gap: .3rem;
        padding: .32rem;
        border-width: 2px;
    }
    body.game-active .card-preview__visual { width: min(100%, 150px); height: auto; aspect-ratio: 1; }
    body.game-active .card-preview h2 { margin-bottom: .18rem; font-size: .9rem; line-height: 1.05; }
    body.game-active .card-preview p { margin-bottom: .2rem; font-size: .62rem; line-height: 1.22; }
    body.game-active .card-preview__cost { top: .2rem; right: .2rem; width: 1.45rem; height: 1.45rem; font-size: .72rem; }
    body.game-active .card-preview__stats { gap: .2rem; }
    body.game-active .card-preview__stat { min-width: 0; gap: .15rem; padding: .16rem .25rem; }
    body.game-active .card-preview__stat small { font-size: .52rem; }
    body.game-active .card-preview__stat strong { font-size: .72rem; }
    body.game-active .card-preview__keywords { gap: .15rem; }
    body.game-active .card-preview__keyword { padding: .15rem .25rem; font-size: .5rem; }

    body.game-active .activity-panel { grid-template-rows: auto minmax(0, 1fr); gap: 2px; }
    body.game-active .side-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 30px; align-content: start; gap: 2px; }
    body.game-active .side-controls .drag-hint { display: none; }
    body.game-active .side-controls .button { height: 30px; min-height: 30px; padding: .2rem .1rem; font-size: .58rem; }
    body.game-active #game.target-selection-active #cancel-selection { display: block !important; grid-column: 1 / -1; }
    body.game-active #confirm-no-target-card { grid-column: 1 / -1; animation: confirm-card-pulse .9s ease-in-out infinite alternate; }
    body.game-active #game.target-selection-active #target-hint {
        position: fixed;
        right: 4px;
        bottom: calc(34px + max(4px, env(safe-area-inset-bottom)));
        left: 4px;
        z-index: 24;
        display: block;
        width: max-content;
        max-width: calc(100vw - 8px);
        margin: auto;
        padding: .28rem .55rem;
        border: 1px solid var(--gold);
        border-radius: 999px;
        background: rgba(8, 11, 17, .94);
        color: #fff;
        font-size: .68rem;
        font-weight: 800;
        line-height: 1.15;
        text-align: center;
        pointer-events: none;
        box-shadow: 0 5px 18px rgba(0, 0, 0, .7);
    }
    body.game-active .hand .card.selected {
        z-index: 12;
        border-color: var(--gold-bright);
        outline: 3px solid rgba(242, 204, 117, .9);
        outline-offset: -3px;
        box-shadow: 0 0 18px rgba(242, 204, 117, .9);
    }
    body.game-active .activity-panel .event-panel { padding: .3rem; }
    body.game-active .activity-panel h2 { margin-bottom: .15rem; font-size: .72rem; }
    body.game-active .activity-panel .event-log { gap: .2rem; padding-left: .9rem; font-size: .58rem; line-height: 1.2; }
    body.game-active .full-event-details { font-size: .54rem; }
    body.game-active .full-event-details > summary { padding-top: .2rem; }
    body.game-active .chat-placeholder { display: none; }

    body.game-active .match-result { inset: 4px; overflow-y: auto; }
    body.game-active .match-result--collapsed { inset: 4px 4px auto auto; width: min(220px, 55vw); }

    body.library-active {
        --mobile-status-width: clamp(72px, 11vw, 96px);
        --mobile-preview-width: clamp(145px, 22vw, 190px);
        --mobile-activity-width: clamp(100px, 15vw, 132px);
        --game-card-size: min(
            calc((100dvh - 16px) / 6.15),
            calc((100vw - var(--mobile-status-width) - var(--mobile-preview-width) - var(--mobile-activity-width) - 8px) / 6)
        );
        min-width: 320px;
    }
    .card-library { --library-card-size: clamp(88px, 11vw, 124px); }
    .card-library__header { min-height: 44px; padding: .3rem .5rem; }
    .card-library__header .eyebrow { display: none; }
    .card-library__header h2 { font-size: 1rem; }
    .card-library__header .button { padding: .42rem .65rem; }
    .leaderboard__header { min-height: 44px; padding: .3rem .5rem; }
    .leaderboard__header .eyebrow { display: none; }
    .leaderboard__header h2 { font-size: 1rem; }
    .leaderboard__header .button { padding: .42rem .65rem; }
    .leaderboard__content { padding: .35rem; }
    .leaderboard th, .leaderboard td { padding: .5rem .55rem; font-size: .72rem; }
    .card-library__layout { grid-template-columns: minmax(150px, 25vw) minmax(0, 1fr); gap: 2px; padding: 2px; }
    .library-card-preview { grid-template-rows: minmax(100px, 42%) minmax(0, 1fr); gap: .25rem; padding: .3rem; }
    .library-card-preview .card-preview__visual { width: min(100%, 150px); }
    .library-card-preview h2 { font-size: .9rem; }
    .library-card-preview p { font-size: .62rem; line-height: 1.2; }

    .topbar {
        align-items: center;
        flex-direction: row;
        padding: .45rem max(.55rem, env(safe-area-inset-right)) .45rem max(.55rem, env(safe-area-inset-left));
    }
    .topbar .eyebrow { display: none; }
    .topbar h1 { font-size: 1.25rem; }
    .topbar .connection { font-size: .72rem; }
    main { padding: .35rem; }
    .lobby { gap: .4rem; padding: .5rem; }
    .lobby__intro .eyebrow { margin-bottom: .15rem; font-size: .62rem; }
    .lobby__intro h2 { margin-bottom: 0; font-size: clamp(1.2rem, 4.5vw, 1.7rem); line-height: 1.05; }
    .lobby__description { display: none; }
    .account-statistics { margin-top: .45rem; padding: .55rem; }
    .account-statistics__header { gap: .55rem; }
    .account-level { min-width: 58px; padding: .35rem .45rem; }
    .account-level span { font-size: .55rem; }
    .account-level strong { font-size: 1.25rem; }
    .account-progress__label { align-items: flex-start; flex-direction: column; gap: .1rem; }
    .account-progress__label strong { font-size: .72rem; }
    .account-progress__label span { font-size: .62rem; }
    .account-statistics__modes { gap: .3rem; margin-top: .4rem; }
    .account-statistics__modes article { padding: .4rem; }
    .account-statistics__modes article > strong { font-size: .68rem; }
    .account-statistics__modes article > span { font-size: .66rem; }
    .account-statistics__modes article > small { font-size: .56rem; }
    .account-statistics__note { margin-top: .35rem; font-size: .58rem; }
    .lobby__form { gap: .35rem; padding: .5rem; }
    .lobby__form label > span,
    .lobby__form legend { margin-bottom: .2rem; font-size: .72rem; }
    .lobby__form label > small { display: none; }
    .lobby__form fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem; }
    .lobby__form .choice { gap: .35rem; min-height: 44px; padding: .35rem; }
    .lobby__form .choice small { font-size: .62rem; }
    .lobby__form input { min-height: 44px; padding: .55rem .7rem; }
    .lobby__form .divider { min-height: 16px; }
    .lobby__form .matchmaking-status,
    .lobby__form .error { min-height: .9rem; font-size: .68rem; }
    .asset-preload { padding: .35rem .45rem; }
    .asset-preload > div { font-size: .62rem; }
    .lobby .button, .lobby input, .waiting .button { min-height: 44px; }
    .fullscreen-prompt { padding: .55rem; }
    .fullscreen-prompt .button--primary { min-width: 0; }
}

@media (max-width: 999px) and (orientation: portrait) {
    body.game-active {
        --game-card-size: min(calc((100vw - 4px) / 6), calc((100dvh - 280px) / 6));
    }
    body.game-active #game {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 42px calc(var(--game-card-size) * 2) 42px calc(var(--game-card-size) * 4 + 14px) minmax(120px, 1fr) 34px;
        grid-template-areas:
            "opponent"
            "board"
            "self"
            "hand"
            "preview"
            "activity";
    }
    body.game-active .player-strip { flex-direction: row; align-items: center; gap: .25rem; padding: .2rem .3rem; }
    body.game-active .game-brand { display: none; }
    body.game-active .player-identity { min-width: 58px; text-align: left; }
    body.game-active .ward { width: auto; min-width: 62px; }
    body.game-active .player-strip .power,
    body.game-active .opponent-power { width: auto; flex: 1; grid-template-columns: repeat(5, minmax(28px, 1fr)); }
    body.game-active .presence { display: none; }
    body.game-active .side-match-status { width: 52px; margin-left: auto; padding: 0; border: 0; }
    body.game-active .keyword-help,
    body.game-active .match-details { display: none; }
    body.game-active .battlefield { align-content: center; }
    body.game-active .card-preview { grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
    body.game-active .card-preview__visual { height: 100%; width: auto; max-width: 100%; }
    body.game-active .activity-panel { grid-template-rows: 1fr; }
    body.game-active .side-controls { grid-template-columns: 1fr 1fr; }
    body.game-active #game.card-confirmation-active,
    body.game-active #game.target-selection-active {
        grid-template-rows: 42px calc(var(--game-card-size) * 2) 42px calc(var(--game-card-size) * 4 + 14px) minmax(120px, 1fr) 64px;
    }
    body.game-active .side-controls .button { min-height: 30px; }
    body.game-active .activity-panel .event-panel { display: none; }

    body.library-active { --game-card-size: min(calc((100vw - 4px) / 6), calc((100dvh - 280px) / 6)); }
    .card-library { --library-card-size: clamp(82px, 23vw, 104px); }
    .card-library__layout { grid-template-columns: 1fr; grid-template-rows: minmax(160px, 38%) minmax(0, 1fr); }
    .library-card-preview { grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
    .library-card-preview .card-preview__visual { height: 100%; width: auto; max-width: 100%; }
}

@media (max-width: 999px) and (hover: none) {
    body.game-active .hand .card:not(.inactive):not(.unaffordable):hover,
    .card-library .library-card:hover { transform: none; }
}

@keyframes confirm-card-pulse {
    from { filter: brightness(.92); box-shadow: 0 0 0 rgba(242, 204, 117, 0); }
    to { filter: brightness(1.18); box-shadow: 0 0 14px rgba(242, 204, 117, .85); }
}

@media (prefers-reduced-motion: reduce) {
    body.game-active #confirm-no-target-card { animation: none; }
}
/* Account access */
.topbar__actions,
.account-actions,
.account-profile {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.button--compact {
    min-height: 34px;
    padding: 0.4rem 0.75rem;
}

.account-dialog {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    background: rgba(5, 7, 12, 0.82);
    backdrop-filter: blur(5px);
}

.account-dialog[hidden],
.account-form[hidden] {
    display: none;
}

.account-card {
    width: min(460px, 100%);
    max-height: 94dvh;
    overflow: auto;
    padding: 1.25rem;
}

.account-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.account-card__header h2,
.account-card__header p {
    margin: 0;
}

.auth-choice,
.account-form {
    display: grid;
    gap: 0.8rem;
}

.auth-provider {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.account-form label:not(.account-check) {
    display: grid;
    gap: 0.35rem;
}

.account-form input:not([type="checkbox"]) {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
}

.account-check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    line-height: 1.35;
}

.account-check input {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.account-message {
    color: #9cddb0;
    line-height: 1.45;
}

@media (max-width: 720px) {
    .topbar__actions {
        gap: 0.35rem;
    }

    .account-actions .button,
    .account-profile .button {
        min-height: 40px;
        padding-inline: 0.6rem;
        font-size: 0.85rem;
    }

    .topbar__actions > .connection {
        display: none;
    }

    .account-card {
        padding: 1rem;
    }
}
.language-switcher {
    display: inline-flex;
    gap: 0.2rem;
    padding: 0.18rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: rgba(10, 12, 18, 0.72);
}

.language-switcher__button {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 2rem;
    padding: 0.24rem 0.45rem;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.language-switcher__button:hover,
.language-switcher__button--active {
    color: var(--text);
    border-color: var(--gold);
    background: rgba(193, 145, 53, 0.15);
}

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; }
    .topbar h1 { font-size: 1.05rem; }
    .topbar__actions { flex: 1; justify-content: flex-end; flex-wrap: wrap; }
    .language-switcher__button { min-height: 34px; padding-inline: 0.35rem; }
    .language-switcher__button span { display: none; }
    .account-actions .button,
    .account-profile .button { padding-inline: 0.45rem; font-size: 0.74rem; }
}
body.platform-paused *,
body.platform-paused *::before,
body.platform-paused *::after {
    animation-play-state: paused !important;
}
