/* realmap.tf web interface: edge-to-edge map with floating white panels over it (direction "map tool",
   .impeccable/surfaces/tf2map-dienst-static-index-html.md). One brand colour (orange) for selection,
   active step, frame on the map, sliders and the main button; otherwise ink, muted, hairlines. */

:root {
  --white: #ffffff;
  --surface: #f4f5f7;           /* page background without a map, fill of tiles and segments */
  --surface-hover: #e9ebef;
  --ink: #16181d;
  --ink-hover: #2b2e36;
  --muted: #5f6470;             /* 5.9:1 on white, 5.4:1 on surface */
  --line: #e4e6eb;
  --line-strong: #c9cdd5;    /* outlines of picture buttons, empty budget bars */
  /* One orange in two shades: --brand-graphic for everything without text (frame, handles, sliders, selection,
     toggles, bars), --brand only as a fill under small white text (main button, segment, number dot) */
  --brand-graphic: #d9480f;      /* 4.3:1 on white, 3.9:1 on surface (graphics need 3:1) */
  --brand: #c8420d;             /* white on it 4.95:1; on surface 4.5:1 */
  --brand-dark: #a8360a;      /* hover; text on the brand tint 5.4:1 */
  --map-ground: #e3ecf2;       /* light water tone of the base map: background under preview maps and outline images */
  --brand-light: color-mix(in srgb, var(--brand) 12%, #fff);
  --brand-tint: color-mix(in srgb, var(--brand) 7%, transparent);
  --error: #b42318;            /* 6.6:1 on white */
  --shadow: 0 1px 2px rgba(22, 24, 29, .06), 0 8px 24px rgba(22, 24, 29, .10);
  --shadow-high: 0 2px 4px rgba(22, 24, 29, .06), 0 16px 40px rgba(22, 24, 29, .16);
  --radius: 14px;
  --margin: 16px;                 /* distance of the floating panels from the window edge */
  --header-h: 56px;
  --panel: 420px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, Menlo, monospace;
  --climate-temperate: #8fb46b;
  --climate-dry: #e2c27a;
  --climate-subarctic: #dce5ea;
  --climate-tropical: #3f8a57;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--brand-graphic);
  scrollbar-color: var(--line-strong) transparent;
}
::selection { background: color-mix(in srgb, var(--brand) 22%, #fff); color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--brand-dark); font-weight: 700; cursor: pointer; background: none; border: 0; padding: 0; border-radius: 4px; }
a.link:hover, .link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
/* links with a drawn arrow (instead of "→") or an expand chevron */
.with-arrow { display: inline-flex; align-items: center; gap: 5px; }
.with-arrow .icon { width: 15px; height: 15px; transition: transform .15s; }
.with-arrow.expander[aria-expanded="true"] .icon { transform: rotate(180deg); }
.muted { color: var(--muted); }
h1, h2, h3, p { margin: 0; }
/* Keyboard focus always visible (W3-15). Where an element does not show the ring, a replacement is noted. */
:focus-visible { outline: 2px solid var(--brand-graphic); outline-offset: 2px; }

/* ------------------------------------------------------------ Layout */

/* pages without a map: the header floats at the top on the grey background, the content below */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr; overflow: hidden; background: var(--surface); }
/* pages with a map: the map edge to edge behind, header and panel float over it */
.app.map-full { display: block; position: relative; }
.app.map-full > .header { position: absolute; top: var(--margin); left: var(--margin); right: var(--margin); margin: 0; }
.app.map-full > .workbench { position: absolute; inset: 0; display: block; padding: 0; }

.header {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; position: relative;
  height: var(--header-h); margin: var(--margin) var(--margin) 0; padding: 0 10px 0 18px; min-width: 0; z-index: 10;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
}
.header.simple { display: flex; justify-content: space-between; }

/* Logo: word mark with a small orange square (holding a map sheet) */
.logo {
  display: inline-flex; align-items: center; gap: 9px; position: relative; flex: none;
  font-weight: 800; font-size: 17px; letter-spacing: -.02em; color: var(--ink); cursor: pointer; border-radius: 6px;
}
.logo::before { content: ""; width: 22px; height: 22px; border-radius: 6px; background: var(--brand); flex: none; }
.logo::after {
  content: ""; position: absolute; left: 5px; top: calc(50% - 8px); width: 8px; height: 12px; box-sizing: content-box;
  border: 2px solid var(--white); border-radius: 1.5px;
}
.header > .logo { min-width: 120px; }

.header-right { display: flex; justify-content: flex-end; gap: 6px; align-items: center; font-size: 14px; font-weight: 600; color: var(--muted); min-width: 0; }
.header-right > a, .header-right > button, .header-right > .active { padding: 8px 10px; border-radius: 9px; white-space: nowrap; }
.header-right .active { color: var(--ink); font-weight: 700; }
.header-right > a:hover, .header-right > button:hover { color: var(--ink); background: var(--surface); }
.header-right button { background: none; border: 0; color: inherit; cursor: pointer; }

/* Language picker "DE · EN" */
.lang-picker { display: inline-flex; align-items: center; gap: 0; font-size: 13px; font-weight: 700; }
.lang-picker button { background: none; border: 0; padding: 8px 5px; border-radius: 7px; color: var(--muted); cursor: pointer; font-weight: 700; }
.lang-picker button + button::before { content: "·"; margin: 0 5px 0 -5px; color: var(--muted); font-weight: 500; }
.lang-picker button.on { color: var(--ink); }
.lang-picker button:hover { color: var(--ink); }

/* Daily budget: five small bars, full orange, empty hairline; the sentence is in the aria-label */
.budget { display: inline-flex; align-items: center; gap: 3px; padding: 8px 8px; white-space: nowrap; }
.budget i { display: block; width: 7px; height: 16px; border-radius: 2px; background: var(--line-strong); opacity: .7; }
.budget i.full { background: var(--brand-graphic); opacity: 1; }
.budget-text { display: none; }
.budget-track { display: block; width: 44px; height: 8px; border-radius: 4px; background: var(--line-strong); overflow: hidden; }
.budget-track b { display: block; height: 100%; background: var(--brand-graphic); }
.budget-num { margin-left: 5px; font-size: 13px; font-weight: 700; color: var(--ink); }

/* Game picker TF3/TF2. The official logotypes (Steam store, trademarks of Urban Games) are white:
   chosen on ink, otherwise inverted dark on the surface */
.game-picker { display: inline-flex; gap: 2px; border-radius: 10px; padding: 3px; background: var(--surface); }
.game-picker button { border: 0; background: none; padding: 5px 8px; border-radius: 7px; cursor: pointer; line-height: 0; transition: background .12s; }
.game-picker button img { display: block; height: 20px; width: auto; filter: invert(1); opacity: .5; transition: opacity .12s; }
.game-picker button:not(.on):hover { background: var(--surface-hover); }
.game-picker button:not(.on):hover img { opacity: .85; }
.game-picker button.on { background: var(--ink); }
.game-picker button.on img { filter: none; opacity: 1; }

/* Step bar: tabs with a number dot, the active one as a tinted pill with an orange dot */
.steps { display: flex; justify-content: flex-start; gap: 2px; margin-left: 12px; min-width: 0; overflow: hidden; }
.step {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 10px; border-radius: 10px; white-space: nowrap;
  color: var(--muted); font-size: 14px; font-weight: 600; background: none; border: 0; cursor: pointer;
}
.step:hover { background: var(--surface); color: var(--ink); }
.step .nr {
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; flex: none;
  display: grid; place-items: center; background: var(--surface); color: var(--muted);
}
.step:hover .nr { background: var(--surface-hover); }
.step .nr .icon { width: 12px; height: 12px; }
.step.done .nr { background: var(--ink); color: var(--white); }
.step.active { background: var(--brand-light); color: var(--ink); font-weight: 700; }
.step.active .nr { background: var(--brand); color: var(--white); }   /* carries a small white digit: dark shade */

/* Narrow windows: step display "‹ 2/3 Try out" and menu button */
.step-compact {
  display: none; align-items: center; gap: 6px; justify-self: center; padding: 0 12px 0 8px; height: 40px; border-radius: 10px;
  border: 0; background: var(--brand-light); color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; min-width: 0;
}
.step-compact:disabled { cursor: default; padding-left: 12px; }
.step-compact .icon { width: 16px; height: 16px; }
.step-compact .nr { font-variant-numeric: tabular-nums; color: var(--brand-dark); }
.step-compact .name { overflow: hidden; text-overflow: ellipsis; }
.menu-btn {
  display: none; width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--surface);
  place-items: center; cursor: pointer; color: var(--ink); padding: 0;
}
.menu-btn:hover { background: var(--surface-hover); }
.menu-btn .icon { width: 20px; height: 20px; }
.header.menu-open .menu-btn { background: var(--ink); color: var(--white); }
.header-left { display: flex; gap: 20px; align-items: center; min-width: 0; }
.breadcrumbs { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumbs b { color: var(--ink); font-weight: 700; }
.breadcrumbs a:hover { color: var(--ink); }
.breadcrumbs .sep { margin: 0 8px; color: var(--line-strong); }

/* ------------------------------------------------------------ Workbench */

.workbench { display: grid; grid-template-columns: 1fr var(--panel); gap: var(--margin); padding: var(--margin); min-height: 0; }
.map-area { position: relative; background: #eef0f3; overflow: hidden; min-height: 0; }
.app.map-full .map-area { position: absolute; inset: 0; }
/* own stacking context: the z-index levels of the towns (below) stay under frame, search and panel */
.map-area .maplibregl-map { position: absolute; inset: 0; z-index: 0; }
/* attribution and zoom stay left of the floating panel */
.app.map-full .maplibregl-ctrl-bottom-right { right: calc(var(--panel) + 2 * var(--margin)); }
.app.map-full .maplibregl-ctrl-attrib { margin: 0 0 var(--margin) 0; }

/* The panel: white, rounded, floating; the content scrolls, the foot with the main button stays at the bottom */
.panel {
  display: grid; grid-template-rows: 1fr auto; min-height: 0; padding: 8px; gap: 0;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
}
.app.map-full .panel { position: absolute; z-index: 5; right: var(--margin); top: calc(var(--margin) * 2 + var(--header-h)); bottom: var(--margin); width: var(--panel); }
.panel-body { overflow: auto; display: flex; flex-direction: column; min-height: 0; overscroll-behavior: contain; }
/* sections in the panel are not cards in the card: only a hairline between them */
.panel-body > * + * { border-top: 1px solid var(--line); }
.panel-body > .connection, .panel-body > .error-text { border-top: 0; }
.panel-foot { display: flex; gap: 8px; padding: 8px 0 0; }
.panel-foot > * { flex: 1; white-space: nowrap; }
.panel-foot > .wrap { white-space: normal; }
.panel-foot > .wide { flex: 2; }

/* sections (formerly boxes) */
.box { padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.box.small { padding: 14px; font-size: 13px; }
.box.dashed { color: var(--muted); line-height: 1.5; }
.box.dashed b { color: var(--ink); }
.box.outlined { background: none; }
.box.error-note { color: var(--error); }
.box.error-note h2 { color: var(--error); }
.box.error-note p { color: var(--ink); }
.page .box.error-note { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; max-width: 560px; }
/* connection lost while reloading: subtle above the list or below the status, otherwise invisible */
.connection { font-size: 13px; line-height: 1.45; color: var(--ink); margin: 0 0 16px; display: flex; gap: 8px; align-items: baseline; }
.connection::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--error); transform: translateY(-1px); }
.connection:empty { display: none; }
.panel .connection { margin: 0; padding: 4px 14px 12px; }
.box h2 { font-size: 20px; font-weight: 800; letter-spacing: -.015em; }
.box p { font-size: 14px; color: var(--muted); line-height: 1.5; }
.box p.small { font-size: 13px; }
.box-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.box-head .meta { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* Buttons */
.btn {
  min-height: 44px; padding: 12px 16px; border-radius: 11px; border: 0; background: var(--surface);
  color: var(--ink); font: 700 14px var(--font); cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .12s;
}
.btn:hover { background: var(--surface-hover); }
.btn.primary { min-height: 50px; background: var(--brand); color: var(--white); font-size: 15px; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface); color: var(--muted); cursor: not-allowed; }
.btn.primary:disabled:hover { background: var(--surface); }
.btn.compact { min-height: 44px; padding: 10px 18px; font-size: 14px; }
/* busy: stays orange, with a small spinner */
.btn.primary[aria-busy="true"] { background: var(--brand); color: var(--white); cursor: progress; }
.btn[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: var(--white);
  animation: spin .8s linear infinite;
}
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 8px 12px; border-radius: 9px; background: var(--surface); border: 0;
  font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.chip:hover { background: var(--surface-hover); }

/* Segments */
.field { display: flex; flex-direction: column; gap: 10px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; gap: 12px; }
.field-head .name { font-weight: 700; }
.field-head .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.field-head .num { font-weight: 700; }
.segments { display: grid; gap: 6px; font-size: 13px; font-weight: 600; text-align: center; }
.segments.six { grid-template-columns: repeat(6, 1fr); font-size: 12px; }
.segments.five { grid-template-columns: repeat(5, 1fr); }
.segments.two { grid-template-columns: 1fr 1fr; }
.segments.three { grid-template-columns: repeat(3, 1fr); }
.segments.four { grid-template-columns: repeat(4, 1fr); font-size: 12px; }
.segment {
  padding: 8px 6px; border: 0; border-radius: 9px; background: var(--surface); cursor: pointer; color: var(--ink);
  line-height: 1.15; font-weight: 600; font-size: inherit; min-height: 38px; min-width: 0; hyphens: manual; transition: background .12s;
}
.segment:hover { background: var(--surface-hover); }
.segment:disabled { opacity: .45; cursor: not-allowed; }
.segment:disabled:hover { background: var(--surface); }
.segment.on { background: var(--brand); color: var(--white); font-weight: 700; }
.segment.on:hover { background: var(--brand-dark); }
/* multiple choice (road classes, supply chains): chosen ones tinted with an orange ring instead of a full fill */
.segment.on[data-toggle] { background: var(--brand-light); color: var(--brand-dark); box-shadow: inset 0 0 0 1.5px var(--brand-graphic); }
.segment.on[data-toggle]:hover { background: color-mix(in srgb, var(--brand-graphic) 20%, #fff); }

/* Area: one row per setting, the icon on the left, the choice as a picture on the right */
.settings { display: flex; flex-direction: column; }
.settings .row { display: grid; grid-template-columns: 22px 1fr; gap: 16px; align-items: center; padding: 16px 14px; border: 0; }
.settings .row + .row { border-top: 1px solid var(--line); }
.settings .row > .icon { width: 20px; height: 20px; color: var(--muted); }
.row-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* Size: growing squares, the experimental ones dashed */
.squares { display: flex; align-items: stretch; gap: 5px; min-height: 40px; }
.square { flex: 1; min-width: 0; border: 0; background: none; padding: 0; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; border-radius: 5px; }
.square i {
  display: block; width: calc(var(--a) * 100%); aspect-ratio: 1; border: 1.5px solid var(--line-strong); border-radius: 4px;
  background: var(--surface); transition: background .12s, border-color .12s, box-shadow .12s;
}
.square.exp i { border-style: dashed; background: none; }
.square:hover i { border-color: var(--ink); }
.square.on i { background: var(--brand-graphic); border: 1.5px solid var(--brand-graphic); box-shadow: 0 0 0 3px var(--brand-light); }
.size-value { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.size-value b { font-size: 15px; font-weight: 700; white-space: nowrap; }
.size-value span { color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }
/* Aspect ratio: tiles with the outline in true proportion */
.segment.aspect { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; padding: 8px 2px 6px; min-height: 62px; }
.segment.aspect i { display: block; border: 1.5px solid var(--muted); border-radius: 2px; }
.segment.aspect.on i { border-color: var(--white); }   /* chosen stays on --brand (.segment.on): white "1:2" in 12 px */
.segment.aspect span { font-size: 12px; font-weight: 700; }
/* Rotation: ±15° and compass */
.rotate { display: flex; align-items: center; gap: 10px; }
.rotate .round, .rotate .compass { display: grid; place-items: center; border-radius: 50%; border: 0; cursor: pointer; padding: 0; color: var(--ink); }
.rotate .round { width: 40px; height: 40px; background: var(--surface); }
.rotate .round:hover { background: var(--surface-hover); }
.rotate .compass { width: 46px; height: 46px; background: var(--white); border: 2px solid var(--brand-graphic); color: var(--brand-graphic); }
.rotate .compass:hover { background: var(--brand-light); }
.rotate .round .icon { width: 18px; height: 18px; }
.rotate .compass .icon { width: 26px; height: 26px; transform: rotate(var(--north, 0deg)); transition: transform .2s ease-out; }
.rotate .angle { margin-left: auto; font-weight: 800; font-size: 17px; }
/* Place names: pill switch, the choice in ink */
.pills { display: inline-flex; align-self: flex-start; background: var(--surface); border-radius: 999px; padding: 3px; gap: 2px; }
.pills button { border: 0; background: none; border-radius: 999px; padding: 7px 15px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.pills button:hover:not(:disabled):not(.on) { color: var(--ink); background: var(--surface-hover); }
.pills button.on { background: var(--ink); color: var(--white); }
.pills button:disabled { opacity: .45; cursor: not-allowed; }
/* Climate: colour swatches, the chosen one with an orange ring */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--white); padding: 0; cursor: pointer; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .12s; }
.swatch:hover { box-shadow: 0 0 0 1.5px var(--ink); }
.swatch.on { box-shadow: 0 0 0 2.5px var(--brand-graphic); }
.swatch-temperate { background: var(--climate-temperate); }
.swatch-dry { background: var(--climate-dry); }
.swatch-subarctic { background: var(--climate-subarctic); }
.swatch-tropical { background: var(--climate-tropical); }
.swatch-auto { background: conic-gradient(var(--climate-temperate) 0 25%, var(--climate-dry) 0 50%, var(--climate-subarctic) 0 75%, var(--climate-tropical) 0); }
.small-line { font-size: 12px; font-weight: 600; }
.scale-row { display: grid; grid-template-columns: 20px 1fr 20px; gap: 12px; align-items: center; color: var(--muted); }
.scale-row .icon { width: 20px; height: 20px; display: block; }
@media (pointer: coarse) {
  .rotate .round { width: 44px; height: 44px; }
  .swatch { width: 40px; height: 40px; }
  .pills button { padding: 11px 16px; }
}

/* Slider: 6 px track on the surface, orange fill, white thumb with an orange ring */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: none; margin: 0; cursor: pointer; }
.slider:focus-visible { outline: none; }   /* replacement: ring around the thumb, below for both engines */
.slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--brand-graphic) 0 var(--fill, 0%), var(--surface-hover) var(--fill, 0%) 100%);
}
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-hover); }
.slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand-graphic); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--white);
  border: 2.5px solid var(--brand-graphic); margin-top: -7px; box-shadow: 0 1px 3px rgba(22, 24, 29, .18); transition: box-shadow .12s;
}
.slider::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--white); border: 2.5px solid var(--brand-graphic); box-shadow: 0 1px 3px rgba(22, 24, 29, .18); }
.slider:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--brand-light), 0 1px 3px rgba(22, 24, 29, .18); }
.slider:hover::-moz-range-thumb { box-shadow: 0 0 0 5px var(--brand-light); }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--white), 0 0 0 5px var(--brand-graphic); }
.slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--white), 0 0 0 5px var(--brand-graphic); }
@media (pointer: coarse) {
  .slider { height: 40px; }
  .slider::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -10px; }
  .slider::-moz-range-thumb { width: 21px; height: 21px; }
}
.slider-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 14px; align-items: center; }
.slider-grid .muted { color: var(--muted); font-weight: 600; }
.slider-grid .num { font-weight: 700; min-width: 5em; text-align: right; }   /* fixed width: no jumping between "4.5" and "5" */
.slider-grid .slider { grid-column: 1 / -1; }

