/* Layout: full-screen pixel map, with a wooden HUD bar on top, build bar at the bottom, small panels floating in the corners.
   Type: Nunito for everything you read, Pixelify Sans only for big titles so the pixel look stays without hurting legibility. */
/* Fonts: self-hosted woff2 under fonts/ (both SIL Open Font License 1.1, the licence texts are next to them), latin and
   latin-ext for each weight the game uses: Nunito 600, 700 and 800, Pixelify Sans 600. Relative URLs, so the game still
   opens from disk. Taken from the @fontsource packages (devDependencies only); docs/ui-and-controls.html#fonts. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/nunito-latin-600-normal.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/nunito-latin-ext-600-normal.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/nunito-latin-700-normal.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/nunito-latin-ext-700-normal.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/nunito-latin-800-normal.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/nunito-latin-ext-800-normal.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/pixelify-sans-latin-600-normal.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/pixelify-sans-latin-ext-600-normal.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
  --night: #0d0b08; /* unexplored land and page ground */
  --bark: #241a12; /* panel fill */
  --bark-2: #33261a; /* raised panel / button */
  --bark-3: #45331f; /* button hover */
  --seam: #5e4630; /* panel edges */
  --hi: rgba(255, 236, 200, 0.08); /* bevel highlight */
  --parchment: #f4ead2; /* text */
  --dust: #c4b292; /* secondary text */
  --gold: #e6b04a; /* accent, selection */
  --blood: #e0624a; /* danger */
  --rose: #ffa08c; /* danger text on dark */
  --moss: #8cc265; /* good */
  --leaf: #c2ec9b; /* good text on dark */
  --f-display: 'Pixelify Sans', 'Trebuchet MS', system-ui, sans-serif;
  --f-body: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --toph: 52px;
  --barh: 78px;
  color-scheme: dark;
}
html,
body {
  height: 100%;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--night);
  color: var(--parchment);
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app {
  position: fixed;
  inset: 0;
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}
img.px {
  image-rendering: pixelated;
  width: 24px;
  height: 24px;
  flex: none;
}
b {
  font-weight: 800;
}

.panel {
  background: var(--bark);
  border: 2px solid var(--seam);
  box-shadow:
    inset 0 2px 0 var(--hi),
    0 0 0 2px var(--night),
    0 6px 16px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
}
button {
  font: inherit;
  font-weight: 700;
  text-align: center;
  color: var(--parchment);
  background: var(--bark-2);
  border: 2px solid var(--seam);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 0 var(--hi),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
button:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--bark-3);
}
button:active:not(:disabled) {
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.3);
}
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
button:disabled {
  cursor: not-allowed;
}
button.on {
  border-color: var(--gold);
  background: #4f3a20;
}
button.primary {
  border-color: var(--gold);
  background: #5a4120;
}
button.warn {
  border-color: var(--blood);
  color: var(--rose);
}
kbd {
  display: inline-block;
  font: 800 10px/1 var(--f-body);
  color: var(--dust);
  border: 1px solid var(--seam);
  border-radius: 3px;
  padding: 1px 3px;
  background: var(--night);
}
.x {
  margin-left: auto;
  width: 26px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--dust);
  background: none;
  box-shadow: none;
  border-color: transparent;
}
.lbl {
  font: 800 11px/1.2 var(--f-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

#top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px; /* 10px, not 14: the Polish header (Dzień, wolnych) fits one row at 1280px wide */
  align-items: center;
  border-width: 0 0 2px;
  border-radius: 0;
  z-index: 3;
}
.brand {
  font-family: var(--f-display);
  font-weight: 600;
  color: var(--gold);
  font-size: 20px;
  letter-spacing: 0.02em;
}
.res {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  line-height: 24px;
  padding: 3px 8px;
  background: var(--night);
  border: 1px solid #3a2c1e;
  border-radius: 4px;
}
.chip b {
  min-width: 2ch;
  text-align: center;
}
.chip small {
  color: var(--dust);
  font-size: 12px;
  font-weight: 700;
}
.chip.hungry {
  border-color: var(--blood);
}
.chip.hungry b {
  color: var(--rose);
}
.chip.flash b {
  color: var(--leaf);
}
#clock {
  font-size: 14px;
  color: var(--dust);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#clock.night {
  color: #a9b8ff;
}
#raid {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 3px 0;
  color: var(--dust);
  font-size: 14px;
  cursor: default;
  font-variant-numeric: tabular-nums;
}
#raid.hot {
  color: var(--rose);
}
#raid.alarm {
  color: #fff;
  background: var(--blood);
  padding: 3px 10px;
  cursor: pointer;
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
  to {
    background: #a83d2a;
  }
}
.ctl {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.ctl button {
  min-width: 36px;
  height: 32px;
  padding: 0 9px;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ctl button.off {
  color: var(--dust);
  text-decoration: line-through;
}

/* Left column: goal on top, village overview under it, events history pinned to the bottom. Nothing in it can overlap. */
#lcol {
  position: absolute;
  left: 12px;
  top: calc(var(--toph) + 10px);
  bottom: calc(var(--barh) + 12px);
  width: min(360px, calc(100% - 172px));
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}
#lcol > * {
  pointer-events: auto;
}
#goal {
  padding: 8px 12px 10px;
  display: grid;
  gap: 3px;
  flex: none;
}
#goal .txt {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
#goal .rw {
  font-size: 13px;
  color: var(--dust);
}
#goal .prog {
  height: 4px;
  background: var(--night);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
