:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --ink: #1f2933;
  --ink-soft: #5b6670;
  --line: #e2ddd2;
  --accent: #2d6cdf;
  --accent-ink: #ffffff;
  --brand: #e0483e;

  --ocean: #cfe6f3;
  --graticule: rgba(255, 255, 255, 0.55);
  --land: #f3e7c9;
  --land-stroke: #9a8c70;
  --land-inactive: #e7e4dd;
  --land-inactive-stroke: #c9c4b9;
  --hover: #ffd166;
  --selected: #5b8def;
  --first: #3fae5a;
  --ok: #f0b43c;
  --missed: #e2574c;
  --hint: #8e44ec;

  --hover-bg: #f4f2ee;
  --subtle-bg: #f6f3ec;
  --track: #ece8df;
  --pip-used: #e3dfd6;
  --missed-bg: #fde8e6;
  --ok-ink: #c98a0b;
  --code-bg: #ece7dc;
  --selected-hover: #86a9f2;
  --flash-wrong-alt: #ffb3ad;
  --flash-right-from: #ffffff;
  --hint-alt: #e9d8ff;
  --attribution: rgba(31, 41, 51, 0.55);
  --scrim: rgba(31, 41, 51, 0.35);
  --tooltip-bg: rgba(31, 41, 51, 0.92);
  --toast-bg: #1f2933;

  --radius: 12px;
  --shadow: 0 6px 24px rgba(31, 41, 51, 0.12);
  color-scheme: light;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
}

/* Dark theme. js/theme.js sets data-theme from the saved choice, or the device setting if none. */
:root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #14181d;
    --panel: #1e242b;
    --ink: #e6e9ec;
    --ink-soft: #9ca7b2;
    --line: #333c46;
    --accent: #3b7be8;
    --brand: #ef5a50;

    --ocean: #10293b;
    --graticule: rgba(255, 255, 255, 0.07);
    --land: #4a4535;
    --land-stroke: #8f8468;
    --land-inactive: #262b31;
    --land-inactive-stroke: #3b424a;
    --hover: #f2c04f;
    --selected: #5b8def;
    --first: #3a9e53;
    --ok: #d9a232;
    --missed: #d6544a;
    --hint: #9b5cf0;

    --hover-bg: #283039;
    --subtle-bg: #262d35;
    --track: #2a313a;
    --pip-used: #3a424c;
    --missed-bg: #3d2523;
    --ok-ink: #e8b443;
    --code-bg: #2a313a;
    --selected-hover: #7ea3f2;
    --flash-wrong-alt: #7a2d27;
    --flash-right-from: #c9f0d2;
    --hint-alt: #4a2d78;
    --attribution: rgba(230, 233, 236, 0.5);
    --scrim: rgba(0, 0, 0, 0.55);
    --tooltip-bg: rgba(10, 13, 16, 0.94);
    --toast-bg: #0b0e11;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