/* Toggle (share) */
.toggle { width: 44px; height: 26px; border-radius: 13px; background: var(--line-strong); position: relative; border: 0; cursor: pointer; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(22, 24, 29, .2); transition: left .15s; }
.toggle.on { background: var(--brand-graphic); }
.toggle.on::after { left: 21px; }
.toggle:disabled { opacity: .6; cursor: progress; }

.link-row { margin-top: 10px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.link-row.manage { margin-top: 0; padding: 14px; }
.link.delete { color: var(--ink); }
.link.delete:hover { color: var(--error); }
.link:disabled { opacity: .45; cursor: not-allowed; text-decoration: none; }
.warn-note { color: var(--ink) !important; display: flex; gap: 6px; align-items: flex-start; line-height: 1.45; }
.warn-note .icon, .warning .icon { width: 16px; height: 16px; margin-top: 1px; color: var(--brand-dark); flex: none; }
.warn-note code { font-size: 12px; font-family: var(--mono); }
/* Service region (beta): note above "Next" while the frame leaves the shaded-free area; the frame turns dashed */
.panel-foot:has(> .region-note) { flex-wrap: wrap; }
.panel-foot > .region-note { flex-basis: 100%; white-space: normal; margin: 0 0 4px; }
.region-note[hidden] { display: none; }
.frame.outside { border-style: dashed; }

/* ------------------------------------------------------------ Floating elements on the map */

.floating { position: absolute; z-index: 3; background: var(--white); border-radius: 12px; box-shadow: var(--shadow); }
.search { left: var(--margin); top: calc(var(--margin) * 2 + var(--header-h)); width: 360px; border-radius: 12px; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 44px; font-size: 14px; cursor: text; }
.search-field .icon { width: 17px; height: 17px; color: var(--muted); }
.search-field input { border: 0; background: none; outline: none; font-weight: 600; flex: 1; min-width: 0; padding: 0; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search:focus-within { outline: 2px solid var(--brand-graphic); outline-offset: 2px; }   /* replacement for the ring on the search field */
.search-field input::placeholder { color: var(--muted); font-weight: 500; opacity: 1; }
.search-hits { border-top: 1px solid var(--line); max-height: 320px; overflow: auto; padding: 4px; }
.hit { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; cursor: pointer; font-size: 14px; font-weight: 600; border-radius: 8px; }
.hit:hover, .hit.marked { background: var(--surface); }
.hit.marked { background: var(--brand-light); }
.hit .kind { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
/* Zoom: bottom right next to the panel, above the attribution */
.zoom { right: calc(var(--panel) + 2 * var(--margin)); bottom: 52px; display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.zoom button { width: 40px; height: 40px; color: var(--ink); background: none; border: 0; display: grid; place-items: center; cursor: pointer; padding: 0; }
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: var(--surface); }
.zoom button .icon { width: 18px; height: 18px; }
.zoom button:focus-visible { outline-offset: -3px; }
/* Bar with the fixed area: top left, so the attribution stays free */
.summary {
  left: var(--margin); top: calc(var(--margin) * 2 + var(--header-h)); display: flex; align-items: center; gap: 14px; padding: 0 14px; min-height: 44px;
  font-size: 13px; font-weight: 700; max-width: calc(100% - var(--panel) - 4 * var(--margin) - 56px); flex-wrap: wrap;
}

/* ------------------------------------------------------------ Frame on the map */

.frame-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.frame { position: absolute; border: 2.5px solid var(--brand-graphic); border-radius: 3px; background: var(--brand-tint); }
.frame .handle {
  position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--white); border: 2.5px solid var(--brand-graphic);
  pointer-events: auto; touch-action: none; box-shadow: 0 1px 3px rgba(22, 24, 29, .25);
}
.frame .handle::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; }   /* hit area 32 px */
.frame .handle:hover { transform: scale(1.15); }
.frame .handle.tl { left: -8.5px; top: -8.5px; cursor: nwse-resize; }
.frame .handle.tr { right: -8.5px; top: -8.5px; cursor: nesw-resize; }
.frame .handle.bl { left: -8.5px; bottom: -8.5px; cursor: nesw-resize; }
.frame .handle.br { right: -8.5px; bottom: -8.5px; cursor: nwse-resize; }
/* Rotate handle: orange round button on a stem above the top edge; rotates with the frame */
.frame .rotate-stem { position: absolute; left: 50%; top: -24px; width: 2px; height: 22px; margin-left: -1px; background: var(--brand-graphic); }
.frame .rotate-handle {
  position: absolute; left: 50%; top: -52px; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%;
  background: var(--brand-graphic); color: var(--white); display: grid; place-items: center; padding: 0;
  cursor: grab; pointer-events: auto; box-shadow: 0 2px 6px rgba(22, 24, 29, .25); touch-action: none; transition: background .12s;
}
.frame .rotate-handle .icon { width: 16px; height: 16px; transform: rotate(var(--unrotate, 0deg)); }
.frame .rotate-handle::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; }   /* hit area 44 px */
.frame .rotate-handle:hover { background: var(--brand-dark); }
.frame.rotating .rotate-handle { cursor: grabbing; background: var(--ink); }
.frame .rotate-readout {
  position: absolute; left: 50%; top: -50px; margin-left: 22px; padding: 4px 8px; border-radius: 999px;
  background: var(--ink); color: var(--white); font-size: 12px; font-weight: 700; white-space: nowrap; opacity: 0; transition: opacity .15s;
}
.frame .rotate-readout { transform: rotate(var(--unrotate, 0deg)); transform-origin: left center; }
.frame.rotating .rotate-readout, .frame .rotate-handle:focus-visible ~ .rotate-readout { opacity: 1; }
.frame .rotate-handle:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.frame .usage-hint.gone { opacity: 0; transition: opacity .35s; }
/* Short hint in the middle of the frame; only with a mouse and only if it fits (placeFrame) */
.frame .usage-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(var(--unrotate, 0deg)); font-size: 12px; font-weight: 700;
  background: var(--white); color: var(--ink); padding: 6px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow);
}
.frame .usage-hint.too-tight { visibility: hidden; }
@media (pointer: coarse) { .frame .usage-hint { display: none; } }
.icon-inline, .frame .usage-hint .icon-inline { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
/* Edge dimensions as small ink pills; on short edges only the real value (class short, placeFrame) */
.frame .dim-bottom, .frame .dim-right {
  position: absolute; font-size: 11px; font-weight: 700; color: var(--white); background: var(--ink);
  padding: 3px 8px; border-radius: 999px; line-height: 1.3; white-space: nowrap;
}
.frame .short .game { display: none; }
.frame .dim-bottom:empty, .frame .dim-right:empty { display: none; }
.frame .dim-bottom { left: -2px; bottom: -30px; transform: rotate(var(--dim-bottom, 0deg)); }
.frame .dim-right { right: -30px; top: -2px; writing-mode: vertical-rl; padding: 8px 3px; transform: rotate(var(--dim-right, 0deg)); }
/* map is being built: the area in the frame breathes */
.frame.busy::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background: var(--brand-graphic); opacity: 0;
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .12; } }
@media (prefers-reduced-motion: reduce) { .frame.busy::after { animation: none; opacity: .1; } }