#goal .prog i {
  display: block;
  height: 100%;
  background: var(--gold);
}

/* Build menu: category tabs on the left, the open category's buildings on the right. Nothing scrolls. */
#bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: stretch;
  gap: 10px;
  border-width: 2px 0 0;
  border-radius: 0;
  z-index: 3;
}
#tabs {
  display: flex;
  gap: 4px;
  padding-right: 10px;
  border-right: 2px solid var(--seam);
  flex: none;
}
#tabs button {
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  position: relative;
  background: var(--bark);
  color: var(--dust);
  font-size: 12px;
  font-weight: 800;
}
#tabs button img {
  width: 26px;
  height: 26px;
}
#tabs button.cur {
  background: #4f3a20;
  border-color: var(--gold);
  color: var(--gold);
}
#tabs button kbd {
  position: absolute;
  top: 3px;
  right: 3px;
}
#tabs .dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blood);
  box-shadow: 0 0 0 2px var(--bark);
  animation: pulse 1s ease-in-out infinite alternate;
}
#items {
  display: flex;
  gap: 6px;
  min-width: 0;
  flex: 1;
  align-items: stretch;
}
#items button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  flex: 0 1 124px;
  min-width: 0;
  padding: 5px 8px;
  position: relative;
}
#items button kbd {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 9px;
  text-align: center;
}
#items .nm {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
#items .cost {
  font-size: 12px;
  color: var(--dust);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}
#items .cost b {
  font-weight: 700;
}
#items .cost img {
  width: 14px;
  height: 14px;
  image-rendering: pixelated;
  margin-right: 3px;
}
#items .cost img:last-child {
  margin-right: 0;
}
#items button:disabled img,
#items button:disabled .nm {
  opacity: 0.5;
}
#items .cost b.miss {
  color: var(--rose);
}
#items button.na .cost {
  color: var(--dust);
}
#tip {
  position: absolute;
  z-index: 4;
  bottom: calc(var(--barh) + 8px);
  width: 260px;
  padding: 8px 12px;
  display: grid;
  gap: 3px;
  pointer-events: none;
}
#tip h4 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--gold);
}
#tip p {
  margin: 0;
  font-size: 14px;
}
#tip .c {
  color: var(--dust);
  font-size: 13px;
}
#tip .c.bad {
  color: var(--rose);
}
/* the same card over a building's note on the map, placed at the mouse by renderNoteTip */
#tip.at {
  bottom: auto;
  width: auto;
  max-width: 280px;
}
/* a short message that is not part of the game (saving or loading a file), over every overlay */
#toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--barh) + 16px);
  transform: translateX(-50%);
  z-index: 7;
  width: max-content;
  max-width: min(460px, calc(100% - 24px));
  padding: 8px 14px;
  font-size: 14px;
  pointer-events: none;
}
#toast.good {
  border-color: var(--moss);
}
#toast.bad {
  border-color: var(--blood);
}

