/* Håndværker Imperiet – mobile-first, portrait, one thumb.
   Brand: swap the variables below when the haandvaerker.dk brand guide arrives. */

:root {
  --brand: #0e6ba8;        /* primary – white text on it passes WCAG AA */
  --brand-dark: #0a4f7d;
  --brand-tint: #e3f0f9;
  --accent: #f28c28;       /* van stripe, highlights (never used for text) */
  --cta: #d9480f;          /* call to action button, white text 4.6:1 */
  --cta-dark: #b23a0a;
  --ink: #1d2733;
  --ink-soft: #4a5868;     /* 7:1 on --bg */
  --bg: #f6f1e7;
  --card: #ffffff;
  --line: #dcd3c3;
  --good: #1f7a3a;
  --bad: #b3261e;
  --warn-bg: #fff4d6;
  --land: #c9ccc4;
  --land-open: #f3d27a;
  --land-foreign: #d4d6d0;
  --land-2: #dbe3c6;
  --park: #bfd8a2;
  --water: #9fcbe8;
  --road: #c9c2b4;
  --house: #e8b9a0;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --shadow: 0 2px 6px rgba(29, 39, 51, 0.12);
  --tap: 48px;
  --day-ms: 667ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; }
a.btn { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small, small { font-size: 16px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }

.ico { width: 24px; height: 24px; flex: none; vertical-align: middle; }
.stars { display: inline-flex; gap: 1px; vertical-align: middle; }
.stars .ico { width: 18px; height: 18px; }
.avatar { width: 48px; height: 48px; flex: none; border-radius: 50%; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.screen { min-height: 100dvh; }

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); width: 100%; padding: 10px 16px;
  border: 2px solid transparent; border-radius: var(--radius);
  font-weight: 700; text-align: center; text-decoration: none;
  color: var(--ink); background: var(--card); box-shadow: var(--shadow);
  transition: transform 0.08s;
}
.btn:active { transform: scale(0.97); }
.btn > span { display: flex; flex-direction: column; }
.btn small { font-weight: 400; }
.btn-big { min-height: 60px; font-size: 19px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-secondary { background: var(--card); border-color: var(--brand); color: var(--brand-dark); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--brand-dark); text-decoration: underline; }
.btn-danger { background: var(--card); border-color: var(--bad); color: var(--bad); }
.btn-cta { background: var(--cta); color: #fff; }
.btn-cta:active { background: var(--cta-dark); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.18); color: #fff;
}

/* Start ------------------------------------------------------------------ */
#screen-start { display: flex; flex-direction: column; gap: 20px; padding: 24px 16px calc(16px + env(safe-area-inset-bottom)); }
.start-hero { text-align: center; }
.logo { display: inline-flex; align-items: center; gap: 12px; text-align: left; }
.logo-mark { width: 64px; height: 64px; }
.logo-text { font-size: 24px; line-height: 1.05; color: var(--brand-dark); }
.logo-text strong { font-size: 32px; }
.tagline { margin-top: 12px; font-size: 19px; }
.start-scene svg { width: 100%; max-width: 360px; margin-top: 12px; }
.scene-van { animation: drive 7s linear infinite; }
@keyframes drive { from { transform: translateX(-80px); } to { transform: translateX(340px); } }
.start-actions { display: flex; flex-direction: column; gap: 12px; }
.credit { color: var(--ink-soft); text-align: center; margin-top: auto; }

