/*
 * Realm of Karguun: the 2005 look with modern comforts (docs/gdd/02-onboarding-screens.md).
 * Black page, Verdana 12px, dark-red and navy header rows, cream links. Works down to phone width without frames.
 */
:root {
    --bg: #000000;
    --fg: #fffffe;
    --muted: #b8b0a0;
    --link: #ffeecc;
    --link-visited: #ffddbb;
    --cream: #ffeecc;
    --hdr-red: #400000;
    --hdr-navy: #000040;
    --panel: #0a0a0a;
    --panel-green: #001000;
    --rule: #3a3a3a;
    --ok: #9fdf9f;
    --bad: #ff9f8f;
    --warn: #ffd27f;
    --gold: #d8b060;
    --button-face: #2a1a10;
    --button-light: #6a4a30;
    --button-dark: #120a05;
    --menu-width: 150px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--fg);
    font: 12px Verdana, "DejaVu Sans", Geneva, Tahoma, sans-serif;
    line-height: 1.4;
}

a { color: var(--link); text-decoration: none; }

/* Keyboard focus is always visible; the skip link appears when focused. */
:focus-visible { outline: 2px solid var(--warn); outline-offset: 1px; }
main:focus { outline: none; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 10; padding: 4px 10px; background: var(--hdr-red); color: var(--fg); border: 1px solid var(--warn); }
.skip-link:focus { top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
a:visited { color: var(--link-visited); }
a:hover, a:focus { text-decoration: underline; }

h1, h2 { font-size: 13px; font-weight: bold; color: var(--cream); margin: 14px 0 6px; }

.y { color: var(--cream); font-weight: bold; }
.small { font-size: 11px; color: var(--muted); }
.warn { color: var(--warn); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.label { color: var(--cream); }

/* ---------- Tables, the heart of the look ---------- */
.ktable { border-collapse: collapse; margin: 0 0 10px; background: var(--panel); }
.ktable th, .ktable td { border: 1px solid var(--rule); padding: 3px 7px; vertical-align: top; }
.ktable th { text-align: left; }
.ktable.wide { width: 100%; }
.ktable.narrow { width: 100%; max-width: 480px; }
.ktable.compact td, .ktable.compact th { padding: 2px 5px; font-size: 11px; }
.hdr-red, .hdr-red th, .hdr-red td { background: var(--hdr-red); font-weight: bold; color: var(--fg); }
.hdr-navy, .hdr-navy th, .hdr-navy td { background: var(--hdr-navy); font-weight: bold; color: var(--fg); }
.summary-box { background: #300000; }
.scroll-x { overflow-x: auto; max-width: 100%; margin-bottom: 10px; }
.scroll-x > .ktable { margin-bottom: 0; }
.scroll { overflow-x: auto; max-width: 100%; } /* the Chronicle's pipe tables and the Hall: a wide table scrolls in its own box, never the page */
.queue td.num { min-width: 34px; }
.sticky { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.hdr-navy .sticky { background: var(--hdr-navy); }
.hdr-red .sticky { background: var(--hdr-red); }
.two-col { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.two-col > .ktable { flex: 1 1 300px; }

/* ---------- Forms ---------- */
input, select, button, textarea { font: inherit; }
select, input { max-width: 100%; }
/* The target forms (Thievery, the Mystics, the War Room): a province's name with its acres and networth makes a long
   option, and a select in a table cell stays as wide as its longest option whatever its max-width, so on a phone the form
   pushed the page sideways. A percentage width lets the select shrink to its cell and the table to the page; max-content
   keeps each select no wider than its options where there is room, as before. */
.thief-op > .ktable select, .mystic-cast > .ktable select, form[data-keep="attack"] > .ktable select { width: 100%; max-width: max-content; }
input[type=text], input[type=number], input[type=password], input[type=email], input:not([type]), select {
    background: #111; color: var(--fg); border: 1px solid #555; padding: 3px 4px;
}
.small-input { width: 80px; }
button, .button {
    display: inline-block;
    background: var(--button-face);
    color: var(--cream);
    border: 2px solid;
    border-color: var(--button-light) var(--button-dark) var(--button-dark) var(--button-light);
    padding: 3px 12px;
    cursor: pointer;
    font-weight: bold;
}
button:active { border-color: var(--button-dark) var(--button-light) var(--button-light) var(--button-dark); }
button:not(:disabled):not(.linklike):not(.term):hover, .button:hover { background: #3a2414; text-decoration: none; }
/* An order on its way: its form waits (aria-busy), and a second press sends nothing. */
form[aria-busy="true"] button[type=submit] { opacity: 0.7; cursor: progress; }
/* An order that cannot be given now: dimmed, flat and not pressable (the reason is written beside it). */
button:disabled, input:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:active { border-color: var(--button-light) var(--button-dark) var(--button-dark) var(--button-light); }
.cant-cast { color: var(--muted); }
.linklike { background: none; border: none; padding: 0; font-weight: normal; }
form.inline, .inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; }
.stack { display: flex; flex-direction: column; gap: 6px; max-width: 360px; }
.stack label { display: flex; flex-direction: column; gap: 2px; }
.stack label.check { flex-direction: row; align-items: flex-start; gap: 6px; }
.stack label.check input { margin: 2px 0 0; flex: none; }
.check { display: block; margin: 3px 0; }
.next-age { max-width: 520px; }
.next-age label { display: block; padding-left: 22px; text-indent: -22px; }
.next-age label input { margin: 0 6px 0 0; vertical-align: middle; }
.next-age label .small { display: block; text-indent: 0; color: var(--muted, #bbb); }
.hall-ages { margin: 8px 0; }
.hall-ages a, .hall-ages strong { margin-right: 10px; }
.hall-boards td, .hall-boards th { padding: 2px 10px; }
/* M16: rulers' temperaments revealed in the Hall, and the line an intel report shows */
.hall-natures { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; }
.hall-natures .nature h3 { margin: 10px 0 2px; font-size: 13px; }
.nature-list { margin: 2px 0 4px; padding-left: 18px; }
.nature-changed { margin: 2px 0; color: var(--cream); }
.temperament-line { margin: 8px 0; max-width: 760px; }
fieldset { border: 1px solid var(--rule); margin: 0 0 8px; padding: 6px 10px; }
/* Standing orders: the "Set it for later" box inside the War Room, Thievery and Mystics forms. */
.launch-when { margin-top: 10px; min-width: 0; max-width: 100%; box-sizing: border-box; }
.launch-when label { display: inline-block; margin: 0 12px 6px 0; max-width: 100%; }
.launch-when select { max-width: 100%; }
.launch-when [hidden] { display: none; }
.launch-when .launch-ahead { font-weight: bold; }
.launch-fits, .order-fits { color: var(--ok); }
legend { color: var(--cream); font-weight: bold; padding: 0 4px; }
.form-table { width: 100%; max-width: 760px; }
.form-table td:first-child { width: 150px; }
.inline-details { display: inline-block; margin-left: 6px; }
.inline-details > summary { cursor: pointer; color: var(--link); }
.inline-details[open] { display: block; margin: 6px 0 0; }

/* ---------- Notices ---------- */
.notice { border: 1px solid var(--rule); padding: 6px 10px; margin: 6px 0 10px; background: #0d0d0d; }
.notice.ok { color: var(--ok); border-color: #2f5f2f; }
.notice.bad { color: var(--bad); border-color: #6f2f2f; }
/* The advisor's answer arrives: it slides in and its seal pops, unless motion is unwelcome. The welcome back is gold. */
@media (prefers-reduced-motion: no-preference) {
    .content > .notice:not(.looking-ahead) { animation: notice-in 0.35s ease-out; }
    .content > .notice:not(.looking-ahead)::before { animation: notice-pop 0.5s ease-out; }
    .notice.welcome .notice-emblem { animation: notice-pop 0.6s ease-out; }
}
@keyframes notice-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}
@keyframes notice-pop {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.35); opacity: 1; }
    100% { transform: scale(1); }
}
.notice.welcome { display: flex; align-items: center; gap: 8px; color: var(--gold); border-color: #8a7a32; background: linear-gradient(90deg, rgba(216, 176, 96, 0.16), #0d0d0d 70%); }
.notice.ok.welcome::before { content: none; }
.notice-emblem { flex: 0 0 26px; width: 26px; height: 26px; color: var(--gold); }
/* The advisor's seal: a tick for what was done, a cross for what was refused. */
.notice::before { float: left; margin-right: 6px; font-weight: bold; }
.notice.ok::before { content: "✓"; }
.notice.bad::before { content: "✗"; }
span.ok { color: var(--ok); }
/* Under a refusal the ruler can do something about: when it passes, or the page that helps. */
.notice .fix-it { display: block; margin-top: 4px; color: var(--cream); font-size: 11px; }
/* Some of a form's orders went through before one was refused: each reply on its own line, the last the refusal. */
.notice .notice-line { display: block; }
.notice .notice-line.done { color: var(--ok); }
.advisor { font-style: italic; max-width: 760px; }
.lead { color: var(--cream); font-weight: bold; }

/* ---------- Game frame: left menu, resource bar, content ---------- */
.frame { display: grid; grid-template-columns: var(--menu-width) 1fr; min-height: 100vh; }
.sidebar { background: #050505; border-right: 1px solid #222; padding: 8px 6px; }
.logo { display: block; color: var(--cream); font-weight: bold; font-size: 13px; text-align: center; padding: 6px 0 10px; letter-spacing: 1px; font-variant: small-caps; }
a.logo:visited { color: var(--cream); }
.logo-crest { display: block; width: 28px; height: 28px; margin: 0 auto 2px; color: #d8b060; }
.menu-toggle, .menu-button { display: none; }
.menu-group { list-style: none; margin: 0 0 8px; padding: 0; }
.menu-group + .menu-group { padding-top: 8px; border-top: 1px solid #2a1c10; }
.menu-item {
    display: block;
    margin: 0 0 2px;
    padding: 3px 6px;
    background: linear-gradient(#2a1a10, #170d07);
    border: 1px solid;
    border-color: #5a3a24 #0d0603 #0d0603 #5a3a24;
    color: var(--cream);
    font-weight: bold;
    font-size: 11px;
    text-align: left;
    width: 100%;
}
a.menu-item:visited { color: var(--cream); }
a.menu-item:hover, a.menu-item:focus-visible { background: linear-gradient(#4a2c16, #24140a); text-decoration: none; }
.menu-item { box-shadow: inset 1px 1px 0 rgba(255, 220, 160, .12); text-shadow: 1px 1px 0 #000; }
.menu-item.current { background: linear-gradient(#5a1a10, #300a05); }
.menu-item.disabled { color: #6a6058; cursor: default; background: #0d0806; border-color: #2a1d14 #050302 #050302 #2a1d14; }
/* Each menu group's heading: small gold capitals above its links (read out as the list's label, not as an item). */
.menu-heading { margin: 0 0 3px; padding: 0 2px; color: #b0915a; font-size: 10px; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; }
.main { min-width: 0; }
.resource-bar { background: var(--hdr-navy); border-bottom: 1px solid #223; padding: 4px 10px; }
.resources { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.clock { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 2px; color: var(--muted); }
.real-clock { color: var(--fg); }
.next-event { display: inline-flex; gap: 6px; max-width: 100%; min-width: 0; }
.next-event a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32em; }
.coming-soon { margin: 6px 0 10px; }
.coming-soon caption { text-align: left; padding: 3px 6px; }
.coming-soon caption a { margin-left: 10px; font-weight: normal; }
.content { padding: 8px 14px 30px; max-width: 1100px; }
.page-banner {
    display: flex; align-items: center; gap: 10px;
    font-size: 16px; letter-spacing: 2px; font-variant: small-caps;
    margin: 4px 0 10px; padding: 5px 10px;
    background: linear-gradient(90deg, #4a0505, #240000 55%, rgba(0, 0, 0, 0) 100%);
    border-top: 1px solid #6a2a1a; border-bottom: 1px solid #1a0000;
}
.page-banner .emblem { flex: none; width: 30px; height: 30px; color: #d8b060; filter: drop-shadow(1px 1px 0 #000); }
.status-lines p { margin: 4px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0 12px; }
.tab { padding: 3px 8px; background: var(--hdr-red); border: 1px solid #5a2020; font-weight: bold; }
.tab.current { background: #7a1010; color: #fff; }
a.tab:not(.current):hover, a.tab:not(.current):focus-visible { background: #5a1414; color: #fff; text-decoration: none; }
.tab.disabled { background: #1a0a0a; color: #6a6058; border-color: #2a1414; }
.throne { max-width: 760px; gap: 0; }
.throne > .ktable { flex: 1 1 280px; margin-right: -1px; }
.throne td.label { width: 50%; }
/* The battle report: every value starts just after the longest label, numbers and words alike. */
.battle-report td.label { width: 1%; white-space: nowrap; padding-right: 24px; }
.battle-report td.num { text-align: left; }
.build-grid input { width: 64px; }

/* One click to act on a province from wherever it is named (Game/ActLinks.cs), and "hit back" on the news of an attack. */
.act-line { margin: 4px 0 10px; }
.ledger .act-links { font-size: 11px; }
.hit-back, .aid-link { margin-left: 4px; }
.aid-ask { margin-top: 14px; }

/* ---------- Kingdom, paper, couriers, moot ---------- */
.badge { display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 4px; background: #7a1010; color: #fff; border-radius: 8px; font-size: 10px; text-align: center; }

/* The Kingdom Notices: the bell beside the date while something is new, and the page's list (Pages/Kingdom/Notices). */
.notices-bell { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border-radius: 8px; background: #7a1010; color: #fff; font-weight: bold; }
.notices-bell svg { width: 13px; height: 13px; }
.notices-bell:hover { color: #fff; background: #9a1818; }
.notices { list-style: none; margin: 8px 0; padding: 0; }
.news-warn { color: var(--warn); }
.notices .notice-line { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border: 1px solid var(--rule); border-left: 3px solid var(--rule); background: var(--panel); margin-bottom: -1px; }
.notices .notice-line.new { border-left-color: var(--gold); background: #15110a; }
.notice-icon { flex: 0 0 22px; width: 22px; height: 22px; margin-top: 1px; color: var(--muted); }
.notice-attack .notice-icon { color: #c05a4a; }
.notice-spell .notice-icon { color: #9a8ad8; }
.notice-op .notice-icon { color: #b8b0a0; }
.notice-aid .notice-icon { color: var(--gold); }
.notice-body { flex: 1 1 auto; min-width: 0; }
.notice-body p { margin: 0; }
.notice-detail { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.notice-new { color: var(--gold); font-weight: bold; text-transform: uppercase; letter-spacing: 0.05em; }
.in-protection, a.in-protection, a.in-protection:visited { color: #7fdf7f; }
.monarch, a.monarch, a.monarch:visited { color: #ff6f5f; } /* 2005: red is the monarch, bold is you */
.roster td { white-space: nowrap; }
.roster tr.unclaimed td { color: var(--muted); text-align: center; }
/* A kingdom-mate's page: the ruler's name over their province, each people and personality's line beneath its name. */
.member-of { display: block; font-weight: normal; color: var(--muted); }
.member-marks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 10px; }
.member-crown { width: 14px; height: 14px; vertical-align: -2px; }
.member .blurb { display: block; margin-top: 2px; }
.member td.num { white-space: normal; } /* a figure and its place wrap on a phone, not the page */
.member-courier input { width: 100%; }
.member-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
tr.mine td { background: #1a1408; }
tr.unread td { font-weight: bold; }
.pre { white-space: pre-wrap; word-break: break-word; }
.nowrap { white-space: nowrap; }
.wide-form { max-width: 640px; }
.wide-form textarea { width: 100%; background: #111; color: var(--fg); border: 1px solid #555; padding: 4px; font: inherit; }
.masthead { font-size: 15px; letter-spacing: 2px; text-align: center !important; font-variant: small-caps; }
.legend { margin-top: 8px; }
.news-intra { color: #c8c8c8; }
.news-relations { color: #ffe07a; }
.news-against { color: #ff8070; }
.news-dragon { color: #d79bff; }
.news-by { color: #8fe08f; }
.news-obituary { color: #c05050; }
.news-province { color: var(--fg); }

/* ---------- Public pages ---------- */
.public-frame { max-width: 794px; margin: 0 auto; padding: 0 16px 30px; }
.public-header { background: var(--panel-green); border: 1px solid #1a3a1a; border-top: none; padding: 18px 16px 12px; text-align: center; }
.title-art { display: block; }
.title-art img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.tagline { color: var(--muted); margin-top: 4px; }
.public-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; background: #050f05; border: 1px solid #1a3a1a; border-top: none; padding: 5px 8px; margin-bottom: 14px; }
.public-content { min-height: 320px; }
.public-footer { margin-top: 24px; color: var(--muted); font-size: 11px; text-align: center; }
.front-columns { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; }
.chapters { margin: 6px 0; padding-left: 22px; }

/* ---------- Phones ---------- */
@media (max-width: 767px) {
    body { font-size: 14px; }
    .menu-item { font-size: 13px; padding: 6px 8px; }
    .frame { grid-template-columns: 1fr; }
    .sidebar { border-right: none; border-bottom: 1px solid #222; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; }
    .logo { padding: 4px; }
    .menu-button { display: inline-block; padding: 6px 12px; border: 1px solid #5a3a24; background: var(--button-face); color: var(--cream); font-weight: bold; cursor: pointer; }
    /* The menu's checkbox stays reachable by keyboard, unseen; its focus ring shows on the Menu button. */
    .menu-toggle { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }
    .menu-toggle:focus-visible ~ .sidebar .menu-button { outline: 2px solid var(--warn); outline-offset: 1px; }
    .menu-toggle:checked ~ .sidebar .menu-button { background: #4a1a10; }
    .menu { display: none; width: 100%; margin-top: 8px; }
    .menu-toggle:checked ~ .sidebar .menu { display: block; }
    .menu-group { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
    .menu-heading { grid-column: 1 / -1; margin: 0; }
    .content { padding: 8px 10px 30px; }
    .throne > .ktable { margin-right: 0; }
    .front-columns { grid-template-columns: 1fr; }
    .form-table td { display: block; width: auto !important; border: none; }
    .form-table tr { display: block; border-bottom: 1px solid var(--rule); }
    /* The build grid shows two buildings a row; on a phone the second wraps under the first, in the same four columns. */
    .build-grid, .build-grid tbody { display: block; }
    .build-grid tr { display: grid; grid-template-columns: minmax(0, 1fr) 44px 64px 76px; }
    .build-grid th, .build-grid td { margin: 0 -1px -1px 0; padding: 3px 4px; }
    .build-grid th { font-size: 11px; overflow-wrap: anywhere; }
    .build-grid input { width: 100%; box-sizing: border-box; }
    .build-grid .second { display: none; }
    /* Order tables (Military, Sciences, the Mystics' own spells): on a phone each row's name takes a line of its own and
       its figures and box or button fill the line below, so nothing is hidden off to the side; a long description takes
       a line of its own too. */
    .phone-grid, .phone-grid tbody { display: block; }
    .phone-grid tr { display: grid; grid-auto-flow: row dense; }
    .phone-grid.cols-4 tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .phone-grid.cols-5 tr { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .phone-grid tr > :first-child, .phone-grid .own-line { grid-column: 1 / -1; }
    .phone-grid th, .phone-grid td { margin: 0 -1px -1px 0; padding: 3px 4px; }
    .phone-grid th { font-size: 11px; overflow-wrap: anywhere; }
    .phone-grid input { width: 100%; box-sizing: border-box; }
}

/* The Scrying Ledger's plain-text copy box. */
textarea.copy-text { width: 100%; max-width: 760px; box-sizing: border-box; font-family: "Courier New", monospace; font-size: 11px; }

/* Relations: attitudes coloured like the Paper's relation news. */
.relation-unfriendly { color: #f0d060; }
.relation-hostile, .relation-war { color: #ff6050; font-weight: bold; }

/* M9 comforts: the Courier Bell and the Kingdom Watch */
caption.hdr-red, caption.hdr-navy { text-align: left; padding: 3px 7px; border: 1px solid var(--rule); border-bottom: 0; }
.ktable td.idle { color: #ff6050; }
.ktable td.hit { color: #ffb070; font-weight: bold; }
.ktable tr.total th, .ktable tr.total td { border-top: 2px solid var(--rule); font-weight: bold; }
.bell { margin-left: 8px; }
.app-refresh { color: var(--link); cursor: pointer; }
/* The installed app's pull to refresh (karguun.js): a mark that drops in from the top as the page is pulled down. */
.pull-refresh {
    position: fixed; top: 4px; left: 50%; z-index: 1000; width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1;
    background: var(--hdr-red); border: 1px solid var(--button-light); color: var(--cream);
    opacity: 0; pointer-events: none; transform: translate(-50%, 0); transition: opacity 0.15s;
}
.pull-refresh.shown { opacity: 0.6; }
.pull-refresh.ready { opacity: 1; color: var(--ok); }
.pull-refresh.refreshing { opacity: 1; transform: translate(-50%, 48px); }
@media (prefers-reduced-motion: no-preference) {
    .pull-refresh.refreshing { animation: pull-refresh-spin 0.8s linear infinite; }
}
@keyframes pull-refresh-spin { from { transform: translate(-50%, 48px) rotate(0deg); } to { transform: translate(-50%, 48px) rotate(360deg); } }
.front-logout { display: block; margin: -6px 0 10px; }

/* The music strip in the resource bar */
.music { margin-left: auto; color: var(--muted); }
.volume-link { margin-left: 4px; }
.volume-sliders label.volume { display: grid; grid-template-columns: 9em 1fr 3.5em; align-items: center; gap: 2px 8px; }
.volume-sliders label.volume input[type=range] { width: 100%; min-width: 0; }
.volume-sliders label.volume output { text-align: right; font-variant-numeric: tabular-nums; }
.volume-sliders label.volume .volume-where { grid-column: 1 / -1; color: var(--muted); }
.music button { color: var(--link); padding: 0 3px; }
@media (max-width: 767px) {
    /* Big enough to tap on a phone. */
    .music button { padding: 4px 6px; }
}
.music button[aria-pressed=true] { color: var(--fg); font-weight: bold; text-decoration: underline; }
.music .music-wait { display: none; font-size: 11px; }
.music .music-more { display: none; }
.music.waiting .music-wait { display: inline; }
.sound-toggle button { color: var(--link); padding: 0 3px; }
.sound-toggle button[aria-pressed=true] { color: var(--fg); font-weight: bold; }

/* Kingdom banners */
.banner { display: inline-block; vertical-align: middle; }
.banner-sm { width: 16px; height: 19px; }
.banner-md { width: 24px; height: 29px; }
.banner-lg { width: 36px; height: 43px; }
.banner-xl { width: 96px; height: 115px; }
.banner-panel { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.kingdom-lead { display: flex; align-items: center; gap: 8px; }

/* The first-days checklist */
.first-days tr.done td { color: var(--muted); }
.first-days .tick { display: inline-block; width: 1.2em; color: var(--warn); font-weight: bold; }
.first-days tr.done .tick { color: var(--ok); }
.first-days-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.first-days-actions form { margin: 0; }

/* Charts and the Atlas */
.charts { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 12px; }
.chart { margin: 0; flex: 1 1 300px; max-width: 480px; background: var(--panel); border: 1px solid var(--rule); padding: 4px 6px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart figcaption { font-size: 11px; color: var(--muted); }
.kingdom-history { margin: 8px 0 12px; }
.kingdom-history > summary { cursor: pointer; color: var(--link); }
/* The War Ledger and the battle log's charts (Game/BattleCharts.cs): colours by class, never by style attribute. */
.chart .chart-label, .chart .chart-axis { fill: var(--muted); }
.chart .chart-value { fill: var(--fg); }
.chart .chart-axis-line { stroke: var(--rule); }
.chart .bar-track { fill: #141414; }
.chart .bar-ours { fill: #d8b060; }
.chart .bar-fell, .chart .bar-lost { fill: #ff8070; }
.chart .bar-won { fill: #8fe08f; }
.chart .bar-theirs { fill: #8a8274; }
.chart .bar-land { fill: #9fbf6f; }
.chart .bar-other { fill: #5a5448; }
.chart .gauge-short { fill: #3a1a14; }
.chart .gauge-broke { fill: #14301a; }
.chart .gauge-line { stroke: var(--warn); }
.chart .gauge-marker { fill: var(--cream); }
.battle-visual .chart { flex: 1 1 280px; }
.battle-notes { margin: 0 0 12px; padding-left: 18px; }
.visual-heading { margin-top: 10px; }
.war-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 12px; }
.war-tile { background: var(--panel); border: 1px solid var(--rule); padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.war-tile .tile-label { color: var(--muted); font-size: 11px; }
.war-tile .big { font-size: 20px; font-weight: bold; }
.war-ledger td.direction { text-align: center; color: var(--muted); }
.ledger-filter { margin-bottom: 8px; }
.atlas { margin: 0 auto 12px; max-width: 600px; }
.atlas svg { display: block; width: 100%; height: auto; }
.atlas-island:hover circle, a:focus-visible .atlas-island circle { stroke: var(--warn); stroke-width: 3; }
.atlas-key { display: inline-block; width: 10px; height: 10px; border: 2px solid; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: middle; }
.atlas-key.mine { border-color: #d8b060; }
.atlas-key.enemy { border-color: #ff6050; }
.atlas-kingdoms { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.atlas-kingdoms li a { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; background: var(--panel); border: 1px solid var(--rule); }
.atlas-kingdoms li.mine a { border-color: #d8b060; }
.atlas-kingdoms li.enemy a { border-color: #ff6050; }
.atlas-name { font-weight: bold; }

/* Deeds and the story of an age */
.deeds .deed-mark { width: 1.4em; text-align: center; color: var(--warn); font-size: 14px; }
.deeds tr.deed-todo td { color: var(--muted); }
.deeds tr.deed-todo .deed-mark { color: var(--rule); }
.deeds tr.deed-todo strong { color: var(--muted); }
.deeds-line { margin: 6px 0; }
.deeds-line .deed { color: var(--warn); white-space: nowrap; cursor: help; }
.story section { margin-bottom: 10px; }
.story ol, .story ul { margin: 4px 0; padding-left: 22px; }
.story li { margin: 3px 0; }
.story ul.rise { list-style: none; padding-left: 4px; }
.story .rose { color: var(--ok); }
.story .fell { color: var(--bad); }

/* Alternate Display (2005): the menu runs along the bottom of the page */
@media (min-width: 769px) {
    body.alt-display .frame { grid-template-columns: 1fr; }
    body.alt-display .sidebar { order: 2; border-right: none; border-top: 1px solid #222; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 16px; }
    body.alt-display .main { order: 1; }
    body.alt-display .menu { display: flex; flex-wrap: wrap; gap: 6px 14px; }
    body.alt-display .menu-group { display: flex; flex-wrap: wrap; gap: 3px; margin: 0; }
    body.alt-display .menu-group + .menu-group { padding-top: 0; border-top: none; padding-left: 10px; border-left: 1px solid #2a1c10; }
    body.alt-display .menu-heading { align-self: center; margin: 0 4px 0 0; }
}

/* Announcements: the game update box */
.game-update { margin-bottom: 10px; }
.announcement { border-bottom: 1px solid var(--rule); padding: 4px 0 8px; }

/* The Hearth: the kingdom's live talk */
.hearth-log { height: 340px; max-height: 60vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--rule); padding: 6px 8px; margin-bottom: 6px; }
.hearth-line { margin: 2px 0; word-break: break-word; }
.hearth-line .small { margin-right: 4px; }
.hearth-take-back { margin-left: 4px; }
.hearth-form input[name=Line] { flex: 1 1 260px; min-width: 0; }
.hearth-pages { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 4px; }
.hearth-pages a { padding: 4px 0; }
.hearth-line .mention { color: var(--warn); }

/* The Campaign: the kingdom's war planning */
.campaign-targets tr.priority-1 td:first-child { color: var(--bad); font-weight: bold; }
.campaign-targets tr.priority-3 td:first-child { color: var(--muted); }
.campaign-give select { max-width: 130px; }

/* Help: the ? beside each title, tap-to-explain words, and order previews */
.page-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.page-head .page-banner { flex: 1 1 auto; margin: 0; }
.page-help-button {
    flex: none; width: 28px; height: 28px; padding: 0; border-radius: 50%;
    font-weight: bold; font-size: 15px; line-height: 1; cursor: help;
}
.term {
    padding: 0; margin: 0; border: none; background: none; box-shadow: none;
    color: inherit; font: inherit; text-align: inherit; cursor: help;
    text-decoration: underline dotted; text-decoration-color: #8a7a60; text-underline-offset: 3px;
}
.term:hover, .term:focus-visible { color: var(--cream); text-decoration-color: var(--warn); }
[popover].tip-pop, [popover].help-panel {
    max-width: min(26rem, calc(100vw - 32px)); padding: 10px 14px; margin: auto;
    background: #120a05; color: var(--fg); border: 1px solid var(--button-light); border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.8); line-height: 1.45;
}
[popover].tip-pop strong { color: var(--cream); }
[popover].tip-pop a { display: inline-block; margin-left: 4px; font-size: 11px; }
[popover].help-panel { max-width: min(34rem, calc(100vw - 32px)); max-height: 80vh; overflow-y: auto; }
.help-panel h2 { margin: 8px 0 4px; }
.help-panel h2:first-child { margin-top: 0; }
.help-panel ul { margin: 4px 0; padding-left: 20px; }
.help-panel .help-close { margin-top: 6px; }
[popover]::backdrop { background: rgba(0, 0, 0, 0.35); }
.effect-now { color: var(--muted); font-size: 11px; font-weight: normal; }
.order-preview { color: var(--cream); margin: 6px 0; }
.order-preview.over { color: var(--warn); }
/* The resource bar's change since this tab last saw it (+1,234 or −32,800), fading unless motion is unwelcome. */
.bar-delta { margin-left: 4px; font-size: 11px; font-weight: bold; }
.bar-delta.up { color: var(--ok); }
.bar-delta.down { color: var(--bad); }
@media (prefers-reduced-motion: no-preference) {
    .bar-delta { animation: bar-delta 5s ease-out forwards; }
}
@keyframes bar-delta {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}
.day-turned, .day-late { margin: 4px 0 0; color: var(--cream); }
/* A countdown under five minutes (not the day's own), and the Courier Bell's rows marked by kind. */
.countdown.soon { color: var(--warn); font-weight: bold; }
.timers tr:has(.countdown.soon) td { background: rgba(255, 210, 127, 0.07); }
.timers tr[class^="timer-"] td:first-child { border-left: 3px solid var(--rule); }
.timers tr.timer-army td:first-child, .timers tr.timer-order-attack td:first-child, .timers tr.timer-enemy td:first-child { border-left-color: #c05a4a; }
.timers tr.timer-spell td:first-child, .timers tr.timer-mana td:first-child, .timers tr.timer-order-spell td:first-child { border-left-color: #9a8ad8; }
.timers tr.timer-stealth td:first-child, .timers tr.timer-order-op td:first-child { border-left-color: #b8b0a0; }
.timers tr.timer-protection td:first-child, .timers tr.timer-hostile td:first-child { border-left-color: var(--warn); }
.timers tr.timer-build td:first-child, .timers tr.timer-train td:first-child, .timers tr.timer-land td:first-child, .timers tr.timer-research td:first-child { border-left-color: var(--gold); }
.day-reload { color: var(--link); text-decoration: underline dotted; cursor: pointer; }
.day-reload:hover, .day-reload:focus-visible { text-decoration: underline; }
/* The new day, said once on the page it brought: a gold strip with the rising sun, rising in unless motion is unwelcome. */
.dawn { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; padding: 3px 10px; color: #1a1408; font-weight: bold; font-variant: small-caps; letter-spacing: 0.04em; background: linear-gradient(90deg, var(--gold), rgba(216, 176, 96, 0.35) 70%, transparent); border-left: 3px solid #f3d58e; }
.dawn[hidden] { display: none; }
.dawn-emblem { flex: 0 0 18px; width: 18px; height: 18px; }
@media (prefers-reduced-motion: no-preference) {
    .dawn { animation: dawn-rise 1.4s ease-out; }
}
@keyframes dawn-rise {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
}
/* A figure that fills in its box when clicked (the script makes it a button): a small chip, not a word to explain. */
button.fill { color: var(--link); cursor: pointer; border: 1px solid rgba(255, 238, 204, 0.35); border-radius: 3px; padding: 0 4px; background: rgba(255, 238, 204, 0.06); }
button.fill:hover, button.fill:focus-visible { border-color: var(--gold); background: rgba(216, 176, 96, 0.15); }
.term-list { margin: 4px 0 8px; }
.term-list .term { margin-right: 10px; }

/* The Glossary */
.glossary-groups { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 4px; }
dl.glossary { margin: 4px 0 14px; }
dl.glossary dt { color: var(--cream); font-weight: bold; margin-top: 8px; }
dl.glossary dd { margin: 2px 0 0 16px; max-width: 760px; }

/* Hover tips and hints (M15): placed beside their word by the script; no dimming behind a small tip */
[popover].tip-pop::backdrop { background: transparent; }
[popover].tip-pop.hint { max-width: min(20rem, calc(100vw - 32px)); padding: 6px 10px; font-size: 11px; color: var(--cream); }
.help-settings .help-open { margin: 0 0 4px 22px; padding: 2px 8px 4px; border: 1px solid var(--rule); }
.help-settings .help-open legend { font-size: 11px; color: var(--muted); }

/* Single player (M17): the banner, the solo bar's speed and jump buttons, goals and the digest */
.solo-banner { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 4px 10px; background: #1d2a3a; border: 1px solid var(--rule); color: var(--cream); font-size: 12px; }
.solo-banner span { flex: 1 1 auto; }
.catch-up-banner { background: #2f2a14; border-color: #8a7a32; }
/* M19: the tutorial's lesson, on every page of a tutorial file. */
.lesson-strip { margin: 6px 0 0; padding: 6px 10px; background: #102a14; border: 1px solid #3f6b45; color: var(--fg); font-size: 12px; }
.lesson-strip p { margin: 2px 0; }
/* The tutorial's Train lesson on Military: the troop it asks for stands out; the others wait until it is done. */
.lesson-focus-note { color: var(--gold); }
.lesson-focus > td { background: rgba(216, 176, 96, 0.12); }
.lesson-focus .label { color: var(--gold); }
.lesson-locked > td { opacity: 0.5; }
.lesson-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.lesson-why summary { cursor: pointer; color: var(--link); }
.lesson-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 4px; }
.lesson-actions form.inline { margin: 0; }
.lessons tr.current td { background: #102a14; }
.lessons tr.done td .y { color: var(--ok); }
.tutorial-callout { border: 2px solid var(--warn); }
/* The tutorial's first step: peoples and personalities as cards to pick from. */
.choice-cards { border: 1px solid var(--rule); margin: 10px 0; padding: 0 10px 10px; }
.choice-cards legend { padding: 2px 10px; color: var(--cream); font-weight: bold; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.card { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 8px; background: var(--panel); border: 1px solid var(--rule); cursor: pointer; }
.card input { grid-row: span 2; margin: 2px 0 0; }
.card-name { color: var(--cream); font-weight: bold; }
.card-text { font-size: 12px; color: var(--muted); }
.card-tag { margin-left: 6px; padding: 0 5px; border: 1px solid var(--ok); color: var(--ok); font-size: 10px; font-weight: normal; }
.card:has(input:checked) { border-color: var(--warn); background: #102a14; }
.card:has(input:focus-visible) { outline: 2px solid var(--warn); }
.tutorial-callout td { background: #102a14; }
.tutorial-callout p { margin: 4px 0; }
.callout-button { padding: 6px 18px; font-size: 14px; }
.help-first { margin: 0 0 8px; }
.solo-clock { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.solo-speed, .solo-jumps { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.solo-clock form.inline { margin: 0; }
.speed-button, .jump-button { padding: 1px 7px; font-size: 11px; min-height: 24px; }
.speed-button[aria-pressed="true"] { background: var(--warn); color: #000; font-weight: bold; }
.jump-button[disabled] { opacity: 0.5; cursor: wait; }
.solo-goals meter.goal-bar { width: 80px; height: 8px; margin-left: 6px; vertical-align: middle; }
.solo-goals tr.goal-met td:first-child .y { color: var(--ok, #8fd18f); }
.solo-digest-news, .away-digest-news { margin: 2px 0; padding-left: 18px; }
.solo-digest-news li, .away-digest-news li { margin: 2px 0; }
.solo-panel { margin: 8px 0; }
.solo-panel > summary { cursor: pointer; padding: 4px 8px; background: var(--panel); border: 1px solid var(--rule); color: var(--cream); font-weight: bold; }
.choice-row { display: flex; flex-wrap: wrap; gap: 4px 12px; border: none; padding: 0; margin: 0 0 2px; }
.choice-row .choice { white-space: nowrap; }
.stack-tight { display: flex; flex-direction: column; gap: 3px; border: none; padding: 0; margin: 0; }
.solo-files form.inline, details.confirm form { margin: 0; }
details.confirm { display: inline-block; margin-left: 8px; }
details.confirm > summary { cursor: pointer; color: var(--warn); }
button.danger { background: #6a1010; color: var(--cream); }
.raw-state { max-height: 420px; overflow: auto; font-size: 11px; background: var(--panel); padding: 6px; }
.marked { color: var(--warn); }
@media (max-width: 600px) {
    .solo-clock { gap: 4px 6px; }
    .speed-button, .jump-button { padding: 1px 5px; }
    .solo-goals td.nowrap, .solo-digest td.nowrap, .away-digest td.nowrap { white-space: normal; }
    .solo-goals meter.goal-bar { display: block; width: 64px; margin: 3px 0 0; }
}

/* Achievements: a medal per tier, earned ones bright. */
.achievements { margin-bottom: 12px; table-layout: fixed; }
.achievements .col-medal { width: 6.5em; }
.achievements .col-when { width: 9.5em; }
.achievements caption { text-align: left; padding: 3px 6px; }
.achievements .medal { white-space: nowrap; }
.achievements .medal-mark { font-size: 1.2em; margin-right: 4px; }
.achievement.tier-bronze .medal-mark { color: #cd7f32; }
.achievement.tier-silver .medal-mark { color: #c0c0c0; }
.achievement.tier-gold .medal-mark { color: #ffd700; }
.achievement-todo { opacity: 0.6; }
.achievement-todo .medal-mark { color: var(--muted); }
.ruler-title { font-style: italic; color: var(--cream); }
.title-picker { margin: 6px 0 12px; }
@media (max-width: 600px) {
    .achievements .col-medal { width: 2em; }
    .achievements .medal .small { display: none; }
    .achievements .col-when { width: 5.8em; }
    .achievements td.num { white-space: normal; }
}

/* Two Crowns: the crown that won a season, in the Story of the Age and the Hall. */
.crown-won { font-weight: bold; }
.crown-won .crown-mark { color: #ffd700; }

/* The Building page: what the buildings give (each line of a cell stays on one line, so the cells line up), and how they work. */
.building-breakdown td > div { white-space: nowrap; } /* Internal Affairs: one line a cell, kept level across the row */
.building-breakdown .status-none { color: var(--muted); }
.building-breakdown .status-atmost, .building-breakdown .status-pasthalf { color: var(--warn); }
/* The Building page: a row for each thing a building gives, wrapping freely, the building's own cell spanning them. */
.building-breakdown td.building { width: 1%; min-width: 92px; }
.building-breakdown .own { display: block; font-weight: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.building-breakdown .status { font-size: 11px; }
.building-breakdown tbody + tbody tr:first-child td { border-top-width: 2px; }
/* The math done (BuildingValue): each new one, and a returns meter of ten text blocks coloured by how much is left. */
.effect-now .each-new { color: var(--fg); }
.returns .meter { font-size: 10px; letter-spacing: -1px; }
.returns-good { color: var(--ok); }
.returns-falling { color: var(--warn); }
.returns-low { color: var(--bad); }
.returns-none, .building-breakdown .steady { color: var(--muted); }
.building-breakdown .returns-line { white-space: nowrap; }
.building-breakdown .each-total { color: var(--fg); }
.build-outlook { margin: 4px 0 8px; font-size: 12px; color: var(--ok); }
/* The Council's Income tab: each line with a word on what it is. */
.income-table td.label { width: 50%; }
.income-table .why, .income-people .why, .income-room .why, .income-table td.why { font-size: 11px; font-weight: normal; color: var(--muted); }
.income-verdict { margin: 4px 0 10px; }
.income-raise li + li { margin-top: 3px; }
.build-outlook div + div { margin-top: 2px; }
@media (max-width: 767px) {
    .building-breakdown thead { display: none; }
    .building-breakdown.phone-grid tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .building-breakdown.phone-grid tr.more > :first-child { grid-column: auto; }
    .building-breakdown td.building { width: auto; min-width: 0; background: var(--hdr-navy); }
    .building-breakdown .own { display: inline; margin-left: 6px; }
    .building-breakdown td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; color: var(--muted); }
}
.how-buildings > summary { cursor: pointer; margin: 14px 0 6px; }
.how-buildings > summary h2 { display: inline; }
.how-buildings p { max-width: 640px; }
.how-dragons td.label { width: 1%; white-space: nowrap; }
.how-dragons .live { margin-top: 4px; color: var(--gold); }

/* The Mystics' and Thievery's outlook: what each spell and op would cost, do and dare. */
.odds-hint { display: block; font-weight: normal; font-size: 10px; }
.for-us div + div, .effect-on div + div, .haul div + div { margin-top: 2px; }
.ktable tr.op-group th { text-align: left; }
@media (max-width: 767px) {
    .phone-grid.cols-3 tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .phone-grid.spells tr > :last-child { grid-column: span 3; } /* the Cast button and why not, beside Active */
}

/* The Spellbook (/Spellbook): what each spell and op does gets the room; on a phone each row stands as a card, its name
   and what it does across the top and its facts two to a line, each under its column's name. */
.spellbook-table td.does { min-width: 260px; }
.spellbook-table tr:target td { background: #2a1d10; }
@media (max-width: 767px) {
    .spellbook-table, .spellbook-table tbody { display: block; }
    .spellbook-table tr.hdr-navy { display: none; }
    .spellbook-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 6px; }
    .spellbook-table td { margin: 0 -1px -1px 0; }
    .spellbook-table td.y, .spellbook-table td.does { grid-column: 1 / -1; min-width: 0; }
    .spellbook-table td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; color: var(--muted); }
}

/* The One More page: what one more of each gives, and how it is worked out (small, wrapping anywhere: rules paths are long words). */
.one-more td.label { width: 30%; }
.one-more .gives > div + div { margin-top: 2px; }
.one-more .how { margin-top: 4px; overflow-wrap: anywhere; }
.one-more-each { margin: 4px 0 10px; padding-left: 18px; }
.one-more-each li + li { margin-top: 2px; }
.each-one { overflow-wrap: anywhere; }

/* Reveals (Pages/Shared/_Reveal.cshtml, wwwroot/js/reveal.js): a battle, a spell or a thief op played out in beats. The
   markup is the final frame. While .reveal-playing, each [data-beat] part waits for its beat (.on); the section carries
   at-N for the beat now and past-N for each beat reached. The stage is letterboxed and vignetted while it plays, a title
   card opens it, the scene's camera moves on one timeline per kind, and the verdict grades the colours. All motion is
   kept for those who have not asked for less; the final frame stands still for those who have. */
/* Until its script takes over, a reveal waits unseen, so its result never shows before the play begins. Without scripts
   (reveal-noscript.css), with less motion, or should the script never come, it stands as its final frame. */
.reveal.reveal-pending { visibility: hidden; animation: rv-unveil 0s 3s forwards; }
@keyframes rv-unveil { to { visibility: visible; } }
@media (prefers-reduced-motion: reduce) { .reveal.reveal-pending { visibility: visible; animation: none; } }
.reveal { position: relative; margin: 8px 0 14px; padding: 12px 14px 10px; background: radial-gradient(ellipse at 50% 0%, rgba(216, 176, 96, 0.11), transparent 62%), linear-gradient(#0e0a06, #030303 72%); border: 1px solid #5a4520; box-shadow: inset 0 0 0 1px #160f06, inset 0 0 44px rgba(216, 176, 96, 0.06), 0 8px 26px rgba(0, 0, 0, 0.7); }
.reveal::before, .reveal::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--gold); pointer-events: none; }
.reveal::before { top: 4px; left: 4px; border-right: 0; border-bottom: 0; }
.reveal::after { right: 4px; bottom: 4px; border-left: 0; border-top: 0; }
.reveal.tone-loss { border-color: #5a2018; box-shadow: inset 0 0 0 1px #160806, inset 0 0 44px rgba(255, 96, 70, 0.05), 0 8px 26px rgba(0, 0, 0, 0.7); }
.reveal.tone-loss::before, .reveal.tone-loss::after { border-color: #b0503c; }
/* Until the verdict, a loss looks like any other deed. */
.reveal-playing.tone-loss:is(.reveal-battle:not(.past-3), .reveal-op:not(.past-3), .reveal-spell:not(.past-2)) { border-color: #5a4520; box-shadow: inset 0 0 0 1px #160f06, inset 0 0 44px rgba(216, 176, 96, 0.06), 0 8px 26px rgba(0, 0, 0, 0.7); }
.reveal-playing.tone-loss:is(.reveal-battle:not(.past-3), .reveal-op:not(.past-3), .reveal-spell:not(.past-2))::before,
.reveal-playing.tone-loss:is(.reveal-battle:not(.past-3), .reveal-op:not(.past-3), .reveal-spell:not(.past-2))::after { border-color: var(--gold); }
.reveal-head { text-align: center; }
.reveal-title { margin: 0; font: bold 17px Georgia, "Times New Roman", serif; color: var(--gold); letter-spacing: 0.05em; text-shadow: 0 0 12px rgba(216, 176, 96, 0.25); }
.reveal-subtitle { margin: 2px 0 8px; font-size: 11px; letter-spacing: 0.04em; color: var(--muted); }
.reveal-stage { position: relative; overflow: hidden; border: 1px solid #2c2210; background: #000; box-shadow: 0 0 0 1px #000, 0 4px 18px rgba(0, 0, 0, 0.8); }
.reveal-stage::before, .reveal-stage::after { content: ""; position: absolute; left: 0; right: 0; height: 0; background: #000; z-index: 3; pointer-events: none; }
.reveal-stage::before { top: 0; }
.reveal-stage::after { bottom: 0; }
.reveal-playing .reveal-stage { cursor: pointer; }
.reveal-stage .scene { display: block; width: 100%; height: auto; }
.reveal-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0.75; background: radial-gradient(ellipse at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.6) 100%); }
.reveal-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle at 55% 58%, rgba(255, 244, 214, 0.9), rgba(255, 190, 90, 0.28) 28%, transparent 62%); }
.reveal-spell .reveal-flash { background: radial-gradient(circle at 82% 48%, rgba(230, 210, 255, 0.9), rgba(160, 110, 255, 0.3) 26%, transparent 60%); }
.reveal-spell.spell-self .reveal-flash { background: radial-gradient(circle at 50% 42%, rgba(230, 210, 255, 0.9), rgba(160, 110, 255, 0.3) 26%, transparent 60%); }
.reveal-spell.spell-reflected .reveal-flash { background: radial-gradient(circle at 18% 48%, rgba(255, 200, 190, 0.9), rgba(255, 110, 90, 0.3) 26%, transparent 60%); }
.reveal.tone-loss.reveal-op .reveal-flash { background: radial-gradient(circle at 63% 38%, rgba(255, 90, 70, 0.75), rgba(255, 60, 40, 0.22) 30%, transparent 64%); }
.reveal-card { display: none; position: absolute; inset: 0; z-index: 4; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), transparent 70%); }
.reveal-card p { margin: 0; text-align: center; }
.card-title { font: bold clamp(17px, 4.4vw, 30px) Georgia, "Times New Roman", serif; letter-spacing: 0.12em; text-transform: uppercase; color: #f6dc96; text-shadow: 0 0 18px rgba(255, 200, 100, 0.45), 0 2px 0 #000; }
.card-subtitle { margin-top: 4px; font: italic clamp(11px, 2.4vw, 14px) Georgia, "Times New Roman", serif; color: var(--cream); text-shadow: 0 1px 0 #000; }
.reveal-rays { position: absolute; left: 50%; top: 50%; width: 180%; aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; opacity: 0.6; }
.reveal-rays::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255, 214, 130, 0.22) 0deg 6deg, transparent 6deg 17deg); -webkit-mask-image: radial-gradient(circle, #000 12%, transparent 58%); mask-image: radial-gradient(circle, #000 12%, transparent 58%); }
.reveal-stamp { position: absolute; inset: 0; z-index: 2; margin: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.stamp-plate { max-width: 92%; padding: 2px 18px 4px; border: 4px double #e8b850; background: rgba(0, 0, 0, 0.66); transform: rotate(-7deg); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), 0 6px 22px rgba(0, 0, 0, 0.75); }
.stamp-text { display: block; font: bold clamp(19px, 6.6vw, 44px) Georgia, "Times New Roman", serif; letter-spacing: 0.1em; text-align: center; text-transform: uppercase; color: transparent; background: linear-gradient(100deg, #9a6c18 0%, #f2cc6a 30%, #fff8dc 46%, #f2cc6a 60%, #9a6c18 100%); background-size: 260% 100%; background-position: 0% 0; -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 10px rgba(255, 200, 90, 0.5)); }
.tone-loss .stamp-plate { border-color: #e06a50; }
.tone-loss .stamp-text { background-image: linear-gradient(100deg, #7a1a10 0%, #ff7a62 30%, #ffe2d8 46%, #ff7a62 60%, #7a1a10 100%); filter: drop-shadow(0 0 10px rgba(255, 90, 60, 0.5)); }
.tone-neutral .stamp-plate { border-color: var(--cream); }
.tone-neutral .stamp-text { background-image: linear-gradient(100deg, #8a8070 0%, #ffeecc 40%, #fff 50%, #ffeecc 60%, #8a8070 100%); }
.reveal.tone-loss .reveal-stage .scene { filter: saturate(0.5) brightness(0.8) contrast(1.06); }
.reveal.tone-win .reveal-stage .scene { filter: saturate(1.15) brightness(1.04); }
.reveal-power { margin: 8px 0 0; text-align: center; color: var(--muted); }
.reveal-power strong { display: inline-block; color: var(--fg); font: bold 16px Georgia, "Times New Roman", serif; }
.luck-chip { display: inline-block; margin-left: 6px; padding: 0 7px; border: 1px solid; border-radius: 9px; font-size: 11px; }
.luck-up { color: var(--ok); background: rgba(159, 223, 159, 0.08); }
.luck-down { color: var(--bad); background: rgba(255, 159, 143, 0.08); }
.reveal-margin { display: block; margin-top: 2px; font-style: italic; }
.reveal-narration { margin: 10px auto 2px; max-width: 46em; text-align: center; font: italic 14px Georgia, "Times New Roman", serif; color: var(--cream); text-shadow: 0 0 10px rgba(255, 238, 204, 0.12); }
.reveal-reason { margin: 2px 0; text-align: center; color: var(--bad); }
.reveal-tallies { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.reveal-tallies .tally { min-width: 98px; padding: 5px 10px 6px; text-align: center; background: linear-gradient(#18120a, #0a0806); border: 1px solid #3c2f18; box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.09), 0 3px 8px rgba(0, 0, 0, 0.6); }
.reveal-tallies dt { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.reveal-tallies dd { margin: 0; font: bold 22px Georgia, "Times New Roman", serif; }
.tally.tone-win dd { color: var(--ok); text-shadow: 0 0 10px rgba(159, 223, 159, 0.25); }
.tally.tone-loss dd { color: var(--bad); text-shadow: 0 0 10px rgba(255, 159, 143, 0.25); }
.tally.tone-neutral dd { color: var(--cream); }
.reveal-march, .reveal-coda { margin: 6px 0 2px; text-align: center; font-size: 11px; color: var(--muted); }
.march-track { display: inline-block; position: relative; width: 90px; height: 3px; margin-right: 6px; vertical-align: middle; background: linear-gradient(90deg, #2a2418, #5a4a28); }
.march-dot { position: absolute; top: -4px; right: 0; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2c0, var(--gold) 55%, #7a5a20); }
.reveal-controls { display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: flex-end; align-items: center; margin-top: 8px; font-size: 11px; }

/* The scenes' paint: colours by class, never by style attribute. */
.scene .far .peaks { fill: #2a1206; opacity: 0.85; }
.scene-spell .far { fill: #120a20; }
.scene .hills { fill: #160a04; }
.scene-spell .hills { fill: #0c0616; }
.scene .ground { fill: #0b0603; }
.scene-op .ground { fill: #04060c; }
.scene .fort rect, .scene .fort path, .scene .keep rect, .scene .tower path { fill: #1b1510; stroke: #3a2e22; }
.scene .fort.ours rect, .scene .keep.ours rect { fill: #2a1f0e; stroke: var(--gold); }
.scene .fort .slit { fill: #ffb04a; stroke: none; opacity: 0.7; }
.scene .fort .gate, .scene .keep .gate { fill: #050302; }
.scene .pole { stroke: #8a7350; }
.scene .flag { fill: var(--gold); }
.scene .horde circle, .scene .horde path { fill: #4a1a10; stroke: #8a3a24; }
.scene .horde line { stroke: #c06a40; }
.scene .pip { fill: var(--gold); }
.scene .pip.u-soldier { fill: #e6d8b8; }
.scene .pip.u-elite { fill: #ffe08a; }
.scene .pip.u-defSpec { fill: #9fb6dc; }
.scene .pip.u-horse { fill: #b98b58; }
.scene .pip.u-prisoner { fill: #8a8274; }
.reveal:not(.reveal-playing) .pip.fell, .reveal.past-4 .pip.fell { fill: #7a2a22; opacity: 0.5; }
.scene .impact { opacity: 0; }
.scene .spark { stroke: #ffe6a0; stroke-linecap: round; }
.scene .meter-back { fill: #000; opacity: 0.55; }
.scene .meter-short { fill: #3a1a14; }
.scene .meter-broke { fill: #14301a; }
.scene .meter-fill.won { fill: #6fbf6f; opacity: 0.8; }
.scene .meter-fill.lost { fill: #d0604a; opacity: 0.8; }
.scene .meter-line { stroke: var(--warn); }
.scene .meter-marker { fill: var(--cream); }
.scene .meter-axis { fill: var(--muted); }
.scene .star { fill: #ddd6ff; opacity: 0.7; }
.scene .tower .window, .scene .keep .window { fill: #ffcf6a; stroke: none; }
.scene .rune-ring { fill: none; stroke: #c9a8ff; stroke-width: 2.5; }
.scene .rune-ring.inner { stroke: var(--gold); stroke-width: 1; }
.scene .bead { fill: var(--gold); }
.scene .glyph { fill: none; stroke: #f0e0ff; stroke-linecap: round; }
.scene .bolt-path { fill: none; stroke: #d8b4ff; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1 2; opacity: 0.85; }
.scene .bolt-path.dies { stroke-dasharray: 0.48 2; }
.scene .bolt-path.back { stroke: #ff9a8a; }
.scene .bolt-guide { fill: none; stroke: none; }
.scene .mirror { fill: #cfe6ff; stroke: #fff; }
.scene .puff { fill: #4a4458; opacity: 0.75; }
.scene .moon { fill: #fff2d0; }
.scene .cloud-n { fill: #1a2036; opacity: 0.85; }
.scene .walls rect, .scene .walls path { fill: #0c0e16; stroke: #222a40; }
.scene .walls .window-dark { fill: #2a2a1a; stroke: none; }
.scene .lantern { fill: #ffd76a; }
.scene .lantern.alarm { fill: #ff4a3a; }
.scene .beam.caught { fill: #ff503c; opacity: 0.32; }
.reveal-playing:not(.past-2) .scene .beam.caught { fill: url(#rv-beam); opacity: 1; }
.reveal-playing:not(.past-2) .scene .lantern.alarm { fill: #ffd76a; }
.scene .thief path, .scene .thief circle { fill: #262b40; stroke: #4e5878; }
.reveal:not(.reveal-playing) .thief.lost path, .reveal:not(.reveal-playing) .thief.lost circle,
.reveal.past-3 .thief.lost path, .reveal.past-3 .thief.lost circle { fill: #4a1410; stroke: #7a2a22; }
.scene .alarm-burst .ray { stroke: #ff6a50; stroke-linecap: round; }
.scene .bang { fill: #ff6a50; font-family: Georgia, "Times New Roman", serif; font-weight: bold; }
.scene .m .ring { fill: none; stroke: #9fe0ff; stroke-width: 3; }
.scene .m .ring.r2 { stroke: var(--gold); stroke-width: 1.5; }
.scene .m .rune { fill: #9fe0ff; }
.scene .m .cloud { fill: #3a3550; stroke: #5e5880; }
.scene .m .rain { stroke: #7a8ab0; }
.scene .m .bolt { fill: #ffe680; }
.scene .m .bolt.big { fill: #fff0a0; stroke: #ffd040; }
.scene .m .flame.outer { fill: #ff6a1a; }
.scene .m .flame.inner { fill: #ffd25a; }
.scene .m .gust { fill: none; stroke: #a8b0c0; stroke-width: 3; }
.scene .m .coin { fill: #f0c040; stroke: #8a6a20; stroke-width: 1.5; }
.scene .m .pile { fill: #c89a30; }
.scene .m .tile { fill: #5f8f35; stroke: #8fbf55; }
.scene .m .sprout { fill: none; stroke: #9fdf6f; }
.scene .m .lid { fill: #120a1e; stroke: #ffeecc; stroke-width: 2; }
.scene .m .iris { fill: #8fc8ff; }
.scene .m .pupil { fill: #05030a; }
.scene .m .paper { fill: #e8dcbc; }
.scene .m .roll { fill: #c8b890; }
.scene .m .writing { stroke: #5a4a30; }
.scene .m .arc { fill: none; stroke: #b48cff; stroke-linecap: round; }
.scene .m .core { fill: #fff8e8; }
.scene .m .crescent { fill: #e8e0ff; }
.scene .m .star-m { fill: #fff; }
.scene .m .sack { fill: #6a4a28; stroke: #9a7040; }
.scene .m .tie { stroke: var(--gold); }
.scene .m .blade { fill: #d0d8e8; stroke: #fff; }
.scene .m .hilt { fill: #6a4a28; }
.scene .m .stick { stroke: #6a4a28; }
.scene .m .shaft { stroke: #8a6a40; }
.scene .m .orb { fill: #b48cff; }
.scene .m .crack { fill: none; stroke: #fff; }
.scene .m .link { fill: none; stroke: #a0a0a8; }
.scene .m .ray { stroke: var(--gold); stroke-linecap: round; }

@media (prefers-reduced-motion: no-preference) {
    /* Each part waits for its beat, then comes in. (Only opacity on SVG groups: a transform would undo their placing.) */
    .reveal-playing [data-beat]:not(.on) { opacity: 0; }
    .reveal-playing [data-beat].on { animation: rv-in 0.45s ease-out both; }
    .reveal-playing .tally.on, .reveal-playing .reveal-reason.on { animation: rv-rise 0.5s ease-out both; }
    .reveal-playing .tally.on:nth-child(2) { animation-delay: 0.14s; }
    .reveal-playing .tally.on:nth-child(3) { animation-delay: 0.28s; }
    .reveal-playing .tally.on:nth-child(n+4) { animation-delay: 0.42s; }
    .reveal-playing .tally.landed { animation: rv-land 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
    .reveal-playing .reveal-power.landed strong { animation: rv-land 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
    .reveal-playing .reveal-narration.on { animation: rv-type 1.3s steps(46, end) both; }
    .reveal-playing .reveal-stamp.on .stamp-plate { animation: rv-stamp 0.55s cubic-bezier(0.2, 1.55, 0.35, 1) both; }
    .reveal-playing .reveal-stamp.on .stamp-text { animation: rv-sheen 1.5s 0.5s ease-in-out both; }
    .reveal-playing .reveal-rays.on { animation: rv-rays-in 0.9s ease-out both; }
    .reveal-playing .reveal-power.on .luck-chip { animation: rv-pop 0.4s 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
    .reveal-rays::before { animation: rv-spin 40s linear infinite; }

    /* The cinema: letterbox, vignette, title card, grade, one camera timeline per kind. */
    .reveal-playing .reveal-stage::before, .reveal-playing .reveal-stage::after { animation: rv-letterbox 5.4s ease-in-out both; }
    .reveal-playing.reveal-spell .reveal-stage::before, .reveal-playing.reveal-spell .reveal-stage::after { animation-duration: 3.5s; }
    .reveal-playing.reveal-op .reveal-stage::before, .reveal-playing.reveal-op .reveal-stage::after { animation-duration: 4s; }
    .reveal-playing .reveal-vignette { animation: rv-vignette 5.4s ease-in-out both; }
    .reveal-playing .reveal-card { display: flex; animation: rv-card 1.1s ease-out both; }
    .reveal-playing .card-title { animation: rv-track 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
    .reveal-playing.reveal-battle:not(.past-3) .scene, .reveal-playing.reveal-op:not(.past-3) .scene, .reveal-playing.reveal-spell:not(.past-2) .scene { filter: none; }
    .reveal-playing .scene { transition: filter 0.9s ease-out; }
    .reveal-playing .camera { transform-box: view-box; transform-origin: 300px 140px; }
    .reveal-playing.reveal-battle.side-attacking .camera { animation: cam-attack 5.4s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing.reveal-battle.side-defending .camera { animation: cam-defend 5.4s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing.spell-landed .camera { animation: cam-spell 3.5s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing.spell-failed .camera { animation: cam-spell-fail 3.5s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing.spell-reflected .camera { animation: cam-spell-back 3.5s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing.spell-self .camera { animation: cam-spell-self 3.5s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing.reveal-op .camera { animation: cam-op 4s cubic-bezier(0.45, 0, 0.2, 1) both; }
    .reveal-playing .scene .far { animation: rv-parallax 5s ease-out both; }

    /* The battle: the march, the volley, the clash (flash, hit and shake), the stamp's thump, the fallen, the march home. */
    .reveal-playing.reveal-battle.past-1 .marcher { animation: rv-march 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
    .reveal-battle.at-2 .advance { animation: rv-lunge 0.55s ease-in-out; }
    .reveal-battle.at-2 .impact { animation: rv-impact 0.9s 0.22s ease-out both; }
    .reveal-battle.at-2 .burst { animation: rv-burst 0.9s 0.22s ease-out both; transform-box: fill-box; transform-origin: center; }
    .reveal-battle.at-2 .reveal-flash { animation: rv-flash 0.7s 0.24s ease-out both; }
    .reveal-battle.at-2 .reveal-stage { animation: rv-shake 0.55s 0.24s linear; }
    .reveal-battle.at-2 .scene { animation: rv-hit 0.35s 0.24s ease-out; }
    .reveal-battle.at-3 .reveal-stage, .reveal-op.at-3 .reveal-stage, .reveal-spell.at-2 .reveal-stage { animation: rv-thump 0.35s ease-out; }
    .reveal-playing.reveal-battle.past-4 .pip.fell { animation: rv-fall 0.8s ease-in both; }
    .reveal-battle.at-5 .march-dot { animation: rv-home 1.2s ease-in-out both; }

    /* The spell: the circle draws itself and turns, the glyphs kindle, the spell flies (and dies, or comes back). */
    .scene .ring-turn { transform-box: view-box; transform-origin: 112px 86px; }
    .spell-self .scene .ring-turn { transform-origin: 300px 92px; }
    .scene .ring-turn.cw { animation: rv-spin 10s linear infinite; }
    .scene .ring-turn.ccw { animation: rv-spin-back 14s linear infinite; }
    .reveal-playing .scene .ring-turn { animation-duration: 2.6s; }
    .reveal-spell.at-0 .rune-ring { animation: rv-draw 1.1s ease-out both; }
    .reveal-spell.at-0 .aura { animation: rv-charge 1.3s ease-in both; transform-box: fill-box; transform-origin: center; }
    .reveal-spell.at-0 .glyph { animation: rv-in 0.3s ease-out both; }
    .reveal-spell.at-0 .glyph.g2, .reveal-spell.at-0 .glyph.g6 { animation-delay: 0.3s; }
    .reveal-spell.at-0 .glyph.g3, .reveal-spell.at-0 .glyph.g7 { animation-delay: 0.6s; }
    .reveal-spell.at-0 .glyph.g4, .reveal-spell.at-0 .glyph.g8 { animation-delay: 0.9s; }
    .reveal-playing.reveal-spell.past-1 .bolt-path { animation: rv-draw 0.55s ease-in both; }
    .reveal-playing.reveal-spell.past-1 .bolt-path.back { animation-delay: 0.55s; }
    .reveal-playing.reveal-spell.past-1 .smoke { animation: rv-smoke 1.2s 0.45s ease-out both; }
    .reveal-playing.reveal-spell.past-1 .motif.on { animation-delay: 0.45s; }
    .reveal-playing.spell-reflected.past-1 .motif.on { animation-delay: 1.1s; }
    .reveal-spell.at-1.tone-win .reveal-flash { animation: rv-flash 0.7s 0.5s ease-out both; }
    .reveal-spell.at-1.spell-reflected .reveal-flash { animation: rv-flash 0.7s 1.1s ease-out both; }
    .reveal-spell.at-1.tone-win .reveal-stage { animation: rv-shake 0.45s 0.5s linear; }
    .reveal-playing .motif.on .m { animation: rv-pop 0.6s 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; transform-box: fill-box; transform-origin: center; }
    .reveal-playing.spell-reflected .motif.on .m { animation-delay: 1.1s; }
    .reveal-op.reveal-playing .motif.on .m { animation-delay: 0s; }

    /* The thief op: the crew creeps in, hopping, the lantern sweeps, the alarm, the lost, the way home. */
    .reveal-playing.reveal-op.past-0 .crew { animation: rv-creep 1.4s ease-out both; }
    .reveal-playing.reveal-op:not(.past-2) .hop { animation: rv-hop 0.34s ease-in-out infinite alternate; }
    .reveal-playing.reveal-op .hop.h1 { animation-delay: 0.11s; }
    .reveal-playing.reveal-op .hop.h2 { animation-delay: 0.22s; }
    .reveal-playing.reveal-op.past-1 .beam { animation: rv-sweep 1s ease-in-out both; transform-origin: 377px 92px; }
    .reveal-op.at-2 .lantern.alarm { animation: rv-blink 0.3s steps(2) 6; }
    .reveal-playing.reveal-op.past-2 .alarm-burst { animation: rv-flare 0.9s ease-out both; }
    .reveal-op.at-2.tone-loss .reveal-flash { animation: rv-flash 0.6s ease-out; }
    .reveal-op.at-2.op-caught .reveal-vignette { animation: rv-alarm 0.5s ease-in-out 3; }
    .reveal-playing .exclaim.on .bang { animation: rv-bang 0.45s cubic-bezier(0.2, 1.8, 0.4, 1) both; transform-box: fill-box; transform-origin: 50% 100%; }
    .reveal-playing .exclaim.on .bang.b2 { animation-delay: 0.14s; }
    .reveal-playing.reveal-op.past-3 .thief.lost { animation: rv-fall 0.8s ease-in both; }
    .reveal-op.at-4.tone-win .crew { animation: rv-retreat 1s ease-in both; }

    /* What lives on once it has come: flags, flames, coins, wards, rain, storms, eyes, stars, clouds, the lantern. */
    .scene .flag { animation: rv-flutter 1.3s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 0 50%; }
    .scene .m-fire .flame, .scene .m-torches .flame { animation: rv-flicker 0.8s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
    .scene .m-fire .flame.f2, .scene .m-torches .flame.f2 { animation-duration: 0.65s; }
    .scene .m-fire .flame.f3, .scene .m-torches .flame.f3 { animation-duration: 0.95s; }
    .scene .m-coins .coin { animation: rv-coin 1.6s ease-in infinite; }
    .scene .m-coins .coin.c2, .scene .m-coins .coin.c5 { animation-delay: 0.4s; }
    .scene .m-coins .coin.c3, .scene .m-coins .coin.c6 { animation-delay: 0.8s; }
    .scene .m-coins .coin.c4, .scene .m-coins .coin.c7 { animation-delay: 1.2s; }
    .scene .m-ward .ring { animation: rv-pulse 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
    .scene .m-ward .ring.r2 { animation-delay: 0.9s; }
    .scene .m-cloud .rain { animation: rv-rain 0.7s linear infinite; }
    .scene .m-cloud .rain.d1 { animation-delay: 0.23s; }
    .scene .m-cloud .rain.d2 { animation-delay: 0.46s; }
    .scene .m-cloud .bolt, .scene .m-lightning .bolt { animation: rv-strike 2.4s steps(1) infinite; }
    .scene .m-whirlwind .gust { animation: rv-sway 0.9s ease-in-out infinite alternate; }
    .scene .m-whirlwind .gust.g1 { animation-direction: alternate-reverse; }
    .scene .m-vortex .spin { animation: rv-spin 2.2s linear infinite; transform-box: fill-box; transform-origin: center; }
    .scene .m-eye .iris, .scene .m-eye .pupil { animation: rv-look 3s ease-in-out infinite; }
    .scene .m-moon .star-m, .scene .star { animation: rv-twinkle 2.6s ease-in-out infinite; }
    .scene .m-moon .star-m.s2, .scene .star:nth-of-type(3n) { animation-delay: 0.9s; }
    .scene .m-moon .star-m.s3, .scene .star:nth-of-type(3n+1) { animation-delay: 1.7s; }
    .scene .m-spark .ray, .scene .m-staff .orb { animation: rv-twinkle 1.2s ease-in-out infinite; }
    .scene .clouds .c1 { animation: rv-drift 16s ease-in-out infinite alternate; }
    .scene .clouds .c2 { animation: rv-drift 22s ease-in-out infinite alternate-reverse; }
    .scene .lantern { animation: rv-glow 2.4s ease-in-out infinite; }
    .scene .fort .slit { animation: rv-glow 1.7s ease-in-out infinite; }
}

@keyframes rv-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rv-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rv-land { 0% { transform: scale(1); } 40% { transform: scale(1.16); box-shadow: 0 0 0 1px rgba(255, 220, 140, 0.5), 0 0 18px rgba(255, 210, 120, 0.35); } 100% { transform: scale(1); } }
@keyframes rv-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes rv-stamp {
    0% { opacity: 0; transform: rotate(-17deg) scale(3.2); filter: blur(6px); }
    55% { opacity: 1; transform: rotate(-6deg) scale(0.9); filter: blur(0); }
    78% { transform: rotate(-7.5deg) scale(1.04); }
    100% { opacity: 1; transform: rotate(-7deg) scale(1); filter: blur(0); }
}
@keyframes rv-sheen { from { background-position: 100% 0; } to { background-position: 0% 0; } }
@keyframes rv-rays-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } to { opacity: 0.6; transform: translate(-50%, -50%) scale(1); } }
@keyframes rv-pop { 0% { opacity: 0; transform: scale(0.3); } 70% { opacity: 1; transform: scale(1.12); } 100% { opacity: 1; transform: scale(1); } }
@keyframes rv-letterbox { 0% { height: 0; } 9% { height: 11%; } 84% { height: 11%; } 100% { height: 0; } }
@keyframes rv-vignette { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0.75; } }
@keyframes rv-card { 0% { opacity: 0; } 22% { opacity: 1; } 68% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rv-track { from { letter-spacing: 0.5em; filter: blur(3px); } to { letter-spacing: 0.12em; filter: blur(0); } }
@keyframes cam-attack {
    0% { transform: translate(110px, 22px) scale(1.34); }
    13% { transform: translate(100px, 20px) scale(1.3); }
    33% { transform: translate(10px, 8px) scale(1.12); }
    36% { transform: translate(-8px, 10px) scale(1.24); }
    42% { transform: translate(-4px, 6px) scale(1.14); }
    50% { transform: translate(0, 4px) scale(1.08); }
    62% { transform: translate(0, 2px) scale(1.04); }
    100% { transform: none; }
}
@keyframes cam-defend {
    0% { transform: translate(-110px, 22px) scale(1.32); }
    13% { transform: translate(-90px, 18px) scale(1.26); }
    33% { transform: translate(10px, 8px) scale(1.12); }
    36% { transform: translate(8px, 10px) scale(1.24); }
    42% { transform: translate(4px, 6px) scale(1.14); }
    50% { transform: translate(0, 4px) scale(1.08); }
    62% { transform: translate(0, 2px) scale(1.04); }
    100% { transform: none; }
}
@keyframes cam-spell {
    0% { transform: translate(150px, 30px) scale(1.45); }
    36% { transform: translate(140px, 28px) scale(1.4); }
    44% { transform: translate(20px, 10px) scale(1.15); }
    53% { transform: translate(-120px, 8px) scale(1.35); }
    59% { transform: translate(-100px, 6px) scale(1.28); }
    72% { transform: translate(-20px, 0) scale(1.08); }
    100% { transform: none; }
}
@keyframes cam-spell-back {
    0% { transform: translate(150px, 30px) scale(1.45); }
    36% { transform: translate(140px, 28px) scale(1.4); }
    44% { transform: translate(20px, 10px) scale(1.15); }
    52% { transform: translate(-120px, 8px) scale(1.35); }
    58% { transform: translate(-40px, 8px) scale(1.18); }
    68% { transform: translate(140px, 24px) scale(1.34); }
    80% { transform: translate(30px, 6px) scale(1.08); }
    100% { transform: none; }
}
@keyframes cam-spell-fail {
    0% { transform: translate(150px, 30px) scale(1.45); }
    36% { transform: translate(140px, 28px) scale(1.4); }
    47% { transform: translate(10px, 62px) scale(1.32); }
    58% { transform: translate(0, 48px) scale(1.22); }
    72% { transform: translate(0, 16px) scale(1.08); }
    100% { transform: none; }
}
@keyframes cam-spell-self {
    0% { transform: translate(0, 44px) scale(1.5); }
    36% { transform: translate(0, 38px) scale(1.42); }
    44% { transform: translate(0, 20px) scale(1.2); }
    52% { transform: translate(0, 26px) scale(1.32); }
    66% { transform: translate(0, 10px) scale(1.1); }
    100% { transform: none; }
}
@keyframes cam-op {
    0% { transform: translate(140px, -40px) scale(1.45); }
    25% { transform: translate(110px, -34px) scale(1.4); }
    45% { transform: translate(-40px, -6px) scale(1.25); }
    52% { transform: translate(-90px, 10px) scale(1.38); }
    67% { transform: translate(-40px, 4px) scale(1.15); }
    100% { transform: none; }
}
@keyframes rv-parallax { from { transform: translateX(26px); } to { transform: none; } }
@keyframes rv-march { from { opacity: 0; transform: translateX(-90px); } to { opacity: 1; transform: none; } }
@keyframes rv-lunge { 0%, 100% { transform: none; } 45% { transform: translateX(46px); } }
@keyframes rv-impact { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rv-burst { from { transform: scale(0.2); } to { transform: scale(1.7); } }
@keyframes rv-flash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rv-hit { 0% { filter: brightness(2.4) contrast(1.5); } 30% { filter: brightness(1.5) contrast(1.2); } 100% { filter: none; } }
@keyframes rv-shake {
    0%, 100% { transform: none; }
    12% { transform: translate(-7px, 3px) rotate(-0.4deg); }
    26% { transform: translate(6px, -3px) rotate(0.3deg); }
    40% { transform: translate(-5px, 2px); }
    55% { transform: translate(4px, -1px); }
    70% { transform: translate(-2px, 1px); }
    85% { transform: translate(1px, 0); }
}
@keyframes rv-thump { 0%, 100% { transform: none; } 30% { transform: scale(1.015) translateY(3px); } }
@keyframes rv-fall { 0% { opacity: 1; } 30% { opacity: 0.15; } 55% { opacity: 0.9; } 100% { opacity: 0.5; } }
@keyframes rv-home { from { transform: translateX(-80px); } to { transform: none; } }
@keyframes rv-draw { from { stroke-dasharray: 1 2; stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes rv-charge { 0% { opacity: 0.2; transform: scale(0.6); } 85% { opacity: 1; transform: scale(1.25); } 100% { opacity: 1; transform: scale(1.1); } }
@keyframes rv-smoke { from { opacity: 0; transform: translateY(6px); } 40% { opacity: 0.8; } to { opacity: 0.6; transform: translateY(-8px); } }
@keyframes rv-creep { from { opacity: 0; transform: translateX(-90px); } to { opacity: 1; transform: none; } }
@keyframes rv-hop { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes rv-sweep { 0% { transform: rotate(-30deg); } 60% { transform: rotate(12deg); } 100% { transform: none; } }
@keyframes rv-blink { 0% { opacity: 1; } 100% { opacity: 0.2; } }
@keyframes rv-flare { 0% { opacity: 0; } 15% { opacity: 1; } 40% { opacity: 0.4; } 60% { opacity: 1; } 100% { opacity: 0.8; } }
@keyframes rv-alarm { 0%, 100% { box-shadow: inset 0 0 0 rgba(255, 40, 20, 0); } 50% { box-shadow: inset 0 0 70px rgba(255, 40, 20, 0.55); } }
@keyframes rv-bang { 0% { opacity: 0; transform: scale(0.2) translateY(8px); } 100% { opacity: 1; transform: none; } }
@keyframes rv-retreat { from { transform: none; opacity: 1; } to { transform: translateX(-60px); opacity: 0.7; } }
@keyframes rv-flutter { from { transform: skewY(-5deg) scaleX(0.92); } to { transform: skewY(5deg) scaleX(1); } }
@keyframes rv-flicker { from { transform: scale(1, 1); opacity: 0.9; } to { transform: scale(0.92, 1.12); opacity: 1; } }
@keyframes rv-coin { 0% { opacity: 0; transform: translateY(-34px); } 25% { opacity: 1; } 85% { opacity: 1; transform: translateY(16px); } 100% { opacity: 0; transform: translateY(20px); } }
@keyframes rv-pulse { 0%, 100% { opacity: 0.55; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes rv-rain { from { opacity: 0.9; transform: translateY(-6px); } to { opacity: 0; transform: translateY(10px); } }
@keyframes rv-strike { 0%, 70%, 78%, 100% { opacity: 0; } 72%, 80% { opacity: 1; } }
@keyframes rv-sway { from { transform: translateX(-5px); } to { transform: translateX(5px); } }
@keyframes rv-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes rv-spin-back { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
@keyframes rv-look { 0%, 100% { transform: none; } 30% { transform: translateX(-6px); } 65% { transform: translateX(6px); } }
@keyframes rv-twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes rv-glow { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
@keyframes rv-drift { from { transform: translateX(-20px); } to { transform: translateX(40px); } }

/* The Labs: the quick scenes, and the reveal above the result. */
.lab-scenes { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 4px 0 10px; }
.lab-scenes a { padding: 2px 8px; border: 1px solid var(--rule); background: var(--panel); }
.lab-scenes a.current { border-color: var(--gold); color: var(--gold); }

/* The Sound Lab: each sound's versions, a play button and a choice for each. */
.sound-lab-all { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.sound-lab-picks { color: var(--gold); }
.sound-board .sound-name { width: 42%; }
.sound-board .sound-name .small { display: block; }
.sound-versions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sound-version { display: inline-flex; align-items: center; gap: 5px; }
.sound-version.dark label { color: var(--gold); }
.sound-everyone { border: 1px solid var(--rule); padding: 0 4px; }
.sound-play { min-width: 2.2em; padding: 1px 6px; line-height: 1.4; }

/* The spell or op just carried out, offered again under its reveal: hidden while the reveal plays. */
.again-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 4px 0 10px; }
.again-bar[hidden], .reveal.reveal-playing ~ .again-bar { visibility: hidden; }
.again-bar[hidden] { display: none; }

/* A spell of our own about to run out (the stewards say so too). */
.spells tr.expiring td { background: rgba(255, 210, 127, 0.07); }

/* Standing orders for our own spells, below the cast form on the Mystics. */
.self-later { margin: 10px 0; }
.self-later > summary { cursor: pointer; color: var(--link); }
.later-link { display: block; margin-top: 2px; }

/* Another kingdom's roster: rulers out of our conquest range are dimmed. */
tr.out-of-range td { opacity: 0.6; }
.roster .act-links { font-size: 11px; }

/* ---------- Touch screens ---------- */
/* Fingers are wider than pointers: buttons, tabs and the bar's switches grow to be tapped (not the words and figures in
   running text). On a phone the music strip folds to the song playing, with "Songs" to open the rest. */
@media (pointer: coarse) {
    button:not(.linklike):not(.term):not(.fill), .button, input[type=submit] { min-height: 44px; }
    .tab { display: inline-flex; align-items: center; min-height: 40px; padding: 4px 12px; }
    .page-help-button { min-width: 40px; min-height: 40px; }
    .speed-button, .jump-button { min-height: 40px; }
}
@media (pointer: coarse) and (max-width: 767px) {
    .menu-item { min-height: 40px; }
    .clock .linklike, .clock .bell, .notices-bell, .app-refresh, .sound-toggle button, .ambience-toggle button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; vertical-align: middle; }
    .clock > span { vertical-align: middle; }
    .music .music-more { display: inline-flex; }
    .music:not(.open) button[data-track]:not([aria-pressed=true]):not([data-track=off]) { display: none; }
    .volume-link { display: none; }
}

/* ---------- The Wager Hall (Pages/WagerHall, wwwroot/js/wager.js) ----------
   A lantern-lit table of green felt in a dark wood rim; dice of old ivory; boards facing each other across the table. The
   motion (a die tumbling, dice dropping in and smashed away, the stamp of a verdict, coins for the winner, the table
   shaking) is for those who have not asked for less. */
.wager-who { display: inline-block; margin: 0 8px 2px 0; }
.wager-who.friend { color: var(--ok); }
.wager-who.foe { color: var(--bad); }
.wager-who.empty { color: var(--muted); font-style: italic; }
.wager-room { max-width: 420px; }
.wager-fortunes { display: flex; flex-wrap: wrap; gap: 10px; }
.wager-how { margin: 12px 0; max-width: 640px; }
.wager-how > summary { cursor: pointer; color: var(--cream); }
.wager-taunts { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.wager-taunt { font-size: 11px; }
.wager-seats-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); }
.wager-seats-line:empty { display: none; }
.wager-seats-button { font-size: 11px; padding: 3px 10px; }
.wager-practice-note { margin: 4px 0 8px; padding: 4px 10px; border-left: 3px solid var(--gold); background: rgba(216, 176, 96, .08); color: var(--cream); }

.wager-table {
    position: relative; max-width: 560px; margin: 8px 0 10px; padding: 10px 10px 14px; border-radius: 18px;
    background: radial-gradient(ellipse at 50% 40%, #1f5a2e 0%, #143d20 55%, #0b2413 100%);
    border: 10px solid #3b2412; box-shadow: inset 0 0 40px rgba(0, 0, 0, .7), 0 0 0 2px #1a0f06, 0 8px 24px rgba(0, 0, 0, .8);
}
.wager-busy .bones-col { cursor: progress; }
.wager-status { min-height: 1.3em; margin: 6px 0 0; color: var(--warn); text-align: center; }
.wager-waiting, .wager-watching { text-align: center; color: var(--cream); }
.wager-watching { color: var(--muted); }

.wager-seats { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 10px; }
.wager-seat {
    position: relative; flex: 1 1 140px; padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, .45);
    border: 1px solid rgba(255, 220, 160, .15); display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline;
}
.wager-seat.you { border-color: var(--gold); }
.wager-seat.to-move { box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(216, 176, 96, .6); }
.wager-seat.friend .wager-seat-name { color: var(--ok); }
.wager-seat.foe .wager-seat-name { color: var(--bad); }
.wager-seat-name { font-weight: bold; }
.wager-chips { color: var(--gold); margin-left: auto; }
.wager-net { font-size: 11px; color: var(--muted); }
.wager-net.up { color: var(--ok); }
.wager-net.down { color: var(--bad); }
.wager-ready { font-size: 10px; color: var(--ok); text-transform: uppercase; letter-spacing: 1px; }
.wager-bubble {
    position: absolute; left: 10px; bottom: 100%; margin-bottom: 4px; padding: 3px 8px; border-radius: 10px; z-index: 3;
    background: #fff6dc; color: #2a1a10; font-size: 11px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .6);
    animation: wg-bubble .25s ease-out;
}

/* Bones: two boards facing each other, the die between. */
.bones { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bones-board { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bones-board.them { flex-direction: column-reverse; }
.bones-head { display: flex; gap: 12px; align-items: baseline; color: var(--cream); }
.bones-total { color: var(--gold); font-weight: bold; }
.bones-cols { display: flex; gap: 8px; }
.bones-col {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px; border-radius: 8px;
    background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 220, 160, .12); color: inherit; font: inherit; min-width: 0;
}
button.bones-col { cursor: pointer; border-color: rgba(216, 176, 96, .55); background: rgba(216, 176, 96, .1); box-shadow: none; text-shadow: none; }
button.bones-col:hover, button.bones-col:focus-visible, .bones-col.previewing { background: rgba(216, 176, 96, .25); outline: 2px solid var(--gold); }
.bones-board.them .bones-cells { flex-direction: column-reverse; }
.bones-cells { display: flex; flex-direction: column; gap: 3px; }
.bones-cell { position: relative; display: block; width: 46px; height: 46px; border-radius: 7px; background: rgba(0, 0, 0, .25); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .6); }
.bones-col-score { font-size: 11px; color: var(--cream); min-height: 1.2em; }
.bones-gain {
    position: absolute; top: -10px; right: -8px; padding: 1px 5px; border-radius: 8px; background: var(--gold); color: #1a0f06;
    font-weight: bold; font-size: 11px; z-index: 2;
}
.bones-middle { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.bones-die-holder { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); }
.bones-die-holder .die { width: 52px; height: 52px; }
.bones-die-holder.mine .die { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(216, 176, 96, .7), inset 0 -3px 0 rgba(0, 0, 0, .18); }
.bones-turn { display: flex; align-items: center; gap: 8px; color: var(--cream); }
.bones-turn.mine { color: var(--gold); font-weight: bold; }
.bones-smashed {
    position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) rotate(-8deg); color: #ff6050; font-weight: bold;
    font-size: 14px; text-shadow: 0 1px 0 #000, 0 0 6px #000; pointer-events: none; animation: wg-pop .9s ease-out forwards; z-index: 3;
}

/* A die: nine places in a grid, the pips dark on ivory. */
.die {
    display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); width: 100%; height: 100%; padding: 6px; border-radius: 8px;
    background: linear-gradient(145deg, #fffaf0, #e6dcc6); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 2px 3px rgba(0, 0, 0, .6);
}
.die .pip, .die .spot { display: block; margin: auto; width: 70%; height: 70%; border-radius: 50%; }
.die .pip { background: radial-gradient(circle at 35% 35%, #4a2a1a, #120805); }
.die.pair { background: linear-gradient(145deg, #fff3c4, #e8cf7a); }
.die.triple { background: linear-gradient(145deg, #ffe08a, #d6a23a); box-shadow: 0 0 10px rgba(255, 200, 80, .8), inset 0 -3px 0 rgba(0, 0, 0, .18); }
.die.doomed { background: linear-gradient(145deg, #ffd0c4, #e88a7a); box-shadow: 0 0 0 2px #ff6050; }
.die.ghost { position: absolute; left: 0; top: 0; width: 46px; height: 46px; pointer-events: none; animation: wg-shatter .8s ease-in forwards; }

.wager-ring {
    --left: 1; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 10px; color: var(--cream);
    background: radial-gradient(closest-side, #0b2413 78%, transparent 80% 100%), conic-gradient(var(--gold) calc(var(--left) * 360deg), rgba(0, 0, 0, .4) 0);
}
.wager-ring.hurry { color: #ff8070; background: radial-gradient(closest-side, #0b2413 78%, transparent 80% 100%), conic-gradient(#ff6050 calc(var(--left) * 360deg), rgba(0, 0, 0, .4) 0); }

.wager-verdict { margin: 10px auto 0; text-align: center; }
.wager-verdict-line { font-size: 15px; font-weight: bold; color: var(--cream); margin: 4px 0; }
.wager-verdict.won .wager-verdict-line { color: var(--gold); text-shadow: 0 0 8px rgba(216, 176, 96, .6); }
.wager-verdict.lost .wager-verdict-line { color: var(--bad); }
.wager-again { font-size: 13px; padding: 5px 16px; }

.wager-stamp {
    position: absolute; left: 50%; top: 45%; z-index: 5; padding: 6px 22px; border: 4px solid currentColor; border-radius: 8px;
    font: bold 30px/1 Georgia, serif; letter-spacing: 3px; text-transform: uppercase; background: rgba(0, 0, 0, .55);
    transform: translate(-50%, -50%) rotate(-10deg); pointer-events: none; animation: wg-stamp 2.6s ease-out forwards;
}
.wager-stamp.won { color: var(--gold); }
.wager-stamp.lost { color: #ff6050; }
.wager-stamp.draw { color: var(--cream); }
.wager-coins { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 4; }
.wager-coin {
    position: absolute; width: 14px; height: 14px; margin: -7px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff2b0, #d8a030 60%, #8a5a10); box-shadow: 0 0 4px rgba(255, 210, 90, .8);
    animation: wg-coin 1.4s cubic-bezier(.2, .8, .3, 1) var(--delay, 0ms) forwards; opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .die.rolled.tumble { animation: wg-tumble .65s cubic-bezier(.2, .7, .3, 1); }
    .bones-cell.dropped .die { animation: wg-drop .35s cubic-bezier(.2, 1.4, .4, 1); }
    .wager-table.shake { animation: wg-shake .35s ease-in-out; }
    .bones-die-holder.mine .die { animation: wg-glow 1.6s ease-in-out infinite; }
    .wager-ring.hurry { animation: wg-pulse .5s ease-in-out infinite alternate; }
}
@media (prefers-reduced-motion: reduce) {
    .wager-stamp { animation: none; opacity: 0; }
    .die.ghost, .wager-coin, .bones-smashed { display: none; }
}

@keyframes wg-tumble {
    0% { transform: translateY(-30px) rotate(-200deg) scale(.6); opacity: 0; }
    55% { transform: translateY(4px) rotate(25deg) scale(1.08); opacity: 1; }
    75% { transform: translateY(-3px) rotate(-8deg); }
    100% { transform: none; }
}
@keyframes wg-drop {
    0% { transform: translateY(-26px) scale(1.4); opacity: 0; }
    70% { transform: translateY(2px) scale(.96); opacity: 1; }
    100% { transform: none; }
}
@keyframes wg-shatter {
    0% { transform: none; opacity: 1; }
    100% { transform: translate(var(--dx, 0), 60px) rotate(var(--spin, 180deg)) scale(.3); opacity: 0; }
}
@keyframes wg-shake {
    0%, 100% { transform: none; }
    20% { transform: translate(-5px, 2px) rotate(-.5deg); }
    40% { transform: translate(5px, -2px) rotate(.5deg); }
    60% { transform: translate(-3px, 1px); }
    80% { transform: translate(2px, -1px); }
}
@keyframes wg-stamp {
    0% { transform: translate(-50%, -50%) rotate(-10deg) scale(3); opacity: 0; }
    12% { transform: translate(-50%, -50%) rotate(-10deg) scale(.92); opacity: 1; }
    18% { transform: translate(-50%, -50%) rotate(-10deg) scale(1); }
    80% { opacity: 1; }
    100% { transform: translate(-50%, -50%) rotate(-10deg) scale(1); opacity: 0; }
}
@keyframes wg-coin {
    0% { transform: translate(0, 0) scale(.6); opacity: 1; }
    60% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 1; }
    100% { transform: translate(calc(var(--dx) * 1.15), calc(var(--dy) + 90px)) scale(.8); opacity: 0; }
}
@keyframes wg-glow {
    0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(216, 176, 96, .5), inset 0 -3px 0 rgba(0, 0, 0, .18); }
    50% { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(216, 176, 96, .95), inset 0 -3px 0 rgba(0, 0, 0, .18); }
}
@keyframes wg-pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@keyframes wg-pop {
    0% { transform: translate(-50%, -50%) rotate(-8deg) scale(.4); opacity: 0; }
    30% { transform: translate(-50%, -50%) rotate(-8deg) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -90%) rotate(-8deg) scale(1); opacity: 0; }
}
@keyframes wg-bubble { from { transform: translateY(6px) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 767px) {
    .wager-table { padding: 8px 6px 12px; border-width: 6px; border-radius: 12px; }
    .bones-cell { width: 40px; height: 40px; }
    .die.ghost { width: 40px; height: 40px; }
    .wager-stamp { font-size: 22px; }
}

/* Tally (wager.js tally()): each side a grid of nine places, its total and its sets; cards of the shoe in parchment, plus
   cards blue, minus cards red, either-way cards gilded; one's hand face up below, the other's face down above. */
.tally { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tally-set { color: var(--gold); font: bold 13px/1 Georgia, serif; letter-spacing: 2px; text-transform: uppercase; }
.tally-side { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 10px; background: rgba(0, 0, 0, .22); }
.tally-side.them { flex-direction: column-reverse; }
.tally-side.stood { box-shadow: inset 0 0 0 1px rgba(216, 176, 96, .5); }
.tally-head { display: flex; gap: 10px; align-items: center; color: var(--cream); }
.tally-total { min-width: 36px; padding: 2px 8px; border-radius: 12px; background: rgba(0, 0, 0, .5); color: var(--cream); font: bold 18px/1.2 Georgia, serif; text-align: center; }
.tally-total.near { color: var(--warn); }
.tally-total.twenty { color: #1a0f06; background: var(--gold); box-shadow: 0 0 12px rgba(216, 176, 96, .8); }
.tally-total.over { color: #fff; background: #a02010; }
.tally-pips { display: inline-flex; gap: 3px; }
.tally-pip { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--gold); }
.tally-pip.won { background: var(--gold); box-shadow: 0 0 6px rgba(216, 176, 96, .8); }
.tally-stood { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); }
.tally-grid { display: grid; grid-template-columns: repeat(9, 38px); gap: 4px; }
.tally-slot { width: 38px; height: 52px; border-radius: 5px; background: rgba(0, 0, 0, .25); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .6); }
.tally-hand { display: flex; gap: 6px; min-height: 52px; align-items: center; }
.tally-middle { min-height: 40px; display: flex; align-items: center; }
.tally-acts { display: flex; gap: 10px; margin-top: 4px; }
.tally-act { font-size: 14px; padding: 6px 18px; }
.tally-act.stand { border-color: var(--gold); color: var(--gold); }

.tcard {
    position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 38px; height: 52px;
    border-radius: 5px; font: bold 17px/1 Georgia, serif; box-shadow: 0 2px 3px rgba(0, 0, 0, .6), inset 0 0 0 2px rgba(255, 255, 255, .25);
}
.tcard.shoe { background: linear-gradient(160deg, #f8ecd0, #dcc79a); color: #2a1a10; }
.tcard.plus { background: linear-gradient(160deg, #6aa0e8, #2a5aa8); color: #fff; }
.tcard.minus { background: linear-gradient(160deg, #e87a6a, #a83a2a); color: #fff; }
.tcard.either { background: linear-gradient(160deg, #ffe08a, #c8902a); color: #2a1a10; }
.tcard.back { background: repeating-linear-gradient(45deg, #4a1810 0 4px, #2a0c06 4px 8px); box-shadow: 0 2px 3px rgba(0, 0, 0, .6), inset 0 0 0 2px #d8b060; }
.tcard-from { font-size: 9px; opacity: .8; }
.tcard.hand { width: 44px; height: 60px; font-size: 18px; }
.tcard.hand.playable { cursor: pointer; transform: translateY(-3px); box-shadow: 0 0 0 2px var(--gold), 0 6px 10px rgba(0, 0, 0, .6); }
.tcard-play {
    position: absolute; inset: 0; width: 100%; padding: 0; border: 0; border-radius: 5px; background: transparent; box-shadow: none;
    color: transparent; font-size: 0; text-shadow: none; cursor: pointer;
}
.tcard-play.up, .tcard-play.down {
    position: absolute; left: 0; width: 100%; height: 50%; color: #2a1a10; font: bold 14px/1 Georgia, serif; background: rgba(255, 255, 255, .0);
}
.tcard-play.up { top: 0; inset: auto; top: 0; left: 0; border-radius: 5px 5px 0 0; }
.tcard-play.down { inset: auto; bottom: 0; left: 0; border-radius: 0 0 5px 5px; }
.tcard.hand.either.playable .tcard-value { opacity: .35; }
.tcard-play:hover, .tcard-play:focus-visible { background: rgba(255, 255, 255, .35); outline: 2px solid var(--gold); }

.tally-deck { margin: 10px auto 0; max-width: 460px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .35); text-align: center; }
.tally-deck h3 { margin: 0 0 4px; color: var(--gold); font-size: 13px; }
.tally-deck-grid { display: grid; grid-template-columns: repeat(6, 44px); gap: 5px; justify-content: center; margin: 6px 0; }
.tcard.pick { width: 44px; height: 54px; padding: 0; border: 0; cursor: pointer; opacity: .55; text-shadow: none; }
.tcard.pick[aria-pressed="true"] { opacity: 1; transform: translateY(-3px); box-shadow: 0 0 0 2px #fff, 0 0 10px rgba(255, 255, 255, .5); }
.tcard.pick:disabled { opacity: .2; cursor: not-allowed; }
.tally-deck-count { margin: 2px 0; color: var(--cream); }
.tally-deck-count.ready { color: var(--ok); }
.tally-deck-buttons { display: flex; gap: 8px; justify-content: center; }
.tally-deck-now { margin: 6px 0 0; }
.wager-stamp.small { font-size: 22px; padding: 4px 14px; animation-duration: 1.9s; }

@media (prefers-reduced-motion: no-preference) {
    .tcard.dealt { animation: wg-deal .35s cubic-bezier(.2, .9, .3, 1); }
    .tcard.flicked { animation: wg-flick .4s cubic-bezier(.2, 1.3, .4, 1); }
    .tally-total.twenty { animation: wg-glow-total 1.2s ease-in-out infinite; }
}
@keyframes wg-deal {
    0% { transform: translate(-120px, -40px) rotate(-25deg) scale(.7); opacity: 0; }
    100% { transform: none; opacity: 1; }
}
@keyframes wg-flick {
    0% { transform: translateY(40px) rotate(12deg) scale(1.3); opacity: 0; }
    100% { transform: none; opacity: 1; }
}
@keyframes wg-glow-total {
    0%, 100% { box-shadow: 0 0 8px rgba(216, 176, 96, .6); }
    50% { box-shadow: 0 0 18px rgba(216, 176, 96, 1); }
}

@media (max-width: 767px) {
    .tally-grid { grid-template-columns: repeat(5, 34px); }
    .tally-slot, .tally-grid .tcard { width: 34px; height: 46px; font-size: 15px; }
    .tally-deck-grid { grid-template-columns: repeat(6, 40px); }
    .tcard.pick { width: 40px; height: 50px; }
}

/* A gathering's countdown, before a game of more than two. */
.wager-starts { text-align: center; color: var(--gold); }

/* Hold'em (wager.js holdem()): an oval of felt within the table, each seat round it (the cards above a plate with the name
   and chips, what they did below, the dealer's button beside), bets in front of the seats, the board and the pot in the
   middle. Cards of ivory with red and black suits; backs of the hall's red and gold. */
.holdem { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hm-felt { position: relative; width: 100%; height: 400px; margin-bottom: 14px; }
.hm-rail {
    position: absolute; inset: 14% 10%; border-radius: 50%;
    background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, .05), rgba(0, 0, 0, .22) 75%);
    box-shadow: inset 0 0 0 3px rgba(216, 176, 96, .28), inset 0 0 30px rgba(0, 0, 0, .5);
}
.hm-seat {
    position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); z-index: 2;
    display: flex; flex-direction: column; align-items: center; gap: 2px; width: 104px;
}
.hm-cards { display: flex; gap: 2px; min-height: 42px; align-items: flex-end; }
.hm-plate {
    display: flex; flex-direction: column; align-items: center; width: 100%; padding: 2px 6px; border-radius: 8px; box-sizing: border-box;
    background: rgba(0, 0, 0, .65); border: 1px solid rgba(255, 220, 160, .18); line-height: 1.25;
}
.hm-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: bold; color: var(--cream); }
.hm-seat.friend .hm-name { color: var(--ok); }
.hm-seat.foe .hm-name { color: var(--bad); }
.hm-seat.you .hm-name { color: var(--gold); }
.hm-stack { color: var(--gold); font-size: 12px; }
.hm-seat.you .hm-plate { border-color: var(--gold); }
.hm-seat.to-move .hm-plate { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(216, 176, 96, .7); }
.hm-seat.folded .hm-plate, .hm-seat.out .hm-plate { opacity: .5; }
.hm-seat.winner .hm-plate { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 210, 90, .9); }
.hm-last {
    padding: 0 6px; border-radius: 8px; background: #fff6dc; color: #2a1a10; font-size: 10px; font-weight: bold;
    letter-spacing: .5px; text-transform: uppercase; white-space: nowrap;
}
.hm-last.fold { background: rgba(0, 0, 0, .5); color: var(--muted); }
.hm-last.allin { background: #a02010; color: #fff; }
.hm-last.bet, .hm-last.raise, .hm-last.won { background: var(--gold); color: #1a0f06; }
.hm-last.waiting { background: transparent; color: var(--muted); font-weight: normal; letter-spacing: 0; text-transform: none; }
.hm-button {
    position: absolute; right: -8px; top: 30px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff, #d8d0c0); color: #1a0f06; font: bold 10px/1 Georgia, serif; box-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.hm-ring { position: absolute; left: -10px; top: -8px; z-index: 3; width: 30px; height: 30px; font-size: 9px; }
.hm-seat .wager-bubble { left: 50%; bottom: 100%; transform: translateX(-50%); }

.pcard {
    position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 30px; height: 42px;
    border-radius: 4px; background: linear-gradient(160deg, #fffdf6, #ece2cc); box-shadow: 0 2px 3px rgba(0, 0, 0, .6); font: bold 14px/1 Georgia, serif;
}
.pcard.red { color: #b0201a; }
.pcard.black { color: #1a1410; }
.pcard-suit { font-size: 15px; line-height: 1; }
.pcard.back { background: repeating-linear-gradient(45deg, #6a1a12 0 4px, #3a0c08 4px 8px); box-shadow: 0 2px 3px rgba(0, 0, 0, .6), inset 0 0 0 2px #d8b060; }
.hm-seat.you .pcard { width: 38px; height: 54px; font-size: 18px; }
.hm-seat.you .pcard .pcard-suit { font-size: 19px; }
.pcard.lit { box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(255, 210, 90, .9); }
.pcard.dim { opacity: .45; }

.hm-middle { position: absolute; left: 50%; top: 50%; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translate(-50%, -50%); }
.hm-handno { font-size: 10px; color: rgba(255, 246, 220, .5); letter-spacing: 1px; text-transform: uppercase; }
.hm-board { display: flex; gap: 4px; }
.hm-slot { width: 34px; height: 48px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 220, 160, .2); }
.hm-slot .pcard { width: 34px; height: 48px; font-size: 16px; }
.hm-pot { display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 10px; background: rgba(0, 0, 0, .45); color: var(--gold); font-weight: bold; }
.hm-chip {
    display: inline-block; width: 14px; height: 14px; border-radius: 50%;
    background: radial-gradient(circle, #f6e7b8 0 30%, #b02a20 32% 62%, #f6e7b8 64% 70%, #b02a20 72%); box-shadow: 0 1px 2px rgba(0, 0, 0, .7);
}
.hm-bet {
    position: absolute; left: var(--x); top: var(--y); z-index: 1; display: inline-flex; align-items: center; gap: 3px; padding: 0 6px 0 2px;
    border-radius: 9px; background: rgba(0, 0, 0, .4); color: var(--cream); font-size: 11px; transform: translate(-50%, -50%);
}
.hm-flying { position: absolute; left: 50%; top: 50%; z-index: 4; margin: -7px; animation: hm-sweep .8s cubic-bezier(.3, .1, .3, 1) var(--delay, 0ms) forwards; }

.hm-made { margin: 2px 0 0; color: var(--gold); font-weight: bold; }
.hm-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 440px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .35); box-sizing: border-box; }
.hm-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hm-act { min-width: 84px; padding: 6px 14px; font-size: 14px; }
.hm-act.fold { border-color: #a06050; color: #ffb0a0; }
.hm-act.raise { border-color: var(--gold); color: var(--gold); font-weight: bold; }
.hm-act.raise.all { border-color: #ff6050; color: #ff8070; }
.hm-picker { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.hm-slider { width: 100%; accent-color: var(--gold); }
.hm-sizes { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.hm-size { padding: 3px 8px; font-size: 11px; }
.hm-tocall { margin: 0; }
.wager-verdict.hm-verdict .wager-verdict-line { color: var(--cream); font-size: 14px; }
.wager-verdict.hm-verdict .wager-verdict-line.side { font-size: 13px; }
.wager-verdict.hm-verdict .wager-verdict-line.mine { color: var(--gold); text-shadow: 0 0 8px rgba(216, 176, 96, .6); }

@media (prefers-reduced-motion: no-preference) {
    .pcard.dealt { animation: hm-deal .35s cubic-bezier(.2, .9, .3, 1) var(--deal, 0ms) both; }
    .pcard.turned { animation: hm-turn .45s ease-out var(--deal, 0ms) both; }
    .pcard.flip { animation: hm-turn .4s ease-out both; }
    .hm-bet.slid { animation: hm-slide .3s ease-out; }
    .hm-seat.to-move .hm-plate { animation: hm-glow 1.6s ease-in-out infinite; }
    .hm-seat.winner .hm-plate { animation: hm-glow 1s ease-in-out 3; }
}
@media (prefers-reduced-motion: reduce) {
    .hm-flying { display: none; }
}
@keyframes hm-deal { 0% { transform: translateY(-60px) rotate(-30deg) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes hm-turn { 0% { transform: rotateY(90deg) scale(.9); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes hm-slide { 0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } 100% { transform: translate(-50%, -50%); opacity: 1; } }
@keyframes hm-sweep { 0% { opacity: 1; } 100% { left: var(--x); top: var(--y); opacity: .2; } }
@keyframes hm-glow { 50% { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(255, 210, 90, 1); } }

@media (max-width: 767px) {
    .hm-felt { height: 440px; }
    .hm-seat { width: 84px; }
    .hm-slot, .hm-slot .pcard { width: 28px; height: 40px; font-size: 13px; }
    .pcard { width: 26px; height: 36px; font-size: 12px; }
    .pcard-suit { font-size: 12px; }
    .hm-seat.you .pcard { width: 34px; height: 48px; font-size: 16px; }
}