#mini {
  position: absolute;
  right: 12px;
  top: calc(var(--toph) + 10px);
  width: 136px;
  height: 136px;
  image-rendering: pixelated;
  z-index: 2;
  cursor: pointer;
}
/* Right column under the minimap: village overview on top, selection details at the bottom, never overlapping. */
#side {
  position: absolute;
  right: 12px;
  top: calc(var(--toph) + 158px);
  bottom: calc(var(--barh) + 12px);
  width: 268px;
  max-width: calc(100% - 24px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.side {
  pointer-events: auto;
  padding: 10px 12px 12px;
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  flex: 0 1 auto;
  scrollbar-width: thin;
  scrollbar-color: var(--seam) transparent;
}
#info {
  margin-top: auto;
  max-height: 100%;
}
#village {
  flex: 0 1 auto;
}
.side .hd {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}
.side h3 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--gold);
  line-height: 1.1;
}
.side p {
  margin: 0;
  font-size: 14px;
}
.side .muted {
  color: var(--dust);
}
.side .bad {
  color: var(--rose);
}
.side .lv {
  font: 800 11px/1 var(--f-body);
  color: var(--night);
  background: var(--gold);
  border-radius: 3px;
  padding: 3px 5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.side .acts {
  display: grid;
  gap: 5px;
  margin-top: 2px;
}
.side .acts button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 6px 10px;
  line-height: 1.25;
}
.side .acts button span {
  color: var(--dust);
  font-weight: 600;
  font-size: 12px;
}
.side .acts button:disabled {
  opacity: 0.55;
}
.trade {
  display: grid;
  gap: 4px;
}
.trade .chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.trade .chips button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 2px;
  font-size: 12px;
}
.trade .chips img {
  width: 18px;
  height: 18px;
}
.trade .chips button:disabled {
  opacity: 0.35;
}
.side .upg {
  padding: 6px 8px;
  background: var(--night);
  border-radius: 4px;
  font-size: 13px;
  color: var(--dust);
}
.hpbar {
  height: 6px;
  background: var(--night);
  border-radius: 3px;
  overflow: hidden;
}
.hpbar i {
  display: block;
  height: 100%;
  background: var(--moss);
}
#village table {
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
#village th {
  text-align: left;
  font-weight: 700;
  color: var(--dust);
  font-size: 12px;
  padding: 0 4px 3px 0;
}
#village th + th,
#village td.n {
  text-align: center;
}
#village td {
  padding: 2px 4px 2px 0;
  border-top: 1px solid #33261a;
}
#village td img {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 5px;
}
#village td.up {
  color: var(--leaf);
}

/* Events history, bottom left: a scrollable list of recent messages with a show/hide toggle under it. */
#events {
  margin-top: auto;
  flex: none;
  pointer-events: none !important;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
#log {
  pointer-events: auto;
  width: 100%;
  max-height: 168px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: rgba(13, 11, 8, 0.78);
  border: 1px solid #3a2c1e;
  border-radius: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--seam) transparent;
}
#log div {
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 1px 2px;
}
#log time {
  flex: none;
  width: 34px;
  text-align: right;
  font-size: 12px;
  color: var(--dust);
  font-variant-numeric: tabular-nums;
}
#log .bad {
  color: var(--rose);
}
#log .good {
  color: var(--leaf);
}
#log .old {
  opacity: 0.62;
}
#b-log {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
#b-log .n {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--gold);
  color: var(--night);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#b-log .car {
  font-size: 10px;
  color: var(--dust);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(13, 11, 8, 0.76);
  z-index: 5;
  padding: 16px;
  overflow-y: auto;
}
.card {
  max-width: 520px;
  padding: 20px 22px;
  display: grid;
  gap: 12px;
}
.card h2 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  color: var(--gold);
  font-size: 30px;
  line-height: 1.1;
  text-wrap: balance;
}
.card p,
.card li {
  margin: 0;
  line-height: 1.45;
}
.card .lead {
  font-size: 16px;
}
/* The start card and game menu (src/ui/menu.js): a narrow card, one screen at a time, every screen short enough for a
   360x640 phone without the page scrolling; the rules scroll inside their own box. */
