:root {
  --wood: #7a4b2a;
  --wood-d: #4a2a12;
  --paper: #f6e7c4;
  --paper-d: #e3cc9c;
  --ink: #3a2414;
  --muted: #7a5f45;
  --green: #4f9c3a;
  --red: #b8392a;
  --px: "Press Start 2P", monospace;
  --th: "Chakra Petch", system-ui, sans-serif;
  --slot: min(48px, calc((100vw - 28px) / 12));
  --safe-b: env(safe-area-inset-bottom, 0px);
  --mm: 0px;                                  /* room the mini map takes under the clock */
  --clock-b: 128px;                           /* bottom edge of the clock panel, measured by the game */
  /* the free strip along the top between the clock (left) and the map and friends (right):
     toasts and the "whose farm" chip sit in the middle of it */
  --gap-x: calc((366px + 100vw - 170px) / 2);
  --gap-w: calc(100vw - 366px - 170px - 16px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1d2b1a;
  color: var(--ink);
  font: 400 16px/1.5 var(--th);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  cursor: pointer;
  position: fixed;
  left: 0;
  top: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.panel {
  background: var(--paper);
  border: 3px solid var(--wood-d);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px var(--paper-d), 0 3px 0 rgb(0 0 0 / .35);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }

/* ---- HUD ------------------------------------------------------------------ */
.hud-btn {
  position: relative;
  width: 44px;
  height: 44px;
  font-size: 20px;
  line-height: 1;
}
#corner-btns {
  position: fixed;
  left: 10px;
  bottom: calc(10px + var(--safe-b));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* on phones the joystick owns this corner; sound and full screen are in the menu */
.touch #corner-btns { display: none; }
#hud-left {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.count {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 18px;
  padding: 2px 4px;
  border-radius: 9px;
  background: #c0392b;
  color: #fff;
  font: 9px/1.2 var(--px);
}

/* ---- other farmers ------------------------------------------------------- */
#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgb(20 14 8 / .7);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
#hint {
  position: fixed;
  left: 0;
  top: 0;
  max-width: 260px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgb(20 14 8 / .82);
  color: #fff6dc;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
#profile {
  position: fixed;
  right: 10px;
  top: calc(max(10px, env(safe-area-inset-top)) + var(--mm));
  width: 230px;
  padding: 12px;
  font-size: 14px;
}
#profile p { margin: 6px 0; }
#profile .btn { width: 100%; margin-top: 6px; }
.pf-head { display: flex; gap: 10px; align-items: center; }
.has-friends #profile { right: 72px; }

/* mini map under the clock; tap it to walk there */
body.has-map { --mm: 112px; }
#minimap {
  position: fixed;
  right: 10px;
  top: max(10px, env(safe-area-inset-top));
  padding: 4px;
  line-height: 0;
  cursor: crosshair;
}
#minimap canvas { display: block; width: 132px; height: 96px; image-rendering: pixelated; }
#btn-map[aria-pressed="false"] { opacity: .6; }

/* friend shortcuts down the right edge */
#friends {
  position: fixed;
  right: 10px;
  top: calc(max(10px, env(safe-area-inset-top)) + var(--mm));
  max-height: calc(100dvh - 10px - var(--mm) - var(--slot) - 80px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 2px;
}
.friend {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  padding: 0;
  overflow: visible;
  display: grid;
  place-items: center;
  background: #fff6dc;
}
/* a photo fills the frame exactly, whatever its shape (the grid would let a tall one run over) */
.friend img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.friend .emoji { font-size: 26px; line-height: 1; }
.friend.current { border-color: #ff5a36; box-shadow: 0 0 0 3px #ff5a36; }
.friend .dot {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3fc23f;
  border: 2px solid #fff;
}
.friend .lv {
  position: absolute;
  left: -6px;
  top: -6px;
  padding: 1px 4px;
  border-radius: 8px;
  background: #d9534f;
  color: #fff;
  font: 700 10px/1.3 var(--th);
}
.pf-head small { display: block; color: var(--muted); }
.pf-av {
  flex: none;
  width: 48px;
  height: 48px;
  border: 2px solid var(--wood-d);
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff6dc;
  font-size: 26px;
}
.pf-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-av.small { width: 36px; height: 36px; font-size: 20px; }
.pf-online { color: var(--muted); font-weight: 600; }
.pf-online.on, .dot-on { color: #2f8a2f; }
.dot-on { font-size: 12px; margin-left: 4px; }
.pf-hearts { color: #d9534f; letter-spacing: 1px; font-size: 16px; }
.pf-stat { font-weight: 600; }

/* the status card, top left: my face on the left (tap it for my profile), then the date, time and
   money, the energy bar, the level, the next pickup, and what is on me as icons */
#clock {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 66px;
  width: 290px;
  padding: 6px 8px 7px 6px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
}
#me-badge {
  flex: none; width: 58px; height: 58px; padding: 3px; cursor: pointer;
  background: linear-gradient(#fff6dc, #e8d4a8); border: 3px solid var(--wood-d); border-radius: 12px;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / .12), 0 2px 0 rgb(0 0 0 / .25);
}
#me-badge:hover { filter: brightness(1.05); }
#me-badge canvas { display: block; width: 46px; height: 46px; image-rendering: pixelated; }
.hud-main { flex: 1; min-width: 0; }
#clock-date { font-weight: 700; font-size: 13px; white-space: nowrap; }
.clock-row { display: flex; align-items: baseline; gap: 8px; margin: 1px 0 5px; }
#clock-time { font: 11px/1 var(--px); }
#clock-money { font: 11px/1 var(--px); color: #7a4b00; margin-left: auto; }
.hud-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.hud-label { font-size: 11px; font-weight: 700; color: var(--wood); }
#clock-truck { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--wood); white-space: pre-line; }
#buffs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
#buffs[hidden] { display: none; }
.buff { width: 24px; height: 24px; padding: 0; font-size: 14px; line-height: 1; border: 2px solid var(--wood-d); border-radius: 6px; background: #fff6dc; cursor: help; }
.buff.bad { background: #f8d8d0; border-color: #a0392b; }
#energy {
  position: relative;
  flex: 1;
  height: 12px;
  background: #3a2414;
  border: 2px solid var(--wood-d);
  border-radius: 2px;
  overflow: hidden;
}
#energy-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: #5cc23f; transition: width .2s;
  background-image: repeating-linear-gradient(-45deg, rgb(255 255 255 / .18) 0 4px, transparent 4px 8px); }
#energy-text { position: absolute; inset: 0; font: 8px/12px var(--px); color: #fff; text-align: center; text-shadow: 1px 1px 0 #000; }

#update {
  position: fixed;
  left: 50%;
  bottom: calc(var(--slot) + 56px + var(--safe-b));
  translate: -50% 0;
  z-index: 6;
  padding: 8px 14px;
  font-weight: 700;
  background: #fff6dc;
}
#toast {
  z-index: 5;
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: var(--gap-x);
  translate: -50% -140%;
  max-width: max(200px, min(520px, var(--gap-w)));
  padding: 8px 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transition: translate .2s, opacity .2s;
  pointer-events: none;
}
#toast.show { translate: -50% 0; opacity: 1; }

