/* "Bureau" art direction: a sheet of graph paper on a wooden desk, ink, markers and sticky notes. */
:root {
  color-scheme: light;
  --paper: #fbf8ef;
  --paper-2: #fffdf6;
  --grid: rgba(70, 130, 200, 0.18);
  --ink: #22305a;
  --ink-soft: rgba(34, 48, 90, 0.55);
  --muted: #5b6487;
  --red: #d7263d;
  --green: #2f855a;
  --gold: #b45309;
  --sticky: #ffe66d;
  --wood: #a9764a;
  --wood-dark: #8b5a2b;
  --ruler: #e9c46a;
  --highlight: #fff176;
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
  --script: "Caveat", "Patrick Hand", cursive;
  --marker: "Permanent Marker", "Patrick Hand", cursive;
  --board: "Kalam", "Patrick Hand", cursive;
  font-family: var(--hand);
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  background-color: var(--wood);
  background-image: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 3px, transparent 3px 41px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 13px);
}
.hidden { display: none !important; }
h1 { margin: 0; font-family: var(--marker); font-weight: 400; letter-spacing: 0.02em; }
small, .muted { color: var(--muted); font-size: 0.85rem; }
kbd { font-family: var(--hand); font-size: 0.8rem; color: var(--muted); }
button {
  background: var(--paper-2); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 6px;
  padding: 5px 10px; font: inherit; font-size: 1rem; cursor: pointer;
}
button:hover:not(:disabled) { background: #fff9d6; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.active { background: var(--highlight); }
.cta { background: var(--sticky); font-weight: 700; box-shadow: 2px 3px 0 var(--ink); }
.cta.big { height: 52px; font-size: 1.15rem; border-radius: 10px; }
input {
  background: transparent; border: none; border-bottom: 2px solid var(--ink); color: var(--ink);
  padding: 6px 2px; font: inherit; font-size: 1.1rem; width: 100%;
}
input:focus { outline: none; border-bottom-color: var(--red); }
.row { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.error { color: var(--red); margin: 0; min-height: 1.2em; }
.hint { color: var(--muted); margin: 0; text-align: center; }
.hint.left { text-align: left; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; border: 1.5px solid var(--ink); }
.tag { font-size: 0.85rem; color: var(--muted); }
.bonus { color: var(--green); }
.malus { color: var(--red); font-weight: 700; }
.gold-text { color: var(--gold); font-family: var(--board); font-weight: 700; }

/* paper surfaces */
.card {
  position: relative; background: var(--paper-2); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 2px 6px 12px rgba(60, 40, 0, 0.22);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.eyebrow { font-family: var(--script); font-weight: 700; font-size: 1.6rem; line-height: 1; }
.eyebrow.teal { color: var(--red); }
.postit { background: var(--sticky); transform: rotate(-1.2deg); }
.postit::before {
  content: ""; position: absolute; left: 38%; top: -11px; width: 84px; height: 22px;
  background: rgba(255, 255, 255, 0.55); transform: rotate(3deg);
}
.index-card {
  background-color: #fff;
  background-image: linear-gradient(#e88 0 0), repeating-linear-gradient(transparent 0 23px, rgba(70, 130, 200, 0.3) 23px 24px);
  background-size: 100% 2px, 100% 100%; background-position: 0 40px, 0 40px; background-repeat: no-repeat, repeat;
  transform: rotate(0.8deg);
}
.scrap { transform: rotate(-0.6deg); }
.notebook {
  background-color: #fff;
  background-image: linear-gradient(90deg, transparent 26px, rgba(215, 38, 61, 0.45) 26px 28px, transparent 28px),
    repeating-linear-gradient(transparent 0 25px, rgba(70, 130, 200, 0.28) 25px 26px);
  padding-left: 36px;
}

/* join and lobby */
.screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding: 16px; gap: 14px; }
.screen h1 { color: var(--paper); font-size: 2.6rem; text-shadow: 2px 3px 0 rgba(0, 0, 0, 0.3); }
.subtitle { color: var(--paper); margin: 0; text-align: center; font-size: 1.15rem; }
.card.form { width: min(380px, 100%); padding: 22px; background: var(--sticky); transform: rotate(-1deg); }
label { display: flex; flex-direction: column; gap: 2px; font-size: 1rem; color: var(--muted); }
#lobby-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#lobby-players li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--ink-soft); font-size: 1.1rem; }
#lobby-players li .name { flex: 1; }
#lobby-players li button { padding: 0 8px; }
.lang-toggle { font-family: var(--marker); padding: 3px 10px; }

/* speaker button and the sound panel, a sticky note pinned under the top bar */
.sound-toggle { display: inline-flex; align-items: center; justify-content: center; padding: 3px 8px; }
.sound-toggle svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .cone { fill: var(--sticky); }
.sound-toggle .cross, .sound-toggle.muted .waves { display: none; }
.sound-toggle.muted .cross { display: inline; stroke: var(--red); }
.sound-panel {
  position: fixed; z-index: 60; top: calc(env(safe-area-inset-top) + 60px); right: 16px; width: min(270px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; background: var(--sticky);
  border: 1.5px solid var(--ink); border-radius: 4px; box-shadow: 3px 6px 14px rgba(40, 20, 0, 0.35); transform: rotate(-0.6deg);
}
.sound-panel h3 { margin: 0; font-family: var(--script); font-size: 1.7rem; line-height: 1; color: var(--red); }
.sound-volume { display: flex; flex-direction: column; gap: 2px; }
.sound-volume input { border: none; padding: 6px 0; accent-color: var(--red); height: 28px; }
.sound-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.sound-buttons button { flex: 1 1 auto; background: var(--paper-2); }
.sound-buttons button.active { background: var(--highlight); }

/* game shell */
#game { display: grid; grid-template-columns: 290px 92px minmax(0, 1fr) 340px; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
/* no ruler any more: the money sits centred above the board, the buttons on its right */
#topbar { grid-column: 3; grid-row: 1; display: flex; justify-content: center; padding: 12px 4px 0 0; min-width: 0; }
.brand { display: none; }
.stats { display: flex; align-items: center; justify-content: center; gap: 14px; }
.stat.gold {
  align-items: center; padding: 2px 16px 0; background: var(--sticky); border: 1.5px solid var(--ink);
  box-shadow: 2px 3px 0 rgba(40, 20, 0, 0.35); transform: rotate(-1.2deg);
}
.stat.gold .value { font-size: 2.15rem; color: #3a2a12; }
.stat.gold .label .clip { width: 0.9em; height: 1.7em; }
.stat { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; color: #3a2a12; }
.stat .label { font-size: 1rem; }
.stat.wave .value { color: var(--red); }
.stat .value { font-family: var(--board); font-weight: 700; font-size: 1.6rem; color: var(--gold); }
.stat .unit-label { font-size: 0.9rem; }
.stat.gold .unit-label { display: none; }
.stat.mobile-only { display: none; }
.pills { flex: 1; display: none; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.pill { flex: none; height: 30px; padding: 0 10px; border-radius: 6px 6px 0 0; border: 1.5px solid var(--ink); border-bottom: 3px solid var(--pill); background: var(--paper-2); font-size: 0.95rem; display: flex; align-items: center; gap: 4px; }
.pill.focused { background: var(--highlight); }
.pill.dead { opacity: 0.4; text-decoration: line-through; }
.pill .role { font-size: 0.75rem; color: var(--muted); }
.top-actions { grid-column: 1; grid-row: 1; display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 14px 0; }
.top-actions kbd { display: none; }
.top-actions button { background: var(--paper-2); }

.column { display: flex; flex-direction: column; gap: 16px; padding: 18px 14px; overflow-y: auto; min-height: 0; }
#left { grid-column: 1; grid-row: 2; }
#right { grid-column: 4; grid-row: 1 / -1; }
.sheet-handle { display: none; }

/* leaderboard post-it with my income and lives */
.income { display: flex; flex-direction: column; gap: 3px; font-family: var(--board); font-weight: 700; }
.income .line { display: flex; justify-content: space-between; font-size: 1rem; }
.income .line b { color: var(--gold); }
.bar { height: 7px; border: 1.5px solid var(--ink); border-radius: 4px; overflow: hidden; background: var(--paper-2); }
.bar > span { display: block; height: 100%; background: var(--green); }
#my-status { font-family: var(--board); font-weight: 700; color: var(--red); }
#scoreboard { width: 100%; border-collapse: collapse; font-family: var(--board); font-weight: 700; font-size: 1rem; }
#scoreboard td { padding: 2px 2px; border-bottom: 1px dashed rgba(34, 48, 90, 0.25); }
#scoreboard tr { cursor: pointer; }
#scoreboard tr.dead { opacity: 0.5; text-decoration: line-through; }
.leader-star { color: #d4a017; text-shadow: 0 0 1px var(--ink); }
#scoreboard tr.me td { color: var(--red); font-weight: 700; }
#scoreboard td.num { text-align: right; white-space: nowrap; }
#scoreboard td:nth-child(2) { white-space: nowrap; width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
#scoreboard td.num { padding-left: 4px; }
#minimap { width: 100%; height: 150px; display: block; cursor: pointer; }
#feed { display: flex; flex-direction: column; gap: 2px; font-size: 0.95rem; min-height: 40px; }
#feed .Warn { color: var(--gold); }
#feed .Error { color: var(--red); }
#feed .Info { color: var(--green); }
#chat-form input { font-size: 1rem; }

/* build palette: stickers */
#palette { grid-column: 2; grid-row: 1 / -1; display: flex; flex-direction: column; gap: 8px; padding: 18px 6px; overflow-y: auto; }
#palette button {
  width: 78px; min-height: 70px; padding: 4px 2px; border-style: dashed; border-radius: 8px; background: rgba(255, 253, 246, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
#palette button:nth-child(odd) { transform: rotate(-1deg); }
#palette button:nth-child(even) { transform: rotate(1deg); }
#palette button.active { background: var(--highlight); border-style: solid; }
#palette .tower-portrait { width: 30px; height: 30px; }
#palette .name { font-size: 0.95rem; }
#palette .cost { font-size: 0.8rem; color: var(--gold); }

#board-wrap { grid-column: 3; grid-row: 2; position: relative; min-width: 0; min-height: 0; margin: 12px 4px 12px 0; box-shadow: 0 10px 30px rgba(40, 20, 0, 0.35); }
#board { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.lane-hint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); font-size: 0.95rem; color: var(--muted); pointer-events: none; width: max-content; max-width: calc(100% - 16px); text-align: center; }
.tower-card { position: absolute; left: 8px; top: 8px; width: 250px; z-index: 5; transform: rotate(-0.8deg); background: var(--paper-2); border: 1.5px solid var(--ink); }
.tower-card .row button { flex: 1; min-height: 40px; }
.pips { letter-spacing: 2px; color: var(--red); }
#radial { position: absolute; inset: 0; pointer-events: none; }
#radial button {
  position: absolute; pointer-events: auto; width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--ink);
  font-family: var(--marker); font-size: 0.8rem; padding: 0; box-shadow: 2px 3px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
#radial .tower-portrait { width: 20px; height: 20px; margin: 2px 0 0; }
#radial button span { font-family: var(--hand); font-size: 0.6rem; line-height: 0.9; }
#radial button .clip { width: 7px; height: 12px; }
#radial button b { font-weight: 400; white-space: nowrap; font-size: 0.72rem; line-height: 1; }

/* right column: clipboard */
#right { background: var(--wood-dark); margin: 12px 10px 12px 0; border-radius: 14px; padding: 30px 12px 12px; box-shadow: 0 8px 18px rgba(40, 20, 0, 0.4); position: relative; }
#right::before { content: ""; position: absolute; left: calc(50% - 50px); top: 6px; width: 100px; height: 22px; border-radius: 6px; background: #c0c4cc; box-shadow: inset 0 -4px 0 #8a8f99; }
#right .card { box-shadow: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 0 8px; border: 1.5px solid var(--ink-soft); border-radius: 12px; font-size: 0.9rem; }
.chip.good { border-color: var(--red); color: var(--red); }
.segmented { display: inline-flex; gap: 6px; }
.segmented button { border-radius: 14px; padding: 1px 12px; }
.segmented button.active { border-color: var(--red); color: var(--red); background: transparent; border-width: 2px; }

.unit-list { display: flex; flex-direction: column; }
.unit {
  position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto 14px; gap: 8px; align-items: center;
  text-align: left; padding: 4px 4px; border: none; border-bottom: 1px solid rgba(70, 130, 200, 0.35); border-radius: 0; background: transparent;
}
.unit .portrait { width: 24px; height: 24px; margin: -3px 0; }
.unit .title { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit .income-tag { display: block; font-size: 0.85rem; }
.unit .cost { padding: 0 6px; background: var(--sticky); transform: rotate(-3deg); font-size: 0.95rem; }
.unit .key { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; }
.unit.selected { background: var(--highlight); }
.unit .stock { margin-left: 4px; color: var(--muted); font-size: 0.8rem; }
.unit .reload { position: absolute; left: 22px; right: 4px; bottom: 1px; height: 3px; background: rgba(70, 90, 120, 0.15); border-radius: 2px; overflow: hidden; pointer-events: none; }
.unit .reload i { display: block; height: 100%; background: #4aa8ff; transition: width 0.1s linear; }
.unit.empty .reload i { background: var(--red); }
.unit .lock { display: none; }
.unit.locked { opacity: 1; }
.unit.locked > :not(.lock) { opacity: 0.35; }
.unit.locked .lock {
  display: block; position: absolute; right: 30px; top: 50%; transform: translateY(-50%) rotate(-3deg);
  padding: 0 6px; background: var(--paper-2, #f4efe2); border: 1.5px solid var(--ink); font-size: 0.9rem; white-space: nowrap;
}
.unit.locked .reload { display: none; }
.unit.fresh { animation: unit-fresh 1s ease-in-out 3; }
@keyframes unit-fresh { 50% { background: var(--sticky); } }
@media (prefers-reduced-motion: reduce) { .unit.fresh { animation: none; background: var(--sticky); } }
#send-cta { display: none; }

/* research notebook */
.research-summary { margin: 0; font-size: 0.95rem; color: var(--green); }
.research-list { display: flex; flex-direction: column; gap: 4px; }
.research-list button {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
  text-align: left; padding: 4px 6px; border: 1.5px dashed var(--ink-soft); background: rgba(255, 255, 255, 0.6);
}
.research-list .icon { grid-row: 1 / 3; font-size: 1.3rem; color: var(--red); text-align: center; }
.research-list .name { font-size: 1.05rem; }
.research-list .pips { font-size: 1rem; text-align: right; }
.research-list .effect { grid-column: 2 / 4; font-size: 0.85rem; color: var(--muted); }
.research-list .effect b { color: var(--ink); font-weight: 400; }
.research-list .effect .next { color: var(--gold); }
.research-list button.owned { border-style: solid; border-color: var(--ink); }
.research-list button.suggested { border-color: var(--red); border-width: 2px; }

#mobile-bar, #sheet-backdrop, .head-button, #mobile-menu { display: none; }
#overlay { position: fixed; inset: 0; background: rgba(40, 25, 10, 0.45); display: flex; align-items: center; justify-content: center; z-index: 40; }
#overlay .card { align-items: center; text-align: center; padding: 24px 28px; background: var(--sticky); transform: rotate(-1deg); }
#overlay ol { text-align: left; margin: 0; font-size: 1.1rem; }
#overlay.passive { background: transparent; pointer-events: none; }
.countdown { font-family: var(--marker); font-size: 5rem; color: var(--red); text-shadow: 2px 3px 0 rgba(0, 0, 0, 0.15); }

@media (min-width: 801px) {
  body:has(#game:not(.hidden)) .sound-panel { left: 16px; right: auto; }
  /* everything about my income sits next to the gold, not in the leaderboard */
  #income-line { display: none; }
  .stats { flex-wrap: wrap; row-gap: 6px; }
  .stat.income-box {
    flex-direction: column; align-items: stretch; gap: 3px; min-width: 190px; padding: 4px 10px 5px;
    background: rgba(255, 253, 246, 0.92); border: 1.5px solid var(--ink); border-radius: 6px; transform: rotate(0.8deg);
  }
  .income-box .line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.95rem; }
  .income-box .value { font-size: 1.35rem; color: var(--green); }
  .income-box b { font-family: var(--board); color: var(--gold); }
  .income-box .bar { height: 6px; }
  .income-box .kills { font-size: 0.85rem; color: var(--muted); }
}

@media (max-width: 1200px) {
  #game { grid-template-columns: 240px 86px minmax(0, 1fr) 300px; }
  #scoreboard { font-size: 0.9rem; }
  .top-actions kbd { display: none; }
}

/* phones */
@media (max-width: 800px) {
  :root { font-size: 16px; }
  #game { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; position: relative; }
  /* floating header over the lane: gold post-it, income and lives chips, menu on the right */
  #topbar { position: absolute; top: 8px; left: 8px; right: 140px; z-index: 6; display: flex; padding: 0; pointer-events: none; }
  #topbar > * { pointer-events: auto; }
  .stats { justify-content: flex-start; flex-wrap: wrap; gap: 4px 6px; padding: 0; }
  .stat { gap: 3px; }
  .stat.gold { order: 0; padding: 0 10px; }
  .stat.gold .value { font-size: 1.5rem; }
  .stat.mobile-only, .stat.wave { display: flex; align-items: center; padding: 1px 8px; border: 1.5px solid var(--ink); border-radius: 12px; background: rgba(255, 253, 246, 0.92); }
  .stat.mobile-only:not(.lives) { order: 1; }
  .stat.lives { order: 2; }
  .stat.wave { order: 3; }
  .stat .label { display: none; }
  .stat .value { font-size: 1.05rem; }
  .stat.gold .unit-label, .stat.lives .unit-label { display: inline; }
  .stat.gold .label { display: inline-block; order: 2; }
  .pills, .top-actions { display: none; }
  .head-button {
    display: block; position: fixed; top: 8px; z-index: 7; width: 40px; height: 40px; padding: 0;
    font-size: 1.4rem; line-height: 1; border-radius: 8px; background: rgba(255, 253, 246, 0.92);
  }
  #menu-toggle { right: 8px; }
  #players-toggle { right: 52px; color: #d4a017; text-shadow: 0 0 1px var(--ink); }
  #research-toggle { right: 96px; }
  .brand, #overview-toggle, kbd, .desktop-only { display: none; }
  #left, #right, #palette { display: none; }
  #board-wrap { grid-column: 1; grid-row: 1; margin: 0; padding-top: 52px; box-shadow: none; }

  /* send strip under the lane: tap a chip to send it now */
  #mobile-bar {
    display: flex; grid-row: 2; align-items: center; gap: 8px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--wood-dark); box-shadow: 0 -4px 12px rgba(40, 20, 0, 0.35);
  }
  #strip-mult {
    flex: none; width: 50px; height: 78px; padding: 0; border: 2px solid var(--red); border-radius: 8px;
    background: var(--paper-2); color: var(--red); font-family: var(--board); font-weight: 700; font-size: 1.3rem;
  }
  .send-strip { flex: 1; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding-top: 6px; }
  .send-strip .chip {
    position: relative; flex: none; width: 68px; height: 78px; padding: 4px 2px 2px; scroll-snap-align: start;
    display: flex; flex-direction: column; align-items: center; gap: 1px; border-radius: 8px; background: var(--paper-2);
  }
  .chip .ring { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
  .chip .portrait { width: 32px; height: 32px; border-radius: 50%; background: var(--paper); }
  .chip .name { max-width: 100%; font-size: 0.8rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chip .price { font-family: var(--board); font-weight: 700; font-size: 0.85rem; line-height: 1.1; color: #b45309; }
  .chip .count { position: absolute; top: -6px; right: -4px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--paper-2); font-size: 0.75rem; }
  .chip .count:empty { display: none; }
  .chip.locked { opacity: 0.55; background: #e9e2d2; }
  .chip.locked .price { color: var(--muted); }
  .chip.empty .ring { box-shadow: 0 0 0 2px var(--red); }
  .chip.fresh { animation: unit-fresh 1s ease-in-out 3; }
  .chip:disabled { cursor: default; }

  /* the ≡ menu: research, players and the former top-bar buttons */
  body.sheet-menu #mobile-menu {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 18px 12px calc(14px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: var(--paper-2);
    box-shadow: 0 -6px 16px rgba(40, 20, 0, 0.3);
  }
  #mobile-menu button { min-height: 52px; font-size: 1.1rem; }

  body.sheet-send #right, body.sheet-research #right, body.sheet-players #left {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; max-height: 78dvh; z-index: 30; margin: 0;
    border-radius: 18px 18px 0 0; padding: 30px 12px calc(14px + env(safe-area-inset-bottom));
  }
  body.sheet-players #left { background: var(--wood-dark); }
  body.sheet-send #right > section:not(#attack),
  body.sheet-research #right > section:not(#research) { display: none; }
  body.sheet-tower .tower-card { position: fixed; left: 8px; right: 8px; top: auto; bottom: 12px; width: auto; z-index: 30; transform: none; }
  body[class*="sheet-"] #sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(40, 25, 10, 0.45); z-index: 25; }
  .unit-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .unit { grid-template-columns: 24px minmax(0, 1fr) auto; min-height: 60px; border: 1.5px dashed var(--ink-soft); border-radius: 8px; }
  .unit .key { display: none; }
  .unit.locked .lock { right: 4px; font-size: 0.8rem; padding: 0 4px; }
  .unit .reload { left: 8px; right: 8px; bottom: 3px; }
  #send-cta { display: block; height: 56px; position: sticky; bottom: 0; z-index: 1; flex: none; }
  .research-list button { min-height: 52px; }
  #minimap { height: 130px; }
}

/* Gold is counted in paperclips. The clip is drawn on a 24x40 grid so that at 20px and 40px tall every
   wire lands on whole pixels: a 1px steel line at 1x, ink-outlined at 2x, shaded steel on the gold post-it. */
.clip {
  display: inline-block;
  width: 12px;
  height: 20px;
  margin-left: 2px;
  vertical-align: calc(0.36em - 10px);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 40'%3E%3ClinearGradient id='m' x2='1'%3E%3Cstop stop-color='%234d6185'/%3E%3Cstop offset='1' stop-color='%2322305a'/%3E%3C/linearGradient%3E%3Cpath d='M21 11v17a9 9 0 0 1-18 0V9a6 6 0 0 1 12 0v19a3 3 0 0 1-6 0V13' fill='none' stroke='url(%23m)' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (min-resolution: 2dppx) {
  .clip { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 40' fill='none' stroke-linecap='round'%3E%3Cpath id='p' d='M21 11v17a9 9 0 0 1-18 0V9a6 6 0 0 1 12 0v19a3 3 0 0 1-6 0V13'/%3E%3Cuse href='%23p' stroke='%2322305a' stroke-width='4'/%3E%3Cuse href='%23p' stroke='%23c9d2dd' stroke-width='2'/%3E%3C/svg%3E"); }
}
.stat.gold .label .clip {
  width: 24px; height: 40px; margin: 0; vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 40' fill='none' stroke-linecap='round'%3E%3ClinearGradient id='m' x2='1'%3E%3Cstop stop-color='%23eef2f7'/%3E%3Cstop offset='.5' stop-color='%23b9c3cf'/%3E%3Cstop offset='1' stop-color='%237b8798'/%3E%3C/linearGradient%3E%3Cpath id='p' d='M21 11v17a9 9 0 0 1-18 0V9a6 6 0 0 1 12 0v19a3 3 0 0 1-6 0V13'/%3E%3Cuse href='%23p' stroke='%2322305a' stroke-width='4'/%3E%3Cuse href='%23p' stroke='url(%23m)' stroke-width='2'/%3E%3Cuse href='%23p' stroke='%23fff' stroke-width='1' x='-.5' y='-.5'/%3E%3C/svg%3E");
}
@media (max-width: 800px) {
  .stat.gold .label .clip { width: 12px; height: 20px; }
}
/* stats post-it that follows the pointer; never catches clicks */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; width: max-content; max-width: 250px;
  padding: 8px 11px 9px; background: var(--sticky); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 3px;
  box-shadow: 3px 6px 12px rgba(40, 20, 0, 0.32); transform: rotate(-0.8deg); font-size: 0.95rem; line-height: 1.25;
}
.tooltip::before {
  content: ""; position: absolute; left: 34%; top: -9px; width: 62px; height: 17px;
  background: rgba(255, 255, 255, 0.55); transform: rotate(3deg);
}
.tip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-family: var(--marker); font-size: 1.05rem; }
.tip-head b { font-weight: 400; }
.tip-head span { font-family: var(--hand); font-size: 0.9rem; }
.tip-desc { margin: 2px 0 4px; font-size: 0.88rem; color: var(--ink-soft); }
.tip-row { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px dashed rgba(34, 48, 90, 0.25); }
.tip-row b { display: inline-flex; align-items: center; gap: 4px; }
.tip-chips { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 2px; }
.tip-chips .chip { font-size: 0.82rem; background: var(--paper-2); }
#palette button, #send-buttons button, #radial button { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