.card.menu {
  width: min(400px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;
  overflow-y: auto;
}
.mscreen {
  display: grid;
  gap: 12px;
  min-height: 0;
}
.mscreen h3 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 23px;
  line-height: 1.15;
  color: var(--gold);
}
.mbtns {
  display: grid;
  gap: 8px;
}
.card .mbtns .go {
  width: 100%;
  min-width: 0;
}
#rules {
  max-height: min(420px, calc(100vh - 210px));
  max-height: min(420px, calc(100dvh - 210px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px 10px 4px;
  background: var(--night);
  border: 1px solid var(--seam);
  border-radius: 4px;
}
#rules:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
/* the difficulty: its label on a row of its own, then three equal buttons */
.card.menu .diff {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.card.menu .diff .lbl {
  grid-column: 1 / -1;
  margin: 0;
}
.card.menu .diff button {
  min-width: 0;
}
.card .hint {
  font-size: 13px;
  color: var(--dust);
}
.mfoot {
  display: flex;
  padding-top: 10px;
  border-top: 1px solid var(--seam);
}
.mfoot .back {
  min-width: 96px;
}
.card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: #e6dbc1;
}
.card li::marker {
  color: var(--gold);
}
.card .btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.diff button {
  min-width: 72px;
}
.card .go.alt {
  background: var(--bark-2);
  border-color: var(--seam);
}
.card .go.confirm {
  border-color: var(--blood);
  color: var(--rose);
}
#oops {
  position: absolute;
  left: 50%;
  top: calc(var(--toph) + 12px);
  transform: translateX(-50%);
  z-index: 6;
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
  border-color: var(--blood);
}
.card .go {
  font-size: 15px;
  font-weight: 800;
  padding: 9px 16px;
  min-width: 180px;
  border-color: var(--gold);
  background: #5a4120;
}
.diff {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.diff .lbl {
  color: var(--dust);
  margin-right: 4px;
}
.diff button {
  font-size: 14px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.stats div {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bark-2);
  border: 2px solid var(--seam);
  border-radius: 4px;
}
.stats b {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
.stats span {
  font-size: 12px;
  color: var(--dust);
}

/* The debug overlay's panel (the ` key, src/ui/debug.js): top right, left of the minimap, where no other panel
   goes; under the minimap on narrower screens; over the goal on a phone. Never takes a click. */
#dbg-panel {
  position: absolute;
  right: 160px;
  top: calc(var(--toph) + 10px);
  z-index: 2;
  width: 330px;
  max-height: calc(100% - var(--toph) - var(--barh) - 30px);
  overflow: hidden;
  padding: 6px 9px 7px;
  background: rgba(13, 11, 8, 0.84);
  font-size: 12px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#dbg-panel h4 {
  margin: 0 0 2px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
}
#dbg-panel p {
  margin: 0;
}
#dbg-panel b {
  color: var(--gold);
}
#dbg-panel .muted {
  color: var(--dust);
  font-size: 11px;
}
#dbg-panel .sub {
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px solid var(--seam);
  color: var(--dust);
}
#dbg-panel .f {
  margin-top: 2px;
}
#dbg-panel .f b {
  text-transform: uppercase;
  font-size: 10.5px;
}
#dbg-panel .bug b,
#dbg-panel b.bad {
  color: var(--blood);
}
#dbg-panel .unreachable b {
  color: #f39a5b;
}
#dbg-panel .shortage b {
  color: var(--dust);
}
@media (max-width: 900px) {
  #dbg-panel {
    right: 12px;
    top: calc(var(--toph) + 158px);
    width: 268px;
  }
}
@media (max-width: 640px) {
  #dbg-panel {
    left: 8px;
    right: 112px;
    width: auto;
    top: calc(var(--toph) + 8px);
    max-height: 40vh;
    font-size: 11px;
    background: var(--bark);
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }
  #top {
    gap: 4px 8px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .res {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    scrollbar-width: none;
  }
  .res::-webkit-scrollbar {
    display: none;
  }
  .chip {
    font-size: 15px;
    padding: 2px 7px 2px 4px;
    flex: none;
  }
  img.px {
    width: 20px;
    height: 20px;
  }
  .ctl button {
    min-width: 32px;
    height: 30px;
    padding: 0 7px;
  }
  #mini {
    width: 96px;
    height: 96px;
    right: 8px;
  }
  #lcol {
    left: 8px;
    right: 8px;
    width: auto;
  }
  #goal {
    margin-right: 108px;
  }
  #log {
    max-height: 92px;
  }
  #side {
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    top: calc(var(--toph) + 112px);
  }
  #info {
    max-height: 46vh;
  }
  #b-zout,
  #b-zin,
  #clock {
    display: none;
  }
  #raid {
    flex: 1;
    text-align: left;
  }
  #bar {
    padding-left: 8px;
    padding-right: 8px;
    flex-direction: column;
    gap: 6px;
  }
  #tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0 0 6px;
    border-right: 0;
    border-bottom: 2px solid var(--seam);
  }
  #tabs button {
    width: auto;
    gap: 1px;
    height: 44px;
    font-size: 10.5px;
    letter-spacing: -0.01em;
  }
  #tabs button img {
    width: 18px;
    height: 18px;
  }
  #tabs button kbd {
    display: none;
  }
  #items {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
  }
  #items button {
    width: auto;
    min-width: 0;
    padding: 4px 2px;
  }
  /* 10.5px and a little tighter, like the tabs above: the longest one-word Polish name (Kamieniołom) has to fit
     a fifth of a 390px bar without being cut, since a single word cannot wrap */
  #items .nm {
    font-size: 10.5px;
    letter-spacing: -0.02em;
    white-space: normal;
    hyphens: auto;
    line-height: 1.1;
    text-align: center;
  }
  #items .cost {
    font-size: 11px;
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
  }
  #items .cost img {
    width: 12px;
    height: 12px;
    margin-right: 1px;
  }
  #items button kbd {
    display: none;
  }
  #tip {
    display: none;
  }
  .brand {
    display: none;
  }
}
@media (hover: none) {
  #tip {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* The menu's links to the changelog, the privacy policy and the cookie choice: small and quiet at the foot of the
   main screen, under a rule. */
.card .links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  padding-top: 10px;
  border-top: 1px solid var(--seam);
}
.card .links a,
.card .links button {
  color: var(--dust);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.card .links a:hover,
.card .links button:hover {
  color: var(--parchment);
}
.card .links button,
.page-foot button,
.page-body button {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
.card .links button:hover:not(:disabled),
.page-foot button:hover:not(:disabled),
.page-body button:hover:not(:disabled) {
  background: none;
}

/* The consent card (src/ui/analytics.js). On the game page a centred modal layer over everything (#consent.modal,
   src/ui/modal.js), shown before the start card on a first visit; on the text pages a small card in the corner
   (.corner) that never blocks reading. The two answers share one rule: same size, weight and colours. */
#consent.corner {
  position: fixed;
  right: 12px;
  bottom: calc(var(--barh) + 12px);
  z-index: 8;
  width: 340px;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
}
.consent-card {
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}
#consent.modal .consent-card {
  width: min(420px, 100%);
  box-sizing: border-box;
  padding: 18px 20px;
  gap: 12px;
  font-size: 15px;
  line-height: 1.45;
}
.consent-card:focus {
  outline: none;
}
.consent-card h2 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--gold);
}
#consent.modal .consent-card h2 {
  font-size: 22px;
}
.consent-card p {
  margin: 0;
  color: #e6dbc1;
}
.consent-card a {
  color: var(--gold);
  text-underline-offset: 2px;
}
.consent-card .btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.consent-card .btns button {
  font-size: 14px;
  font-weight: 800;
  padding: 7px 10px;
  border-color: var(--gold);
  background: #5a4120;
}
#consent.modal .consent-card .btns button {
  font-size: 15px;
  padding: 9px 12px;
}
@media (max-width: 640px) {
  #consent.corner {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    bottom: calc(var(--barh) + 8px);
  }
}