[data-theme='dark'] .flag { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
input, select { background: var(--panel); }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.btn:hover { background: var(--hover-bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: 14px 26px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-icon { display: inline-flex; margin-left: 2px; }
/* Outline icon at the start of a button label. */
.btn .ico { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon svg { height: 0.8em; width: auto; }
/* A trailing triangle tapers to a point, so trim the padding on that side to look balanced. */
.btn.big.icon-after { padding-right: 22px; }

.flag {
  width: 1.5em; height: 1.125em; object-fit: cover; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); flex: none; vertical-align: middle;
}

/* ---------------- Map ---------------- */
.map-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--ocean); }
.geomap { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.geomap .sphere { fill: var(--ocean); }
.geomap .graticule { fill: none; stroke: var(--graticule); stroke-width: 0.6px; vector-effect: non-scaling-stroke; }
.geomap .country {
  fill: var(--land); stroke: var(--land-stroke); stroke-width: 0.6px; vector-effect: non-scaling-stroke;
  stroke-linejoin: round; cursor: pointer; transition: fill 0.15s;
}
.geomap .country.other,
.geomap .country.inactive { fill: var(--land-inactive); stroke: var(--land-inactive-stroke); cursor: default; }
.geomap .dot {
  fill: var(--land); stroke: var(--land-stroke); stroke-width: 1px; vector-effect: non-scaling-stroke;
  cursor: pointer; fill-opacity: 0.9;
}
.geomap .dot.inactive { display: none; }
.geomap .hover { fill: var(--hover); }
.geomap .selected { fill: var(--selected); }
.geomap .selected.hover { fill: var(--selected-hover); }
.geomap .s-first { fill: var(--first); }
.geomap .s-ok { fill: var(--ok); }
.geomap .s-missed { fill: var(--missed); }
.geomap .s-first.hover, .geomap .s-ok.hover, .geomap .s-missed.hover { fill-opacity: 0.75; }

.geomap .flash-wrong { animation: flash-wrong 0.9s ease-out; }
@keyframes flash-wrong {
  0%, 40% { fill: var(--missed); }
  20%, 60% { fill: var(--flash-wrong-alt); }
}
.geomap .flash-right { animation: flash-right 0.8s ease-out; }
@keyframes flash-right {
  0% { fill: var(--flash-right-from); }
  100% { fill: var(--first); }
}
.geomap .hint { animation: hint-pulse 0.9s ease-in-out infinite; }
@keyframes hint-pulse {
  0%, 100% { fill: var(--hint); }
  50% { fill: var(--hint-alt); }
}
.geomap .ring circle {
  fill: none; stroke: var(--hint); stroke-width: 3px; vector-effect: non-scaling-stroke;
  transform-box: fill-box; transform-origin: center; animation: ring 0.9s ease-in-out infinite alternate;
}
@keyframes ring {
  from { transform: scale(1.5); opacity: 0.35; }
  to { transform: scale(1); opacity: 1; }
}

.map-tooltip {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--tooltip-bg); color: #fff; border-radius: 8px; font-weight: 600; font-size: 0.95rem;
  white-space: nowrap; box-shadow: var(--shadow);
}
/* Game mode: the label is the target to find, not the hovered country, so make it read as a prompt. */
.map-tooltip.has-caption { background: var(--accent); padding-left: 6px; }
.map-tooltip-caption {
  padding: 2px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.22);
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}

.zoom-controls {
  position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 5;
}
.zoom-controls button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  font-size: 1.25rem; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); line-height: 1;
}
.zoom-controls button:hover { background: var(--hover-bg); }

.attribution {
  position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: var(--attribution); z-index: 5;
}
.attribution a { color: inherit; }

