/*
 * 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;
    --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; }
.queue td.num { min-width: 34px; }
.sticky { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.hdr-navy .sticky { background: var(--hdr-navy); }
.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%; }
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); }
.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; }
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; }
.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; }
.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); }
.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; }
.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%; }
.build-grid input { width: 64px; }

/* ---------- 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; }
.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; }
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; }
    .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); }
    .build-grid .second { display: none; }
}

/* 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; }

/* The music strip in the resource bar */
.music { margin-left: auto; color: var(--muted); }
.music button { color: var(--link); padding: 0 3px; }
.music button[aria-pressed=true] { color: var(--fg); font-weight: bold; text-decoration: underline; }
.music .music-wait { display: none; font-size: 11px; }
.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); }
.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; }
}

/* 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; }

/* 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; }
.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; }
.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 { margin: 2px 0; padding-left: 18px; }
.solo-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 { white-space: normal; }
    .solo-goals meter.goal-bar { display: block; width: 64px; margin: 3px 0 0; }
}