/* Modal layers over the game (src/ui/modal.js): the consent card above and the page modal, outside #app at the end of
   <body>, so above every panel and overlay of the game. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(13, 11, 8, 0.78);
}
#consent.modal {
  z-index: 18;
}
/* The page modal: the site's Zmiany or Polityka prywatności in a frame of fixed height whose content scrolls inside. */
.modal-box {
  width: min(760px, 100%);
  height: min(80vh, 640px);
  height: min(80dvh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}
.modal-box.off {
  height: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 18px;
  border-bottom: 2px solid var(--seam);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.2;
  color: var(--gold);
}
.modal-head .x {
  width: 34px;
  height: 32px;
  font-size: 22px;
}
#page-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: var(--bark);
  visibility: hidden;
}
#page-frame.ready {
  visibility: visible;
}
.modal-wait {
  margin: 0;
  padding: 18px 22px 0;
  color: var(--dust);
}
.modal-off {
  padding: 18px 22px;
  color: #e6dbc1;
}
.modal-off p {
  margin: 0 0 10px;
}
.modal-off a {
  color: var(--gold);
  text-underline-offset: 3px;
}
@media (max-width: 640px) {
  .modal {
    padding: 8px;
  }
  .modal-box {
    height: min(86vh, 640px);
    height: min(86dvh, 640px);
  }
}