/* ------------------------------------------------------------ Towns on the map */

.place { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; color: var(--ink); }
/* names with a white halo, so dots and lines below do not cut through the text */
.place .name {
  transition: opacity .12s;
  text-shadow: -1.5px -1.5px 0 var(--white), 1.5px -1.5px 0 var(--white), -1.5px 1.5px 0 var(--white), 1.5px 1.5px 0 var(--white),
    0 -2px 0 var(--white), 0 2px 0 var(--white), -2px 0 0 var(--white), 2px 0 0 var(--white), 0 0 5px var(--white);
}
/* Layer order: names of larger towns above the dots of smaller ones, everything above the hollow candidates */
.place.candidate { z-index: 1; }
.place.k0 { z-index: 2; } .place.k1 { z-index: 3; } .place.k2 { z-index: 4; } .place.k3 { z-index: 5; } .place.k4 { z-index: 6; }
.place .name.covered { opacity: 0; }
.place.large { font-size: 13px; font-weight: 700; }
/* Chosen towns: filled ink dot, size by class; from medium town on the dot carries the class icon */
.place .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px rgba(255, 255, 255, .9);
  display: grid; place-items: center; color: var(--white); flex: none; pointer-events: auto; transition: background .12s, box-shadow .12s; }
.place .dot .icon { width: 72%; height: 72%; }
.place.k0 .dot { width: 7px; height: 7px; }
.place.k1 .dot { width: 10px; height: 10px; }
.place.k2 .dot { width: 14px; height: 14px; }
.place.k3 .dot { width: 18px; height: 18px; }
.place.k4 .dot { width: 22px; height: 22px; }
/* name left of the dot if it would run across the frame line on the right (declutterLabels) */
.place.left .name { position: absolute; right: 100%; margin-right: 6px; }
.place.manual .dot { box-shadow: 0 0 0 2px var(--white), 0 0 0 3.5px var(--brand-graphic); }
/* Only the dot and a visible name take clicks: otherwise a covered (invisible) name lay over the
   dot of the neighbouring town and selected the wrong town on click */