/* ---- hotbar --------------------------------------------------------------- */
#bottom {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-b));
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#item-label {
  max-width: calc(100vw - 24px);
  padding: 3px 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hotbar {
  display: grid;
  grid-template-columns: repeat(12, var(--slot));
  padding: 3px;
  gap: 2px;
  background: var(--wood-d);
  border-radius: 4px;
  box-shadow: 0 3px 0 rgb(0 0 0 / .35);
}
.slot {
  position: relative;
  width: var(--slot);
  height: var(--slot);
  padding: 0;
  background: var(--paper);
  border: 2px solid var(--paper-d);
  border-radius: 3px;
}
.slot, .bag-slot, .stall-zone li { touch-action: none; }
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 1000;
  filter: drop-shadow(0 3px 0 rgb(0 0 0 / .35));
}
.dragging { opacity: .4; }
.drop-over { outline: 3px dashed #ff5a36; outline-offset: -3px; }
.stall-zone { margin-top: 6px; padding: 2px 6px 6px; border: 2px dashed var(--paper-d); border-radius: 6px; }
.stall-zone.drop-over { background: #fff6dc; }
.stall-zone li { cursor: grab; }
.bag-slot .key { position: absolute; left: 3px; top: 2px; font: 7px/1 var(--px); color: var(--muted); }
.slot img { width: 76%; height: 76%; image-rendering: pixelated; display: block; margin: auto; pointer-events: none; }
.slot.sel { border-color: #ff5a36; background: #fff6dc; box-shadow: inset 0 0 0 2px #ff5a36; }
.slot .qty {
  position: absolute;
  right: 2px;
  bottom: 2px;
  font: 8px/1 var(--px);
  color: #fff;
  text-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000;
}
.slot .key {
  position: absolute;
  left: 2px;
  top: 2px;
  font: 8px/1 var(--px);
  color: var(--ink);
  opacity: .7;
}
.slot.sel .key { color: #c0391b; opacity: 1; }
.slot .meter { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; background: #3a2414; }
.slot .meter i { display: block; height: 100%; background: #4fa3e8; }
.touch .slot .key { display: none; }

/* ---- touch controls ------------------------------------------------------- */
#touch { position: fixed; inset: 0; pointer-events: none; }
#stick, #btn-a, #btn-b { pointer-events: auto; position: absolute; touch-action: none; }
#stick {
  left: 18px;
  bottom: calc(var(--slot) + 70px + var(--safe-b));
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgb(0 0 0 / .22);
  border: 3px solid rgb(255 255 255 / .35);
}
#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgb(255 255 255 / .75);
  border: 3px solid var(--wood-d);
}
#btn-a, #btn-b {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid var(--wood-d);
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  box-shadow: 0 3px 0 rgb(0 0 0 / .35);
}
#btn-a { right: 18px; bottom: calc(var(--slot) + 90px + var(--safe-b)); background: var(--green); }
#btn-b { right: 96px; bottom: calc(var(--slot) + 62px + var(--safe-b)); background: #c9862a; width: 56px; height: 56px; font-size: 15px; }

/* ---- dialog --------------------------------------------------------------- */
#modal {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 18px 20px 16px;
  background: var(--paper);
  color: var(--ink);
  border: 4px solid var(--wood-d);
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--paper-d), 0 6px 0 rgb(0 0 0 / .4);
  user-select: text;
  -webkit-user-select: text;
}
#modal::backdrop { background: rgb(10 14 8 / .55); }
#modal-title { margin: 0 0 10px; font-size: 22px; line-height: 1.3; }
#modal-title.logo {
  font: 30px/1.2 var(--px);
  text-align: center;
  color: var(--green);
  text-shadow: 3px 3px 0 var(--wood-d);
  margin: 10px 0 14px;
}
#modal-body p { margin: 0 0 10px; }
#modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.tagline { text-align: center; }
.tagline b { font-size: 20px; color: var(--wood); }
.center { text-align: center; }