/* ---------------- Game ---------------- */
.game { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); min-height: 64px; z-index: 10; flex-wrap: wrap;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--hover-bg); }
.icon-btn svg { width: 20px; height: 20px; }
/* Show the moon in light mode (switch to dark) and the sun in dark mode (switch to light). */
.lang-select {
  flex: none; height: 40px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.lang-select:hover { background: var(--hover-bg); }
.lang-picker { position: relative; display: inline-flex; flex: none; }
.lang-picker[hidden] { display: none; }
.lang-picker .lang-select { appearance: none; -webkit-appearance: none; padding: 0 32px 0 34px; }
.lang-picker svg { position: absolute; top: 50%; transform: translateY(-50%); pointer-events: none; }
.lang-picker .i-translate { left: 10px; width: 19px; height: 19px; color: var(--ink-soft); }
.lang-picker .i-chevron { right: 11px; width: 13px; height: 13px; color: var(--ink); }
.theme-toggle .i-sun, [data-theme='dark'] .theme-toggle .i-moon { display: none; }
[data-theme='dark'] .theme-toggle .i-sun { display: block; }
.prompt { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; }
.prompt .label { color: var(--ink-soft); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.06em; }
.prompt .target { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.prompt .target .flag { width: 2.1rem; height: 1.575rem; }
.guesses { display: flex; gap: 5px; margin-left: 4px; }
.guesses span { width: 12px; height: 12px; border-radius: 50%; background: var(--first); }
.guesses span.used { background: var(--pip-used); }
.stats { display: flex; gap: 18px; align-items: center; }
.stat { text-align: center; min-width: 54px; }
.stat b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--ink-soft); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.progress { height: 4px; background: var(--track); }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

.feedback {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6;
  padding: 8px 16px; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow);
  background: var(--panel); display: flex; align-items: center; gap: 8px; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
}
.feedback.good { background: var(--first); color: #fff; }
.feedback.bad { background: var(--missed); color: #fff; }
.feedback.hint { background: var(--hint); color: #fff; }
.feedback.pop { animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(0.9); } to { transform: translateX(-50%) scale(1); } }

.overlay {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--scrim); overflow: auto;
}
.card {
  background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 28px;
  width: min(560px, 100%); max-height: 100%; overflow: auto;
}
.card h1 { margin: 0 0 6px; font-size: 1.8rem; }
.card h2 { margin: 18px 0 8px; font-size: 1rem; }
.card p { margin: 6px 0; color: var(--ink-soft); line-height: 1.45; }
.card .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
/* Low-key text link for teacher-only actions, tucked at the end of an actions row. */
.subtle-link {
  margin-left: auto; align-self: flex-end; padding: 4px 2px;
  font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; opacity: 0.8;
}
.subtle-link:hover { opacity: 1; text-decoration: underline; }
/* Quiet footer row at the bottom of a card, for secondary links like Customize. */
.card-foot { display: flex; justify-content: flex-end; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-foot .subtle-link { margin-left: 0; align-self: auto; }
.card label.field { display: block; margin-top: 16px; font-weight: 600; }
.card label.field input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; }

/* Wordmark: bold caps "WHERE IS IT" with a map pin standing in for the question mark. */
.wordmark { display: inline-flex; flex-direction: column; align-items: flex-start; font-size: 1.4rem; color: var(--ink); text-decoration: none; line-height: 1; }
.wordmark .wm-name { font-weight: 900; text-transform: uppercase; letter-spacing: -0.015em; white-space: nowrap; }
.wordmark .wm-tag {
  margin-top: 0.4em; font-size: max(0.36em, 11px); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
}
.wordmark.large { font-size: 2.6rem; }
.pin { height: 0.82em; width: auto; margin-left: 0.12em; vertical-align: baseline; overflow: visible; }
.pin path { fill: var(--brand); }
.pin circle { fill: #fff; }
.pin-icon { display: inline-flex; font-size: 1.3rem; }
.pin-icon .pin { margin: 0; }
.hero { margin: 4px 0 14px; }
.card > .wordmark { margin-bottom: 12px; }
.prompt .label:empty { display: none; }

.score-big { display: flex; gap: 14px; margin: 18px 0 8px; }
.score-big div { flex: 1; background: var(--subtle-bg); border-radius: 12px; padding: 12px; text-align: center; }
.score-big b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.score-big small { color: var(--ink-soft); font-weight: 600; }

.result-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.result-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--subtle-bg); font-size: 0.9rem; }
.result-list li .mark { margin-left: auto; font-weight: 800; }
.result-list li.first .mark { color: var(--first); }
.result-list li.ok .mark { color: var(--ok-ink); }
.result-list li.missed { background: var(--missed-bg); }
.result-list li.missed .mark { color: var(--missed); }

.preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.preset-list a { justify-content: flex-start; white-space: normal; text-align: left; }
.preset-list a small { white-space: nowrap; }

.show-results { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; box-shadow: var(--shadow); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--toast-bg); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow);
}