.place.editable { cursor: grab; }
.place.editable .dot, .place.editable .name:not(.covered) { pointer-events: auto; }
.place.editable:active { cursor: grabbing; }
.place.selected { color: var(--brand-dark); }
.place.selected .dot { background: var(--brand-graphic); box-shadow: 0 0 0 2px var(--white), 0 0 0 5px color-mix(in srgb, var(--brand-graphic) 30%, transparent); }
/* show covered names on hover */
.place:hover, .place.highlight, .place.selected { z-index: 10; }
.place:hover .name.covered, .place.highlight .name.covered { opacity: 1; }
.place:hover .name, .place.highlight .name { background: rgba(255, 255, 255, .94); border-radius: 4px; padding: 0 4px; margin-left: -4px; }
.place.editable:hover .dot, .place.highlight .dot { background: var(--brand-graphic); }
.place.highlight .dot { box-shadow: 0 0 0 2px var(--white), 0 0 0 5px color-mix(in srgb, var(--brand-graphic) 30%, transparent); }
/* Narrowly not chosen places (candidates): hollow dots, name only on hover */
.place.candidate { color: var(--muted); font-weight: 500; }
.place.candidate .dot { width: 8px; height: 8px; background: rgba(255, 255, 255, .85); border: 1.5px solid var(--muted); box-shadow: none; cursor: pointer; }
.place.candidate:hover .dot { border-color: var(--brand-graphic); background: var(--white); }
.place.candidate .name { opacity: 0; }
.place.candidate:hover .name, .place.candidate.highlight .name { opacity: 1; }
/* Placing mode: first "Place town", then a click on the map places a town */
.placing .maplibregl-canvas-container.maplibregl-interactive, .placing .maplibregl-canvas { cursor: crosshair; }
.link.on { color: var(--brand-dark); font-weight: 700; }