/* ---- sign-in --------------------------------------------------------------- */
.login label { display: block; margin: 8px 0; font-weight: 600; }
.field {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: #fffaf0;
  border: 2px solid var(--wood);
  border-radius: 4px;
}
.field:focus-visible { outline: 3px solid #ffd23f; outline-offset: 1px; }
.login-actions { display: flex; gap: 8px; justify-content: center; }
.login .warn:empty { display: none; }

/* ---- backpack / stall ------------------------------------------------------ */
.bag-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 58px)); justify-content: center; gap: 4px; }
.bag-slot {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  background: #fff6dc;
  border: 2px solid var(--paper-d);
  border-radius: 4px;
}
.bag-slot.hot { border-color: var(--wood); }
.bag-slot.picked { border-color: #ff5a36; box-shadow: inset 0 0 0 2px #ff5a36; }
.bag-slot.dim img { opacity: .35; }
.bag-slot img { width: 70%; height: 70%; image-rendering: pixelated; display: block; margin: auto; }
.bag-slot .qty {
  position: absolute;
  right: 3px;
  bottom: 3px;
  font: 8px/1 var(--px);
  color: #fff;
  text-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000;
}
.bag-put { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 4px; min-height: 34px; font-weight: 600; }
.bag-put span { flex: 1 1 100%; }
.bag-total { font-weight: 700; text-align: right; }
.order-line, .order-ok { margin: 4px 0; font-size: 14px; }
.order-ok { color: #2f8a2f; font-weight: 700; }
.order { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--paper-d); }
.order img { width: 36px; height: 36px; image-rendering: pixelated; flex: none; }
.order span, .order small { display: block; }
.order small { color: var(--muted); }
ul.farms li { grid-template-columns: 36px 1fr auto auto; }
/* a message row (loading, empty, error) is plain text, not the avatar grid */
ul.shop > li.muted, ul.shop > li.warn { display: block; }
ul.farms .info b { display: block; }
.muted { color: var(--muted); font-size: 14px; }
.warn { color: var(--red); font-weight: 600; }
.news { color: var(--green); font-weight: 700; }

.btn {
  padding: 8px 16px;
  background: var(--wood);
  color: #fff5dd;
  border: 2px solid var(--wood-d);
  border-radius: 4px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--wood-d);
}
.btn:active { translate: 0 2px; box-shadow: 0 1px 0 var(--wood-d); }
.btn.primary { background: var(--green); }
.btn.danger { background: var(--red); }
.btn.small { padding: 4px 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.help { margin: 0 0 12px; padding-left: 22px; }
.help li { margin-bottom: 4px; }

table.sold { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.sold td { padding: 3px 0; border-bottom: 1px dashed var(--paper-d); }
table.sold td:last-child { text-align: right; font-family: var(--px); font-size: 11px; }
table.sold tfoot td { font-weight: 700; border-bottom: 0; padding-top: 6px; }

.tabs {
  display: flex;
  flex-wrap: wrap;                 /* every tab stays visible; no hidden sideways scroll */
  gap: 4px;
  margin: 8px 0 6px;
  padding-bottom: 4px;
  border-bottom: 3px solid var(--wood);
}
.tab {
  flex: none;
  padding: 6px 11px;
  background: var(--paper-d);
  border: 2px solid var(--wood);
  border-radius: 6px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--wood); color: #fff5dd; }
ul.shop.gift li { grid-template-columns: 36px 1fr; }
#music {
  position: fixed;
  left: 66px;
  top: calc(var(--clock-b) + 8px);
  width: 220px;
  padding: 4px;
  z-index: 3;
}
#music iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 3px; }
.music-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; padding: 0 2px 4px; }
.music-head button { border: 0; background: none; font-size: 14px; padding: 0 4px; }
.creator-preview { display: block; width: 256px; max-width: 100%; margin: 0 auto 10px; image-rendering: pixelated; background: #86c064; border: 3px solid var(--wood-d); border-radius: 6px; }
.creator-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.creator-row > span { flex: 0 0 64px; font-weight: 700; }
.swatch { width: 30px; height: 30px; padding: 0; border: 2px solid var(--wood-d); border-radius: 6px; }
.swatch.text { width: auto; padding: 0 10px; background: var(--paper-d); font-weight: 700; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px #ff5a36; }
.swatch.text[aria-checked="true"] { background: var(--wood); color: #fff5dd; }
.shop-scroll { overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.shop-money b { font-family: var(--px); font-size: 12px; color: #7a4b00; }
ul.shop { list-style: none; margin: 0 0 6px; padding: 0; }
.shop-h { margin: 12px 0 2px; font-size: 16px; color: var(--wood); border-bottom: 2px solid var(--paper-d); }
ul.shop li {
  display: grid;
  grid-template-columns: 36px 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--paper-d);
}
ul.shop img { width: 36px; height: 36px; image-rendering: pixelated; }
ul.shop .info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
ul.shop small { color: var(--muted); }
ul.shop .price { font: 11px/1 var(--px); color: #7a4b00; }

@media (max-width: 560px) {
  #clock { left: 56px; width: auto; max-width: calc(100vw - 56px - 110px); min-width: 200px; }
  #me-badge { width: 46px; height: 46px; border-radius: 10px; }
  #me-badge canvas { width: 34px; height: 34px; }
  #profile { top: calc(var(--clock-b) + 8px); left: 58px; right: 8px; width: auto; padding: 8px; font-size: 13px; }
  #profile p { margin: 3px 0; }
  #profile .muted, #profile .pf-hearts, #profile .pf-farm { display: none; }
  #profile .pf-av { width: 36px; height: 36px; font-size: 20px; }
  #profile .btn { padding: 4px 10px; }
  .has-friends #profile { right: 58px; }
  #friends { right: 8px; top: calc(max(10px, env(safe-area-inset-top)) + var(--mm)); gap: 6px; max-height: calc(100dvh - 10px - var(--mm) - var(--slot) - 190px); }
  #minimap { right: 8px; top: max(10px, env(safe-area-inset-top)); }
  #minimap canvas { width: 88px; height: 64px; }
  body.has-map { --mm: 80px; }
  .friend { width: 40px; height: 40px; }
  .friend .emoji { font-size: 20px; }
  .hud-btn { width: 38px; height: 38px; font-size: 17px; }
  #music { left: 56px; width: 150px; }
  .tab { padding: 6px 9px; font-size: 14px; }
  #clock-date { font-size: 13px; }
  #toast { left: 50%; max-width: calc(100vw - 24px); top: calc(var(--clock-b) + 8px); z-index: 5; }
  ul.shop li { grid-template-columns: 32px 1fr auto auto; }
  ul.shop .price { grid-column: 2; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  #toast, #energy-fill { transition: none; }
}

/* ---- menu / settings --------------------------------------------------------- */
.menu-head { display: flex; gap: 14px; align-items: center; padding: 10px 12px; background: var(--paper-d); border-radius: 4px; }
.menu-head canvas { flex: none; image-rendering: pixelated; }
.menu-head div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-head b { font-size: 18px; overflow-wrap: anywhere; }
.menu-head small { font-size: 13px; }
.menu section { margin-top: 14px; }
.menu h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: .04em; color: var(--muted); border-bottom: 2px dashed var(--paper-d); padding-bottom: 4px; }
.menu-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 2px; font-weight: 600; cursor: pointer; }
.menu-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.menu-toggle i { flex: none; position: relative; width: 48px; height: 26px; border-radius: 13px; background: #c9b489; border: 2px solid var(--wood-d); transition: background .15s; }
.menu-toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff5dd; border: 2px solid var(--wood-d); transition: translate .15s; }
.menu-toggle input:checked + i { background: var(--green); }
.menu-toggle input:checked + i::after { translate: 22px 0; }
.menu-toggle input:focus-visible + i { outline: 3px solid var(--wood); outline-offset: 2px; }
.menu-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-buttons .btn:only-child { grid-column: 1 / -1; }
.menu-buttons .btn { padding: 8px 6px; white-space: nowrap; }
.menu-install { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 10px; background: var(--paper-d); border-radius: 4px; }
.menu-install b:first-child { display: block; }
.menu-install small { display: block; font-size: 13px; color: var(--muted); }
.menu-install > :first-child { flex: 1; }
.visit-head { margin: 4px 0 6px; font-size: 14px; color: var(--muted); }
.visit-head ~ .visit-head { margin-top: 14px; }
.friend.npc { background: #e9f4d6; }
.friend.done { opacity: .55; }
.friends-sep { flex: none; width: 36px; margin: 2px auto; border: 0; border-top: 3px dotted rgb(255 245 221 / .7); }

/* someone needs help / I passed out */
#alert, #downed {
  position: fixed;
  left: 50%;
  translate: -50% 0;
  z-index: 6;
  max-width: min(520px, calc(100vw - 24px));
  padding: 8px 12px;
  font-weight: 600;
}
#alert { top: calc(max(10px, env(safe-area-inset-top)) + 52px); display: flex; align-items: center; gap: 8px; }
#alert span { flex: 1; }
#alert[hidden] { display: none; }
#downed { bottom: calc(var(--slot) + 70px + var(--safe-b)); text-align: center; background: #3a2a4a; color: #fff6dc; }
#dismount { position: fixed; left: 50%; translate: -50% 0; bottom: calc(var(--slot) + 70px + var(--safe-b)); z-index: 6; padding: 6px 14px; font-weight: 700; }
#dismount[hidden] { display: none; }
#editbar {
  position: fixed;
  left: 50%;
  translate: -50% 0;
  top: calc(max(10px, env(safe-area-inset-top)) + 8px);
  z-index: 6;
  max-width: min(560px, calc(100vw - 140px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-weight: 600;
}
#editbar[hidden] { display: none; }
#level { font: 10px/1 var(--px); color: #7a4b00; }
.hud-chip { padding: 3px 7px; border-radius: 10px; background: #3a2414; color: #ffe08a; white-space: nowrap; }
#xp { flex: 1; height: 6px; background: #3a2414; border: 1px solid var(--wood-d); border-radius: 2px; overflow: hidden; }
#xp-fill { height: 100%; width: 0; background: #f2b92f; transition: width .2s; }

/* the stall screen: my bag on the left, the stall on the right */
#modal.wide { width: min(820px, calc(100vw - 24px)); }
.stall-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.stall-bag { min-width: 0; padding: 2px; border-radius: 6px; }
.stall-bag.drop-over { background: #fff6dc; }
.stall-side { min-width: 0; }
.stall-side .stall-zone { margin-top: 0; }
@media (max-width: 560px) { .stall-cols { grid-template-columns: 1fr; } }
.stall-cols .bag-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); justify-content: stretch; }
.bag-slot.empty { pointer-events: none; }
.stall-side .stall-zone { padding: 2px 6px 6px; }

/* the welcome screen */
.title { display: flex; flex-direction: column; gap: 12px; }
.title-tag { margin: -6px 0 2px !important; text-align: center; color: var(--muted); font-size: 15px; }
.title-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--paper-d);
  border: 2px solid var(--wood);
  border-radius: 6px;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / .08);
}
.title-card canvas { flex: none; image-rendering: pixelated; background: #cfe6b0; border: 2px solid var(--wood-d); border-radius: 4px; }
.title-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.title-info b { font-size: 19px; overflow-wrap: anywhere; }
.title-info span { font-size: 15px; }
.title-info small { color: var(--muted); font-size: 12px; }
.title-play { width: 100%; padding: 12px 16px; font-size: 20px; }
.title-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.title-links .btn { background: transparent; color: var(--wood); box-shadow: none; border-color: var(--paper-d); }
.title-links .btn:hover { background: #fff6dc; }
.login-card { align-items: flex-start; }
.login-card .title-info { flex: 1; }
.login-card label { margin: 4px 0 0; font-size: 14px; }
.login-card .warn { margin: 0; min-height: 0; }
.login-card .warn:empty { display: none; }
.title-info small b { font-size: inherit; }

/* chat */
#chat {
  position: fixed; z-index: 4;
  left: 64px; bottom: calc(var(--slot) + 70px + var(--safe-b));
  width: min(360px, calc(100vw - 80px)); height: min(320px, 50dvh);
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
}
#chat[hidden] { display: none; }
.chat-head { display: flex; gap: 6px; align-items: center; }
.chat-head .tab { position: relative; flex: 1; }
.chat-head .tab[aria-selected="true"] { background: var(--wood); color: #fff5dd; }
.chat-head .count { position: absolute; right: -4px; top: -6px; }
.chat-list { flex: 1; overflow-y: auto; margin: 0; padding: 4px 6px; list-style: none; background: #fff6dc; border: 2px solid var(--paper-d); border-radius: 4px; font-size: 14px; user-select: text; -webkit-user-select: text; overscroll-behavior: contain; }
.chat-list li { padding: 4px 0; border-bottom: 1px dashed var(--paper-d); overflow-wrap: anywhere; }
.chat-list li.mine b { color: var(--green); }
.chat-list small { color: var(--muted); font-size: 11px; }
.chat-form { display: flex; gap: 6px; }
.chat-form .field { margin: 0; padding: 6px 8px; }
/* a message over the head of whoever said it */
.tag .say { position: absolute; left: 50%; bottom: calc(100% + 4px); translate: -50% 0; max-width: 180px; width: max-content; padding: 4px 8px; border-radius: 8px; background: #fff6dc; color: var(--ink); border: 2px solid var(--wood-d); font-size: 12px; font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
.tag .say:empty { display: none; }
.tag.silent { background: none; }
.tag.silent > span { display: none; }
@media (max-width: 560px) {
  #chat { left: 50px; right: 8px; width: auto; top: calc(var(--clock-b) + 8px); bottom: auto; height: 42dvh; }
}

/* visiting: a small chip at the top saying whose farm this is; ⓘ opens the full card */
#profile.folded {
  top: max(10px, env(safe-area-inset-top)); left: var(--gap-x); right: auto; translate: -50% 0;
  width: auto; max-width: max(200px, var(--gap-w)); padding: 4px 6px;
}
#profile.folded > div { display: flex; align-items: center; gap: 6px; }
#profile.folded > div > :not(.pf-head):not(.pf-home):not(.pf-add) { display: none; }
#profile.folded .pf-head { min-width: 0; }
#profile.folded .pf-head small { display: none; }
#profile.folded .pf-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; display: block; }
#profile.folded .pf-av { width: 28px; height: 28px; font-size: 16px; }
#profile.folded .btn { width: auto; margin: 0; padding: 4px 8px; white-space: nowrap; }
#profile .pf-toggle { width: auto; margin: 0 0 0 auto; padding: 2px 8px; flex: none; }
.visiting #toast { top: calc(max(10px, env(safe-area-inset-top)) + 48px); }
@media (max-width: 560px) {
  #profile.folded { display: none; }            /* phones: the framed avatar on the right says where I am; tap it for the card */
  .visiting #toast { top: calc(var(--clock-b) + 8px + var(--mm)); }
}

/* the farm sign: drawing on it */
/* the sign editor, laid out like Paint */
.paint { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "top top" "box desk" "colors colors" "status status";
  background: #ece8df; border: 2px solid var(--wood-d); border-radius: 6px; overflow: hidden; font-size: 13px; color: #2a1c10; }
.paint button { font: inherit; color: inherit; cursor: pointer; }
.paint button:disabled { opacity: .35; cursor: default; }
.paint-top { grid-area: top; display: flex; gap: 4px; padding: 4px 6px; background: linear-gradient(#fbf9f4, #e6e1d6); border-bottom: 1px solid #c9c1b0; }
.paint-q { min-width: 32px; height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; background: none; font-size: 16px !important; }
.paint-q:not(:disabled):hover { background: #fff; border-color: #c9c1b0; }
.paint-box { grid-area: box; display: flex; flex-direction: column; gap: 8px; padding: 6px; background: #f4f1ea; border-right: 1px solid #c9c1b0; }
.paint-tools { display: grid; grid-template-columns: repeat(2, 34px); gap: 3px; }
.paint-tool { width: 34px; height: 34px; padding: 0; border: 1px solid #c9c1b0; border-radius: 4px; background: #fff; font-size: 17px !important; line-height: 1; }
.paint-tool:hover { border-color: #8a7a60; }
.paint-tool.on, .paint-size.on { background: #cfe3f7; border-color: #3a78c0; box-shadow: inset 0 0 0 1px #3a78c0; }
.paint-sizes { display: flex; flex-direction: column; gap: 2px; padding: 3px; border: 1px solid #c9c1b0; border-radius: 4px; background: #fff; }
.paint-size { height: 22px; padding: 0; border: 1px solid transparent; border-radius: 3px; background: none; display: grid; place-items: center; }
.paint-size i { display: block; border-radius: 50%; background: #1a1a1a; }
.paint-flow { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
.paint-flow input { width: 70px; accent-color: #3a78c0; }
.paint-desk { grid-area: desk; display: grid; place-items: center; padding: 14px; background: #9aa0aa; min-width: 0; }
.paint-desk canvas { display: block; width: 100%; max-width: 640px; aspect-ratio: 2; background: #e8c890; box-shadow: 2px 3px 0 rgba(0,0,0,.35); touch-action: none; cursor: crosshair; }
.paint-colors { grid-area: colors; display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: #f4f1ea; border-top: 1px solid #c9c1b0; }
.paint-well { flex: none; width: 40px; height: 40px; padding: 3px; border: 1px solid #8a7a60; background: #fff; }
.paint-well span { display: block; width: 100%; height: 100%; border: 1px solid #5a5a5a; }
.paint-palette { display: grid; grid-template-columns: repeat(14, 20px); grid-auto-rows: 20px; gap: 3px; }
.paint-palette button { width: 20px; height: 20px; padding: 0; border: 1px solid #6a6a6a; border-radius: 2px; }
.paint-palette button.on { outline: 2px solid #3a78c0; outline-offset: 1px; }
.paint-edit { position: relative; display: flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid #c9c1b0; border-radius: 4px; background: #fff; cursor: pointer; white-space: nowrap; }
.paint-edit input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.paint-status { grid-area: status; display: flex; gap: 16px; padding: 3px 8px; background: #e3ded2; border-top: 1px solid #c9c1b0; font-size: 12px; color: #5a4a36; }
.paint-status span:empty { display: none; }
@media (max-width: 620px) {
  .paint { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "box" "desk" "colors" "status"; }
  .paint-box { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: none; border-bottom: 1px solid #c9c1b0; }
  .paint-tools { display: flex; flex-wrap: wrap; }
  .paint-tool { width: 30px; height: 30px; font-size: 15px !important; }
  .paint-sizes { flex-direction: row; }
  .paint-size { width: 26px; }
  .paint-desk { padding: 8px; }
  .paint-colors { flex-wrap: wrap; }
  .paint-palette { grid-template-columns: repeat(9, 20px); }
}
.sign-view { display: block; width: min(100%, 480px); aspect-ratio: 2; margin: 0 auto; border: 6px solid #8a5a2b; outline: 2px solid #5b361c; border-radius: 3px; }
/* chat: drag by the top bar; see-through while not in use */
.chat-head { cursor: move; touch-action: none; }
#chat { transition: background-color .3s, box-shadow .3s, opacity .3s; }
#chat.idle { background: rgb(246 231 196 / .35); box-shadow: none; border-color: rgb(74 42 18 / .35); }
#chat.idle .chat-list { background: rgb(255 246 220 / .25); border-color: transparent; text-shadow: 0 1px 0 #fff6dc, 0 0 3px #fff6dc; }
#chat.idle .chat-form, #chat.idle .chat-head .tab:not([aria-selected="true"]) { opacity: .45; }
#chat.ping { box-shadow: 0 0 0 3px #f2cf3a; }
/* resting: touches go through to the game (joystick, tiles); the top bar still wakes or moves it */
#chat.idle { pointer-events: none; }
#chat.idle .chat-head { pointer-events: auto; }

/* the fish book */
.dex-sum { margin: 0 0 8px !important; }
.dex .tabs { margin-bottom: 8px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 4px; max-height: 50dvh; overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
.dex-slot { position: relative; aspect-ratio: 1; padding: 0; background: #fff6dc; border: 2px solid var(--paper-d); border-radius: 4px; }
.dex-slot img { width: 70%; height: 70%; image-rendering: pixelated; display: block; margin: auto; }
.dex-slot span { position: absolute; left: 3px; top: 1px; font: 7px/1 var(--px); color: var(--muted); }
.dex-slot.unknown img { filter: brightness(0) opacity(.28); }
.dex-slot.now { border-color: var(--green); }
.dex-info { min-height: 44px; margin: 8px 0 0 !important; }
.dex-info small { color: var(--muted); }
/* the book shows three rows at a time (about 33 fish), the rest scrolls */
.dex-grid { grid-template-columns: repeat(auto-fill, 52px); grid-auto-rows: 52px; justify-content: center; max-height: calc(3 * 52px + 2 * 4px + 4px); }
.dex-slot { width: 52px; height: 52px; }
.dex .tabs .tab { padding: 4px 8px; font-size: 13px; }

/* the bag: bigger slots, and the bag part scrolls once it has grown */
.bag .bag-grid { grid-template-columns: repeat(6, minmax(0, 68px)); gap: 6px; }
.bag-pack { max-height: calc(4.5 * 74px); overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
.bag-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.bag-tabs .tab { padding: 4px 8px; font-size: 13px; }
.bag-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 10px; }
.bag-foot .muted { flex: 1 1 200px; }
.stall-cols .bag-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dex-slot.empty { background: #f4e8cc; border-style: dashed; }

/* ---- the phone: just the handset, no paper dialog around it ---------------------------------- */
#modal[data-kind="phone"] { width: auto; padding: 0; background: none; border: 0; box-shadow: none; overflow: visible; }
#modal[data-kind="phone"] #modal-title, #modal[data-kind="phone"] #modal-actions { display: none; }
.phone { margin: 0 auto; display: flex; flex-direction: column; align-items: stretch; font-family: var(--th); }
.phone-status { display: flex; justify-content: space-between; font-size: 11px; padding: 2px 8px; }
.phone-app { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.phone-title { font-weight: 700; padding: 6px 10px 4px; }
.phone-list { list-style: none; margin: 0; padding: 0 6px 6px; }
.phone-list li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid rgb(0 0 0 / .12); }
.phone-list li > div { flex: 1; min-width: 0; }
.phone-list b { display: block; font-size: 14px; line-height: 1.2; }
.phone-list small { display: block; font-size: 11px; opacity: .75; line-height: 1.3; }
.phone-list button { flex: none; min-width: 34px; height: 30px; border-radius: 15px; border: 0; font-size: 15px; cursor: pointer; }
.phone-list button:disabled { opacity: .4; cursor: not-allowed; }
.phone-ico { font-size: 20px; width: 26px; text-align: center; }

/* the old keypad phone: grey plastic, green LCD, number keys */
.phone.basic { width: 240px; padding: 18px 16px 16px; background: linear-gradient(#3a3f47, #23272d); border-radius: 30px 30px 40px 40px; box-shadow: inset 0 2px 0 #5a606a, 0 8px 0 rgb(0 0 0 / .4); }
.phone.basic .phone-ear { width: 50px; height: 5px; margin: 0 auto 10px; background: #15181c; border-radius: 3px; }
.phone.basic .phone-screen { height: 260px; display: flex; flex-direction: column; background: #b8cfa0; color: #1f2e14; border: 4px solid #15181c; border-radius: 6px; box-shadow: inset 0 0 12px rgb(0 0 0 / .25); }
.phone.basic .phone-list li { border-color: rgb(31 46 20 / .25); }
.phone.basic .phone-list button { background: #1f2e14; color: #b8cfa0; }
.phone.basic .phone-foot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.phone.basic .phone-foot button { height: 30px; border: 0; border-radius: 12px; background: #4a5059; color: #e8ecf0; font: 700 14px/1 var(--px); box-shadow: 0 2px 0 #15181c; cursor: pointer; }
.phone.basic .phone-foot .green { background: #3fa84a; grid-column: 1; }
.phone.basic .phone-foot .red { background: #c0392b; grid-column: 3; }
.phone.basic .phone-foot .key { cursor: default; }

/* the smartphone: black glass, app icons, a home bar */
.phone.smart { width: 280px; padding: 12px 10px 10px; background: #111418; border-radius: 34px; box-shadow: inset 0 0 0 2px #3a3f47, 0 8px 0 rgb(0 0 0 / .4); }
.phone.smart .phone-ear { width: 80px; height: 16px; margin: 0 auto 6px; background: #000; border-radius: 10px; }
.phone.smart .phone-screen { height: 440px; display: flex; flex-direction: column; background: linear-gradient(160deg, #cfe8ff, #f4e7c6 60%, #bde0b0); color: #1a2030; border-radius: 22px; overflow: hidden; }
.phone.smart .phone-list li { background: rgb(255 255 255 / .55); border-radius: 12px; margin-top: 6px; border: 0; }
.phone.smart .phone-list button { background: #3fa84a; color: #fff; }
.phone-apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 8px; padding: 22px 12px; }
.phone-apps button { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; cursor: pointer; }
.phone-apps span { width: 58px; height: 58px; display: grid; place-items: center; font-size: 30px; background: #fff; border-radius: 16px; box-shadow: 0 3px 8px rgb(0 0 0 / .18); }
.phone-apps small { font-size: 12px; font-weight: 600; color: #1a2030; }
.phone.smart .phone-foot { display: flex; justify-content: space-around; align-items: center; padding-top: 8px; }
.phone.smart .phone-foot button { width: 44px; height: 28px; background: none; border: 0; color: #cfd6e0; font-size: 16px; cursor: pointer; }
.phone.smart .phone-foot .phone-homebtn { font-size: 22px; }
.jome-bar { margin: 8px; padding: 6px 10px; background: #fff; border-radius: 16px; font-size: 12px; color: #3a4a5a; box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.jome-page { text-align: center; padding: 30px 12px; }
.jome-logo { font: 700 38px/1 var(--th); margin-bottom: 12px; }
.phone-soon { margin-top: 20px; padding: 10px; background: rgb(255 255 255 / .6); border-radius: 12px; font-weight: 700; }

/* the bag, like the fish book; it floats above the game so the toolbar below stays reachable */
#modal[data-kind="bag"] { width: min(640px, calc(100vw - 24px)); }
dialog#modal[open]:not(:modal) {
  position: fixed; left: 50%; top: max(10px, env(safe-area-inset-top)); translate: -50% 0; margin: 0; z-index: 8;
  max-height: calc(100dvh - var(--slot) - 40px - var(--safe-b));
}
.bag .bag-pack { grid-template-columns: repeat(auto-fill, 52px); grid-auto-rows: 52px; justify-content: center; gap: 4px; max-height: calc(5 * 52px + 4 * 4px + 4px); }
.bag .bag-pack .bag-slot { width: 52px; height: 52px; }
.bag-slot.empty { background: #f4e8cc; border-style: dashed; }
.bag-info { min-height: 40px; margin: 8px 0 0 !important; font-size: 14px; }

/* windows the player can drag by the title (the bag, the stall) or the top of the phone */
#modal.movable:modal { translate: var(--mx, 0px) var(--my, 0px); }
dialog#modal[open].movable:not(:modal) { translate: calc(-50% + var(--mx, 0px)) var(--my, 0px); }
#modal.movable #modal-title, #modal.movable [data-grip] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
#modal.movable #modal-title::after { content: ' ⠿'; font-size: .7em; opacity: .35; }
.stall-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stall-head .shop-h { margin: 0; }

/* my profile (tap my face in the status card) */
.my-profile .pf-head { align-items: flex-start; }
.my-face { width: 48px; height: 72px; image-rendering: pixelated; flex: none; background: #f4e8cc; border: 3px solid var(--wood-d); border-radius: 10px; padding: 2px; }
.my-farm { margin: 4px 0 0 !important; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.my-farm .btn { padding: 2px 6px; }
.my-buffs { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.my-buffs li { padding: 4px 8px; border-radius: 6px; background: #fff6dc; border: 1px solid var(--paper-d); font-size: 14px; }
.my-buffs li.bad { background: #f8d8d0; border-color: #d9a097; }
.my-visitors { max-height: 260px; overflow: auto; }

/* ---- my profile: portrait, name and farm, level and energy, money, visitors and stats on the side,
   what is on me, and the three best fish in tanks ------------------------------------------------ */
#modal[data-kind="profile"] { width: min(900px, calc(100vw - 24px)); }
#modal[data-kind="profile"] #modal-title {
  width: max-content; margin: -4px auto 12px; padding: 6px 28px; font: 22px/1.2 var(--px); letter-spacing: 2px;
  color: #fff6dc; background: linear-gradient(#8a5a2b, #6b4220); border: 3px solid var(--wood-d); border-radius: 8px;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .2), 0 3px 0 rgb(0 0 0 / .3); text-shadow: 2px 2px 0 #3a2414;
}
.prof { display: grid; grid-template-columns: 150px minmax(0, 1fr) 250px; gap: 10px; align-items: start; }
.prof h4 { margin: 0; padding: 4px 8px; font: 12px/1.2 var(--px); color: #fff6dc; background: #7a4b22; border-radius: 5px 5px 0 0; text-align: center; letter-spacing: 1px; }
.prof h4 small { display: block; font: 600 11px/1.3 var(--th); letter-spacing: 0; opacity: .9; }
.prof-box { border: 2px solid var(--wood-d); border-radius: 7px; background: #fff6dc; overflow: hidden; }
.prof-box > p { margin: 0; padding: 8px 10px; font-weight: 700; font-size: 16px; }
.prof-portrait { grid-row: span 1; padding: 6px; border: 3px solid var(--wood-d); border-radius: 10px; background: radial-gradient(#fff4c8, #e8c890); box-shadow: inset 0 0 0 3px #f4d9b0; }
.prof-portrait canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.prof-main { display: grid; gap: 8px; }
.prof-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 2px solid var(--wood-d); border-radius: 7px; background: #fff6dc; }
.prof-names { justify-content: space-between; flex-wrap: wrap; font-size: 14px; }
.prof-names .btn { padding: 1px 5px; }
.prof-tag { flex: none; width: 72px; font: 12px/1.1 var(--px); color: #7a4b22; text-align: center; }
.prof-tag small { display: block; font: 600 11px/1.3 var(--th); letter-spacing: 0; }
.prof .shield { flex: none; display: grid; place-items: center; width: 28px; height: 30px; font: 11px/1 var(--px); color: #fff6dc;
  background: #5a6470; border: 2px solid #2a3038; clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%); }
.prof .bolt { flex: none; font-size: 18px; }
.prof .meter { flex: 1; height: 14px; border: 2px solid #3a2414; border-radius: 4px; background: #3a2414; overflow: hidden; }
.prof .meter i { display: block; height: 100%; background-image: repeating-linear-gradient(-45deg, rgb(255 255 255 / .2) 0 5px, transparent 5px 10px); }
.prof .meter.lv i { background-color: #e8762a; }
.prof .meter.en i { background-color: #3f9ae0; }
.prof-num { flex: none; min-width: 58px; text-align: right; font-weight: 700; color: var(--wood); }
.prof-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prof-side { grid-column: 3; grid-row: 1 / span 2; display: grid; gap: 8px; }
.prof-visitors { list-style: none; margin: 0; padding: 4px; max-height: 190px; overflow: auto; }
.prof-visitor { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 5px; color: inherit; font: inherit; }
.prof-visitor:hover { background: #f4e2b8; }
.prof-visitor small { display: block; color: var(--muted); font-size: 12px; }
.prof dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin: 0; padding: 8px 10px; font-size: 14px; }
.prof dt { font-weight: 600; }
.prof dd { margin: 0; font-weight: 700; text-align: right; }
.prof-buffs { grid-column: 1 / span 2; border: 2px solid var(--wood-d); border-radius: 7px; background: #fff6dc; overflow: hidden; }
.prof-buffs h4 { width: max-content; border-radius: 0 0 6px 0; }
.prof-buffs > div { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; }
.prof-buff { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; max-width: 260px; }
.prof-buff i { font-style: normal; display: grid; place-items: center; width: 32px; height: 32px; flex: none; font-size: 18px; border: 2px solid var(--wood-d); border-radius: 7px; background: #d8ecc0; }
.prof-buff.bad i { background: #f8d8d0; }
.prof-catches { grid-column: 1 / -1; border: 2px solid var(--wood-d); border-radius: 8px; background: #6b4220; overflow: hidden; }
.prof-catches h4 { background: none; font-size: 14px; }
.tanks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 10px 12px; }
.tank { border: 3px solid #3a2414; border-radius: 6px; background: #4a2e16; overflow: hidden; box-shadow: 0 4px 0 #2a1a0c; }
.tank-name { padding: 4px 6px; text-align: center; font-weight: 700; color: #fff6dc; background: #3a2414; font-size: 14px; }
.tank-water { display: flex; align-items: center; gap: 8px; min-height: 86px; padding: 8px; background: linear-gradient(#9ad0e8, #4f86c0); color: #0e2438; }
.tank-water img { width: 64px; height: 64px; image-rendering: pixelated; flex: none; filter: drop-shadow(0 2px 0 rgb(0 0 0 / .25)); }
.tank-water p { margin: 0; font-size: 12px; line-height: 1.45; background: rgb(255 255 255 / .55); padding: 4px 6px; border-radius: 5px; }
.tank.empty .tank-water { justify-content: center; opacity: .75; }
.tank .legend { color: #b8860b; } .tank .rare { color: #1f5fa0; } .tank .uncommon { color: #2f7d3a; } .tank .common { color: #555; }
@media (max-width: 760px) {
  .prof { grid-template-columns: 100px minmax(0, 1fr); }
  .prof-side { grid-column: 1 / -1; grid-row: auto; grid-template-columns: 1fr 1fr; }
  .prof-buffs { grid-column: 1 / -1; }
  .tank-water { flex-direction: column; text-align: center; }
}
@media (max-width: 480px) {
  .prof { grid-template-columns: 1fr; }
  .prof-portrait { width: 110px; justify-self: center; }
  .prof-side { grid-template-columns: 1fr; }
  .prof-pair { grid-template-columns: 1fr; }
  .tanks { grid-template-columns: 1fr; }
  .tank-water { flex-direction: row; text-align: left; }
}

/* the race scene: full screen over the game, the steering pad at the bottom */
#race { position: fixed; inset: 0; z-index: 30; background: #2a3a24; touch-action: none; user-select: none; -webkit-user-select: none; }
#race canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.race-pad { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); display: flex; justify-content: space-between; gap: 10px; padding: 0 14px; pointer-events: none; }
.race-pad button { pointer-events: auto; min-width: 76px; height: 64px; font: 700 22px/1 var(--th); color: #fff6dc; background: rgb(58 36 20 / .75); border: 3px solid #fff6dc; border-radius: 14px; }
.race-pad button[data-k="jump"] { font-size: 16px; flex: 0 1 130px; }
.race-pad button:active { background: rgb(92 220 90 / .8); }
.friend .lv.player { background: #3a2414; color: #ffe08a; border: 1px solid #ffe08a; }   /* a friend's farmer level */
.prof-actions { display: grid; gap: 6px; padding: 8px; }
.prof-actions .btn { width: 100%; }
.prof-row .pf-hearts { flex: 1; margin: 0; }
.phone-list li.phone-btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 0; }
.phone-list li.phone-btnrow button { min-width: 0; padding: 0 6px; font-size: 12px; font-weight: 700; background: #3fa84a; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-list li.phone-btnrow button:last-child { grid-column: 1 / -1; }
/* อั๋นยานยนต์: dressing the bike */
ul.shop li.moto-hero { grid-template-columns: 120px 1fr; }
ul.shop li.moto-hero canvas { width: 120px; height: 70px; image-rendering: pixelated; background: radial-gradient(#fff6dc, #e8d4a8); border: 2px solid var(--wood-d); border-radius: 8px; }
ul.shop li.moto-part { display: block; padding: 8px 4px 2px; border-bottom: 0; color: var(--wood); }
.moto-sw { width: 28px; height: 28px; border: 2px solid var(--wood-d); border-radius: 6px; flex: none; }

/* ---- the kitchen: pick a dish, see what it takes, cook it ------------------------------------- */
.cook { background: var(--paper); border: 3px solid var(--wood-d); border-radius: 6px; padding: 12px; color: var(--ink); }
.cook-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; align-items: start; }
.cook-frame { padding: 6px; background: linear-gradient(#8a5a2b, #6b4220); border: 3px solid var(--wood-d); border-radius: 6px; box-shadow: inset 0 0 0 2px #a8733a, 0 2px 0 rgba(0,0,0,.25); }
.cook-scene { display: block; width: 100%; aspect-ratio: 5 / 3; image-rendering: pixelated; border-radius: 2px; }
.cook.cooking .cook-scene { filter: brightness(1.2) saturate(1.1); }
.cook-card { display: flex; flex-direction: column; gap: 8px; }
.cook-name { display: flex; align-items: center; gap: 8px; }
.cook-name img { width: 34px; height: 34px; image-rendering: pixelated; }
.cook-name b { font-size: 17px; }
.cook-gives { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; }
.ctag { padding: 2px 8px; background: var(--paper-d); border-radius: 10px; }
.ctag.cbuff { background: #dcf0cc; }
.cook-needs { display: flex; flex-direction: column; gap: 4px; }
.cook-need { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: #fff6dc; border: 2px solid var(--paper-d); border-radius: 5px; font-size: 13px; }
.cook-need.ok { border-color: var(--green); }
.cook-need.short { border-color: var(--red); background: #fdeeea; }
.cook-need img { width: 24px; height: 24px; image-rendering: pixelated; }
.cook-need .nn { flex: 1; min-width: 0; }
.cook-need .nq { font: 9px/1 var(--px); }
.cook-need.short .nq { color: var(--red); }
.cook-pick { max-width: 45%; font: inherit; font-size: 12px; padding: 2px 4px; border: 2px solid var(--paper-d); border-radius: 4px; background: var(--paper); color: var(--ink); }
.cook-go { align-self: flex-start; }
.cook-miss { margin: 0; font-size: 12px; color: var(--muted); }
.bag-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0 2px; }
.cook-label { margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.cook-menu { margin-top: 6px; max-height: 260px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 5px; padding: 6px; background: var(--paper-d); border: 2px solid var(--wood-d); border-radius: 5px; }
.cook-item { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border: 2px solid transparent; border-radius: 5px; background: #fff6dc; text-align: left; cursor: pointer; font: inherit; color: var(--ink); opacity: .6; }
.cook-item.can { opacity: 1; }
.cook-item.on { border-color: var(--wood); box-shadow: inset 0 0 0 2px #fff; }
.cook-item.can.on { border-color: var(--green); }
.cook-item:hover { border-color: var(--wood); }
.cook-item img { width: 30px; height: 30px; image-rendering: pixelated; }
.cook-item .ci { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cook-item .ci small { font-size: 11px; color: var(--muted); }
.cook-item .cv { font-size: 12px; white-space: nowrap; color: var(--muted); }
@media (max-width: 680px) {
  .cook { padding: 8px; }
  .cook-top { grid-template-columns: minmax(0, 1fr); }
  .cook-menu { max-height: 220px; grid-template-columns: minmax(0, 1fr); }
}