/* The site's text pages (privacy/, changelog/, 404.html, written by tools/build-site.js): the game's palette and
   type on a scrolling page, one reading column in a panel. */
body.page {
  --barh: 0px;
  height: auto;
  min-height: 100%;
  overflow: auto;
  font-size: 16px;
  line-height: 1.55;
}
.page-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 32px;
  display: grid;
  gap: 16px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
}
.page-head .brand {
  display: inline; /* the phone layout hides the game's .brand */
  color: var(--gold);
  text-decoration: none;
}
.page-head .play {
  font-weight: 800;
  color: var(--parchment);
  text-decoration: none;
  border: 2px solid var(--gold);
  border-radius: 4px;
  background: #5a4120;
  padding: 5px 12px;
}
.page-head .play:hover {
  background: var(--bark-3);
}
.page-body {
  padding: 20px 22px 24px;
}
.page-body h1 {
  margin: 0 0 6px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.1;
  color: var(--gold);
}
.page-body h2 {
  margin: 28px 0 8px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.2;
  color: var(--gold);
}
.page-body p,
.page-body ul {
  margin: 0 0 10px;
  color: #e6dbc1;
}
.page-body ul {
  padding-left: 20px;
}
.page-body li {
  margin-bottom: 6px;
}
.page-body li::marker {
  color: var(--gold);
}
.page-body .lead {
  font-size: 17px;
  color: var(--parchment);
}
.page-body .meta {
  color: var(--dust);
  font-size: 14px;
}
.page-body a,
.page-body button,
.page-foot a,
.page-foot button {
  color: var(--gold);
  text-underline-offset: 3px;
}
.page-body code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--night);
  border: 1px solid var(--seam);
  border-radius: 3px;
  padding: 0 4px;
}
.page-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 15px;
}
.page-body th,
.page-body td {
  text-align: left;
  vertical-align: top;
  padding: 6px 8px;
  border-top: 1px solid var(--seam);
}
.page-body th {
  color: var(--dust);
  font-weight: 800;
}
.page-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: center;
  font-size: 14px;
  color: var(--dust);
}
.page-body button,
.page-foot button {
  text-decoration: underline;
  cursor: pointer;
}
@media (max-width: 640px) {
  .page-wrap {
    padding: 10px 8px 24px;
  }
  .page-body {
    padding: 16px 14px 18px;
  }
  .page-body h1 {
    font-size: 27px;
  }
}

/* A text page inside the game's page modal (?embed=1 in a frame, <html class="embed">, tools/build-site.js): no header,
   no footer and no title (the modal's head has it), one plain column on the frame's background. */
html.embed body.page {
  background: var(--bark);
}
html.embed .page-head,
html.embed .page-foot,
html.embed .page-body > h1 {
  display: none;
}
html.embed .page-wrap {
  max-width: none;
  padding: 0;
  display: block;
}
html.embed .page-body {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
  padding: 16px 22px 24px;
}
@media (max-width: 640px) {
  html.embed .page-body {
    padding: 12px 14px 18px;
  }
}