/* ------------------------------------------------------------ Try out: towns overview */

.icon { width: 18px; height: 18px; flex: none; display: block; }
.overview { gap: 16px; }
.ov-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ov-num { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.ov-num b { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ov-num > span { font-size: 14px; font-weight: 700; }
.ov-num .ov-of { font-size: 12px; font-weight: 500; color: var(--muted); }
.ov-hint { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: help; }
.ov-hint .icon { width: 14px; height: 14px; color: var(--brand-dark); }
.ov-busy { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand-graphic);
  animation: spin .8s linear infinite; align-self: center; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ov-busy, .btn[aria-busy="true"]::before { animation: none; } }
.ov-actions { display: flex; gap: 2px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0;
  background: none; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface); color: var(--ink); }
.icon-btn.on { background: var(--brand-light); color: var(--brand-dark); }
.icon-num { position: absolute; right: -3px; top: -3px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--ink); color: var(--white);
  font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; line-height: 1; }
.ov-state, .ov-placing { font-size: 13px; color: var(--muted); line-height: 1.45; }
.ov-busy-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.btn.ov-new { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; font-size: 14px; }
.btn.ov-new .icon { width: 18px; height: 18px; }
.ov-placing { color: var(--brand-dark); font-weight: 700; }
/* Distribution by size: five tiles with class icon and number */
.distribution { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.distribution > div { display: grid; justify-items: center; gap: 4px; padding: 10px 0 8px; border-radius: 9px; background: var(--surface); cursor: default; }
.distribution > div.zero { color: var(--muted); }
.distribution > div.zero .icon { opacity: .45; }
.distribution .icon { width: 22px; height: 22px; }
.distribution b { font-size: 14px; font-weight: 800; }
.overview.stale .distribution, .overview.stale .ov-num b { opacity: .45; }
/* Rules: rows with icon, name, bold value and slider below */
.rules { display: grid; gap: 0; margin: 0 -14px -16px; }
.rule { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.rule .icon { color: var(--muted); width: 20px; height: 20px; }
.rule label { font-size: 14px; font-weight: 600; }
.rule .num { font-weight: 800; font-size: 15px; min-width: 4.5em; text-align: right; }
.rule .slider { grid-column: 2 / -1; }
/* Explanations via the (i) button: the same sentences as in the tooltip, for touch without hover */
.rule-help { grid-column: 2 / -1; font-size: 12px; line-height: 1.45; color: var(--muted); }
.ov-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12px; line-height: 1.4; color: var(--muted); }
.ov-legend li { display: flex; gap: 8px; align-items: flex-start; }
.ov-legend .icon { width: 16px; height: 16px; color: var(--muted); }
.tp-help { font-size: 12px; line-height: 1.4; color: var(--muted); }

/* Network, industries, water: rows that expand in place */
.extras { display: flex; flex-direction: column; }
.mini-row + .mini-row { border-top: 1px solid var(--line); }
.mini {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) 18px; gap: 16px; align-items: center; width: 100%;
  padding: 14px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; line-height: 1.4; font-size: 13px;
}
.mini:hover { background: var(--surface); }
.mini > .icon { color: var(--muted); width: 20px; height: 20px; }
.mini .t { font-weight: 700; font-size: 14px; }
.mini .s { color: var(--muted); }
.mini .arrow { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; }
.mini.open .arrow { transform: rotate(180deg); color: var(--ink); }
.mini.open > .icon:first-child { color: var(--brand-graphic); }
.mini-detail { padding: 2px 14px 18px 52px; display: flex; flex-direction: column; gap: 14px; }
.mini-detail p.small { font-size: 12px; line-height: 1.45; color: var(--muted); }
.mini-detail .field-head .name { font-size: 13px; }
.btn.icon-foot { flex: 0 0 50px; display: grid; place-items: center; padding: 0; }
.btn.icon-foot .icon { width: 20px; height: 20px; }