/* ---------------- Setup ---------------- */
.setup { display: flex; height: 100%; }
.sidebar {
  width: 380px; flex: none; display: flex; flex-direction: column; background: var(--panel);
  border-right: 1px solid var(--line); min-height: 0;
}
.sidebar header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: start; padding: 14px 16px 8px;
}
.sidebar header .wordmark { grid-area: 1 / 1; margin-top: 2px; }
.sidebar header .wm-tag { line-height: 1.3; }
.sidebar header .header-tools { grid-area: 1 / 2; display: flex; gap: 8px; }
.sidebar header p { grid-column: 1 / -1; margin: 12px 0 0; color: var(--ink-soft); font-size: 0.9rem; }
.sidebar .section { padding: 10px 16px; border-top: 1px solid var(--line); }
.sidebar .section h3 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.tree-tools { display: flex; gap: 8px; align-items: center; }
.tree-tools input[type='search'] { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); min-width: 0; }
.tree { flex: 1; overflow: auto; padding: 4px 8px 12px; min-height: 120px; border-top: 1px solid var(--line); }
.tree .row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 6px; }
.tree .row:hover { background: var(--subtle-bg); }
.tree .row label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; min-width: 0; }
.tree .row label span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .row .count { color: var(--ink-soft); font-size: 0.8rem; margin-left: auto; font-variant-numeric: tabular-nums; }
.tree .row.region { font-weight: 700; margin-top: 4px; }
.tree .row.sub { padding-left: 22px; font-weight: 600; }
.tree .row.country { padding-left: 50px; font-size: 0.92rem; }
.tree .row.country .terr { font-size: 0.72rem; color: var(--ink-soft); }
.tree .caret {
  width: 22px; height: 22px; border: 0; background: none; cursor: pointer; border-radius: 4px; flex: none;
  color: var(--ink-soft); transition: transform 0.15s; padding: 0;
}
.tree .caret.open { transform: rotate(90deg); }
.tree input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin: 0; }
.tree .zoom-to { border: 0; background: none; cursor: pointer; color: var(--ink-soft); padding: 0 4px; font-size: 0.85rem; visibility: hidden; }
.tree .row:hover .zoom-to { visibility: visible; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 0.9rem; }
.options label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.options label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; grid-column: span 2; }
.options input[type='text'], .options input[type='number'], .options select {
  padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); width: 100%; font-weight: 400;
}
.options .wide { grid-column: span 2; }
.lang-opts .opt-heading { display: block; font-weight: 600; margin-bottom: 4px; }
.lang-opts small { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 0.8rem; }
/* Sidebar row that summarises the student languages and opens the picker panel. */
.lang-summary {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left;
}
.lang-summary:hover { background: var(--hover-bg); }
.lang-summary .i-translate {
  width: 18px; height: 18px; flex: none; color: var(--ink-soft);
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.lang-summary-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-summary-action { display: inline-flex; align-items: center; gap: 2px; flex: none; color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.lang-summary-action svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* A panel that replaces the sidebar's contents while it's open (e.g. the language picker). */
.sidebar.panel-open > :not(.sidebar-panel) { display: none; }
.sidebar-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.sidebar-panel .panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.sidebar-panel .panel-head h2 { margin: 0; font-size: 1.15rem; }
.sidebar-panel .panel-tools { padding: 0 16px 8px; }
.sidebar-panel .panel-tools input[type='search'] { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); }
.panel-tools-row { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 0.85rem; }
.panel-tools-row #lang-count { flex: 1; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.link-btn {
  border: 0; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: inherit;
}
.link-btn:hover:not(:disabled) { background: var(--hover-bg); }
.link-btn:disabled { color: var(--ink-soft); opacity: 0.6; cursor: default; }
.lang-list {
  flex: 1; overflow: auto; min-height: 120px; padding: 6px 8px 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.lang-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 8px; cursor: pointer;
}
.lang-row:hover { background: var(--subtle-bg); }
.lang-row.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lang-row input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
.lang-row .lang-name { font-weight: 600; }
.lang-row .lang-local { margin-left: auto; color: var(--ink-soft); font-size: 0.85rem; }
.lang-empty { margin: 12px 10px; color: var(--ink-soft); font-size: 0.9rem; }
.sidebar-panel .panel-foot { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.sidebar-panel .panel-foot small { color: var(--ink-soft); font-size: 0.8rem; }
.lang-warn { margin: 0; color: var(--missed); font-size: 0.85rem; font-weight: 600; }
.share { display: flex; flex-direction: column; gap: 8px; }
.share .summary { font-weight: 700; }
.share input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 0.85rem; color: var(--ink-soft); }
.share .row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.share .row-btns .btn { flex: 1 1 auto; }
.map-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 5; background: var(--panel);
  padding: 6px 14px; border-radius: 999px; font-size: 0.85rem; color: var(--ink-soft); box-shadow: var(--shadow);
  pointer-events: none;
}