/* Game screen ------------------------------------------------------------ */
#screen-game { display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.stats { flex: 1; display: flex; gap: 6px; min-width: 0; }
.stat {
  position: relative; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.16);
  font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stat .neg { color: #ffd2cc; }
#stat-money { flex: 1 1 auto; min-width: 0; }
#stat-money.bump { animation: bump 0.4s; }
@keyframes bump { 50% { transform: scale(1.12); } }
.float-num {
  position: absolute; left: 36px; top: 100%; color: #fff; background: var(--good);
  padding: 0 8px; border-radius: 999px; font-size: 16px; pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
}
.float-num.neg { background: var(--bad); }
@keyframes floatUp { from { transform: translateY(20px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-6px); opacity: 0; } }

.monthbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--brand-tint); }
.month-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; min-width: 7.2em; color: var(--brand-dark); }
.bar { --p: 0; position: relative; display: block; height: 10px; border-radius: 999px; background: rgba(29, 39, 51, 0.12); overflow: hidden; }
.bar > span { position: absolute; inset: 0; width: 100%; transform-origin: left; transform: scaleX(var(--p)); background: var(--brand); border-radius: inherit; transition: transform var(--day-ms) linear; }
.month-progress { flex: 1; }
.bar-late > span { background: var(--bad); }

.game-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.map-wrap {
  position: relative; aspect-ratio: 420 / 340;
  width: min(100%, calc(36dvh * 420 / 340)); margin: 0 auto;
}
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.region { fill: var(--land); stroke: #fff; stroke-width: 1.2; transition: fill 0.6s; }
.region.open { fill: var(--land-open); }
.region-label { font-size: 15px; font-weight: 700; text-anchor: middle; fill: #8a8f97; paint-order: stroke; stroke: rgba(255, 255, 255, 0.7); stroke-width: 3px; }
.region-label.open { fill: var(--ink); }
.city { fill: #9aa1a8; }
.city.open { fill: var(--brand); stroke: #fff; stroke-width: 1.5; }
.map-layer { position: absolute; inset: 0; }
.pin {
  position: absolute; min-width: 24px; height: 24px; padding: 0 6px; transform: translate(-50%, -110%);
  border: 2px solid #fff; border-radius: 12px 12px 12px 3px; background: var(--cta); color: #fff;
  font-size: 15px; font-weight: 800; line-height: 20px; text-align: center; pointer-events: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); animation: pinIn 0.35s ease-out;
}
@keyframes pinIn { from { transform: translate(-50%, -60%) scale(0.3); opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.18); } }
.map-van { position: absolute; transform: translate(2px, -6px); pointer-events: none; color: var(--brand-dark); }
.map-van > .ico { width: 22px; height: 22px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.map-hammer { position: absolute; right: -16px; top: -10px; transform-origin: 20% 80%; animation: hammer 0.6s ease-in-out infinite; }
@keyframes hammer { 50% { transform: rotate(-35deg); } }

.tasks { padding: 4px 10px 12px; }
.section-h { font-size: 16px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); margin: 6px 2px; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-list .empty { padding: 14px; text-align: center; color: var(--ink-soft); background: var(--card); border-radius: var(--radius); }
.task-card {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 64px;
  padding: 8px 10px 12px; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); text-align: left; overflow: hidden;
  animation: cardIn 0.3s ease-out;
}
.task-card.size-L { border-color: var(--accent); }
@keyframes cardIn { from { transform: translateY(-8px); opacity: 0; } }
.tc-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-tint); flex: none; }
.tc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tc-title { font-weight: 700; overflow-wrap: anywhere; }
.tc-sub { font-size: 16px; color: var(--ink-soft); }
.tc-budget { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-timer { --p: 1; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--brand-tint); }
.tc-timer::after { content: ""; position: absolute; inset: 0; background: var(--good); transform-origin: left; transform: scaleX(var(--p)); transition: transform var(--day-ms) linear; }
.tc-timer.urgent::after { background: var(--bad); }