/* Town popup on the map */
.town-popup-float { position: absolute; z-index: 4; padding: 10px; border-radius: 12px; background: var(--white); box-shadow: var(--shadow-high); }
.town-popup { display: grid; gap: 10px; width: 236px; }
.tp-top { display: flex; gap: 4px; align-items: center; }
.tp-name { font: inherit; font-weight: 700; font-size: 14px; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px;
  background: none; width: 100%; min-width: 0; color: var(--ink); }
.tp-name:hover { background: var(--surface); }
.tp-name:focus { border-color: var(--brand-graphic); background: var(--white); outline: none; }
.tp-warn { color: var(--brand-dark); display: grid; place-items: center; cursor: help; }
.tp-sizes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; background: var(--surface); border-radius: 10px; padding: 3px; }
.tp-sizes button { display: grid; place-items: end center; height: 40px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  color: var(--muted); padding: 0 0 7px; }
.tp-sizes button:hover { background: var(--white); color: var(--ink); }
.tp-sizes button.on { background: var(--brand-graphic); color: var(--white); }
.tp-sizes .icon { width: 20px; height: 20px; }
.tp-facts { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); }
.tp-facts span { display: inline-flex; align-items: center; gap: 4px; }
.tp-facts .icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------ Generate */

/* Title and subtitle: filled fields at rest, so they read as inputs */
.box.inputs { gap: 8px; }
.title-input, .subtitle-input {
  border: 1px solid transparent; background: var(--surface); outline: none; width: 100%; border-radius: 10px; padding: 9px 12px;
  transition: background .12s, border-color .12s;
}
.title-input { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.subtitle-input { font-size: 15px; font-weight: 600; color: var(--ink); }
.title-input:hover, .subtitle-input:hover { background: var(--surface-hover); }
.title-input:focus-visible, .subtitle-input:focus-visible { outline: none; border-color: var(--brand-graphic); background: var(--white); box-shadow: 0 0 0 3px var(--brand-light); }
.title-input::placeholder, .subtitle-input::placeholder { color: var(--muted); opacity: 1; }
.error-text { font-size: 13px; line-height: 1.5; color: var(--error); font-weight: 600; padding: 0 14px 14px; }
/* Generate: one button, below it in small type how many maps are left today */
.generate-foot { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.generate-foot .budget-rest { font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; white-space: normal; padding-bottom: 2px; }
.label { font-size: 13px; color: var(--muted); font-weight: 600; }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 12px; font-family: var(--mono); }

/* ------------------------------------------------------------ Waiting */

.progress { height: 6px; border-radius: 3px; background: var(--surface-hover); position: relative; overflow: hidden; }
.progress span { position: absolute; left: 0; top: 0; height: 6px; background: var(--brand-graphic); border-radius: 3px; transition: width .4s; }
.box.dark { gap: 14px; }
.box.dark h2 { font-size: 17px; }
.box.dark p { font-size: 13px; }
.box.dark p.light { color: var(--ink); font-weight: 600; }
.step-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 13px; line-height: 1.4; }
.step-list li { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.step-list .dot { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; border: 1.5px solid var(--line-strong); color: var(--muted); }
.step-list .dot .icon { width: 12px; height: 12px; }
.step-list .done { color: var(--muted); }
.step-list .done .dot { border: 0; background: var(--ink); color: var(--white); }
.step-list .now { font-weight: 700; color: var(--ink); }
.step-list .now .dot { background: var(--brand); color: var(--white); border: 0; box-shadow: 0 0 0 3px var(--brand-light); }
.step-list .open { color: var(--muted); }
/* Failed: the heading carries the red */
.box.error h2 { color: var(--error); }
.log { margin: 10px 0 0; max-height: 260px; overflow: auto; font: 11px/1.5 var(--mono); white-space: pre-wrap; color: var(--muted); background: var(--surface); border-radius: 9px; padding: 10px 12px; }
.log-box { display: block; }
.notes p { margin: 0; font-size: 13px; line-height: 1.5; }
.notes p + p { margin-top: 6px; }
.notes summary { font-weight: 600; }
.notes[open] summary { margin-bottom: 8px; }
.notes .nudged { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; font-size: 13px; }
.notes .nudged li { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.notes .nudged li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes .nudged li .muted { flex: none; font-variant-numeric: tabular-nums; }
/* Log: without the browser triangle, the same chevron as for chains and sea depth, rotated when open */
.log-box summary { cursor: pointer; font-weight: 700; color: var(--muted); border-radius: 6px; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.log-box summary::-webkit-details-markers { display: none; }
.log-box summary .arrow { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; }
.log-box[open] summary .arrow { transform: rotate(180deg); color: var(--ink); }
.log-box summary:hover, .log-box[open] summary { color: var(--ink); }
.job-title { font-size: 24px !important; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.job-subtitle { font-size: 15px; color: var(--muted); }

/* ------------------------------------------------------------ Finished and shared map */

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; font-size: 14px; }
.facts .l { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.facts .w { font-weight: 700; }
.list { font-size: 14px; gap: 0; }
.list .t { font-weight: 700; margin-bottom: 6px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.row .muted { text-align: right; }
/* Preview image: fills the left area without white margins; what the aspect ratio leaves free is light map ground */
.preview-frame { border-radius: var(--radius); background: var(--map-ground); box-shadow: var(--shadow); position: relative; overflow: hidden; min-height: 0; }
/* wide: the preview fills the area (cropped), "View large" shows the whole image */
.preview-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preview-frame .actions { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 8px; }
.preview-frame .actions .chip { background: var(--white); box-shadow: var(--shadow); }
.preview-frame .actions .chip:hover { background: var(--surface); }
.preview-frame .placeholder-text { position: absolute; left: 20px; top: 18px; font-size: 13px; font-weight: 600; color: var(--muted); }
.game-badge { position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; border-radius: 999px; background: var(--white); font-size: 11px; font-weight: 700; color: var(--ink); box-shadow: 0 1px 2px rgba(22, 24, 29, .12); }

/* ------------------------------------------------------------ My maps */

.page { padding: 40px 48px 48px; display: flex; flex-direction: column; gap: 28px; overflow: auto; min-height: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.tile {
  border: 0; background: var(--white); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  text-align: left; padding: 0; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
}
.tile:hover { box-shadow: var(--shadow-high); transform: translateY(-1px); }
.tile .image { height: 200px; background: var(--surface); position: relative; overflow: hidden; }
.tile .image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .image .tag { position: absolute; left: 12px; top: 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
/* Without a preview map: the frame as an orange outline on the light map ground, like the frame on the map */
.tile .image.outline-image { background: var(--map-ground); }
.tile .outline { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile .image img.map-thumb { position: absolute; inset: 0; animation: fade-in .4s ease-out; }
.tile .image.with-thumb .outline rect { fill: color-mix(in srgb, var(--brand) 10%, transparent); stroke-width: 2.5; }
.tile .image.with-thumb .tag { background: var(--white); color: var(--ink); padding: 4px 10px; border-radius: 999px; box-shadow: 0 1px 2px rgba(22, 24, 29, .12); }
.tile.expired .image.with-thumb img.map-thumb { filter: grayscale(1); opacity: .45; }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tile .image img.map-thumb { animation: none; } }
.tile .outline rect { fill: var(--brand-tint); stroke: var(--brand-graphic); stroke-width: 2; vector-effect: non-scaling-stroke; }
.tile.expired .outline rect { fill: none; stroke: var(--line-strong); stroke-dasharray: 5 4; }
.tile .status { position: absolute; right: 10px; top: 10px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 24, 29, .12); }
.tile .status.dark { background: var(--ink); color: var(--white); }
.tile .status.accent { background: var(--brand); color: var(--white); }
.tile .status.error { color: var(--error); }
.tile .text { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.tile .name { font-size: 17px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.tile .meta { font-size: 13px; color: var(--muted); }
.tile.expired { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--muted); }
.tile.expired:hover { background: var(--white); box-shadow: var(--shadow); }
.tile.expired .image.outline-image { background: none; }
.tile.expired .next { font-size: 13px; color: var(--brand-dark); font-weight: 700; align-self: flex-start; }
.empty-maps { padding: 40px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; max-width: 560px; }
.empty-maps h2 { font-size: 20px; font-weight: 800; letter-spacing: -.015em; }
.empty-maps p { color: var(--muted); line-height: 1.5; font-size: 14px; }
.empty-maps.with-image { padding: 28px; gap: 20px; }
.empty-image { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; display: block; }

/* ------------------------------------------------------------ Without invitation (gate) */

/* Start page: hero (claim, access, facts | example preview map), the three steps as pictures, data credit */
.start { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.start main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--margin); }
.start-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: center; padding: 56px 24px 64px; }
.hero-text { display: flex; flex-direction: column; gap: 24px; max-width: 540px; }
.start h1 { font-size: 52px; line-height: 1.02; font-weight: 800; letter-spacing: -.04em; text-wrap: balance; margin: 0; }
.start .intro { font-size: 17px; line-height: 1.55; color: var(--muted); text-wrap: pretty; margin: 0; }
.start-go { display: flex; gap: 10px; flex-wrap: wrap; }
.start-go .btn.primary { padding: 14px 24px; }
.start-go .btn.primary .icon { width: 18px; height: 18px; }
.start-invite { padding: 22px 24px; gap: 8px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.start-invite p { margin: 0; line-height: 1.5; }
.start-invite .t { font-weight: 700; font-size: 15px; }
.start-invite .link { font-size: 14px; margin-top: 4px; text-align: left; align-self: flex-start; }
.start-note { margin: 0; font-size: 14px; color: var(--muted); }
.hero-image { margin: 0; position: relative; aspect-ratio: 4 / 3; max-height: 72vh; justify-self: end; width: 100%; max-width: 640px;
  border-radius: var(--radius); overflow: hidden; background: var(--map-ground); box-shadow: var(--shadow-high); }
.hero-image img, .hero-image video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-image figcaption { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 2px;
  background: var(--white); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); }
.hero-image .n { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.hero-image .m { font-size: 12px; font-weight: 600; color: var(--muted); }
.start-idea { padding: 0 24px 48px; max-width: 760px; }
.start-idea h2 { margin: 0 0 14px; font-size: 28px; font-weight: 800; letter-spacing: -.025em; }
.start-idea p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--muted); text-wrap: pretty; }
.start-idea p + p { margin-top: 10px; }
.start-steps ol { list-style: none; margin: 0; padding: 0 24px 56px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.start-step { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.start-step .image { aspect-ratio: 16 / 10; background: var(--map-ground); border-bottom: 1px solid var(--line); }
.start-step .image img, .start-step .image video { display: block; width: 100%; height: 100%; object-fit: cover; }
.start-step .text { display: flex; gap: 14px; padding: 18px 20px 22px; }
.start-step .nr { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--white);
  display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.start-step h3 { margin: 2px 0 6px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.start-step p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.start-faq { padding: 0 24px 56px; max-width: 760px; }
.start-faq h2 { margin: 0 0 12px; font-size: 28px; font-weight: 800; letter-spacing: -.025em; }
.start-faq details { border-bottom: 1px solid var(--line); }
.start-faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 0; font-size: 16px; font-weight: 700; }
.start-faq summary::-webkit-details-markers { display: none; }
.start-faq summary .arrow { width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform .15s; }
.start-faq details[open] summary .arrow { transform: rotate(180deg); color: var(--ink); }
.start-faq summary:hover { color: var(--brand-dark); }
.start-faq details p { margin: 0 0 18px; font-size: 15px; line-height: 1.6; color: var(--muted); text-wrap: pretty; }
.start-foot { padding: 20px 40px 28px; font-size: 13px; color: var(--muted); text-align: center; }
.warning { font-size: 14px !important; line-height: 1.5; color: var(--ink) !important; font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.warning .icon { color: var(--error); margin-top: 2px; }

/* ------------------------------------------------------------ Instructions (dialog) */

dialog.instructions { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 64px); border: 0; border-radius: var(--radius); padding: 0; background: var(--white); color: var(--ink); box-shadow: var(--shadow-high); }
dialog.instructions::backdrop { background: rgba(22, 24, 29, .32); }
.instructions-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); }
.instructions-head h2 { font-size: 18px; font-weight: 800; }
.instructions-text { padding: 8px 24px 24px; line-height: 1.6; font-size: 14px; }
.instructions-text h1 { font-size: 24px; font-weight: 800; margin: 16px 0 8px; letter-spacing: -.02em; }
.instructions-text h2 { font-size: 17px; font-weight: 800; margin: 20px 0 8px; }
.instructions-text p, .instructions-text ul { margin: 8px 0; }
.instructions-text code { font-family: var(--mono); font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.instructions-text pre { background: var(--surface); padding: 10px 12px; border-radius: 9px; overflow: auto; font-size: 12px; }
.instructions-text pre code { background: none; padding: 0; }
.instructions-text table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.instructions-text td, .instructions-text th { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }

/* ------------------------------------------------------------ Narrower windows */

/* Header: below 1180 px the compact step display instead of the bar */
@media (max-width: 1180px) {
  .header .steps { display: none; }
  .step-compact { display: inline-flex; }
}
@media (min-width: 1001px) and (max-width: 1280px) { .grid { grid-template-columns: repeat(2, 1fr); } }
/* Header with steps below 900 px, simple header below 640 px: right side as a menu */
@media (max-width: 900px) {
  .header:not(.simple) .menu-btn { display: grid; }
  .header:not(.simple) .header-right { display: none; }
  .header:not(.simple).menu-open .header-right { display: flex; }
  .header > .logo { min-width: 0; }
}
@media (max-width: 640px) {
  .header.simple .menu-btn { display: grid; flex: none; }
  .header.simple:has(> .menu-btn) .header-right { display: none; }
  .header.simple.menu-open:has(> .menu-btn) .header-right { display: flex; }
  .header.simple { gap: 12px; }
  .header-left { min-width: 0; gap: 12px; }
}
/* The menu: a white panel below the header */
@media (max-width: 900px) {
  .header:not(.simple) .header-right {
    position: absolute; right: 0; top: calc(100% + 8px); flex-direction: column; align-items: stretch; gap: 2px;
    padding: 8px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-high); min-width: 220px;
  }
  .header:not(.simple) .header-right > * { justify-content: flex-start; }
  .header:not(.simple) .header-right .collapsible { display: inline; }
  .header:not(.simple) .header-right > a, .header:not(.simple) .header-right > .active { padding: 11px 10px; }
  .header:not(.simple) .header-right .game-picker { align-self: flex-start; margin: 4px 6px; }
  .header:not(.simple) .header-right .budget, .header.simple .header-right .budget { padding: 11px 10px; }
  .header:not(.simple) .header-right .budget-text, .header.simple .header-right .budget-text { display: inline; margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .header:not(.simple) .header-right .lang-picker { padding: 0 4px; }
}
@media (max-width: 640px) {
  .header.simple:has(> .menu-btn) .header-right {
    position: absolute; right: 0; top: calc(100% + 8px); flex-direction: column; align-items: stretch; gap: 2px;
    padding: 8px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-high); min-width: 220px;
  }
  .header.simple:has(> .menu-btn) .header-right > a, .header.simple .header-right > button, .header.simple .header-right > .active { padding: 11px 10px; text-align: left; }
  .header.simple .header-right .lang-picker { padding: 0 4px; }
}

/* Below 1000 px: panel as a sheet at the bottom over the map; pages without a map stacked */
@media (max-width: 1000px) {
  :root { --margin: 8px; --header-h: 52px; }
  .header { padding: 0 6px 0 12px; gap: 10px; }
  .app:not(.map-full) { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; display: block; }
  .app:not(.map-full) > .header { position: sticky; top: var(--margin); }
  .app.map-full > .workbench { display: flex; flex-direction: column; }
  .app.map-full .map-area { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; }
  .app.map-full .panel {
    position: relative; inset: auto; width: auto; flex: 0 0 auto; max-height: 50vh; max-height: 50dvh; margin-top: -16px;
    border-radius: 18px 18px 0 0; box-shadow: 0 -1px 2px rgba(22, 24, 29, .06), 0 -8px 24px rgba(22, 24, 29, .12);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  /* grip bar at the top of the sheet */
  .app.map-full .panel::before { content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-strong); }
  .app.map-full .panel-body { padding-top: 8px; }
  .app.map-full .maplibregl-ctrl-bottom-right { right: 0; bottom: 16px; }
  .app.map-full .maplibregl-ctrl-attrib { margin: 0 var(--margin) var(--margin) 0; }
  .search { left: var(--margin); width: calc(100% - 2 * var(--margin) - 52px); }
  .zoom { right: var(--margin); bottom: auto; top: calc(var(--margin) * 2 + var(--header-h)); }
  .zoom button { width: 44px; height: 44px; }
  .summary { left: var(--margin); max-width: calc(100% - 2 * var(--margin) - 60px); padding: 6px 12px; gap: 10px; }
  .workbench { display: block; padding: var(--margin); }
  .workbench > .panel { margin-top: var(--margin); }
  /* narrow: the frame takes the aspect ratio of the preview map */
  .preview-frame { min-height: 50vh; }
  .preview-frame:has(img) { min-height: 0; }
  .preview-frame img { position: static; display: block; height: auto; }
  .preview-frame .actions { position: static; justify-content: flex-end; padding: 12px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .page { padding: 24px 12px 32px; overflow: visible; }
  .start-hero { grid-template-columns: 1fr; gap: 28px; padding: 28px 4px 36px; }
  .start h1 { font-size: 36px; }
  .hero-image { justify-self: stretch; max-width: none; aspect-ratio: 16 / 10; max-height: none; }
  .start-steps ol { grid-template-columns: 1fr; padding: 0 4px 36px; gap: 16px; }
  .start-idea { padding: 0 4px 32px; }
  .start-idea h2 { font-size: 24px; }
  .start-faq { padding: 0 4px 36px; }
  .start-faq h2 { font-size: 24px; }
  .start-foot { padding: 8px 20px 24px; }
  .page-head { flex-wrap: wrap; align-items: flex-end; }
  .page-head h1 { font-size: 28px; }
  .empty-maps, .empty-maps.with-image { padding: 22px; }
}
@media (max-width: 420px) {
  .step-list { grid-template-columns: 1fr; }
}

/* Touch: hit areas at least 40 px (zoom, segments, icon buttons), handles easier to grab */
@media (pointer: coarse) {
  .zoom button { width: 44px; height: 44px; }
  .segment { min-height: 44px; }
  .icon-btn { width: 40px; height: 40px; }
  .tp-sizes button { height: 44px; }
  .frame .handle::before { inset: -15px; }
  .lang-picker button { padding: 11px 5px; }
  .chip { min-height: 40px; padding: 10px 14px; }
  .step-compact { height: 40px; }
  .mini { min-height: 56px; }
  .hit { padding: 12px 10px; }
}