@media (max-width: 800px) {
  body { overflow: auto; }
  .setup { flex-direction: column; height: auto; min-height: 100%; }
  .sidebar { width: 100%; border-right: 0; order: 2; }
  .tree { max-height: 50vh; }
  .lang-list { max-height: 60vh; }
  .setup .map-wrap { height: 55vh; flex: none; order: 1; }
  .topbar { gap: 10px; padding: 8px 12px; }
  .prompt .target { font-size: 1.25rem; }
  .stats { gap: 10px; width: 100%; justify-content: space-between; order: 1; }
  .card { padding: 20px; }
}

/* ---------------- Printable worksheet ---------------- */
/* Sheets are always black-on-white (paper), whatever the app theme. */
body.print-page { overflow: auto; height: auto; min-height: 100%; }
.print-toolbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.print-toolbar .print-heading { font-size: 1rem; }
.print-warning {
  flex: 1 1 260px; padding: 6px 10px; border-radius: 8px; font-size: 0.82rem; line-height: 1.35;
  background: var(--missed-bg); color: var(--ink);
}
.print-warning + label { margin-left: auto; }
.print-toolbar label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.print-toolbar select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); }
.print-toolbar input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.sheets { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 24px 16px 48px; overflow-x: auto; }
.print-empty { padding: 40px 16px; color: var(--ink-soft); }
.print-empty a { color: var(--accent); }

.sheet {
  flex: none; display: flex; flex-direction: column; gap: 0.12in; padding: 0; overflow: hidden;
  background: #fff; color: #111; margin: 0.4in 0; box-shadow: 0 0 0 0.4in #fff, 0 0 0 calc(0.4in + 1px) rgba(0, 0, 0, 0.08), var(--shadow);
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.sheet-head { display: flex; align-items: flex-end; gap: 0.3in; flex: none; }
.sheet-head h1 { margin: 0; font-size: 18pt; font-weight: 800; line-height: 1.1; flex: 1; }
.name-line { display: flex; align-items: flex-end; gap: 6px; font-size: 11pt; font-weight: 600; }
.name-line span { display: inline-block; width: 3in; border-bottom: 1px solid #111; }
.sheet-map { flex: 1; min-height: 0; border: 1px solid #555; }
.print-map { display: block; }
.print-map .pm-ocean { fill: #eaf3f9; }
.print-map .pm-land { fill: #dcdcdc; stroke: #a8a8a8; }
.print-map .pm-sel { fill: #fff; stroke: #999; }
.print-map .pm-outline path { fill: none; stroke: #222; }
.print-map .pm-labels line { stroke: #222; }
.print-map .pm-anchor { fill: #222; }
.print-map .pm-badge { fill: #fff; stroke: #222; }
.print-map text { fill: #111; font-weight: 700; text-anchor: middle; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }

.word-bank { flex: none; }
.word-bank h2 { margin: 0 0 0.06in; font-size: 10.5pt; font-weight: 700; }
.word-bank ul { margin: 0; padding: 0; list-style: none; columns: 1.9in; column-gap: 0.25in; font-size: 10.5pt; }
.word-bank li { display: flex; align-items: flex-end; gap: 6px; padding: 3px 0; break-inside: avoid; }
.word-bank .blank { flex: none; width: 0.42in; height: 1em; border-bottom: 1px solid #111; }
.key-list { margin: 0; padding: 0; list-style: none; columns: 2.2in; column-gap: 0.3in; font-size: 11pt; }
.key-list li { display: flex; gap: 8px; padding: 3px 0; break-inside: avoid; }
.key-list b { min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }

@media print {
  body.print-page { background: #fff; }
  .print-toolbar { display: none; }
  .sheets { display: block; padding: 0; overflow: visible; }
  .sheet { margin: 0; box-shadow: none; break-after: page; }
  .sheet:last-child { break-after: auto; }
}