.team {
  flex: none; max-height: 42dvh; overflow-y: auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
.worker { display: flex; gap: 10px; align-items: center; }
.w-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.w-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.w-free { color: var(--good); font-weight: 700; }
.w-task { overflow-wrap: anywhere; }
.w-left { display: inline-flex; align-items: center; gap: 4px; font-size: 16px; color: var(--ink-soft); flex-wrap: wrap; }
.w-left strong { color: var(--bad); }
.w-left .ico { width: 18px; height: 18px; }
.queue { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.queue-head, .queue-more { font-size: 16px; color: var(--ink-soft); }
.btn-start { justify-content: flex-start; flex-wrap: wrap; text-align: left; box-shadow: none; border-color: var(--line); }
.btn-start .q-title { flex: 1; min-width: 0; display: block; overflow-wrap: anywhere; }
.btn-start .q-dead { display: block; font-weight: 400; font-size: 16px; color: var(--ink-soft); }
.btn-start .q-dead.urgent { color: var(--bad); font-weight: 700; }
.btn-start.ready { border-color: var(--brand); background: var(--brand-tint); animation: ready 1.6s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 4px rgba(14, 107, 168, 0.25); } }

/* Sheet (dialog) --------------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(20, 28, 38, 0.5);
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  padding: 16px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; gap: 12px;
  animation: sheetIn 0.22s ease-out;
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { font-size: 21px; line-height: 1.2; display: flex; align-items: center; gap: 8px; }
.sheet .sub { color: var(--ink-soft); font-size: 16px; }
.sheet-head { display: flex; gap: 12px; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.fact { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; background: var(--card); border-radius: 12px; text-align: center; font-weight: 700; }
.fact span { display: flex; flex-direction: column; }
.fact small { font-weight: 400; color: var(--ink-soft); }
.choose { font-weight: 700; }
.offers { display: flex; flex-direction: column; gap: 8px; }
.offer {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name price" "chance profit" "pays pays";
  align-items: center; gap: 4px 10px; width: 100%; min-height: 72px; padding: 10px 14px;
  border: 3px solid var(--line); border-radius: var(--radius); background: var(--card); text-align: left;
  box-shadow: var(--shadow); transition: transform 0.08s;
}
.offer:active { transform: scale(0.98); }
.offer-fair { border-color: var(--brand); }
.o-name { grid-area: name; font-size: 19px; font-weight: 800; }
.o-price { grid-area: price; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.o-chance { grid-area: chance; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.o-chance .bar { flex: 1; max-width: 120px; }
.o-chance .bar > span { background: var(--good); transition: none; }
.o-profit { grid-area: profit; display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; font-weight: 700; color: var(--good); font-variant-numeric: tabular-nums; }
.o-profit .ico { width: 20px; height: 20px; }
.o-profit.neg { color: var(--bad); }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 16px; color: var(--ink-soft); }
.hint .ico { width: 20px; height: 20px; }
.sending, .result, .pause, .about, .confirm, .month-end { display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.sending .avatar, .result .avatar { width: 72px; height: 72px; margin: 0 auto; }
.sending p { font-size: 19px; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); animation: dot 0.9s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 50% { transform: translateY(-8px); opacity: 0.5; } }
.result h2, .pause h2, .month-end h2 { justify-content: center; }
.result.won h2 { color: var(--good); }
.about { text-align: left; }
.about h2 { justify-content: flex-start; }

.rows { margin: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.rows > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; background: var(--card); border-radius: 10px; flex-wrap: wrap; }
.rows dt { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rows dt small { flex-basis: 100%; padding-left: 32px; color: var(--ink-soft); }
.rows dd { margin: 0 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rows dd small { flex-basis: 100%; text-align: right; font-weight: 400; color: var(--ink-soft); }
.rows .total { background: var(--brand-tint); font-size: 19px; }

/* Toasts ----------------------------------------------------------------- */
.toasts { position: fixed; z-index: 30; left: 0; right: 0; top: calc(108px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%;
  padding: 10px 14px; border-radius: var(--radius); background: var(--ink); color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); animation: toastIn 0.25s ease-out; transition: opacity 0.4s;
}
.toast.out { opacity: 0; }
.toast.done { background: var(--good); }
.toast.warn { background: var(--bad); }
.toast.review { background: var(--card); color: var(--ink); }
.toast.review small { display: block; color: var(--ink-soft); }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } }

