:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    --ink: #f4efe8;
    --muted: #aaa2b2;
    --night: #0d0b12;
    --panel: #18141f;
    --panel-high: #211a29;
    --line: #3b3046;
    --gold: #e8b762;
    --gold-bright: #ffd58b;
    --violet: #9f7aea;
    --red: #d76770;
    --green: #78c49b;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--night); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 0%, rgb(77 47 99 / 30%), transparent 36rem),
        radial-gradient(circle at 90% 30%, rgb(111 62 45 / 20%), transparent 32rem),
        var(--night);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .15;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E");
}

a { color: inherit; }
button, input, select { font: inherit; }

button, .button-link {
    border: 1px solid transparent;
    border-radius: .25rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: .7rem 1.2rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover:not(:disabled), .button-link:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary { background: var(--gold); color: #211608; }
.primary:hover:not(:disabled) { background: var(--gold-bright); }
.primary.danger {
    border-color: #b7545f;
    background: #8e3945;
    color: #fff2f3;
}
.primary.danger:hover:not(:disabled) { background: #a94753; }
.secondary { color: var(--ink); background: transparent; border-color: #675475; }
.secondary:hover:not(:disabled) { background: #2a2132; border-color: var(--violet); }

input, select {
    width: 100%;
    min-height: 3rem;
    border: 1px solid #51425e;
    border-radius: .25rem;
    padding: .7rem .8rem;
    background: #110e16;
    color: var(--ink);
}

input::placeholder { color: #716879; }
label { display: grid; gap: .45rem; color: #d3cad8; font-size: .84rem; font-weight: 600; }
form { display: grid; gap: 1rem; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand, .room-code, .room-code-large {
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: -.02em;
}

.panel {
    border: 1px solid var(--line);
    border-radius: .4rem;
    background: linear-gradient(145deg, rgb(32 26 40 / 94%), rgb(21 17 27 / 96%));
    box-shadow: 0 1.25rem 4rem rgb(0 0 0 / 25%);
}

.eyebrow, .step {
    margin: 0 0 .65rem;
    color: var(--gold);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.muted, .empty { color: var(--muted); }

.gesture-glyph {
    --gesture-color: #cbb6ee;
    position: relative;
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 3.4rem;
    aspect-ratio: 1;
    border: 1px solid color-mix(in srgb, var(--gesture-color) 55%, #33293d);
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--gesture-color) 18%, transparent), transparent 65%),
        #17121d;
    color: var(--gesture-color);
    box-shadow: inset 0 0 1.2rem rgb(0 0 0 / 28%);
    vertical-align: middle;
}

.gesture-glyph svg {
    width: 76%;
    height: 76%;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gesture-glyph .gesture-accent { stroke: var(--gold-bright); }
.gesture-glyph-fingers { --gesture-color: #bca3ef; }
.gesture-glyph-palm { --gesture-color: #e8b762; }
.gesture-glyph-snap { --gesture-color: #e894b9; }
.gesture-glyph-wave { --gesture-color: #89bfee; }
.gesture-glyph-point { --gesture-color: #e69678; }
.gesture-glyph-clap { --gesture-color: #7fc9b3; }
.gesture-glyph-stab { --gesture-color: #dc747c; }
.auto-queue-glyph { --gesture-color: #9dd6c2; }
.auto-queue-glyph .auto-orbit { stroke-width: 3; }
.auto-queue-glyph .auto-arrow {
    fill: none;
    stroke-width: 3;
}
.auto-queue-glyph .auto-letter {
    stroke: #f4e8ca;
    stroke-width: 4;
}
.gesture-glyph-xs { width: 1.65rem; }
.gesture-glyph-xs svg { width: 72%; height: 72%; stroke-width: 3.2; }
.gesture-glyph-sm { width: 2.35rem; }
.gesture-glyph-md { width: 3.4rem; }
.gesture-glyph-lg { width: 4.5rem; }
.gesture-glyph-xl { width: 5.25rem; }

.gesture-token {
    position: absolute;
    right: -.22rem;
    bottom: -.16rem;
    display: grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .2rem;
    border: 1px solid #655470;
    border-radius: 50%;
    background: #0e0b12;
    color: var(--ink);
    font: 700 .62rem/1 ui-monospace, monospace;
    letter-spacing: 0;
}

.gesture-glyph-xs .gesture-token {
    right: -.3rem;
    bottom: -.28rem;
    min-width: .9rem;
    height: .9rem;
    font-size: .48rem;
}

.auto-queue-glyph .gesture-token {
    right: -.58rem;
    min-width: 1.7rem;
    padding-inline: .2rem;
    font-size: .46rem;
}

.landing {
    width: min(76rem, calc(100% - 2rem));
    min-height: 100vh;
    margin: auto;
    padding: clamp(3rem, 8vw, 7rem) 0 2rem;
}

.hero { max-width: 54rem; margin-bottom: clamp(3rem, 6vw, 5.5rem); }
.hero h1 {
    margin: 0;
    font-size: clamp(4rem, 12vw, 9rem);
    line-height: .78;
    font-weight: 600;
    text-transform: uppercase;
    text-shadow: 0 0 4rem rgb(159 122 234 / 20%);
}
.lede { max-width: 42rem; margin: 2rem 0 0; color: #c5bec9; font-size: 1.15rem; line-height: 1.75; }
.service-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem .7rem;
    width: fit-content;
    margin-top: 1.35rem;
    padding: .6rem .8rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgb(13 11 18 / 75%);
    color: var(--muted);
    font-size: .78rem;
}
.service-status strong { color: var(--ink); }
.status-light {
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 .7rem color-mix(in srgb, var(--green) 70%, transparent);
}
.status-light.status-draining { background: var(--gold); }
.status-light.status-sealed { background: var(--red); }

.gesture-language { margin: 2.5rem 0; }
.gesture-language .section-heading { margin-bottom: 1rem; }
.gesture-language .section-heading > p {
    max-width: 22rem;
    margin: 0;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.5;
    text-align: right;
}
.gesture-language h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.3rem); }
.gesture-legend { display: grid; grid-template-columns: repeat(7, 1fr); gap: .55rem; }
.gesture-legend article {
    min-width: 0;
    display: grid;
    justify-items: center;
    gap: .8rem;
    padding: 1rem .55rem .85rem;
    border: 1px solid var(--line);
    border-radius: .35rem;
    background: rgb(21 17 27 / 72%);
    text-align: center;
}
.gesture-legend article > div { display: grid; gap: .18rem; }
.gesture-legend strong { font-family: Georgia, "Times New Roman", serif; font-size: .92rem; }
.gesture-legend article > div span { color: var(--muted); font-size: .65rem; letter-spacing: .09em; text-transform: uppercase; }

.entry-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.entry-panel { padding: clamp(1.4rem, 3vw, 2.2rem); }
.entry-panel h2 { margin-bottom: 1.5rem; font-size: clamp(1.45rem, 3vw, 2rem); }
.code-input { letter-spacing: .2em; text-transform: uppercase; }
.landing-note {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    padding: 2rem 0 0;
    color: #817888;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.landing-note span::before { content: "◇"; margin-right: .6rem; color: var(--gold); }

.centered-page {
    width: min(36rem, calc(100% - 2rem));
    min-height: 100vh;
    margin: auto;
    display: grid;
    align-content: center;
    gap: 1.25rem;
    padding: 2rem 0;
}
.back-link { color: var(--muted); text-decoration: none; font-size: .86rem; }
.back-link:hover { color: var(--ink); }
.join-card, .state-card { padding: clamp(1.5rem, 5vw, 3rem); }
.join-card .room-code { margin: 0 0 1rem; color: var(--gold-bright); font-size: clamp(3rem, 12vw, 5rem); letter-spacing: .12em; }
.join-card > p:not(.eyebrow, .notice) { color: var(--muted); }

.notice {
    width: min(72rem, calc(100% - 2rem));
    margin: 1rem auto;
    border: 1px solid;
    border-radius: .25rem;
    padding: .8rem 1rem;
}
.notice.error { border-color: #7e3e47; background: #32181d; color: #ffc6c9; }
.notice.warning { border-color: #735e39; background: #2b2316; color: #f3d59b; }

.game-shell { width: min(88rem, calc(100% - 2rem)); min-height: 100vh; margin: auto; padding-bottom: 4rem; }
.game-shell.help-active {
    width: min(88rem, calc(100% - 28rem));
    margin-right: 27rem;
}
.game-header {
    min-height: 5rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); font-weight: 700; text-decoration: none; letter-spacing: .08em; }
.turn-marker { display: flex; align-items: baseline; gap: .65rem; }
.turn-marker span { color: var(--muted); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.turn-marker strong { color: var(--gold); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: .7rem; }
.help-toggle {
    min-height: 2rem;
    gap: .35rem;
    padding: .35rem .55rem;
    border-color: #675475;
    background: transparent;
    color: var(--muted);
    font-size: .72rem;
}
.help-toggle:hover, .help-toggle.active {
    border-color: var(--gold);
    background: rgb(99 70 42 / 28%);
    color: var(--gold-bright);
}
.help-toggle svg {
    width: 1.1rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 1.7;
}
.help-toggle .help-dot { fill: currentColor; stroke: none; }
.connection { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.status-dot { display: inline-block; width: .55rem; height: .55rem; margin-right: .45rem; border-radius: 50%; background: var(--red); box-shadow: 0 0 .7rem var(--red); }
.connection.online .status-dot { background: var(--green); box-shadow: 0 0 .7rem var(--green); }
.debug-view-toggle {
    min-height: 2rem;
    padding: .35rem .55rem;
    border-color: #50435a;
    background: #110e16;
    color: var(--muted);
    font-size: .64rem;
    letter-spacing: .04em;
    white-space: nowrap;
}
.debug-view-toggle:hover { border-color: #786584; color: var(--ink); }
.debug-view-toggle.active {
    border-color: var(--gold);
    background: rgb(99 70 42 / 28%);
    color: var(--gold-bright);
}
.debug-view-toggle span { margin-right: .28rem; }

.help-panel {
    position: fixed;
    z-index: 80;
    top: 1rem;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    width: 25rem;
    overflow: hidden;
    border: 1px solid #564564;
    border-radius: .4rem;
    background: rgb(24 20 31 / 98%);
    box-shadow: -1rem 0 3rem rgb(0 0 0 / 38%);
}
.help-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.2rem .9rem;
    border-bottom: 1px solid var(--line);
}
.help-panel-header .eyebrow { margin-bottom: .3rem; }
.help-panel-header h1 { margin: 0; color: var(--gold-bright); font-size: 1.55rem; }
.help-close {
    min-width: 2rem;
    min-height: 2rem;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    font-size: 1.45rem;
}
.help-close:hover { border-color: var(--line); background: var(--panel-high); color: var(--ink); }
.help-history {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .55rem .8rem;
    border-bottom: 1px solid var(--line);
    background: #120f18;
}
.help-history button {
    min-width: 2rem;
    min-height: 2rem;
    padding: .2rem .45rem;
    border-color: #51425e;
    background: transparent;
    color: var(--ink);
    font-size: .76rem;
}
.help-history .help-index-button { min-width: auto; }
.help-undock {
    margin-left: auto;
    color: var(--muted);
    font-size: .7rem;
    text-decoration: none;
}
.help-undock:hover { color: var(--gold-bright); }
.help-scroll {
    overflow: auto;
    padding: 1.2rem;
    scrollbar-color: #5f4e6d transparent;
}
.help-summary {
    margin-bottom: 1.4rem;
    color: #cabfd0;
    font-size: .9rem;
    line-height: 1.55;
}
.help-topic-body { color: #e7dfe9; font-size: .92rem; line-height: 1.65; }
.help-topic-body h2 {
    margin: 1.6rem 0 .55rem;
    color: var(--gold);
    font-size: 1.15rem;
}
.help-topic-body h3 { margin: 1.25rem 0 .45rem; font-size: 1rem; }
.help-topic-body p, .help-topic-body li { color: #d2c8d6; }
.help-topic-body ul { padding-left: 1.25rem; }
.help-inline-link {
    display: inline;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--gold-bright);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: .15em;
}
.help-inline-link:hover { transform: none !important; color: #fff0c7; }
.help-topic-index {
    margin-top: 1.6rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}
.help-topic-index h2 { color: var(--gold); font-size: 1.1rem; }
.help-topic-index ol { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.help-topic-index button {
    display: grid;
    justify-content: stretch;
    width: 100%;
    min-height: 0;
    padding: .75rem;
    border-color: #4d3e58;
    background: #120f18;
    color: var(--ink);
    text-align: left;
}
.help-topic-index button:hover { border-color: var(--violet); background: var(--panel-high); }
.help-topic-index button span {
    margin-top: .2rem;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 400;
    line-height: 1.4;
}

.standalone-help {
    width: min(48rem, calc(100% - 2rem));
    min-height: 70vh;
    margin: 3rem auto;
    padding: clamp(1.5rem, 5vw, 3rem);
    border: 1px solid var(--line);
    border-radius: .4rem;
    background: rgb(24 20 31 / 95%);
    box-shadow: 0 1rem 4rem rgb(0 0 0 / 30%);
}
.standalone-help > header .brand { display: inline-block; margin-bottom: 2.5rem; }
.standalone-help > header h1 {
    margin-bottom: .55rem;
    color: var(--gold-bright);
    font-size: clamp(2rem, 6vw, 3rem);
}
.standalone-help-nav {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.5rem 0 2rem;
    padding: .8rem 0;
    border-block: 1px solid var(--line);
    color: var(--muted);
    font-size: .76rem;
}
.standalone-help-nav a { color: var(--gold-bright); font-weight: 700; }

.waiting-stage { max-width: 46rem; margin: 10vh auto 0; text-align: center; }
.waiting-stage h1 { margin-bottom: .75rem; font-size: clamp(3rem, 8vw, 6rem); }
.waiting-stage > p:not(.eyebrow, .room-code-large) { color: var(--muted); }
.waiting-stage label { max-width: 36rem; margin: 2rem auto .7rem; text-align: left; }
.invite-link { text-align: center; color: var(--gold-bright); }
.room-code-large { margin: 2.5rem 0 .5rem; color: var(--gold); font-size: 3rem; letter-spacing: .18em; }
.sigil { color: var(--gold); font-size: 5rem; text-shadow: 0 0 2.5rem var(--violet); }
.sigil.small { font-size: 2.5rem; }

.arena {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: clamp(1rem, 4vw, 4rem);
    padding: clamp(2rem, 6vw, 5rem) clamp(0rem, 3vw, 2rem);
}
.duelist { min-width: 0; }
.duelist-right { text-align: right; }
.duelist-name > span { color: var(--gold); font-size: .65rem; font-weight: 700; letter-spacing: .18em; }
.duelist h2 { margin: .25rem 0 .75rem; overflow: hidden; text-overflow: ellipsis; font-size: clamp(1.55rem, 4vw, 3rem); white-space: nowrap; }
.duelist.dead { opacity: .55; filter: grayscale(.6); }
.health { height: .45rem; overflow: hidden; border-radius: 2rem; background: #352d3a; }
.health span { display: block; height: 100%; background: linear-gradient(90deg, #b7505a, var(--gold)); }
.vitals { margin-top: .45rem; color: var(--muted); font-size: .75rem; }
.vitals strong { color: var(--ink); font-size: 1.2rem; }
.vitals small { margin-left: .6rem; }
.histories { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.duelist-right .histories, .duelist-right .status-pills { justify-content: flex-end; }
.history-strip {
    min-height: 2.15rem;
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    padding: .25rem .48rem;
    border: 1px solid var(--line);
    color: #c9bfd0;
}
.history-strip b { color: var(--gold); font: 700 .64rem/1 ui-monospace, monospace; }
.history-strip .gesture-glyph { border-color: #4b3d56; }
.history-empty { min-width: 1.35rem; color: var(--muted); text-align: center; }
.status-pills { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.status-pills span { border: 1px solid #6b527b; border-radius: 2rem; padding: .2rem .5rem; color: #d6bfeb; font-size: .65rem; }
.phase-orb {
    width: clamp(5rem, 10vw, 7rem);
    aspect-ratio: 1;
    display: grid;
    place-content: center;
    text-align: center;
    border: 1px solid #806490;
    border-radius: 50%;
    background: radial-gradient(circle, #30213c, #15111b 70%);
    box-shadow: 0 0 3rem rgb(159 122 234 / 20%), inset 0 0 1rem rgb(232 183 98 / 10%);
}
.phase-orb span, .phase-orb small { color: var(--muted); font-size: .55rem; letter-spacing: .15em; text-transform: uppercase; }
.phase-orb strong { color: var(--gold-bright); font-family: Georgia, "Times New Roman", serif; font-size: 1.9rem; }

.action-panel, .results-panel { width: min(72rem, 100%); margin: 0 auto 1rem; padding: clamp(1.2rem, 3vw, 2rem); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.section-heading h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); }
.section-heading .eyebrow { margin-bottom: .3rem; }
.version, .count { color: var(--muted); font-size: .72rem; }
.count { min-width: 2rem; min-height: 2rem; display: inline-grid; place-content: center; border: 1px solid var(--line); border-radius: 50%; }
.hands-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.hand-card { padding: 1.1rem; border: 1px solid var(--line); background: #130f19; }
.hand-card label + label { margin-top: .8rem; }
.hand-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; color: var(--muted); font-size: .7rem; letter-spacing: .12em; }
.gesture-picker {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .45rem;
    margin: 0;
    padding: 0;
    border: 0;
}
.gesture-picker legend {
    width: 100%;
    margin-bottom: .5rem;
    color: #d3cad8;
    font-size: .84rem;
    font-weight: 600;
}
.gesture-choice {
    min-width: 0;
    min-height: 5.75rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    padding: .55rem .25rem;
    border-color: #3e3348;
    background: #100d15;
    color: var(--muted);
    font-size: .6rem;
    font-weight: 600;
    overflow: hidden;
}
.gesture-choice:hover:not(:disabled) { border-color: #755f84; background: #19131f; }
.gesture-choice.selected {
    border-color: var(--gold);
    background: linear-gradient(160deg, rgb(93 67 43 / 38%), #18121e 72%);
    color: var(--ink);
    box-shadow: inset 0 0 1.4rem rgb(232 183 98 / 8%);
}
.gesture-choice .gesture-glyph { width: 3rem; pointer-events: none; }
.gesture-choice > span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hand-card > label { margin-top: .9rem; }
.orders { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.orders label { grid-template-columns: 1fr minmax(12rem, .7fr); align-items: center; margin-top: .7rem; }
.commit-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }
.commit-row p { max-width: 36rem; margin: 0; color: var(--muted); font-size: .8rem; }
.locked-plan { display: flex; align-items: center; justify-content: center; gap: 1.25rem; min-height: 10rem; }
.locked-plan h2 { margin-bottom: .4rem; }
.locked-plan p:not(.eyebrow) { margin: 0; color: var(--muted); }
.decision { max-width: 42rem; margin: auto; padding: 1rem; text-align: center; }
.decision p:not(.eyebrow) { color: var(--muted); }
.button-pair { display: flex; justify-content: center; gap: .75rem; }
.reveal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.reveal-grid > div { display: flex; align-items: center; justify-content: space-between; padding: 1rem; background: #120f17; }
.revealed-gestures { display: flex; gap: .65rem; }
.event-log { margin: 1rem 0 0; padding: 0; list-style: none; }
.event-log li { padding: .7rem .8rem; border-bottom: 1px solid #2e2735; color: #c6becb; }
.event-log li::before { content: "◇"; margin-right: .7rem; color: #71627b; }
.event-log li.damage::before { color: var(--red); }
.event-log li.blocked::before, .event-log li.defense::before { color: var(--violet); }
.event-log li.heal::before, .event-log li.victory::before { color: var(--gold); }

.game-progress-panel {
    width: min(72rem, 100%);
    margin: 1rem auto 0;
    padding: 1.25rem;
}

.game-progress-panel summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    list-style: none;
}

.game-progress-panel summary::-webkit-details-marker { display: none; }
.game-progress-panel summary .eyebrow { display: block; margin-bottom: .18rem; }

.progress-log {
    max-height: 34rem;
    margin-top: 1rem;
    overflow: auto;
    border: 1px solid #302738;
    background: #100d15;
}

.progress-turn + .progress-turn { border-top: 1px solid var(--line); }

.progress-turn > header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem .75rem;
    border-bottom: 1px solid #302738;
    background: #1b1521;
}

.progress-turn > header strong {
    color: var(--gold);
    font: 700 .72rem/1 ui-monospace, monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.progress-turn > header small { color: var(--muted); font-size: .65rem; }
.progress-turn ol { margin: 0; padding: 0; list-style: none; }

.progress-entry {
    display: grid;
    grid-template-columns: 6.25rem minmax(0, 1fr) auto;
    align-items: start;
    gap: .75rem;
    padding: .65rem .75rem;
    border-bottom: 1px solid #292230;
    border-left: 2px solid #51415e;
}

.progress-entry:last-child { border-bottom: 0; }
.progress-entry.damage { border-left-color: var(--red); }
.progress-entry.blocked, .progress-entry.defense { border-left-color: var(--violet); }
.progress-entry.heal, .progress-entry.victory { border-left-color: var(--gold); }
.progress-entry.status, .progress-entry.summon { border-left-color: #78bca5; }

.progress-entry p {
    margin: 0;
    color: #d0c8d4;
    font-size: .75rem;
    line-height: 1.45;
}

.progress-entry > small {
    color: #7f7587;
    font: 600 .6rem/1.4 ui-monospace, monospace;
    white-space: nowrap;
}

.progress-kind {
    color: #a995b5;
    font: 700 .6rem/1.4 ui-monospace, monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.lower-grid { width: min(72rem, 100%); margin: 0 auto; display: grid; grid-template-columns: .85fr 1.15fr; gap: 1rem; }
.lower-grid > .panel { padding: 1.25rem; }
.creature-row { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.creature-row div { display: grid; }
.creature-row small, .creature-row > span { color: var(--muted); font-size: .72rem; }
.spellbook summary { cursor: pointer; display: flex; align-items: center; gap: 1rem; list-style: none; }
.spellbook summary::-webkit-details-marker { display: none; }
.spellbook summary .eyebrow { display: block; }
.spellbook-summary-title { min-width: 8rem; }
.spellbook-summary-tools {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-left: auto;
}
.spell-filter-compact {
    position: relative;
    width: clamp(9.5rem, 26vw, 19rem);
    display: flex;
    align-items: center;
}
.spell-filter-compact svg {
    position: absolute;
    left: .55rem;
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.7;
    stroke-linecap: round;
    pointer-events: none;
}
.spell-filter-compact input {
    width: 100%;
    min-height: 2.15rem;
    padding: .38rem .6rem .38rem 1.85rem;
    border: 1px solid var(--line);
    background: #110d16;
    font: 700 .75rem/1 ui-monospace, monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.spell-list { max-height: 32rem; margin-top: .75rem; overflow-y: auto; }
.spell-list article { padding: .8rem 0; border-top: 1px solid var(--line); }
.spell-list article > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.spell-sequences { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; }
.spell-sequence {
    display: inline-flex;
    gap: .2rem;
    padding: .32rem .5rem .42rem .25rem;
    border: 1px solid #3d3346;
    border-radius: 2rem;
    background: #100d15;
}
.spell-list p { margin: .3rem 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.spell-list .spell-filter-empty { padding: 1rem .25rem; border-top: 1px solid var(--line); }
.spell-filter-empty strong { color: var(--ink); font-family: ui-monospace, monospace; }

.duel-board {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 1rem;
    margin: 1rem 0;
}

.duel-board.single-board {
    grid-template-columns: minmax(0, 44rem);
    justify-content: center;
}

.player-board {
    min-width: 0;
    padding: clamp(1rem, 2vw, 1.4rem);
    border-top: 2px solid #685577;
}

.player-board.viewer-board { border-top-color: var(--gold); }
.player-board.opponent-board { border-top-color: #7a5a83; }
.player-board.dead { opacity: .6; filter: grayscale(.55); }

.player-board-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: .3rem 1rem;
}

.player-board-header .duelist-name { min-width: 0; }
.player-board-header h2 {
    margin: .18rem 0 0;
    overflow: hidden;
    font-size: clamp(1.45rem, 3vw, 2.4rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-board-header .vitals {
    margin: 0;
    text-align: right;
    white-space: nowrap;
}

.player-board-header .health { grid-column: 1 / -1; }

.player-assets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .7rem;
    margin: 1rem 0 .7rem;
}

.asset-group {
    min-width: 0;
    padding: .75rem;
    border: 1px solid var(--line);
    background: rgb(13 10 17 / 55%);
}

.asset-empty {
    margin: 0;
    color: var(--muted);
    font-size: .72rem;
}

.owned-creatures { display: grid; gap: .55rem; }
.owned-creature {
    display: grid;
    gap: .45rem;
    padding-top: .55rem;
    border-top: 1px solid #302838;
}

.owned-creature > div { display: grid; }
.owned-creature small { color: var(--muted); font-size: .66rem; }
.owned-creature label { gap: .28rem; color: var(--muted); font-size: .62rem; }
.owned-creature select { min-height: 2rem; padding: .32rem .45rem; font-size: .68rem; }
.owned-creature .skip-note { color: #d2a6db; }

.effect-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.effect-list span {
    border: 1px solid #6b527b;
    border-radius: 2rem;
    padding: .24rem .5rem;
    color: #d6bfeb;
    font-size: .65rem;
}

.hand-timelines {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
}

.hand-timeline {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #110d16;
}

.gesture-history {
    position: relative;
    display: grid;
    gap: .42rem;
    min-height: 5rem;
    margin: 0;
    padding: .7rem;
    list-style: none;
}

.gesture-history::before {
    position: absolute;
    top: .8rem;
    bottom: .35rem;
    left: 1.88rem;
    width: 1px;
    background: linear-gradient(#51415e, #795e83);
    content: "";
}

.gesture-history li {
    position: relative;
    display: grid;
    grid-template-columns: 2.35rem minmax(0, 1fr);
    align-items: center;
    gap: .55rem;
    min-width: 0;
}

.gesture-history li > small {
    overflow: hidden;
    color: var(--muted);
    font-size: .66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gesture-history li.sequence-interruption {
    margin-bottom: .28rem;
    padding-bottom: .7rem;
}

.gesture-history li.sequence-interruption::after {
    position: absolute;
    right: .1rem;
    bottom: 0;
    left: .1rem;
    border-bottom: 1px dashed #c75b67;
    content: "";
}

.gesture-history li.sequence-interruption > .gesture-glyph {
    border-color: #d45b67;
    box-shadow:
        inset 0 0 1.2rem rgb(142 40 53 / 25%),
        0 0 .7rem rgb(199 69 82 / 18%);
}

.sequence-break-word {
    margin-left: .28rem;
    color: #ef858e;
    font-size: .56rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.hand-timeline-left .gesture-history::before {
    right: 1.88rem;
    left: auto;
}

.hand-timeline-left .gesture-history li {
    grid-template-columns: minmax(0, 1fr) 2.35rem;
    text-align: right;
}

.hand-timeline-left .gesture-history li > .gesture-glyph {
    grid-row: 1;
    grid-column: 2;
}

.hand-timeline-left .gesture-history li > small {
    grid-row: 1;
    grid-column: 1;
}

.gesture-history .empty-history {
    display: flex;
    align-items: center;
    min-height: 3.5rem;
    padding-left: .2rem;
    color: var(--muted);
    font-size: .68rem;
}

.gesture-history .empty-history::before {
    width: .68rem;
    height: .68rem;
    margin-right: .55rem;
    border: 1px solid #6b5776;
    border-radius: 50%;
    background: #17121d;
    content: "";
}

.hand-timeline-left .gesture-history .empty-history {
    flex-direction: row-reverse;
    justify-content: flex-start;
    padding-right: .2rem;
    padding-left: 0;
    text-align: right;
}

.hand-timeline-left .gesture-history .empty-history::before {
    margin-right: 0;
    margin-left: .55rem;
}

.next-gesture {
    position: relative;
    min-height: 8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    padding: .8rem .45rem;
    border-top: 1px dashed #755f82;
    background: linear-gradient(#17111d, #100d15);
    text-align: center;
}

.next-gesture::before {
    position: absolute;
    top: -.3rem;
    left: calc(50% - .3rem);
    width: .6rem;
    height: .6rem;
    border: 1px solid #755f82;
    border-radius: 50%;
    background: #15101a;
    content: "";
}

.next-label {
    color: var(--gold);
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.next-gesture strong { max-width: 100%; font-size: .72rem; }
.next-gesture > small { color: var(--muted); font-size: .62rem; }
.own-next.sealed { opacity: .72; }

.hand-timeline-left .next-gesture {
    align-items: flex-end;
    padding-right: .7rem;
    text-align: right;
}

.hand-timeline-right .next-gesture {
    align-items: flex-start;
    padding-left: .7rem;
    text-align: left;
}

.hand-timeline-left .next-gesture::before {
    right: 1.88rem;
    left: auto;
}

.hand-timeline-right .next-gesture::before {
    right: auto;
    left: 1.88rem;
}

.empty-next-gesture {
    width: 4.5rem;
    aspect-ratio: 1;
    display: grid;
    place-content: center;
    border: 1px dashed #5b4967;
    border-radius: 50%;
    color: #887995;
    font: 700 1.6rem/1 ui-monospace, monospace;
}

.hidden-next {
    min-height: 10.75rem;
    color: #b8adbf;
}

.cloud-shape {
    position: relative;
    width: 3.8rem;
    height: 1.7rem;
    margin: .8rem 0 .55rem;
    border: 1px solid #796885;
    border-radius: 2rem;
    background: linear-gradient(180deg, #50465a, #2c2633);
    box-shadow: 0 .5rem 1.3rem rgb(0 0 0 / 30%);
}

.cloud-shape::before,
.cloud-shape::after {
    position: absolute;
    bottom: .45rem;
    border: 1px solid #796885;
    border-bottom: 0;
    border-radius: 50% 50% 0 0;
    background: #484050;
    content: "";
}

.cloud-shape::before { left: .55rem; width: 1.45rem; height: 1.45rem; }
.cloud-shape::after { right: .45rem; width: 1.8rem; height: 2rem; }

.timeline-picker {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .25rem;
    margin: 0;
    padding: .55rem;
    border: 0;
    border-top: 1px solid var(--line);
}

.timeline-choice {
    min-width: 0;
    min-height: 2.55rem;
    display: grid;
    place-content: center;
    padding: .25rem;
    border-color: #3e3348;
    background: #0d0a11;
}

.timeline-choice:hover:not(:disabled) { border-color: #755f84; background: #19131f; }
.timeline-choice.selected {
    border-color: var(--gold);
    background: rgb(99 70 42 / 35%);
    box-shadow: inset 0 0 1rem rgb(232 183 98 / 10%);
}

.timeline-choice .gesture-glyph { pointer-events: none; }
.timeline-choice.auto-choice {
    border-color: #416458;
    background: rgb(31 69 58 / 22%);
}
.timeline-choice.auto-choice:hover:not(:disabled) {
    border-color: #78bca5;
    background: rgb(44 100 81 / 28%);
}
.timeline-choice.auto-choice.selected {
    border-color: #8ed6bd;
    background: rgb(44 100 81 / 40%);
    box-shadow: inset 0 0 1rem rgb(142 214 189 / 12%);
}

.gesture-queue {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: .4rem;
    padding: .45rem .55rem;
    border-top: 1px solid var(--line);
    background: #0d0a11;
}

.queue-prefix {
    color: var(--gold);
    font: 700 .85rem/1 ui-monospace, monospace;
}

.gesture-queue input {
    min-width: 0;
    min-height: 2.1rem;
    padding: .35rem .5rem;
    font: 700 .72rem/1 ui-monospace, monospace;
    letter-spacing: .09em;
}

.queue-warning {
    grid-column: 1 / -1;
    color: #e5bd75;
    font-size: .65rem;
    line-height: 1.35;
}

.queue-position {
    grid-column: 1 / -1;
    color: #9acdbb;
    font-size: .65rem;
    line-height: 1.35;
    letter-spacing: .025em;
}

.queue-position strong {
    color: #d8f1e8;
    font-family: ui-monospace, monospace;
    letter-spacing: .08em;
}

.queue-position span {
    margin: 0 .2rem;
    color: var(--muted);
}

.planning-prompts {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.prompt-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}

.prompt-heading .eyebrow { margin-bottom: .2rem; }
.prompt-heading h3 { margin: 0; font-size: 1.05rem; }
.contextual-prompts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
    gap: .65rem;
    margin-top: .8rem;
}

.hand-prompt {
    display: grid;
    align-content: start;
    gap: .7rem;
    min-width: 0;
    padding: .75rem;
    border: 1px solid var(--line);
    background: #110d16;
}

.hand-prompt > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #d8cfdd;
    font-size: .7rem;
    font-weight: 700;
}

.hand-prompt label { gap: .32rem; color: var(--muted); font-size: .66rem; }
.hand-prompt select { min-height: 2.35rem; padding: .4rem .5rem; font-size: .72rem; }
.no-prompts { margin: .85rem 0 0; color: var(--muted); font-size: .75rem; }

.clap-warning {
    margin-top: .9rem;
    padding: .75rem .85rem;
    border: 1px solid #9c4652;
    background: rgb(75 25 33 / 65%);
    color: #ffd4d7;
}

.clap-warning strong { color: #fff0f1; }
.clap-warning p { margin: .25rem 0 0; font-size: .74rem; }
.clap-warning small { display: block; margin-top: .4rem; color: #f0a7ad; }

.plan-sealed {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: 1rem;
    padding: .85rem;
    border: 1px solid #675271;
    background: rgb(49 35 57 / 45%);
}

.plan-sealed > span {
    display: grid;
    place-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
}

.plan-sealed > div { display: grid; }
.plan-sealed small { color: var(--muted); font-size: .68rem; }
.board-spellbook { width: min(72rem, 100%); margin: 1rem auto 0; padding: 1.25rem; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.state-card { width: min(38rem, calc(100% - 2rem)); margin: 15vh auto 0; }

.site-attribution {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem 2rem;
    width: min(88rem, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 2rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.55;
}

.site-attribution p { margin: 0; }
.site-attribution strong,
.site-attribution cite { color: var(--ink); }
.site-attribution .attribution-label {
    margin-bottom: .25rem;
    color: var(--gold);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.site-attribution nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .65rem 1rem;
}

.site-attribution a {
    color: var(--gold-bright);
    text-underline-offset: .2em;
}

.site-attribution a:hover { color: var(--ink); }

.maintenance-banner {
    position: relative;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .35rem 1rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid #7b6132;
    background: #322713;
    color: #f8e4b7;
    font-size: .82rem;
    text-align: center;
}
.maintenance-banner span { color: #d8c69f; }
.maintenance-banner.mode-normal {
    border-color: var(--line);
    background: #15111b;
}
.maintenance-banner.mode-normal span { color: var(--muted); }

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 1000;
    padding: .8rem 3rem .8rem 1.25rem;
    background: #6e2830;
    box-shadow: 0 -2px 20px rgb(0 0 0 / 35%);
    color: white;
}

#blazor-error-ui .reload { margin-left: .5rem; color: #ffe4a8; }
#blazor-error-ui .dismiss {
    position: absolute;
    top: .45rem;
    right: .75rem;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: white;
    font-size: 1.3rem;
}

@media (max-width: 1200px) {
    .game-shell.help-active {
        width: min(88rem, calc(100% - 2rem));
        margin: auto;
    }
    .help-panel {
        width: min(25rem, calc(100% - 1rem));
        top: .5rem;
        right: .5rem;
        bottom: .5rem;
    }
}

@media (max-width: 720px) {
    .entry-grid, .hands-grid, .lower-grid, .reveal-grid, .duel-board { grid-template-columns: 1fr; }
    .gesture-language .section-heading > p { text-align: left; }
    .gesture-legend { grid-template-columns: repeat(2, 1fr); }
    .game-header { grid-template-columns: 1fr auto; }
    .turn-marker { display: none; }
    .arena { grid-template-columns: 1fr auto 1fr; gap: .75rem; padding: 2rem 0; }
    .phase-orb { width: 4.2rem; }
    .duelist h2 { font-size: 1.25rem; }
    .histories { flex-direction: column; }
    .duelist-right .histories { align-items: flex-end; }
    .commit-row, .section-heading { align-items: stretch; flex-direction: column; }
    .orders label { grid-template-columns: 1fr; }
    .player-assets, .contextual-prompts { grid-template-columns: 1fr; }
    .spellbook summary { gap: .55rem; }
    .spellbook-summary-title .eyebrow { display: none; }
    .spell-filter-compact { width: min(42vw, 12rem); }
    .connection { font-size: 0; }
    .connection .status-dot { margin: 0; }
    .header-actions { gap: .45rem; }
    .help-toggle span { display: none; }
    .help-toggle { padding-inline: .4rem; }
    .debug-view-toggle { font-size: 0; }
    .debug-view-toggle span { margin: 0; font-size: .85rem; }
    .progress-entry {
        grid-template-columns: 1fr auto;
        gap: .25rem .75rem;
    }
    .progress-entry p { grid-column: 1 / -1; grid-row: 2; }
    .site-attribution { grid-template-columns: 1fr; }
    .site-attribution nav {
        display: grid;
        justify-content: stretch;
    }
    .standalone-help { margin: 1rem auto; padding: 1.25rem; }
    .standalone-help-nav { align-items: flex-start; flex-direction: column; }
}

@media (min-width: 721px) and (max-width: 980px) {
    .gesture-legend { grid-template-columns: repeat(4, 1fr); }
    .gesture-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .player-assets { grid-template-columns: 1fr; }
}