/* Annual report ---------------------------------------------------------- */
.report { display: flex; flex-direction: column; gap: 16px; padding: 20px 14px calc(20px + env(safe-area-inset-bottom)); }
.report-card { display: flex; flex-direction: column; gap: 12px; padding: 20px 14px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.report-card .rows > div { background: var(--bg); }
.trophy .ico { width: 64px; height: 64px; animation: popIn 0.6s ease-out; }
@keyframes popIn { 0% { transform: scale(0); } 70% { transform: scale(1.15); } }
.report h1 { font-size: 28px; color: var(--brand-dark); }
.report .sub { color: var(--ink-soft); }
.score { display: flex; flex-direction: column; align-items: center; }
.score-num { font-size: 52px; font-weight: 800; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.score-label { font-weight: 700; color: var(--ink-soft); }
.best { padding: 12px; border-radius: 12px; background: var(--warn-bg); display: flex; flex-direction: column; gap: 6px; }
.best h2 { font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.best-nums { display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 700; flex-wrap: wrap; }
.cta { display: flex; flex-direction: column; gap: 10px; padding: 16px 14px; border-radius: 20px; background: var(--brand-tint); text-align: center; font-weight: 700; }
.report-actions { display: flex; flex-direction: column; gap: 8px; }

.noscript { padding: 20px; text-align: center; }

.level-chip { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; color: var(--brand-dark); }
.level-chip .ico { width: 22px; height: 22px; }
.w-trades { display: inline-flex; gap: 2px; }
.w-trades .ico { width: 18px; height: 18px; }
.game-nav { display: flex; gap: 8px; margin-top: 8px; }
.game-nav .btn { flex: 1; box-shadow: none; }
.btn-small { min-height: var(--tap); width: auto; padding: 8px 12px; font-size: 16px; box-shadow: none; border-color: var(--line); }
.btn-small.btn-primary { border-color: var(--brand); }
.hint.warn { color: var(--bad); font-weight: 700; }
.contract {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); text-align: left;
}
.contract.on { border-color: var(--good); background: #eef7ef; }
.contract small { display: block; color: var(--ink-soft); }
.contract > span:last-child { display: flex; flex-direction: column; }
.switch { position: relative; width: 48px; height: 28px; flex: none; border-radius: 999px; background: #b9b2a4; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.contract.on .switch { background: var(--good); }
.contract.on .switch::after { transform: translateX(20px); }
.o-pays { grid-area: pays; font-size: 16px; color: var(--ink-soft); }
.sheet > *, .manage > * { flex-shrink: 0; }
.manage { display: flex; flex-direction: column; gap: 10px; }
.manage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: -16px; background: var(--bg); padding: 4px 0; z-index: 1; }
.manage h3 { margin: 8px 0 0; font-size: 18px; }
.people, .items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.person, .item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; background: var(--card); border-radius: 12px; }
.item > .ico { width: 32px; height: 32px; margin-top: 2px; }
.item.is-open { background: #fbf6dc; }
.p-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.p-sub { font-size: 16px; color: var(--ink-soft); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.box { padding: 12px; background: var(--card); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.ok { color: var(--good); font-weight: 700; }
.region-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--land); flex: none; margin-top: 4px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.region-dot.open { background: var(--land-open); }

.lang-first { display: flex; flex-direction: column; gap: 10px; }
.lang-picker { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.lang {
  min-height: var(--tap); min-width: var(--tap); padding: 8px 12px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 700; color: var(--ink);
}
.lang.on { border-color: var(--brand); background: var(--brand); color: #fff; }

/* 320 px phones: a bit tighter, still ≥ 16 px text */
@media (max-width: 359px) {
  .stat { padding: 4px 6px; font-size: 16px; gap: 2px; }
  .stat .ico { width: 20px; height: 20px; }
  .topbar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .month-name { min-width: 6.4em; }
  .logo-text { font-size: 21px; }
  .logo-text strong { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  .scene-van { transform: translateX(120px); }
}
