:root {
  --ink: #2f281f;
  --ink-soft: #665b49;
  --cream: #fff5d8;
  --paper: #f5dfad;
  --paper-deep: #e5bd72;
  --green-900: #263f2d;
  --green-800: #315b3b;
  --green-700: #416f40;
  --green-500: #6d9945;
  --leaf: #94bd51;
  --soil: #a35f37;
  --ochre: #d49a53;
  --orange: #df6a3d;
  --water: #3e8e97;
  --water-light: #86c9b8;
  --white: #fffdf4;
  --shadow: rgba(37, 29, 17, .28);
  --panel-border: #744a2e;
  --danger: #a73d35;
  --focus: #ffe06b;
  font-family: "Pretendard", "SUIT", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--ink);
  background: #17281f;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; overflow-x: hidden; }

body {
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 0%, rgba(112, 153, 83, .25), transparent 42rem),
    #17281f;
}

button, input { font: inherit; }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.is-hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

kbd {
  display: inline-grid;
  min-width: 1.75em;
  min-height: 1.75em;
  place-items: center;
  padding: 0 .35em;
  border: 1px solid rgba(45, 35, 24, .5);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #fff6dc;
  color: #3c3023;
  font-size: .76em;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -1px rgba(91, 59, 31, .18);
}

/* Title */
.title-screen {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background: #315b3b url("assets/farm-title.png") center / cover no-repeat;
}

.title-screen::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(25, 32, 19, .58), rgba(25, 32, 19, .06) 55%, rgba(25, 32, 19, .22)),
    linear-gradient(0deg, rgba(18, 33, 23, .68), transparent 46%);
}

.title-vignette {
  position: absolute;
  z-index: -1;
  inset: 0;
  box-shadow: inset 0 0 11rem rgba(20, 20, 12, .58);
  pointer-events: none;
}

.title-card {
  width: min(90vw, 520px);
  margin: 2rem auto;
  padding: clamp(1.5rem, 4vw, 2.4rem);
  border: 4px solid #5b3d27;
  border-radius: 10px;
  background:
    linear-gradient(rgba(255, 248, 218, .95), rgba(242, 217, 160, .96)),
    repeating-linear-gradient(0deg, transparent 0 8px, rgba(91, 61, 39, .03) 8px 9px);
  box-shadow:
    0 0 0 4px rgba(255, 239, 192, .65),
    0 18px 0 -8px rgba(62, 42, 25, .45),
    0 30px 70px rgba(12, 23, 16, .58);
  text-align: center;
}

.title-kicker,
.modal-eyebrow {
  margin: 0 0 .45rem;
  color: var(--orange);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.title-card h1 {
  margin: 0;
  color: #315136;
  font-family: Georgia, "Batang", serif;
  font-size: clamp(2.7rem, 10vw, 5rem);
  font-weight: 950;
  line-height: .95;
  letter-spacing: -.08em;
  text-shadow: 0 3px #fff2c9, 0 6px rgba(87, 51, 24, .16);
}

.title-card h1 span { color: #b75334; }
.title-copy {
  margin: 1rem auto 1.5rem;
  color: var(--ink-soft);
  font-size: .95rem;
  line-height: 1.6;
}

.name-field {
  display: grid;
  gap: .45rem;
  text-align: left;
}

.name-field span {
  color: #65482f;
  font-size: .78rem;
  font-weight: 900;
}

.name-field input {
  width: 100%;
  min-height: 48px;
  padding: .75rem 1rem;
  border: 2px solid #9b7349;
  border-radius: 6px;
  background: #fffaf0;
  color: #2f392b;
  font-size: 1.05rem;
  font-weight: 800;
}

.title-actions,
.modal-actions {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: .75rem;
  margin-top: .85rem;
}

.title-import-button {
  grid-column: 1 / -1;
  min-height: 42px;
}

.primary-button,
.secondary-button,
.help-button {
  min-height: 48px;
  padding: .75rem 1rem;
  border: 2px solid #4f3825;
  border-radius: 6px;
  font-weight: 900;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}

.primary-button {
  background: linear-gradient(#64914b, #416d3e);
  color: white;
  box-shadow: inset 0 2px rgba(255,255,255,.22), 0 4px 0 #2e4a2c;
}

.secondary-button {
  background: linear-gradient(#fff7de, #e8c98f);
  color: #4a3625;
  box-shadow: inset 0 2px rgba(255,255,255,.55), 0 4px 0 #8a6241;
}

.primary-button:hover,
.secondary-button:hover,
.help-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary-button:active,
.secondary-button:active,
.help-button:active { transform: translateY(2px); box-shadow: none; }
.primary-button:disabled,
.secondary-button:disabled { cursor: not-allowed; opacity: .48; filter: grayscale(.45); box-shadow: none; }

.title-hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .55rem 1rem;
  margin-top: 1.5rem;
  color: #69543a;
  font-size: .75rem;
  font-weight: 800;
}

.title-hints span { display: inline-flex; align-items: center; gap: .35rem; }
.title-version {
  position: absolute;
  right: 1rem;
  bottom: calc(.5rem + env(safe-area-inset-bottom));
  margin: 0;
  color: rgba(255,255,255,.72);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .13em;
}

/* Game shell */
.game-screen {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px) 0 0/16px 16px,
    #1d3025;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  min-height: 64px;
  padding: .45rem clamp(.75rem, 2vw, 1.5rem);
  border-bottom: 3px solid #714729;
  background: linear-gradient(#fff3cc, #e7c77f);
  box-shadow: 0 4px 14px rgba(22, 28, 17, .42);
}

.farm-mark {
  display: flex;
  align-items: center;
  gap: .65rem;
  justify-self: start;
  padding: .25rem .45rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
.farm-mark:hover { background: rgba(255,255,255,.32); }
.farm-mark small,
.panel-heading small {
  display: block;
  color: #9b5b32;
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .09em;
}
.farm-mark strong { display: block; color: #304a32; font-size: .98rem; }
.farm-mark-leaf {
  position: relative;
  width: 34px;
  height: 34px;
  border: 2px solid #365738;
  border-radius: 50%;
  background: #f5e1a6;
}
.farm-mark-leaf::before,
.farm-mark-leaf::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 17px;
  border-radius: 10px 1px 10px 1px;
  background: #5f924d;
  transform: rotate(-35deg);
}
.farm-mark-leaf::before { left: 8px; top: 6px; }
.farm-mark-leaf::after { right: 6px; bottom: 4px; transform: rotate(145deg); }

.day-strip,
.resource-strip,
.resource-item {
  display: flex;
  align-items: center;
}
.day-strip {
  gap: .55rem;
  color: #503c28;
  font-size: .84rem;
  font-weight: 800;
  white-space: nowrap;
}
.season-chip {
  padding: .3rem .55rem;
  border: 1px solid #3f6a3e;
  border-radius: 999px;
  background: #5c8b45;
  color: white;
  font-size: .72rem;
}
.strip-divider { width: 1px; height: 20px; background: rgba(83, 57, 34, .3); }
.weather-mark { color: #d78327; font-size: 1.2rem; }
#timeLabel { min-width: 3.5rem; color: #314d36; text-align: right; }
.resource-strip { justify-self: end; gap: .55rem; }
.resource-item {
  gap: .35rem;
  min-height: 34px;
  padding: .35rem .65rem;
  border: 1px solid #9a7446;
  border-radius: 5px;
  background: rgba(255,250,226,.72);
  font-size: .84rem;
  font-weight: 900;
}
.coin-dot {
  width: 14px;
  height: 14px;
  border: 2px solid #9c6320;
  border-radius: 50%;
  background: #f4bd3d;
  box-shadow: inset 2px 2px #ffe37b;
}
.energy-bolt {
  width: 10px;
  height: 17px;
  background: #df6a3d;
  clip-path: polygon(54% 0, 100% 0, 68% 40%, 100% 40%, 34% 100%, 49% 55%, 14% 55%);
}
.icon-button {
  width: 40px;
  height: 40px;
  border: 2px solid #78543a;
  border-radius: 6px;
  background: #fff5d8;
  color: #4e3b2d;
  font-weight: 950;
}
.icon-button:hover { background: white; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: clamp(.75rem, 1.5vw, 1.25rem);
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: clamp(.65rem, 1.25vw, 1.25rem);
}
.play-column { min-width: 0; }
.canvas-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 4px solid #6d452b;
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  background: #30553c;
  box-shadow: 0 8px 0 #13251b, 0 13px 34px rgba(4, 14, 9, .42);
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: #4f8a45;
}
.canvas-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 3rem rgba(20, 30, 20, .18);
}
.save-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: .35rem .55rem;
  border-radius: 4px;
  background: rgba(31, 51, 38, .78);
  color: #fff9e8;
  font-size: .68rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(-6px);
  transition: .22s ease;
}
.save-indicator.is-visible { opacity: 1; transform: translateY(0); }
.day-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  background: rgba(30, 43, 31, .8);
  color: #fff7db;
  text-align: center;
  animation: day-fade 1.45s both;
}
.day-banner span { color: #f1bd58; font-size: .9rem; font-weight: 900; letter-spacing: .08em; }
.day-banner strong { margin-top: .35rem; font-family: Georgia, "Batang", serif; font-size: clamp(1.4rem, 4vw, 2.5rem); }
@keyframes day-fade { 0%,100% { opacity: 0; } 18%,78% { opacity: 1; } }

/* Toolbar */
.toolbar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-top: 1rem;
}
.toolbar {
  display: flex;
  gap: .45rem;
  padding: .5rem;
  border: 3px solid #70482f;
  border-radius: 8px;
  background: linear-gradient(#f2d79c, #c99457);
  box-shadow: 0 5px 0 #38271d;
}
.tool-slot {
  position: relative;
  display: grid;
  grid-template-columns: auto 30px minmax(50px, auto);
  align-items: center;
  gap: .35rem;
  min-height: 50px;
  padding: .35rem .55rem;
  border: 2px solid #8b6543;
  border-radius: 5px;
  background: #f8ebc7;
  color: #49382a;
  font-size: .73rem;
  font-weight: 900;
}
.tool-slot:hover { background: #fff9e8; }
.tool-slot.is-selected {
  border-color: #fff2a2;
  background: #416d3e;
  color: white;
  box-shadow: 0 0 0 2px #294b31, inset 0 0 0 1px rgba(255,255,255,.16);
  transform: translateY(-4px);
}
.tool-slot kbd { position: absolute; left: 3px; top: 3px; min-width: 1.35em; min-height: 1.35em; font-size: .58rem; }
.tool-slot b {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: .59rem;
  opacity: .82;
}
.tool-pixel { position: relative; width: 28px; height: 28px; }
.hoe-pixel::before { content: ""; position: absolute; left: 13px; top: 2px; width: 4px; height: 25px; background: #78502f; transform: rotate(30deg); box-shadow: 2px 0 #4f3523; }
.hoe-pixel::after { content: ""; position: absolute; left: 13px; top: 1px; width: 14px; height: 6px; background: #82908b; border: 2px solid #434d48; transform: rotate(12deg); }
.seed-pixel::before,
.seed-pixel::after { content: ""; position: absolute; box-sizing: border-box; }

/* Seed silhouettes stay intentionally distinct even at the compact toolbar size. */
.seed-potato-pixel::before {
  left: 5px;
  top: 10px;
  width: 23px;
  height: 17px;
  border: 2px solid #5a3825;
  border-radius: 58% 42% 52% 44%;
  background:
    radial-gradient(circle at 25% 34%, #65412b 0 1.4px, transparent 1.7px),
    radial-gradient(circle at 69% 28%, #65412b 0 1.3px, transparent 1.6px),
    radial-gradient(circle at 54% 72%, #65412b 0 1.2px, transparent 1.5px),
    linear-gradient(145deg, #d29a5e, #a96338 68%, #7d472e);
  box-shadow: inset 2px 2px rgba(255,224,158,.38), inset -2px -2px rgba(75,39,25,.18);
  transform: rotate(9deg);
}

.seed-potato-pixel::after {
  left: 14px;
  top: 1px;
  width: 13px;
  height: 13px;
  border-left: 3px solid #416337;
  background: linear-gradient(135deg, #a8cb65, #5d9144);
  clip-path: polygon(48% 100%, 0 58%, 12% 18%, 50% 45%, 82% 0, 100% 42%);
  filter: drop-shadow(1px 1px #314829);
  transform: rotate(8deg);
}

.seed-strawberry-pixel::before {
  left: 3px;
  top: 5px;
  width: 21px;
  height: 24px;
  border: 2px solid #704329;
  border-radius: 2px 2px 4px 4px;
  background:
    linear-gradient(155deg, rgba(255,255,255,.48), transparent 38%),
    linear-gradient(#f5dda1 0 34%, #e7bd70 35% 100%);
  box-shadow: inset 0 -4px rgba(113,66,37,.12), 2px 2px rgba(54,34,23,.16);
  transform: rotate(-5deg);
}

.seed-strawberry-pixel::after {
  z-index: 1;
  right: 1px;
  bottom: 2px;
  width: 18px;
  height: 20px;
  border: 2px solid #692d27;
  border-top: 5px solid #4f7d3d;
  border-radius: 50% 50% 58% 58%;
  background:
    radial-gradient(circle at 28% 35%, #ffe298 0 1px, transparent 1.4px),
    radial-gradient(circle at 66% 41%, #ffe298 0 1px, transparent 1.4px),
    radial-gradient(circle at 47% 68%, #ffe298 0 1px, transparent 1.4px),
    linear-gradient(145deg, #ef6654, #c93636 65%, #9e292c);
  clip-path: polygon(12% 14%, 37% 7%, 50% 15%, 65% 6%, 89% 17%, 91% 51%, 51% 100%, 9% 51%);
  filter: drop-shadow(1px 1px #4c2b22);
  transform: rotate(7deg);
}

.seed-corn-pixel::before {
  left: 9px;
  top: 2px;
  width: 16px;
  height: 28px;
  border: 2px solid #72501f;
  border-radius: 48% 48% 42% 42%;
  background:
    radial-gradient(circle, #fff0a0 0 1.5px, transparent 1.8px) 0 0 / 6px 6px,
    linear-gradient(90deg, #d99b27, #f3ca49 48%, #c98820);
  box-shadow: inset 2px 0 rgba(255,244,157,.45), inset -2px 0 rgba(116,72,22,.22);
  transform: rotate(8deg);
}

.seed-corn-pixel::after {
  left: 3px;
  bottom: 0;
  width: 27px;
  height: 24px;
  background: linear-gradient(135deg, #78a84a, #3f743b 70%);
  clip-path: polygon(0 74%, 39% 23%, 47% 100%, 55% 42%, 100% 8%, 77% 84%, 49% 100%, 22% 94%);
  filter: drop-shadow(1px 1px #31512e);
}
.seed-generic-pixel::before {
  left: 5px;
  top: 8px;
  width: 22px;
  height: 19px;
  border: 2px solid #593c29;
  border-radius: 64% 36% 58% 42%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--seed-color, #c89a58) 72%, white), var(--seed-color, #c89a58));
  box-shadow: inset 2px 2px rgba(255,255,255,.35), inset -2px -2px rgba(67,38,25,.2);
  transform: rotate(18deg);
}
.seed-generic-pixel::after {
  left: 14px;
  top: 1px;
  width: 14px;
  height: 15px;
  border-left: 3px solid #3d6338;
  background: linear-gradient(135deg, color-mix(in srgb, var(--seed-leaf, #61924c) 72%, white), var(--seed-leaf, #61924c));
  clip-path: polygon(45% 100%, 3% 58%, 18% 15%, 54% 48%, 82% 0, 100% 45%);
  filter: drop-shadow(1px 1px #30482b);
}
/* Transplants are a rooted young plant, never the seed/bag silhouette. */
.seedling-pixel::before {
  z-index: 1;
  left: 3px;
  top: 0;
  width: 25px;
  height: 20px;
  border-bottom: 3px solid #426238;
  background: linear-gradient(135deg, color-mix(in srgb, var(--seed-leaf, #61924c) 76%, white), var(--seed-leaf, #61924c));
  clip-path: polygon(48% 100%, 43% 54%, 4% 41%, 13% 10%, 42% 31%, 50% 0, 60% 33%, 91% 13%, 97% 48%, 61% 58%, 57% 100%);
  filter: drop-shadow(1px 1px #30482b);
}
.seedling-pixel::after {
  left: 8px;
  top: 17px;
  width: 17px;
  height: 13px;
  border-top: 4px solid #7b5533;
  background:
    linear-gradient(62deg, transparent 0 38%, #8c633d 40% 47%, transparent 49%) 0 0 / 8px 12px,
    linear-gradient(118deg, transparent 0 38%, #a77748 40% 47%, transparent 49%) 2px 0 / 8px 12px;
  clip-path: polygon(12% 0, 88% 0, 72% 100%, 52% 59%, 37% 100%);
  filter: drop-shadow(1px 1px rgba(64,39,23,.32));
}
.water-pixel::before { content: ""; position: absolute; left: 4px; bottom: 3px; width: 20px; height: 17px; border: 3px solid #355c65; border-radius: 3px 3px 7px 7px; background: #55a7ab; }
.water-pixel::after { content: ""; position: absolute; left: 7px; top: 2px; width: 14px; height: 12px; border: 2px solid #45656a; border-bottom: 0; border-radius: 10px 10px 0 0; }
.drain-pixel::before { content: ""; position: absolute; left: 4px; bottom: 2px; width: 21px; height: 18px; border: 3px solid #315560; border-radius: 4px 4px 8px 8px; background: linear-gradient(#86d0ca 0 35%, #3b95a7 36% 100%); box-shadow: inset 2px 1px rgba(255,255,255,.35); }
.drain-pixel::after { content: ""; position: absolute; left: 7px; top: 1px; width: 15px; height: 13px; border: 2px solid #45656a; border-bottom: 0; border-radius: 11px 11px 0 0; box-shadow: 8px 11px 0 -5px #b9edf0; }
.hand-pixel::before { content: ""; position: absolute; left: 8px; top: 4px; width: 14px; height: 19px; border: 2px solid #74452c; border-radius: 8px 8px 6px 6px; background: #e6a86b; box-shadow: -4px 6px 0 -1px #e6a86b; transform: rotate(-12deg); }
.sprayer-pixel::before { content: ""; position: absolute; left: 6px; bottom: 2px; width: 17px; height: 19px; border: 2px solid #31584d; border-radius: 5px 5px 7px 7px; background: linear-gradient(135deg, #a8d56e, #4f9b67); box-shadow: inset 2px 2px rgba(255,255,255,.32); }
.sprayer-pixel::after { content: ""; position: absolute; left: 14px; top: 1px; width: 15px; height: 10px; border-top: 3px solid #465b55; border-right: 3px solid #465b55; transform: skewY(-10deg); box-shadow: 3px 4px 0 -2px #77c8c0, 7px 7px 0 -2px #77c8c0; }
.fertilizer-pixel::before { content: ""; position: absolute; left: 5px; top: 4px; width: 22px; height: 25px; border: 2px solid #68452c; border-radius: 4px 4px 7px 7px; background: linear-gradient(#f1d792 0 30%, #b6773c 31% 100%); box-shadow: inset 2px 2px rgba(255,255,255,.28); transform: rotate(-3deg); }
.fertilizer-pixel::after { content: "N"; position: absolute; left: 10px; top: 11px; width: 13px; height: 12px; border-radius: 50%; background: #588953; color: #fff6cf; font: 900 9px/12px system-ui, sans-serif; text-align: center; }
.rod-pixel::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 1px;
  width: 3px;
  height: 29px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4b2d1f, #a86a3d 55%, #6e4028);
  box-shadow: 1px 0 rgba(255, 222, 163, .45);
  transform: rotate(31deg);
  transform-origin: 50% 86%;
}
.rod-pixel::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 5px;
  width: 10px;
  height: 21px;
  border-right: 1px solid #d8e2d5;
  border-bottom: 1px solid #d8e2d5;
  border-radius: 0 0 9px;
  box-shadow: 2px 2px 0 -1px #d84f3e;
}
.axe-pixel::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 3px;
  width: 4px;
  height: 25px;
  background: #7b4d2b;
  box-shadow: 2px 0 #4e321e;
  transform: rotate(-23deg);
}
.axe-pixel::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 17px;
  height: 10px;
  border: 2px solid #414b48;
  border-radius: 7px 2px 3px 7px;
  background: #8f9c94;
  transform: rotate(-7deg);
}
.scythe-pixel::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 4px;
  width: 4px;
  height: 27px;
  border-radius: 2px;
  background: linear-gradient(90deg, #4d311f, #956039 58%, #664127);
  box-shadow: 2px 0 #3c291d;
  transform: rotate(-27deg);
  transform-origin: 50% 85%;
}
.scythe-pixel::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 24px;
  height: 15px;
  border-top: 4px solid #47504d;
  border-right: 3px solid #899690;
  border-radius: 52% 80% 15% 0;
  filter: drop-shadow(1px 1px #2f3835);
  transform: rotate(13deg);
}
.pickaxe-pixel::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 5px;
  width: 4px;
  height: 23px;
  background: #79502f;
  box-shadow: 2px 0 #4e3421;
  transform: rotate(28deg);
}
.pickaxe-pixel::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 3px;
  width: 25px;
  height: 7px;
  border-top: 3px solid #47514e;
  border-radius: 50% 50% 0 0;
  background: #8c9993;
  clip-path: polygon(0 30%, 42% 0, 100% 42%, 88% 72%, 43% 34%, 10% 68%);
  transform: rotate(8deg);
}
.seed-cycle-hint { margin: 0; color: rgba(255,248,221,.76); font-size: .72rem; font-weight: 800; }

/* Right panel */
.side-panel { display: grid; align-content: start; gap: .75rem; }
.panel-card {
  border: 3px solid #6e492f;
  border-radius: 7px;
  background:
    linear-gradient(rgba(255,248,222,.97), rgba(240,214,164,.97)),
    repeating-linear-gradient(90deg, transparent 0 12px, rgba(95,65,34,.025) 12px 13px);
  box-shadow: 0 5px 0 #13251b, inset 0 1px rgba(255,255,255,.7);
}
.guide-card { padding: .9rem; }
.panel-heading { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: .55rem; }
.panel-heading h2,
.panel-title-row h2 { margin: .08rem 0 0; color: #3d4c32; font-size: .9rem; }
.panel-heading h2 { line-height: 1.18; }
.panel-icon { width: 32px; height: 32px; border: 2px solid #547044; border-radius: 50%; background: #eef0b3; }
.task-icon::before { content: ""; display: block; width: 11px; height: 17px; margin: 5px auto; border-right: 3px solid #527744; border-bottom: 3px solid #527744; transform: rotate(40deg); }
.progress-pill { padding: .23rem .4rem; border-radius: 999px; background: #d7b56e; color: #5b422b; font-size: .64rem; font-weight: 900; }
.guide-card > p { margin: .75rem 0 .55rem; color: #675840; font-size: .75rem; line-height: 1.55; }
.progress-track { height: 7px; overflow: hidden; border: 1px solid #8a6743; border-radius: 999px; background: #c9a66b; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #5f9447, #93bb52); transition: width .25s ease; }
.inspect-card,
.market-card,
.inventory-card { padding: .85rem; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.panel-title-row h2 { margin: 0; }
.panel-title-row > span,
.text-button { color: #98714c; font-size: .65rem; font-weight: 900; }
.soil-badge { padding: .22rem .42rem; border: 1px solid #947044; border-radius: 999px; background: #ecd59d; }
.inspect-empty { display: flex; align-items: center; gap: .65rem; min-height: 86px; color: #88785f; }
.inspect-empty p { margin: 0; font-size: .69rem; line-height: 1.55; }
.inspect-crosshair { position: relative; width: 36px; height: 36px; border: 2px dashed #aa8557; border-radius: 4px; flex: 0 0 auto; }
.inspect-crosshair::before,
.inspect-crosshair::after { content: ""; position: absolute; background: #aa8557; }
.inspect-crosshair::before { left: 16px; top: 7px; width: 2px; height: 20px; }
.inspect-crosshair::after { left: 7px; top: 16px; width: 20px; height: 2px; }
.inspect-details { display: grid; grid-template-columns: 44px 1fr; gap: .6rem; margin-top: .8rem; }
.crop-preview { display: grid; place-items: center; width: 44px; height: 44px; border: 2px solid #80583b; border-radius: 5px; background: #bb7947; }
.crop-preview::before { content: ""; width: 19px; height: 25px; border-radius: 50% 50% 35% 35%; background: #71a64d; box-shadow: 7px 3px #4a7a43, -6px 4px #8db44f; }
.inspect-copy { min-width: 0; }
.inspect-copy strong { display: block; color: #3c4932; font-size: .83rem; }
.inspect-copy span { display: block; margin-top: .2rem; color: #806c4f; font-size: .66rem; }
.inspect-details dl { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3,1fr); gap: .35rem; margin: 0; }
.inspect-details dl div { padding: .4rem; border: 1px solid #c49b61; border-radius: 4px; background: rgba(255,251,230,.6); text-align: center; }
.inspect-details dt { color: #887052; font-size: .57rem; font-weight: 800; }
.inspect-details dd { margin: .15rem 0 0; color: #394a33; font-size: .66rem; font-weight: 900; }
.market-card { position: relative; overflow: hidden; }
.market-card::after { content: ""; position: absolute; right: -18px; bottom: -22px; width: 74px; height: 74px; border: 8px double rgba(165,73,43,.14); border-radius: 50%; transform: rotate(-14deg); }
.market-headline { position: relative; z-index: 1; margin: .65rem 0; color: #4e432f; font-family: Georgia, "Batang", serif; font-size: .78rem; font-weight: 800; line-height: 1.5; }
.market-ticker { display: flex; gap: .35rem; flex-wrap: wrap; }
.ticker-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .3rem .42rem; border: 1px solid #b98f57; border-radius: 4px; background: rgba(255,255,255,.42); color: #5a4934; font-size: .61rem; font-weight: 900; }
.ticker-chip b.up { color: #b94c34; }
.ticker-chip b.down { color: #317481; }
.text-button { padding: .25rem; border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: #6b452c; }
.inventory-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin-top: .7rem; }
.inventory-item { min-width: 0; padding: .45rem .3rem; border: 1px solid #c09860; border-radius: 4px; background: rgba(255,252,235,.57); text-align: center; }
.inventory-item:is(button) { width: 100%; color: inherit; font: inherit; cursor: pointer; }
.inventory-item:is(button):hover,
.inventory-item:is(button):focus-visible { border-color: #527548; background: #fff8dc; outline: 2px solid rgba(82,117,72,.2); outline-offset: 1px; }
.inventory-swatch { display: block; width: 15px; height: 15px; margin: 0 auto .25rem; border: 2px solid rgba(65,48,31,.45); border-radius: 50%; }
.item-art-icon {
  position: relative;
  display: block;
  background-image: var(--item-art);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 2px 1px rgba(54, 35, 23, .2));
}
.seed-pixel.has-item-art::before,
.seed-pixel.has-item-art::after { content: none; display: none; }
.inventory-seed {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
  margin: -.25rem auto .05rem;
}
.inventory-produce {
  width: 40px;
  height: 40px;
  margin: -.25rem auto .05rem;
}
.inventory-item span { display: block; overflow: hidden; color: #705b40; font-size: .56rem; text-overflow: ellipsis; white-space: nowrap; }
.inventory-item strong { display: block; margin-top: .12rem; color: #344832; font-size: .68rem; }
.help-button { width: 100%; min-height: 44px; border-color: #6e4930; background: #30543b; color: #fff5d8; box-shadow: 0 4px 0 #13251b; }
.help-button kbd { margin-right: .35rem; }

/* Modal system */
.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(16, 27, 20, .72);
  backdrop-filter: blur(4px);
}
.modal {
  position: fixed;
  z-index: 90;
  top: 50%;
  left: 50%;
  width: min(calc(100vw - 2rem), 520px);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: clamp(1.1rem, 3vw, 1.65rem);
  border: 4px solid #65412c;
  border-radius: 9px;
  background: linear-gradient(#fff5d6, #eacb8d);
  box-shadow: 0 0 0 4px rgba(255,239,191,.3), 0 18px 55px rgba(8,17,11,.62);
  animation: modal-in .18s ease both;
}
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)) scale(.98); } }
.modal h2 { margin: 0; color: #354a33; font-family: Georgia, "Batang", serif; font-size: 1.55rem; }
.modal > p { color: #6b5b42; font-size: .78rem; line-height: 1.6; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.modal-close {
  width: 42px;
  height: 42px;
  border: 2px solid #805839;
  border-radius: 5px;
  background: #fff5d8;
  color: #6e4930;
  font-size: 1.45rem;
  font-weight: 900;
}
.dialog-details { margin-top: .8rem; padding: .8rem; border: 1px solid #b68955; border-radius: 5px; background: rgba(255,255,255,.45); color: #5f4f39; font-size: .76rem; line-height: 1.6; }
.stock-detail-grid { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(150px, 1fr); gap: .42rem .75rem; align-items: center; }
.stock-detail-grid span { color: #80694d; font-size: .68rem; }
.stock-detail-grid strong { color: #3f503b; font-size: .74rem; text-align: right; }
.stock-detail-grid .price-up { color: #a04435; }
.stock-detail-grid .price-down { color: #356f82; }
.sale-category-summary { margin-bottom: .55rem; color: #806448; font-size: .66rem; }
.sale-selector-grid { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(115px, .8fr) 92px 92px 92px; gap: .4rem; align-items: end; }
.sale-selector-grid label { display: grid; gap: .15rem; color: #745c40; font-size: .58rem; font-weight: 900; }
.sale-selector-grid input,
.sale-selector-grid select { width: 100%; min-height: 36px; border: 1px solid #957047; border-radius: 5px; background: #fff9df; color: #493f31; font-size: .64rem; font-weight: 800; }
.sale-selection-preview { display: grid; grid-template-columns: 1fr auto; gap: .12rem .6rem; margin-top: .6rem; padding: .55rem .65rem; border: 1px solid #829064; border-radius: 6px; background: rgba(245,249,218,.85); color: #5a6148; font-size: .62rem; line-height: 1.45; }
.sale-selection-preview strong,
.sale-selection-preview b { color: #38543b; text-align: right; }
.sale-selection-preview small { grid-column: 1 / -1; color: #8a6747; }
.shop-modal,
.build-modal { width: min(calc(100vw - 2rem), 1080px); }
.shop-intro { margin: .6rem 0 1rem !important; }
.shop-controls { display: flex; align-items: end; justify-content: space-between; gap: .65rem; margin: -.2rem 0 .75rem; }
.shop-controls > label:first-child { display: grid; flex: 1; gap: .18rem; color: #725c42; font-size: .58rem; font-weight: 900; }
.shop-controls input[type="search"] { width: 100%; min-height: 40px; padding: .45rem .65rem; border: 1px solid #987048; border-radius: 6px; background: #fff8de; color: #473b2c; font-size: .7rem; }
.shop-season-toggle { display: flex; align-items: center; gap: .38rem; min-height: 40px; padding: .4rem .65rem; border: 1px solid #987048; border-radius: 6px; background: rgba(255,248,222,.7); color: #5f513d; font-size: .62rem; font-weight: 850; }
.shop-season-toggle input { accent-color: #4f7747; }
.shop-type-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.25rem 0 .45rem; }
.shop-type-filters button {
  min-height: 32px;
  padding: .3rem .62rem;
  border: 1px solid #8f6c47;
  border-radius: 999px;
  background: rgba(255,248,220,.74);
  color: #66513a;
  font-size: .59rem;
  font-weight: 900;
}
.shop-type-filters button.is-active { border-color: #3f633f; background: #52784a; color: #fff7d9; }
.shop-recent-summary { min-height: 1.1rem; margin: 0 0 .55rem !important; color: #806649 !important; font-size: .57rem !important; }
.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.shop-item { position: relative; display: grid; gap: .45rem; padding: .85rem; border: 2px solid #9b7148; border-radius: 6px; background: rgba(255,252,232,.72); text-align: left; }
.shop-item:hover { border-color: #537844; background: #fffaf0; }
.shop-item.is-locked { opacity: .62; }
.shop-item-head { display: flex; align-items: center; gap: .55rem; }
.shop-item-head > div { min-width: 0; display: grid; gap: .08rem; }
.shop-material-badge { color: #8a6844; font-size: .5rem; font-weight: 900; }
.shop-event-badge { margin-left: auto; padding: .2rem .38rem; border: 1px solid #9d6a36; border-radius: 999px; background: #f3cf72; color: #5f3d24; font-size: .54rem; font-weight: 950; white-space: nowrap; }
.shop-favorite {
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  padding: 0;
  border: 1px solid #a47b4d;
  border-radius: 50%;
  background: #fff7d9;
  color: #92754d;
  font-size: 1rem;
  line-height: 1;
}
.shop-favorite.is-favorite { border-color: #9b6a24; background: #f2d475; color: #664115; }
.shop-seed {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 34px;
  filter: drop-shadow(0 2px 1px rgba(64, 39, 23, .18));
}
.shop-seed.item-art-icon { flex-basis: 44px; width: 44px; height: 44px; margin: -5px -2px; }
.shop-seed.seed-potato-pixel::before { left: 4px; top: 12px; width: 27px; height: 19px; }
.shop-seed.seed-potato-pixel::after { left: 16px; top: 1px; width: 15px; height: 15px; }
.shop-seed.seed-strawberry-pixel::before { left: 1px; top: 4px; width: 24px; height: 27px; }
.shop-seed.seed-strawberry-pixel::after { right: -1px; bottom: 0; width: 20px; height: 22px; }
.shop-seed.seed-corn-pixel::before { left: 11px; top: 1px; width: 18px; height: 31px; }
.shop-seed.seed-corn-pixel::after { left: 2px; bottom: 0; width: 31px; height: 27px; }
.shop-seed.seed-generic-pixel::before { left: 6px; top: 10px; width: 26px; height: 21px; }
.shop-seed.seed-generic-pixel::after { left: 18px; top: 0; width: 16px; height: 17px; }
.shop-seed.seedling-pixel::before { left: 3px; top: 0; width: 31px; height: 24px; }
.shop-seed.seedling-pixel::after { left: 10px; top: 21px; width: 21px; height: 14px; }
.shop-empty { grid-column: 1 / -1; margin: .4rem 0; padding: 1.2rem; border: 1px dashed #9b7148; border-radius: 6px; color: #705b40; text-align: center; }
.shop-item h3 { margin: 0; color: #3b4c34; font-size: .86rem; }
.shop-item p { margin: 0; color: #7c684c; font-size: .65rem; line-height: 1.45; }
.shop-item-meta { display: flex; justify-content: space-between; color: #5b4935; font-size: .64rem; font-weight: 900; }
.shop-item-meta del { margin-right: .2rem; color: #9b7a5c; font-weight: 700; }
.shop-buy { width: 100%; min-height: 38px; padding: .4rem; border: 2px solid #4b643d; border-radius: 4px; background: #5f8949; color: white; font-size: .7rem; font-weight: 900; }
.shop-buy:disabled { cursor: not-allowed; opacity: .46; }
.shop-footer { display: grid; grid-template-columns: auto 1fr; gap: .2rem .55rem; margin-top: 1rem; padding-top: .8rem; border-top: 2px dashed #b48b57; color: #6c563c; font-size: .72rem; }
.shop-footer strong { color: #395036; }
.shop-footer small { grid-column: 1 / -1; opacity: .75; }
.build-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .7rem;
  margin-top: 1rem;
}
.build-item {
  display: grid;
  gap: .5rem;
  min-height: 178px;
  padding: .85rem;
  border: 2px solid #987048;
  border-radius: 6px;
  background: rgba(255, 252, 232, .72);
  text-align: left;
}
.build-item:hover {
  border-color: #4f7542;
  background: #fffaf0;
}
.build-item.is-locked { opacity: .58; }
.build-item-head { display: flex; align-items: center; gap: .55rem; }
.build-preview {
  position: relative;
  display: grid;
  width: 92px;
  height: 62px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid #5e4935;
  border-radius: 7px;
  overflow: hidden;
  background: linear-gradient(145deg, #a5c977, #668f55);
}
.build-preview::before {
  content: "";
  width: 22px;
  height: 18px;
  border: 2px solid #593b27;
  background: #a86b3c;
  box-shadow: inset 0 4px #d89a58;
}
.build-preview.has-art::before { display: none; }
.build-preview canvas { display: block; width: 100%; height: 100%; }
.build-item h3 { margin: 0; color: #3b4c34; font-size: .86rem; }
.build-item p { margin: 0; color: #78654b; font-size: .65rem; line-height: 1.5; }
.build-costs { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: auto; }
.cost-chip {
  padding: .25rem .38rem;
  border: 1px solid #b88c57;
  border-radius: 999px;
  background: #f4dfad;
  color: #5f4b34;
  font-size: .61rem;
  font-weight: 900;
}
.build-select {
  min-height: 38px;
  border: 2px solid #4b643d;
  border-radius: 4px;
  background: #5f8949;
  color: white;
  font-size: .7rem;
  font-weight: 900;
}
.build-select:disabled { cursor: not-allowed; opacity: .45; }
.build-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem 1rem;
  margin-top: 1rem;
  padding-top: .8rem;
  border-top: 2px dashed #b48b57;
  color: #6c563c;
  font-size: .7rem;
}
.build-footer strong { color: #395036; }
.build-tip {
  width: 100%;
  margin: .1rem 0 0;
  color: #7b674b;
  font-size: .65rem;
}

/* Farm management stays off the playfield and opens as one focused workspace. */
.management-modal {
  width: min(calc(100vw - 2rem), 1160px);
  min-height: min(760px, calc(100dvh - 2rem));
  padding: clamp(1rem, 2vw, 1.45rem);
  background:
    radial-gradient(circle at 92% 4%, rgba(255,255,255,.6), transparent 28%),
    linear-gradient(155deg, #fff6d9, #e7c681);
}
.management-header { align-items: center; }
.management-balance {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
  margin: .9rem 0 .75rem;
}
.management-balance span {
  display: grid;
  gap: .18rem;
  padding: .62rem .75rem;
  border: 1px solid rgba(112,75,43,.38);
  border-radius: 7px;
  background: rgba(255,252,231,.62);
  color: #786143;
  font-size: .64rem;
  font-weight: 850;
}
.management-balance strong { color: #334d35; font-size: .88rem; }
.modal-tabs {
  display: flex;
  gap: .38rem;
  padding: .32rem;
  border: 1px solid rgba(112,75,43,.34);
  border-radius: 9px;
  background: rgba(92,60,38,.1);
}
.modal-tabs button {
  min-height: 40px;
  flex: 1;
  padding: .45rem .72rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #685239;
  font-size: .7rem;
  font-weight: 900;
}
.modal-tabs button:hover { background: rgba(255,255,255,.46); }
.modal-tabs button.is-active {
  border-color: #3f633f;
  background: #4f7747;
  color: #fff8dc;
  box-shadow: 0 3px 0 #2d4c31;
}
.compact-tabs { margin: .45rem 0 .15rem; overflow-x: auto; }
.compact-tabs button { min-width: 82px; min-height: 34px; flex: 0 0 auto; padding: .32rem .62rem; font-size: .64rem; }
.management-panel { padding-top: .85rem; }
.management-section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: .65rem; }
.management-section-heading small { color: #9a6339; font-size: .61rem; font-weight: 900; letter-spacing: .06em; }
.management-section-heading h3 { margin: .1rem 0 0; color: #334c34; font-family: Georgia, "Batang", serif; font-size: 1.16rem; }
.management-section-heading p { max-width: 360px; margin: 0; color: #756149; font-size: .65rem; text-align: right; }
.technology-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
  max-height: min(520px, calc(100dvh - 260px));
  padding: .1rem .25rem .5rem .1rem;
  overflow: auto;
}
.tech-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: .42rem;
  min-height: 168px;
  padding: .72rem;
  border: 2px solid #967048;
  border-radius: 8px;
  background: rgba(255,253,235,.72);
}
.tech-card.is-owned { border-color: #55754e; background: rgba(221,239,196,.76); }
.tech-card.is-blocked { opacity: .64; filter: saturate(.7); }
.tech-card-head { display: flex; justify-content: space-between; align-items: start; gap: .35rem; }
.tech-card h4 { margin: 0; color: #344a34; font-size: .79rem; }
.tech-branch, .tech-tier {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: .12rem .36rem;
  border-radius: 999px;
  background: #e0c383;
  color: #694e31;
  font-size: .54rem;
  font-weight: 900;
}
.tech-tier { background: #6b8055; color: #fff8dc; }
.tech-card p { margin: 0; color: #715e46; font-size: .59rem; line-height: 1.45; }
.tech-dependency { color: #8a6040 !important; }
.tech-card-footer { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.tech-card-footer strong { color: #3e5137; font-size: .69rem; }
.tech-buy, .asset-buy, .supply-buy {
  min-height: 34px;
  padding: .32rem .55rem;
  border: 2px solid #45633f;
  border-radius: 5px;
  background: #60894f;
  color: white;
  font-size: .62rem;
  font-weight: 900;
}
.tech-buy:disabled, .asset-buy:disabled, .supply-buy:disabled { cursor: default; border-color: #8b795e; background: #aaa087; opacity: .72; }
.management-subtitle { margin: .85rem 0 .45rem; color: #40543b; font-size: .76rem; }
.owned-facility-grid, .equipment-grid, .supply-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.owned-facility-grid { max-height: 230px; overflow: auto; }
.asset-card, .supply-card, .selected-facility-panel {
  display: grid;
  gap: .34rem;
  padding: .68rem;
  border: 1px solid #a27a4d;
  border-radius: 7px;
  background: rgba(255,253,235,.68);
  color: #6d5840;
  font-size: .6rem;
}
.asset-card h5, .supply-card h4 { margin: 0; color: #354c35; font-size: .72rem; }
.asset-card.is-selected { border: 2px solid #4f7448; background: #edf1d1; }
.asset-card button { width: 100%; }
.asset-card-actions { display: grid; gap: .28rem; }
.trailer-staffing-note { display: block; padding: .32rem .4rem; border: 1px solid #66815b; border-radius: 5px; background: #e3efcf; color: #36543b; font-size: .49rem; font-weight: 850; line-height: 1.45; }
.trailer-staffing-note.is-blocked { border-color: #a36a4e; background: #f5ddbd; color: #844936; }
.equipment-automation-card { grid-column: span 2; align-content: start; }
.equipment-automation {
  display: grid;
  gap: .48rem;
  margin-top: .18rem;
  padding-top: .55rem;
  border-top: 1px dashed #ad875b;
}
.equipment-automation > header { display: flex; align-items: center; justify-content: space-between; gap: .45rem; }
.equipment-automation > header > div { display: flex; align-items: center; gap: .36rem; min-width: 0; }
.equipment-automation > header strong { color: #334d35; font-size: .65rem; }
.equipment-automation > header button,
.equipment-zone-row button,
.equipment-zone-actions button {
  width: auto;
  min-height: 30px;
  padding: .25rem .45rem;
  border: 1px solid #657551;
  border-radius: 5px;
  background: #e9edc8;
  color: #46533d;
  font-size: .52rem;
  font-weight: 900;
}
.equipment-automation button:disabled { cursor: default; opacity: .5; }
.equipment-status {
  flex: 0 0 auto;
  padding: .18rem .35rem;
  border: 1px solid #87795d;
  border-radius: 999px;
  background: #e5dfbd;
  color: #6d5e45;
  font-size: .46rem;
  font-weight: 900;
}
.equipment-status.is-running { border-color: #5d825b; background: #dbeac0; color: #315b37; }
.equipment-status.is-paused { border-color: #9d6a51; background: #efd5ba; color: #814738; }
.equipment-capacity { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .28rem; }
.equipment-capacity span {
  display: grid;
  gap: .08rem;
  padding: .32rem .38rem;
  border: 1px solid #b2946a;
  border-radius: 5px;
  background: rgba(244, 238, 196, .72);
  color: #78634a;
  font-size: .48rem;
}
.equipment-capacity b { color: #3b563c; font-size: .57rem; }
.equipment-automation-warning { margin: 0; color: #934e3f; font-size: .52rem; font-weight: 800; }
.equipment-zone-list { display: grid; gap: .3rem; }
.equipment-zone-list > p { margin: 0; color: #77634b; font-size: .52rem; }
.equipment-zone-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
  gap: .38rem;
  padding: .38rem;
  border: 1px solid #af8e62;
  border-radius: 6px;
  background: rgba(255, 249, 222, .75);
}
.equipment-zone-row > div:first-child { display: grid; gap: .1rem; min-width: 0; }
.equipment-zone-row > div:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .24rem; }
.equipment-zone-row strong { color: #3e5139; font-size: .58rem; }
.equipment-zone-row span { color: #7b654a; font-size: .48rem; }
.equipment-zone-row .route-remove { border-color: #9a5b4c; background: #f1d6bb; color: #804939; }
.equipment-zone-actions { display: grid; gap: .28rem; }
.equipment-existing-zone { display: grid; grid-template-columns: minmax(130px, 1fr) auto; gap: .28rem; }
.equipment-existing-zone select {
  min-height: 31px;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff9df;
  color: #4f4736;
  font-size: .52rem;
  font-weight: 800;
}
.land-planning-panel { margin-bottom: .65rem; }
.land-planning-card {
  display: grid;
  gap: .5rem;
  padding: .72rem;
  border: 2px solid #6d8a61;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(226,241,205,.86), rgba(248,238,190,.78));
}
.land-planning-card.is-locked { border-color: #9b8869; filter: saturate(.72); }
.land-planning-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .7rem; }
.land-planning-heading small { color: #72805e; font-size: .5rem; font-weight: 900; }
.land-planning-heading h4 { margin: .08rem 0 .15rem; color: #34523a; font-size: .8rem; }
.land-planning-heading p { margin: 0; color: #6f6047; font-size: .55rem; line-height: 1.5; }
.land-zone-list { display: grid; gap: .32rem; }
.land-zone-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .45rem;
  padding: .42rem;
  border: 1px solid #9a835c;
  border-radius: 6px;
  background: rgba(255,250,220,.76);
}
.land-zone-card > div { display: grid; gap: .1rem; min-width: 0; }
.land-zone-card strong { color: #38513a; font-size: .61rem; }
.land-zone-card span { color: #756147; font-size: .49rem; }
.land-zone-card button { min-height: 30px; padding: .25rem .45rem; border: 1px solid #9a5b4c; border-radius: 5px; background: #f1d6bb; color: #804939; font-size: .52rem; font-weight: 900; }
.land-zone-card button:disabled { border-color: #938972; background: #ded7c0; color: #706858; opacity: .75; }
.selected-facility-panel { margin-bottom: .6rem; border-width: 2px; }
.selected-facility-summary { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .6rem; }
.selected-facility-panel h4, .selected-facility-panel p { margin: 0; }
.selected-facility-panel h4 { color: #314a32; font-size: .88rem; }
.selected-facility-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.facility-removal-hint { display: block; margin-top: .24rem; color: #52704c; font-size: .5rem; font-weight: 800; line-height: 1.4; }
.facility-removal-hint.is-blocked { color: #94503f; }
.facility-remove-button { border-color: #9a5b4c !important; background: #f1d6bb !important; color: #804939 !important; }
.facility-removal-blockers { display: grid; gap: .3rem; margin: 0; padding-left: 1.2rem; color: #7d4739; }
.facility-control-area { display: grid; gap: .55rem; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed #ad875b; }
.facility-control-block { display: grid; gap: .42rem; }
.facility-control-block h5 { margin: 0; color: #42543b; font-size: .68rem; }
.facility-block-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.facility-transfer-grid, .facility-recipe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
.facility-transfer-grid button, .facility-recipe-grid button {
  display: grid;
  gap: .14rem;
  min-height: 46px;
  padding: .42rem;
  border: 1px solid #8f704c;
  border-radius: 5px;
  background: #f6e6ba;
  color: #4e4e36;
  font-size: .59rem;
  font-weight: 900;
  text-align: left;
}
.facility-transfer-grid button:disabled { opacity: .5; }
.facility-transfer-grid small, .facility-recipe-grid small { color: #806b51; font-size: .52rem; font-weight: 750; }
.workshop-order-controls { display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)); align-items: end; gap: .35rem; }
.workshop-order-controls label { display: grid; gap: .14rem; color: #6e5a42; font-size: .51rem; font-weight: 850; }
.workshop-order-controls input,
.workshop-order-controls select { width: 100%; min-height: 34px; border: 1px solid #8d6a45; border-radius: 5px; background: #fff9df; color: #4f4736; font-size: .56rem; font-weight: 850; }
.workshop-order-list { display: grid; gap: .28rem; }
.workshop-order-list article { display: grid; grid-template-columns: minmax(120px, .45fr) 1fr; gap: .35rem; padding: .38rem .45rem; border: 1px solid #ad9067; border-radius: 5px; background: rgba(247,239,203,.78); }
.workshop-order-list strong { color: #40543b; font-size: .54rem; }
.workshop-order-list span { color: #79654b; font-size: .49rem; }
.facility-transfer-item {
  display: grid;
  gap: .32rem;
  padding: .42rem;
  border: 1px solid #8f704c;
  border-radius: 6px;
  background: #f6e6ba;
}
.facility-transfer-item > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .3rem; }
.facility-transfer-item > div:first-child { grid-template-columns: 1fr; gap: .1rem; }
.facility-transfer-item strong { color: #46533d; font-size: .59rem; }
.facility-transfer-item input {
  width: 100%;
  min-height: 32px;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff9df;
  color: #4f4736;
  font-size: .56rem;
  font-weight: 850;
}
.facility-transfer-item button {
  display: block;
  min-height: 32px;
  padding: .25rem .5rem;
  text-align: center;
}
.facility-plan-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(100px, .7fr) auto auto; gap: .35rem; align-items: end; }
.facility-plan-row select, .facility-plan-row input {
  width: 100%;
  min-height: 36px;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff7db;
  color: #4f4736;
  font-size: .62rem;
  font-weight: 800;
}
.facility-plan-row label { display: grid; gap: .16rem; color: #786249; font-size: .54rem; font-weight: 850; }
.facility-plan-transfer { display: grid; grid-template-columns: 74px auto; align-items: end; gap: .28rem; }
.facility-plan-transfer input {
  width: 100%;
  min-height: 34px;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff9df;
  color: #4f4736;
  font-size: .56rem;
  font-weight: 850;
}
.automation-inline-status { align-self: center; padding: .32rem .5rem; border: 1px solid #5d825b; border-radius: 999px; background: #dbeac0; color: #315b37; font-size: .52rem; font-weight: 900; }
.automation-chain-block { padding-top: .62rem; border-top: 1px dashed #ad875b; }
.automation-chain-badge { flex: 0 0 auto; padding: .26rem .45rem; border: 1px solid #5d825b; border-radius: 999px; background: #dbeac0; color: #315b37; font-size: .5rem; font-weight: 900; }
.automation-chain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .3rem; }
.automation-chain-step {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: .3rem;
  min-height: 57px;
  padding: .4rem;
  border: 1px solid #a88b65;
  border-radius: 6px;
  background: rgba(255,248,219,.78);
}
.automation-chain-step > i { width: 9px; height: 9px; margin-top: .12rem; border: 2px solid #81745d; border-radius: 50%; background: #c8bfa5; }
.automation-chain-step > div { display: grid; align-content: start; gap: .12rem; min-width: 0; }
.automation-chain-step strong { color: #46513e; font-size: .55rem; }
.automation-chain-step span { color: #79664e; font-size: .47rem; line-height: 1.35; }
.automation-chain-step.is-ready { border-color: #6d8d62; background: rgba(221,239,196,.82); }
.automation-chain-step.is-ready > i { border-color: #3d6a40; background: #72aa5e; box-shadow: 0 0 0 2px rgba(112,170,94,.18); }
.automation-chain-step.is-warning { border-color: #b27a52; background: rgba(247,222,184,.84); }
.automation-chain-step.is-warning > i { border-color: #98583d; background: #df924b; }
.smart-farm-runtime-status { display: grid; grid-template-columns: auto repeat(3, auto); align-items: center; gap: .3rem; padding: .42rem .5rem; border: 1px solid #9a8965; border-radius: 6px; background: #eee7c5; color: #635942; }
.smart-farm-runtime-status.is-ready { border-color: #60825b; background: #dcebc6; color: #31583a; }
.smart-farm-runtime-status.is-warning { border-color: #aa674d; background: #f5dabb; color: #874938; }
.smart-farm-runtime-status strong { font-size: .58rem; }
.smart-farm-runtime-status span { padding: .18rem .32rem; border: 1px solid currentColor; border-radius: 999px; font-size: .46rem; font-weight: 900; text-align: center; }
.smart-farm-runtime-status small { grid-column: 1 / -1; font-size: .48rem; font-weight: 750; line-height: 1.35; }
.zone-control-block,
.route-control-block { padding-top: .62rem; border-top: 1px dashed #ad875b; }
.zone-create-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .28rem; }
.zone-create-actions button,
.zone-card button,
.route-card button {
  min-height: 30px;
  padding: .25rem .45rem;
  border: 1px solid #657551;
  border-radius: 5px;
  background: #e9edc8;
  color: #46533d;
  font-size: .52rem;
  font-weight: 900;
}
.zone-card-list,
.route-card-list { display: grid; gap: .35rem; }
.facility-existing-zone { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: .32rem; }
.facility-existing-zone select {
  min-height: 32px;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff9df;
  color: #4f4736;
  font-size: .54rem;
  font-weight: 800;
}
.facility-existing-zone button,
.zone-card-actions button {
  min-height: 30px;
  padding: .25rem .45rem;
  border: 1px solid #657551;
  border-radius: 5px;
  background: #e9edc8;
  color: #46533d;
  font-size: .52rem;
  font-weight: 900;
}
.zone-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem; }
.zone-card,
.route-card {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  align-items: center;
  gap: .4rem;
  padding: .48rem;
  border: 1px solid #aa865b;
  border-radius: 7px;
  background: rgba(255, 248, 215, .72);
}
.zone-card > div:first-child,
.route-card-copy { display: grid; gap: .12rem; min-width: 0; }
.zone-card strong,
.route-card strong { color: #405039; font-size: .62rem; }
.zone-card span,
.route-card span { color: #78624a; font-size: .5rem; line-height: 1.35; }
.route-card-copy small { color: #4f6b4a; font-size: .47rem; font-weight: 800; line-height: 1.35; }
.zone-plan-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto auto;
  align-items: center;
  gap: .32rem;
}
.zone-plan-row label { display: flex; align-items: center; gap: .22rem; color: #695941; font-size: .5rem; font-weight: 850; }
.zone-plan-row input[type="number"] { width: 46px; }
.zone-plan-row select,
.zone-plan-row input,
.route-create-row select,
.route-create-row input,
.manual-carry-row select,
.manual-carry-row input,
.route-card input {
  min-height: 32px;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff9df;
  color: #4f4736;
  font-size: .53rem;
  font-weight: 800;
}
.route-create-row {
  display: grid;
  grid-template-columns: minmax(90px, .7fr) minmax(140px, 1fr) minmax(100px, .72fr) 76px 76px minmax(100px, .75fr) auto;
  align-items: end;
  gap: .32rem;
}
.manual-logistics-block { padding-bottom: .6rem; border-bottom: 1px dashed #ad875b; }
.manual-cargo-active {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: .5rem .58rem;
  border: 1px solid #62815a;
  border-radius: 7px;
  background: #deebc5;
}
.manual-cargo-active > div { display: grid; gap: .1rem; min-width: 0; }
.manual-cargo-active small { color: #55704d; font-size: .48rem; font-weight: 900; }
.manual-cargo-active strong { color: #304e34; font-size: .66rem; }
.manual-cargo-active span { color: #607050; font-size: .5rem; font-weight: 750; }
.manual-cargo-active button { min-height: 32px; padding: .28rem .48rem; border: 1px solid #9a5b4c; border-radius: 5px; background: #f1d6bb; color: #804939; font-size: .52rem; font-weight: 900; }
.manual-carry-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 1fr) 74px auto;
  align-items: center;
  gap: .32rem;
}
.storage-control-block { gap: .5rem; }
.storage-lot-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .34rem; }
.storage-lot-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .45rem;
  padding: .45rem .5rem;
  border: 1px solid #b59a70;
  border-radius: 7px;
  background: #fff7dc;
}
.storage-lot-card.is-terminal { border-color: #a95d4f; background: #f5ddc7; }
.storage-lot-card > div:first-child { display: grid; gap: .12rem; }
.storage-lot-card strong { color: #4d4935; font-size: .56rem; }
.storage-lot-card span { color: #78624a; font-size: .48rem; }
.storage-lot-actions { display: flex; gap: .25rem; flex: 0 0 auto; }
.storage-lot-actions button { min-height: 28px; padding: .22rem .38rem; border: 1px solid #697b55; border-radius: 5px; background: #edf0d2; color: #48553d; font-size: .48rem; font-weight: 900; }
.storage-mold-warning { color: #a23f37; font-weight: 850; }
.route-create-row label,
.route-card label { display: grid; gap: .14rem; color: #6e5a42; font-size: .49rem; font-weight: 850; }
.route-card { grid-template-columns: minmax(170px, 1fr) 74px auto auto auto; }
.route-card.is-disabled { opacity: .58; }
.zone-card .route-remove,
.route-card .route-remove { border-color: #9a5b4c; background: #f1d6bb; color: #804939; }
.compost-control-block { padding-top: .62rem; border-top: 1px dashed #ad875b; }
.compost-stock { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .28rem; }
.compost-stock span {
  padding: .22rem .4rem;
  border: 1px solid #8f7852;
  border-radius: 999px;
  background: #e6dfb6;
  color: #5a533c;
  font-size: .49rem;
  font-weight: 800;
}
.compost-stock b { color: #36503a; }
.compost-start-row,
.compost-apply-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .4rem; }
.compost-start-row > span { color: #705c43; font-size: .52rem; font-weight: 850; }
.compost-batch-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .38rem; }
.compost-batch-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .3rem;
  padding: .48rem;
  border: 1px solid #8e754e;
  border-radius: 7px;
  background: linear-gradient(145deg, #f1e6b9, #d8c58b);
}
.compost-batch-card > div:first-child { display: grid; gap: .1rem; }
.compost-batch-card strong { color: #465039; font-size: .59rem; }
.compost-batch-card span { color: #705e43; font-size: .48rem; }
.compost-batch-card > div:last-child { display: flex; gap: .24rem; }
.compost-batch-card button,
.compost-apply-row button {
  min-height: 30px;
  border: 1px solid #66724d;
  border-radius: 5px;
  background: #e9edc8;
  color: #46533d;
  font-size: .5rem;
  font-weight: 900;
}
.compost-batch-card button:disabled { opacity: .45; }
.compost-progress { grid-column: 1 / -1; overflow: hidden; height: 8px; border: 1px solid #756549; border-radius: 999px; background: #c7b98e; }
.compost-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #71914f, #a7bd62); }
.compost-apply-row select { min-height: 32px; border: 1px solid #8d6a45; border-radius: 5px; background: #fff9df; color: #4f4736; font-size: .53rem; font-weight: 800; }
.facility-passive-note { color: #75634c; font-size: .61rem; }
.utility-status-block .facility-block-heading { align-items: center; }
.utility-status-block p { margin: 4px 0 0; }
.utility-connected { color: #356b55; }
.utility-disconnected { color: #a34a37; }
.utility-state-chip { flex: 0 0 auto; padding: .3rem .55rem; border: 1px solid currentColor; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: -.02em; }
.utility-state-chip.is-connected { color: #356b55; background: #e6f4e5; }
.utility-state-chip.is-disconnected { color: #9d4437; background: #fff0e7; }
.livestock-block {
  padding-top: .7rem;
  border-top: 1px dashed #ad875b;
}
.livestock-block h6 { margin: .25rem 0 0; color: #40513a; font-size: .64rem; }
.livestock-top-actions,
.animal-card-actions,
.animal-sex-actions,
.livestock-breeding { display: flex; flex-wrap: wrap; gap: .3rem; }
.livestock-top-actions { justify-content: flex-end; }
.livestock-output {
  padding: .45rem .55rem;
  border: 1px solid #b69362;
  border-radius: 6px;
  background: rgba(239, 228, 180, .66);
  color: #66543f;
  font-size: .58rem;
}
.animal-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.animal-status-card,
.animal-shop-card {
  border: 1px solid #a17b50;
  border-radius: 8px;
  background: linear-gradient(150deg, rgba(255, 253, 235, .94), rgba(234, 220, 176, .78));
  box-shadow: inset 0 1px rgba(255,255,255,.72);
}
.animal-status-card { display: grid; gap: .42rem; padding: .55rem; }
.animal-status-card.is-sick { border-color: #a35545; background: linear-gradient(150deg, #fff0dc, #e7c2a8); }
.animal-status-card header { display: flex; align-items: center; gap: .48rem; }
.animal-status-card header > div { min-width: 0; }
.animal-status-card header strong { display: block; color: #3d4935; font-size: .67rem; }
.animal-status-card header strong small { color: #82674a; font-size: .5rem; }
.animal-status-card header span { display: block; margin-top: .12rem; color: #7c6045; font-size: .52rem; }
.animal-portrait {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  padding: 3px;
  border: 1px solid rgba(91, 67, 42, .35);
  border-radius: 14px;
  background: radial-gradient(circle at 35% 28%, #fffceb, #d9c58c);
  filter: drop-shadow(0 2px 1px rgba(62, 43, 29, .18));
}
.animal-meters { display: grid; gap: .22rem; }
.animal-meters label { display: grid; grid-template-columns: 42px 1fr 23px; align-items: center; gap: .3rem; color: #665540; font-size: .49rem; font-weight: 850; }
.animal-meters label > span { overflow: hidden; height: 7px; border: 1px solid #8d7658; border-radius: 999px; background: #d9ceb2; }
.animal-meters label > span i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #78a953, #a7c969); }
.animal-meters label > span.stress i { background: linear-gradient(90deg, #e4b04b, #c95e4a); }
.animal-meters b { color: #4f5c42; font-size: .48rem; text-align: right; }
.animal-card-actions button,
.animal-sex-actions button,
.livestock-breeding button {
  min-height: 29px;
  padding: .25rem .4rem;
  border: 1px solid #6f7550;
  border-radius: 5px;
  background: #edf0d0;
  color: #48523d;
  font-size: .5rem;
  font-weight: 900;
}
.animal-card-actions button:disabled,
.animal-sex-actions button:disabled { opacity: .44; }
.animal-shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.animal-shop-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: .42rem; padding: .45rem; }
.animal-shop-card .animal-portrait { width: 40px; height: 40px; border-radius: 11px; }
.animal-shop-card strong { display: block; color: #3c4d37; font-size: .61rem; }
.animal-shop-card small { display: block; margin-top: .12rem; color: #7b6247; font-size: .49rem; line-height: 1.35; }
.animal-sex-actions { display: grid; grid-template-columns: 1fr 1fr; }
.supply-card { grid-template-columns: 1fr auto; align-items: center; }
.supply-card .supply-quantity { color: #3f5b3d; font-size: .78rem; font-weight: 900; }
.small-button { min-height: 36px; padding: .35rem .65rem; }
.commerce-workspace,
.records-workspace { display: grid; gap: .65rem; max-height: min(620px, calc(100dvh - 255px)); padding: .05rem .22rem .5rem .05rem; overflow: auto; }
.commerce-section,
.records-section {
  display: grid;
  gap: .48rem;
  padding: .65rem;
  border: 1px solid #a57c50;
  border-radius: 8px;
  background: rgba(255, 252, 230, .62);
}
.commerce-heading { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.commerce-heading h4 { margin: 0; color: #3d5038; font-size: .72rem; }
.commerce-heading small { color: #7c6549; font-size: .5rem; text-align: right; }
.commerce-logistics-note { margin: 0; padding: .45rem .58rem; border: 1px solid #b98a4e; border-radius: 7px; background: #fff2c8; color: #6c5437; font-size: .49rem; font-weight: 750; line-height: 1.55; }
.season-event-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.season-event-chip { padding: .28rem .45rem; border: 1px solid #9a733f; border-radius: 999px; background: #f1d27b; color: #614326; font-size: .5rem; font-weight: 900; }
.intelligence-grid { display: grid; grid-template-columns: 1.15fr .9fr 1.2fr; gap: .55rem; }
.intelligence-grid > div { min-width: 0; padding: .5rem; border: 1px solid #ad8b5d; border-radius: 7px; background: rgba(247, 237, 205, .76); }
.intelligence-grid h5 { margin: 0 0 .35rem; color: #40533b; font-size: .59rem; }
.forecast-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .24rem; }
.forecast-heading { display: flex; align-items: center; justify-content: space-between; gap: .45rem; margin-bottom: .28rem; }
.forecast-heading h5 { margin: 0; }
.forecast-pager { display: flex; align-items: center; justify-content: flex-end; gap: .28rem; min-width: 0; }
.forecast-pager span { color: #75644f; font-size: .43rem; font-weight: 800; white-space: nowrap; }
.forecast-pager.is-single { justify-content: flex-start; }
.forecast-pager .small-button { min-width: 2rem; padding: .18rem .34rem; }
.forecast-day { display: grid; gap: .1rem; padding: .32rem .24rem; border-radius: 5px; background: #fff8dc; text-align: center; }
.forecast-day span { color: #806b50; font-size: .42rem; }
.forecast-day strong { color: #435647; font-size: .49rem; white-space: nowrap; }
.forecast-day.has-story { align-content: start; border: 1px solid #c49b55; background: linear-gradient(160deg, #fff8dc, #f4e3ac); }
.forecast-stories { display: grid; gap: .1rem; min-width: 0; margin-top: .1rem; padding-top: .18rem; border-top: 1px dashed #c2a56d; text-align: left; }
.forecast-stories em { overflow: hidden; color: #76522f; font-size: .39rem; font-style: normal; font-weight: 800; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.forecast-stories small { color: #8a7153; font-size: .37rem; text-align: right; }
.market-outlook-grid,
.market-news-list { display: grid; gap: .22rem; }
.market-outlook-grid article { display: flex; justify-content: space-between; gap: .35rem; padding: .28rem .34rem; border-bottom: 1px dashed #b8a076; color: #61523e; font-size: .49rem; }
.market-outlook-grid .up { color: #a04435; }
.market-outlook-grid .down { color: #356f82; }
.market-news-card { display: grid; gap: .12rem; padding: .33rem .38rem; border-left: 3px solid #779355; background: #fff8dc; }
.market-news-card strong { color: #4c563c; font-size: .49rem; line-height: 1.35; }
.market-news-card span { color: #897054; font-size: .42rem; }
.commerce-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.commerce-overview > article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .22rem .5rem;
  padding: .55rem;
  border: 1px solid #9c7950;
  border-radius: 7px;
  background: linear-gradient(145deg, #f6ebc8, #e4d39f);
}
.commerce-overview span { color: #6e5a41; font-size: .54rem; font-weight: 850; }
.commerce-overview strong { color: #385039; font-size: .68rem; text-align: right; }
.commerce-overview small { color: #795f43; font-size: .49rem; line-height: 1.4; }
.commerce-overview button,
.commerce-card button,
.commerce-row button,
.shipment-create-row button,
.shipment-action-row button,
.forward-sale-form button,
.finance-actions button,
.driver-row button {
  min-height: 31px;
  padding: .27rem .48rem;
  border: 1px solid #536b45;
  border-radius: 5px;
  background: #5f844e;
  color: #fffbe4;
  font-size: .52rem;
  font-weight: 900;
}
.commerce-overview button:disabled,
.commerce-card button:disabled,
.shipment-create-row button:disabled,
.shipment-action-row button:disabled,
.forward-sale-form button:disabled,
.finance-actions button:disabled { opacity: .48; }
.driver-row { display: grid; grid-template-columns: 70px auto; gap: .3rem; }
.driver-row input,
.shipment-create-row input,
.shipment-create-row select,
.shipment-quality-row input,
.shipment-quality-row select,
.shipment-action-row input {
  min-height: 32px;
  min-width: 0;
  border: 1px solid #8d6a45;
  border-radius: 5px;
  background: #fff9df;
  color: #4f4736;
  font-size: .52rem;
  font-weight: 800;
}
.commerce-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.commerce-card {
  display: grid;
  gap: .3rem;
  padding: .52rem;
  border: 1px solid #9a764d;
  border-radius: 7px;
  background: #f7edcd;
}
.commerce-card header { display: flex; justify-content: space-between; gap: .35rem; color: #3e5039; font-size: .62rem; }
.commerce-card p,
.commerce-card small { margin: 0; color: #6f5b43; font-size: .49rem; line-height: 1.45; }
.commerce-card > div:last-child { display: grid; grid-template-columns: 1fr 1fr; gap: .28rem; }
.contract-progress { overflow: hidden; height: 8px; border: 1px solid #85704e; border-radius: 999px; background: #d6cba5; }
.contract-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6a9656, #a6bf63); }
.shipment-create-panel { display: grid; gap: .38rem; padding: .52rem; border: 1px solid #9e8058; border-radius: 7px; background: rgba(255,248,218,.66); }
.shipment-create-row { display: grid; grid-template-columns: minmax(160px, 1fr) 88px 120px 92px; gap: .32rem; align-items: end; }
.shipment-create-row label,
.shipment-quality-row label,
.shipment-action-row label { display: grid; grid-template-columns: 1fr auto; gap: .12rem .22rem; align-items: center; color: #6d5941; font-size: .48rem; font-weight: 850; }
.shipment-create-row label { grid-template-columns: 1fr; }
.shipment-quality-row { display: grid; grid-template-columns: 132px 86px 86px minmax(230px, 1fr); gap: .32rem; align-items: end; }
.shipment-quality-row > label:first-child { grid-template-columns: 1fr; }
.shipment-quality-row output { display: grid; grid-template-columns: 1fr auto; gap: .08rem .4rem; min-height: 42px; align-content: center; padding: .28rem .46rem; border: 1px solid #879968; border-radius: 5px; background: rgba(255,255,232,.78); color: #536048; font-size: .47rem; line-height: 1.35; }
.shipment-quality-row output strong { color: #355038; text-align: right; }
.shipment-quality-row output > span:last-of-type { grid-column: 1 / -1; }
.shipment-quality-row output > small { grid-column: 1 / -1; color: #8c6948; }
.shipment-action-row { display: flex; justify-content: flex-end; align-items: end; gap: .35rem; }
.shipment-action-row label { grid-template-columns: auto 72px auto; }
.forward-sale-section { border-color: #78905c; background: linear-gradient(145deg, rgba(246, 244, 211, .9), rgba(222, 232, 190, .78)); }
.forward-sale-form { display: grid; grid-template-columns: minmax(220px, 1.35fr) 84px 98px minmax(190px, 1fr) auto; gap: .35rem; align-items: end; }
.forward-sale-form label { display: grid; grid-template-columns: 1fr auto; gap: .12rem .24rem; align-items: center; color: #5d563e; font-size: .48rem; font-weight: 850; }
.forward-sale-form label:first-child { grid-template-columns: 1fr; }
.forward-sale-form input,
.forward-sale-form select,
.finance-actions input {
  min-height: 32px;
  min-width: 0;
  border: 1px solid #7f7148;
  border-radius: 5px;
  background: #fffbea;
  color: #3f4837;
  font-size: .52rem;
  font-weight: 800;
}
.forward-sale-form output { display: grid; gap: .08rem; min-height: 32px; align-content: center; padding: .25rem .45rem; border: 1px solid #8a9b67; border-radius: 5px; background: rgba(255, 255, 238, .75); color: #536048; font-size: .48rem; }
.forward-sale-form output strong { color: #355038; font-size: .54rem; }
.forward-status { justify-self: end; padding: .2rem .38rem; border-radius: 999px; font-size: .45rem; white-space: nowrap; }
.forward-status.is-active { background: #d7bb66; color: #594420; }
.forward-status.is-settled { background: #8eaa76; color: #faffeb; }
.finance-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
.finance-summary article { display: grid; gap: .18rem; padding: .48rem .55rem; border: 1px solid #9e835b; border-radius: 6px; background: #f4e8c3; }
.finance-summary span { color: #705d44; font-size: .48rem; }
.finance-summary strong { color: #38503d; font-size: .69rem; }
.finance-summary article.has-debt { border-color: #b16852; background: #f0d5b7; }
.finance-summary article.has-debt strong { color: #984b3c; }
.finance-actions { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: center; gap: .45rem; padding: .48rem .55rem; border-top: 1px dashed #ad926b; }
.finance-actions > div { display: grid; gap: .12rem; }
.finance-actions strong { color: #40513d; font-size: .56rem; }
.finance-actions small { color: #746149; font-size: .47rem; line-height: 1.4; }
.finance-actions label { display: grid; grid-template-columns: auto 88px; align-items: center; gap: .25rem; color: #65533e; font-size: .48rem; font-weight: 850; }
.commerce-list,
.ledger-list { display: grid; gap: .28rem; }
.commerce-row,
.ledger-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(170px, auto) auto;
  align-items: center;
  gap: .45rem;
  padding: .36rem .45rem;
  border-bottom: 1px dashed #b19269;
  color: #4a523d;
  font-size: .54rem;
}
.commerce-row small,
.ledger-row small { color: #7b654a; font-size: .48rem; }
.ledger-month-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; }
.ledger-month {
  display: grid;
  gap: .17rem;
  padding: .48rem;
  border: 1px solid #a07b52;
  border-radius: 6px;
  background: #f3e6bd;
  color: #695740;
  font-size: .49rem;
}
.ledger-month strong { color: #3f503a; font-size: .6rem; }
.ledger-month b,
.ledger-row b { color: #3d7446; text-align: right; }
.ledger-month b.is-negative,
.ledger-row b.is-negative { color: #a34e40; }
.ledger-month.is-selected { border-color: #4f7948; box-shadow: inset 0 0 0 1px #6c945c; background: #e6ebbd; }
.ledger-month-picker { display: grid; grid-template-columns: auto minmax(150px, 1fr); align-items: center; gap: .3rem; color: #67543f; font-size: .48rem; font-weight: 850; }
.ledger-month-picker select { min-height: 32px; border: 1px solid #806342; border-radius: 5px; background: #fff9df; color: #45503d; font-size: .51rem; font-weight: 850; }
.ledger-month-caption { display: flex; justify-content: space-between; align-items: center; gap: .5rem; color: #77634a; font-size: .46rem; }
.ledger-month-caption strong { color: #46563f; font-size: .52rem; }
.ledger-selected-month { display: grid; gap: .45rem; padding: .55rem; border: 1px solid #9f8057; border-radius: 7px; background: rgba(255, 249, 221, .78); }
.ledger-detail-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .32rem; }
.ledger-detail-summary article { display: grid; gap: .14rem; padding: .38rem .45rem; border-radius: 5px; background: #ece2bc; color: #735d43; font-size: .45rem; }
.ledger-detail-summary strong { color: #397044; font-size: .58rem; }
.ledger-detail-summary .is-negative { color: #a34e40; }
.ledger-detail-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .42rem; }
.ledger-detail-columns > div { min-width: 0; padding: .4rem; border: 1px solid #b69a70; border-radius: 5px; background: rgba(244, 235, 203, .64); }
.ledger-detail-columns h5,
.ledger-transaction-heading h5 { margin: 0 0 .3rem; color: #45543d; font-size: .54rem; }
.ledger-category-list,
.ledger-item-list { display: grid; gap: .2rem; }
.ledger-category-list article { display: grid; grid-template-columns: minmax(90px, 1fr) auto auto auto; align-items: center; gap: .28rem; padding: .25rem .3rem; border-bottom: 1px dashed #c0a77c; color: #705d45; font-size: .43rem; }
.ledger-category-list article > div { display: grid; gap: .05rem; }
.ledger-category-list article strong { color: #44543e; font-size: .48rem; }
.ledger-category-list article small { color: #8b7254; font-size: .39rem; }
.ledger-category-list article b { color: #397044; text-align: right; }
.ledger-category-list article b.is-negative { color: #a34e40; }
.ledger-item-list article { display: grid; grid-template-columns: minmax(80px, 1fr) auto; gap: .08rem .3rem; padding: .25rem .3rem; border-bottom: 1px dashed #c0a77c; color: #6f5b43; font-size: .44rem; }
.ledger-item-list article strong { color: #44543e; }
.ledger-item-list article small { grid-column: 1 / -1; color: #826c50; font-size: .4rem; }
.ledger-transaction-heading { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; }
.ledger-transaction-heading small { color: #826d52; font-size: .42rem; }
.ledger-full-list { max-height: 280px; padding-right: .2rem; overflow: auto; }
.ledger-detail-row > span { display: grid; gap: .06rem; min-width: 0; }
.ledger-detail-row > span strong { color: #46543e; }
.ledger-detail-row > span small { overflow-wrap: anywhere; }
.records-settings { grid-template-columns: 1fr; }
.notification-center { border-color: #7f8f5e; background: linear-gradient(145deg, rgba(248, 246, 214, .92), rgba(228, 235, 198, .76)); }
.notification-center .commerce-heading > div { display: grid; gap: .12rem; }
.notification-unread-count {
  display: inline-grid;
  min-width: 1.15rem;
  height: 1.15rem;
  margin-left: .22rem;
  place-items: center;
  border-radius: 999px;
  background: #a5573f;
  color: #fff9e2;
  font-size: .47rem;
  vertical-align: middle;
}
.notification-history { display: grid; gap: .3rem; }
.notification-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .55rem;
  padding: .48rem .55rem;
  border: 1px solid #a99467;
  border-left: 4px solid #718b58;
  border-radius: 6px;
  background: rgba(255, 251, 226, .9);
}
.notification-record.is-warning { border-left-color: #c48737; }
.notification-record.is-danger { border-left-color: #ad5043; }
.notification-record.is-success { border-left-color: #4f8755; }
.notification-record.is-read { opacity: .68; background: rgba(238, 232, 205, .72); }
.notification-record-main { min-width: 0; display: grid; gap: .13rem; }
.notification-record-main > div { display: flex; align-items: center; gap: .28rem; }
.notification-type {
  padding: .13rem .3rem;
  border-radius: 999px;
  background: #dce4b6;
  color: #4f613e;
  font-size: .43rem;
  font-weight: 900;
}
.notification-record-main i { color: #a14d3e; font-size: .42rem; font-style: normal; font-weight: 900; }
.notification-record-main strong { overflow-wrap: anywhere; color: #46513d; font-size: .53rem; line-height: 1.45; }
.notification-record-main small { color: #806d53; font-size: .44rem; }
.notification-record button:disabled { opacity: .5; }
.notification-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem; margin-top: .45rem; }
.notification-grid label { color: #66543e; font-size: .52rem; font-weight: 800; }
.codex-grid { display: grid; gap: .28rem; margin-top: .45rem; }
.codex-grid article { display: grid; grid-template-columns: 1fr auto; gap: .2rem .4rem; color: #5e513e; font-size: .51rem; }
.codex-grid strong { color: #3d523d; }
.codex-grid i { grid-column: 1 / -1; overflow: hidden; height: 6px; border-radius: 999px; background: #d4c7a1; }
.codex-grid i b { display: block; height: 100%; border-radius: inherit; background: #729654; }
.codex-section .codex-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.codex-section .codex-grid article { padding: .34rem; border: 1px solid #af9668; border-radius: 5px; background: #eee4be; }
.codex-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .28rem; }
.codex-tabs button { display: grid; grid-template-columns: 1fr auto; gap: .08rem .24rem; min-height: 46px; padding: .3rem .4rem; border: 1px solid #9b7b52; border-radius: 5px; background: #f1e5bc; color: #4d593f; font-size: .47rem; font-weight: 850; text-align: left; }
.codex-tabs button strong { color: #406442; text-align: right; }
.codex-tabs button small { grid-column: 1 / -1; color: #876c50; font-size: .39rem; }
.codex-tabs button.is-active { border-color: #4d7749; box-shadow: inset 0 0 0 1px #6e955e; background: #dfe8b6; }
.codex-category-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .42rem .5rem; border-left: 4px solid #6d8f57; background: #f5edcf; }
.codex-category-heading > div { display: grid; gap: .08rem; }
.codex-category-heading strong { color: #42533d; font-size: .58rem; }
.codex-category-heading span { color: #7a654c; font-size: .43rem; }
.codex-category-heading > b { color: #4d7549; font-size: .68rem; }
.codex-entry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .32rem; }
.codex-entry-card { display: grid; gap: .23rem; min-width: 0; padding: .42rem .48rem; border: 1px solid #a98c61; border-radius: 6px; background: linear-gradient(150deg, #fff7d9, #e9dfb8); }
.codex-entry-card header,
.codex-entry-card > div { display: flex; justify-content: space-between; gap: .35rem; }
.codex-entry-card header strong { overflow-wrap: anywhere; color: #3f523d; font-size: .54rem; }
.codex-entry-card header span { color: #7f603d; font-size: .45rem; font-weight: 900; white-space: nowrap; }
.codex-entry-card > div { color: #756149; font-size: .41rem; }
.codex-entry-card > div b { color: #4d7549; }
.codex-entry-card > small { overflow-wrap: anywhere; padding-top: .18rem; border-top: 1px dashed #c3a97a; color: #856b4e; font-size: .39rem; line-height: 1.4; }
.stock-detail-grid .price-stage-label { color: #6d573b; font-weight: 850; }
.stock-detail-grid .price-stage-label.is-final { padding-top: .32rem; border-top: 1px solid #a9895d; color: #38503b; }
.stock-detail-grid .price-final { padding-top: .32rem; border-top: 1px solid #a9895d; color: #2f7040; font-size: .84rem; }
.empty-management-state { grid-column: 1 / -1; padding: 1rem; border: 1px dashed #a27c52; border-radius: 7px; color: #77634b; text-align: center; font-size: .67rem; }
.help-modal { width: min(calc(100vw - 2rem), 720px); }
.help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: 1rem 0; }
.help-grid article { position: relative; padding: .75rem .75rem .75rem 2.65rem; border: 1px solid #b98d58; border-radius: 5px; background: rgba(255,255,255,.4); }
.step-number { position: absolute; left: .7rem; top: .8rem; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: #537843; color: white; font-size: .7rem; font-weight: 900; }
.help-grid h3 { margin: 0; color: #3b4c34; font-size: .79rem; }
.help-grid p { margin: .3rem 0 0; color: #746249; font-size: .66rem; line-height: 1.45; }
.controls-table { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; padding: .7rem; border: 2px solid #9a7148; border-radius: 5px; background: #f7e5bb; font-size: .7rem; }
.controls-table span { color: #776146; }
.controls-table b { color: #3c4934; }
.full-button { width: 100%; margin-top: 1rem; }
.pause-modal,
.rename-modal,
.dialog-modal { text-align: center; }
.pause-actions { display: grid; gap: .65rem; margin: 1.2rem 0; }
.pause-modal > p { margin-bottom: 0; }
.pause-modal > p b { color: #4c6841; }
.danger-button { color: var(--danger); }
.rename-modal .name-field { margin-top: 1rem; }

/* Feedback and touch */
.toast-stack {
  position: fixed;
  z-index: 110;
  left: 50%;
  top: max(78px, calc(env(safe-area-inset-top) + 68px));
  bottom: auto;
  display: flex;
  justify-content: center;
  width: min(calc(100vw - 24px), 540px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  max-width: 100%;
  padding: .52rem .85rem;
  border: 2px solid #755036;
  border-radius: 999px;
  background: rgba(255,246,214,.94);
  color: #493a2a;
  font-size: .72rem;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 3px 0 rgba(36,25,17,.54), 0 7px 18px rgba(11,19,13,.26);
  backdrop-filter: blur(4px);
  animation: toast-in .22s ease both;
}
.toast.success { border-color: #4e713f; color: #365336; }
.toast.warning { border-color: #b25c35; color: #814328; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }
.toast.is-leaving { animation: toast-out .16s ease forwards; }
.touch-controls { display: none; }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 1fr auto; }
  .day-strip { grid-column: 1 / -1; grid-row: 2; justify-self: center; padding: .25rem 0; }
  .game-layout { grid-template-columns: minmax(0,1fr) 280px; }
  .tool-slot { grid-template-columns: 30px; justify-items: center; min-width: 64px; }
  .tool-slot > span:last-of-type { display: none; }
}

@media (max-width: 820px) {
  .topbar { position: static; }
  .farm-mark-leaf, .energy-item { display: none; }
  .resource-item { padding: .3rem .45rem; }
  .game-screen { padding-bottom: calc(174px + env(safe-area-inset-bottom)); }
  .game-layout { display: flex; flex-direction: column; padding: .55rem; }
  .side-panel { grid-template-columns: 1fr 1fr; }
  .guide-card, .inspect-card { min-height: 150px; }
  .help-button { grid-column: 1 / -1; }
  .toolbar-wrap { flex-direction: column; gap: .45rem; margin-bottom: .5rem; }
  .toolbar { max-width: 100%; }
  .touch-controls {
    position: fixed;
    z-index: 45;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: .45rem max(.75rem, env(safe-area-inset-right)) calc(.55rem + env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
    border-top: 3px solid #70482f;
    background: linear-gradient(rgba(29,48,37,.94), rgba(19,37,27,.98));
    box-shadow: 0 -8px 24px rgba(10,25,16,.3);
  }
  .dpad { display: grid; grid-template: repeat(3, 48px) / repeat(3, 48px); gap: 4px; }
  .dpad button, .touch-action, .touch-seed-cycle { border: 2px solid #8d6a45; background: #f2d79c; color: #4d3b2c; font-weight: 900; box-shadow: 0 3px 0 #452f21; touch-action: none; }
  .dpad button[data-direction="up"] { grid-column: 2; }
  .dpad button[data-direction="left"] { grid-row: 2; grid-column: 1; }
  .dpad button[data-direction="down"] { grid-row: 2; grid-column: 2; }
  .dpad button[data-direction="right"] { grid-row: 2; grid-column: 3; }
  .touch-action { width: 76px; height: 76px; border-radius: 50%; }
  .touch-action-stack { display: grid; justify-items: center; gap: .55rem; }
  .touch-seed-cycle { min-width: 88px; min-height: 38px; padding: .35rem .55rem; border-radius: 999px; font-size: .7rem; }
}

@media (max-width: 560px) {
  .topbar { min-height: auto; padding: .4rem .5rem; }
  .farm-mark small { display: none; }
  .farm-mark strong { max-width: 110px; overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
  .day-strip { gap: .35rem; font-size: .68rem; }
  .strip-divider, #weatherLabel { display: none; }
  .cash-item { font-size: .72rem; }
  .canvas-frame { border-width: 3px; }
  .side-panel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .panel-card { flex: 0 0 min(82vw, 300px); scroll-snap-align: start; }
  .help-button { flex: 0 0 220px; }
  .toolbar {
    width: 100%;
    justify-content: flex-start;
    gap: .25rem;
    overflow-x: auto;
    padding: .45rem;
    scrollbar-width: thin;
  }
  .tool-slot { flex: 0 0 54px; min-width: 54px; width: 54px; padding: .25rem; }
  .seed-cycle-hint { display: none; }
  .shop-grid,
  .build-grid { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
  .title-actions, .modal-actions { grid-template-columns: 1fr; }
  .title-version { display: none; }
}

.multiplayer-connection-blocker {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 31, 25, .68);
  backdrop-filter: blur(8px);
}

.multiplayer-connection-card {
  width: min(430px, calc(100vw - 32px));
  padding: 30px;
  border: 2px solid #6f472a;
  border-radius: 18px;
  background: linear-gradient(155deg, #fff5d5, #ead09b);
  color: #44301f;
  text-align: center;
  box-shadow: 0 24px 70px rgba(9, 16, 12, .46), inset 0 0 0 2px rgba(255,255,255,.42);
}

.multiplayer-connection-card h2 { margin: 8px 0 10px; }
.multiplayer-connection-card p { margin: 0 0 20px; line-height: 1.65; }
.multiplayer-connection-spinner {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 4px solid rgba(57, 97, 61, .22);
  border-top-color: #3d6b43;
  border-radius: 50%;
  animation: multiplayer-connection-spin .8s linear infinite;
}

@keyframes multiplayer-connection-spin { to { transform: rotate(360deg); } }

@media (pointer: fine) and (min-width: 821px) {
  .touch-controls { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------------------------
   Multiplayer entry and compact room HUD · v1.1
   -------------------------------------------------------------------------- */

.title-screen {
  overflow-x: hidden;
  overflow-y: auto;
  padding-block: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-bottom));
}

.title-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 1rem 0 .9rem;
  padding: 4px;
  border: 2px solid #8d633f;
  border-radius: 8px;
  background: rgba(111, 74, 43, .14);
  box-shadow: inset 0 1px 3px rgba(62, 40, 23, .16);
}

.title-mode-button {
  min-height: 44px;
  padding: .58rem .75rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #765437;
  font-size: .82rem;
  font-weight: 950;
  letter-spacing: -.01em;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.title-mode-button:not([aria-pressed="true"]):hover {
  background: rgba(255, 250, 226, .58);
  color: #3f5e3b;
}

.title-mode-button[aria-pressed="true"],
.title-mode-button.is-active {
  background: linear-gradient(#668f4e, #416d3e);
  color: #fff8df;
  box-shadow: inset 0 1px rgba(255,255,255,.24), 0 3px 0 #2f4e30;
  text-shadow: 0 1px #29452b;
}

.title-mode-button:active { transform: translateY(1px); }

.title-start-panel {
  display: grid;
  gap: .72rem;
}

.multiplayer-start-panel {
  padding: .85rem;
  border: 1px solid rgba(139, 94, 54, .55);
  border-radius: 7px;
  background: rgba(255, 250, 232, .38);
  box-shadow: inset 0 1px rgba(255,255,255,.55);
}

.multiplayer-panel-copy {
  margin: 0;
  color: #6d5a40;
  font-size: .75rem;
  font-weight: 750;
  line-height: 1.5;
  text-align: left;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.multiplayer-auth-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .68rem;
  min-height: 58px;
  padding: .62rem .68rem;
  border: 1px solid rgba(113, 78, 43, .4);
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(255, 252, 232, .88), rgba(241, 226, 184, .74));
  box-shadow: inset 0 1px rgba(255,255,255,.72), 0 4px 12px rgba(75, 52, 30, .08);
  text-align: left;
}

.multiplayer-auth-mark {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 2px solid #d0a85a;
  border-radius: 50%;
  background: #f5d88d;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.4);
}

.multiplayer-auth-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  width: 9px;
  height: 12px;
  border-right: 3px solid #715d39;
  border-bottom: 3px solid #715d39;
  transform: rotate(40deg);
  opacity: 0;
}

.multiplayer-auth-card[data-state="loading"] .multiplayer-auth-mark {
  border-top-color: transparent;
  animation: multiplayer-auth-spin .8s linear infinite;
}

.multiplayer-auth-card[data-state="signed-in"] .multiplayer-auth-mark {
  border-color: #5b844c;
  background: #d9e8b2;
}

.multiplayer-auth-card[data-state="signed-in"] .multiplayer-auth-mark::after { opacity: 1; }

.multiplayer-auth-card[data-state="signed-out"] .multiplayer-auth-mark,
.multiplayer-auth-card[data-state="error"] .multiplayer-auth-mark {
  border-color: #b77855;
  background: #f1c9a3;
}

@keyframes multiplayer-auth-spin { to { transform: rotate(360deg); } }

.multiplayer-auth-copy {
  display: grid;
  min-width: 0;
  gap: .12rem;
}

.multiplayer-auth-copy small {
  color: #806542;
  font-size: .58rem;
  font-weight: 900;
  letter-spacing: .035em;
}

.multiplayer-auth-copy strong {
  unicode-bidi: isolate;
  overflow: hidden;
  color: #3c5439;
  font-size: .78rem;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiplayer-auth-links { display: flex; gap: .35rem; }

.multiplayer-auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: .35rem .58rem;
  border: 1px solid rgba(111, 75, 39, .45);
  border-radius: 5px;
  background: rgba(255, 250, 226, .84);
  color: #76502d;
  font-size: .62rem;
  font-weight: 950;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.multiplayer-auth-link:hover {
  border-color: #66844f;
  background: #fff9dc;
  color: #405f3c;
}

.multiplayer-auth-link:active { transform: translateY(1px); }
.multiplayer-auth-link:focus-visible { outline: 3px solid rgba(73, 112, 67, .38); outline-offset: 2px; }

.multiplayer-actions > button:disabled {
  cursor: not-allowed;
  filter: saturate(.45);
  opacity: .62;
}

.multiplayer-actions > button[aria-busy="true"] { cursor: progress; }

.multiplayer-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .65rem;
}

.multiplayer-actions > button {
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.multiplayer-lobby-status {
  min-height: 2.2em;
  margin: 0;
  color: #55704b;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.multiplayer-lobby-status[data-state="error"] { color: #a23e34; }
.multiplayer-lobby-status[data-state="connecting"] { color: #8a642d; }

.multiplayer-back-button {
  justify-self: center;
  min-height: 32px;
  padding: .32rem .65rem;
}

/* Keep the shared-world state inside the existing top HUD instead of opening a panel. */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
}

.hud-cluster-left { justify-self: start; }
.resource-strip { justify-self: end; }

.multiplayer-hud {
  justify-self: center;
  gap: 8px;
  max-width: min(30vw, 300px);
  min-height: 54px;
  padding-inline: 10px;
  white-space: nowrap;
}

.multiplayer-connection-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border: 2px solid #321f15;
  border-radius: 50%;
  background: #d8a346;
  box-shadow: 0 0 0 2px rgba(255, 215, 128, .14), 0 0 8px rgba(218, 167, 69, .5);
}

.multiplayer-connection-dot[data-state="connected"],
.multiplayer-connection-dot[data-state="online"] {
  background: #79c75a;
  box-shadow: 0 0 0 2px rgba(173, 234, 117, .16), 0 0 9px rgba(104, 205, 81, .65);
}

.multiplayer-connection-dot[data-state="connecting"],
.multiplayer-connection-dot[data-state="reconnecting"] {
  animation: multiplayer-connection-pulse 1.15s ease-in-out infinite alternate;
}

.multiplayer-connection-dot[data-state="offline"],
.multiplayer-connection-dot[data-state="error"] {
  background: #d95d4c;
  box-shadow: 0 0 0 2px rgba(235, 110, 87, .14), 0 0 8px rgba(219, 80, 65, .48);
}

@keyframes multiplayer-connection-pulse {
  from { opacity: .55; transform: scale(.88); }
  to { opacity: 1; transform: scale(1.08); }
}

.multiplayer-hud-copy {
  display: grid;
  min-width: 0;
  text-align: left;
}

.multiplayer-hud-copy small {
  color: #dba959;
  font-size: .52rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.multiplayer-hud-copy strong {
  overflow: hidden;
  max-width: 116px;
  color: #fff1c5;
  font-size: .7rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  text-shadow: 0 1px #21140e;
}

.multiplayer-players-label {
  flex: 0 0 auto;
  padding: .24rem .42rem;
  border: 1px solid rgba(219, 176, 100, .48);
  border-radius: 999px;
  background: rgba(19, 13, 10, .3);
  color: #f5dfad;
  font-size: .62rem;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
  }

  .hud-cluster-left { grid-column: 1; grid-row: 1; }
  .resource-strip { grid-column: 2; grid-row: 1; }
  .multiplayer-hud {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: min(360px, calc(100vw - 24px));
    min-height: 42px;
    padding-block: 3px;
  }
}

@media (max-width: 560px) {
  .title-screen { place-items: start center; }
  .title-card {
    width: calc(100vw - 24px);
    margin: 0 auto;
    padding: 1.15rem;
  }

  .title-copy { margin: .75rem auto 1rem; }
  .title-mode-switch { margin-block: .78rem; }
  .title-mode-button { min-height: 42px; padding-inline: .4rem; }
  .multiplayer-start-panel { padding: .7rem; }
  .multiplayer-actions { grid-template-columns: 1fr; }

  .multiplayer-auth-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .multiplayer-auth-links {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .multiplayer-auth-link { flex: 1; }

  .multiplayer-hud {
    gap: 6px;
    min-height: 38px;
    padding-inline: 7px;
  }

  .multiplayer-hud-copy small { display: none; }
  .multiplayer-hud-copy strong { max-width: 98px; font-size: .64rem; }
  .multiplayer-players-label { padding-inline: .36rem; }
}

@media (max-height: 720px) {
  .title-screen { place-items: start center; }
  .title-card { margin-block: 0; }
  .title-card h1 { font-size: clamp(2.65rem, 11vh, 4.3rem); }
}

/* --------------------------------------------------------------------------
   Full-screen game presentation
   The world owns the viewport; information appears only as compact HUD layers.
   -------------------------------------------------------------------------- */

:root {
  --hud-wood-1: rgba(76, 48, 29, .94);
  --hud-wood-2: rgba(39, 26, 19, .96);
  --hud-edge: #d5a35a;
  --hud-edge-dark: #3a2418;
  --hud-paper: #f7e7bc;
  --hud-paper-deep: #d7ac68;
  --hud-glow: rgba(255, 224, 143, .2);
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

.game-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #101913;
  isolation: isolate;
}

.game-layout,
.play-column,
.canvas-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.game-layout {
  display: block;
  max-width: none;
}

.play-column {
  display: block;
}

.canvas-frame {
  overflow: hidden;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  background: #365b3a;
  box-shadow: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #456f3d;
  image-rendering: auto;
  cursor: crosshair;
}

#gameCanvas:active { cursor: grabbing; }

.canvas-shade {
  z-index: 5;
  box-shadow:
    inset 0 0 0 1px rgba(255, 246, 203, .06),
    inset 0 0 7rem rgba(12, 25, 15, .23);
  background:
    linear-gradient(180deg, rgba(9, 18, 12, .12), transparent 12%, transparent 78%, rgba(8, 14, 10, .15)),
    radial-gradient(ellipse at center, transparent 58%, rgba(9, 15, 11, .12));
}

/* Floating HUD */
.topbar {
  position: absolute;
  z-index: 30;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
}

.hud-cluster {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 6px;
  border: 3px solid var(--hud-edge-dark);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 16%),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(255,255,255,.025) 42px 43px),
    linear-gradient(180deg, var(--hud-wood-1), var(--hud-wood-2));
  color: #fff4d3;
  box-shadow:
    0 0 0 2px rgba(216, 167, 91, .82),
    inset 0 0 0 1px rgba(255, 229, 164, .12),
    inset 0 -5px rgba(23, 14, 10, .22),
    0 8px 22px rgba(8, 14, 10, .38);
  backdrop-filter: blur(7px);
  pointer-events: auto;
}

.hud-cluster::before,
.hud-cluster::after {
  content: "";
  position: absolute;
  top: 5px;
  width: 3px;
  height: 3px;
  border: 1px solid #4d301e;
  background: #e0b45f;
  box-shadow: inset 1px 1px rgba(255,255,255,.35);
}

.hud-cluster::before { left: 5px; }
.hud-cluster::after { right: 5px; }

.hud-cluster-left { gap: 6px; }

.farm-mark {
  min-height: 38px;
  gap: .55rem;
  padding: .2rem .58rem .2rem .3rem;
  border: 0;
  border-right: 1px solid rgba(235, 194, 120, .3);
  border-radius: 2px;
  color: #fff4d5;
}

.farm-mark:hover { background: rgba(255, 238, 190, .1); }

.farm-mark small {
  color: #e1ad5b;
  font-size: .56rem;
  letter-spacing: .13em;
  text-shadow: 0 1px #27170f;
}

.farm-mark strong {
  max-width: 170px;
  overflow: hidden;
  color: #fff2ca;
  font-size: .9rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-shadow: 0 2px #27170f;
  white-space: nowrap;
}

.farm-mark-leaf {
  width: 35px;
  height: 35px;
  border: 2px solid #2c1b12;
  border-radius: 3px;
  background: linear-gradient(135deg, #e8ca7e, #b68545);
  box-shadow: inset 0 0 0 2px rgba(255,247,202,.28), 0 2px #22150e;
}

.farm-mark-leaf::before,
.farm-mark-leaf::after { background: #507f43; box-shadow: 1px 1px #294f32; }

.day-strip {
  gap: .48rem;
  padding: 0 .55rem 0 .2rem;
  color: #f4e3ba;
  font-size: .74rem;
  text-shadow: 0 1px #24160f;
}

.season-chip {
  padding: .28rem .48rem;
  border: 1px solid #b5d179;
  border-radius: 3px;
  background: linear-gradient(#668f4c, #3c6a3b);
  color: #fff7d9;
  box-shadow: inset 0 1px rgba(255,255,255,.2), 0 2px #24170f;
}

.strip-divider { background: rgba(244, 218, 159, .3); }
.weather-mark { color: #ffc85b; filter: drop-shadow(0 1px #5a3418); }
#timeLabel { color: #fff0ba; text-align: right; }

.resource-strip {
  justify-self: auto;
  gap: 6px;
}

.resource-item {
  min-height: 38px;
  padding: .35rem .62rem;
  border: 1px solid rgba(231, 194, 126, .44);
  border-radius: 3px;
  background: rgba(24, 17, 13, .32);
  color: #fff0c6;
  font-size: .78rem;
  text-shadow: 0 1px #23150e;
  box-shadow: inset 0 1px rgba(255,255,255,.04);
}

.coin-dot {
  border-color: #6e4019;
  background: #f2ba42;
  box-shadow: inset 2px 2px #ffe48b, 0 1px #1f130d;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .38rem;
  width: auto;
  min-width: 40px;
  height: 38px;
  padding: 0 .62rem;
  border: 2px solid #2b1a11;
  border-radius: 3px;
  background: linear-gradient(#f0d699, #c4914d);
  color: #47301f;
  font-size: .72rem;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px rgba(255,251,217,.42), 0 2px #1f140e;
  text-shadow: 0 1px rgba(255,255,255,.32);
}

.icon-button:hover {
  background: linear-gradient(#ffe8ad, #d8a75b);
  transform: translateY(-1px);
}

.icon-button:active { transform: translateY(1px); box-shadow: inset 0 1px rgba(58,34,20,.2); }

.journal-glyph {
  position: relative;
  width: 15px;
  height: 18px;
  border: 2px solid #4a3020;
  border-radius: 2px;
  background: #fff0bd;
  box-shadow: inset 3px 0 #c65e3b;
}

.journal-glyph::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 2px;
  width: 6px;
  height: 2px;
  background: #9e7549;
  box-shadow: 0 4px #9e7549;
}

.pause-button { font-family: Georgia, serif; font-size: .88rem; }

.save-indicator {
  z-index: 24;
  top: 78px;
  right: max(18px, env(safe-area-inset-right));
  padding: .38rem .56rem;
  border: 2px solid rgba(208, 165, 89, .62);
  border-radius: 3px;
  background: rgba(34, 26, 19, .84);
  color: #f7e6bd;
  box-shadow: 0 4px 12px rgba(6,12,8,.26);
}

.day-banner { z-index: 40; backdrop-filter: blur(2px); }

.context-prompt {
  position: absolute;
  z-index: 25;
  bottom: max(104px, calc(env(safe-area-inset-bottom) + 96px));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 9px 11px 9px 15px;
  border: 2px solid rgba(226, 181, 96, .84);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(48, 35, 25, .94), rgba(29, 24, 19, .94));
  color: #fff0c7;
  box-shadow: 0 5px 0 rgba(23, 14, 10, .7), 0 10px 24px rgba(5, 11, 7, .32), inset 0 1px rgba(255, 244, 203, .12);
  transform: translateX(-50%);
  pointer-events: none;
}

.context-prompt > strong {
  overflow: hidden;
  font-size: clamp(.72rem, 1.05vw, .9rem);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-prompt-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: #e7c98e;
  font-size: clamp(.64rem, .9vw, .76rem);
  font-weight: 850;
  white-space: nowrap;
}

.context-prompt-action kbd {
  min-width: 25px;
  padding: 2px 6px 3px;
  border: 1px solid #ad7d48;
  border-bottom-width: 3px;
  border-radius: 4px;
  background: #fff0c2;
  color: #3f2c20;
  font: 900 .68rem/1 system-ui, sans-serif;
  text-align: center;
}

.context-touch-key {
  display: none;
  min-width: 34px;
  padding: 3px 7px;
  border: 1px solid #ad7d48;
  border-radius: 999px;
  background: #fff0c2;
  color: #3f2c20;
  font-size: .62rem;
  font-weight: 950;
  line-height: 1;
  justify-content: center;
}

@media (pointer: coarse) {
  .context-keyboard-key { display: none; }
  .context-touch-key { display: inline-flex; }
}

/* Four-slot quickbar */
.toolbar-wrap {
  position: absolute;
  z-index: 26;
  right: auto;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
  left: 50%;
  display: block;
  margin: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.toolbar {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 6px;
  overflow: visible;
  border: 3px solid #301d13;
  border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(255,255,255,.035) 47px 48px),
    linear-gradient(#71482d, #40291c);
  box-shadow:
    0 0 0 2px rgba(214, 160, 78, .86),
    inset 0 0 0 1px rgba(255,227,164,.12),
    inset 0 -5px rgba(24,14,10,.24),
    0 8px 22px rgba(5,11,7,.46);
  pointer-events: auto;
}

.toolbar::before,
.toolbar::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 3px;
  height: 3px;
  background: #d8a759;
  box-shadow: 0 0 0 1px #332016;
}

.toolbar::before { left: 3px; }
.toolbar::after { right: 3px; }

.tool-slot {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  place-items: center;
  padding: 0;
  border: 2px solid #62462f;
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.36), transparent 38%),
    linear-gradient(#f2dda9, #ca9c60);
  color: #3c2b1e;
  box-shadow: inset 0 0 0 1px rgba(255,247,208,.55), inset 0 -4px rgba(93,55,31,.12);
  transition: transform .13s ease, filter .13s ease, box-shadow .13s ease;
}

.tool-slot:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, rgba(255,255,255,.48), transparent 38%), linear-gradient(#f8e8bb, #d3aa70);
}

.tool-slot.is-selected {
  z-index: 2;
  border-color: #243a27;
  background:
    linear-gradient(135deg, rgba(255,255,255,.16), transparent 40%),
    linear-gradient(#5d8d4d, #365d3b);
  color: #fff5d6;
  box-shadow:
    0 0 0 2px #f4cf70,
    0 0 0 4px #2a1a12,
    inset 0 0 0 1px rgba(255,255,255,.12),
    0 6px 12px rgba(9,15,10,.28);
  transform: translateY(-5px);
}

.tool-slot kbd {
  top: 2px;
  left: 2px;
  min-width: 16px;
  min-height: 16px;
  padding: 0;
  border-radius: 2px;
  font-size: .54rem;
}

.tool-slot .tool-pixel {
  width: 32px;
  height: 32px;
  filter: drop-shadow(1px 2px rgba(52, 34, 22, .26));
  transform: scale(1.06);
}

.smart-tool-pixel::before,
.smart-tool-pixel::after {
  transition: background-color .12s ease, border-color .12s ease, transform .12s ease;
}

.work-pixel::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 4px;
  width: 4px;
  height: 25px;
  border-radius: 2px;
  background: linear-gradient(90deg, #563721, #9a6035 55%, #6a4229);
  box-shadow: 1px 0 #382419;
  transform: rotate(30deg);
}

.work-pixel::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 19px;
  height: 8px;
  border: 2px solid #3f4947;
  border-radius: 55% 20% 45% 18%;
  background: linear-gradient(135deg, #b8c4be, #71817e 58%, #56635f);
  clip-path: polygon(0 28%, 40% 0, 100% 18%, 86% 74%, 48% 46%, 12% 100%);
  transform: rotate(8deg);
}

.tool-slot > span:last-of-type {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  display: block;
  width: max-content;
  max-width: 130px;
  padding: .27rem .48rem;
  overflow: hidden;
  border: 2px solid #2c1c13;
  border-radius: 3px;
  background: rgba(43, 29, 20, .94);
  color: #fff0c5;
  font-size: .66rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(220, 173, 92, .62), 0 4px 10px rgba(9,14,10,.3);
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity .13s ease, transform .13s ease;
  pointer-events: none;
}

.tool-slot.is-selected > span:last-of-type {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tool-slot b {
  right: 2px;
  bottom: 2px;
  display: none;
  min-width: 19px;
  padding: 2px 3px;
  border: 1px solid rgba(45,28,18,.7);
  border-radius: 2px;
  background: rgba(255,244,210,.9);
  color: #493321;
  font-size: .55rem;
  line-height: 1;
  text-align: center;
  text-shadow: none;
}

.tool-slot.is-selected b { display: block; }
.seed-cycle-hint { display: none; }

/* Farm journal: the former dashboard lives here, away from normal play. */
.journal-modal {
  width: min(calc(100vw - 48px), 1120px);
  max-height: min(calc(100dvh - 48px), 820px);
  padding: 20px;
  overflow: auto;
  border: 3px solid #2d1c13;
  border-radius: 5px;
  background:
    repeating-linear-gradient(90deg, transparent 0 74px, rgba(255,255,255,.022) 74px 75px),
    linear-gradient(145deg, #624027, #332117 68%, #271a13);
  box-shadow:
    0 0 0 3px #c9944d,
    0 0 0 5px rgba(40, 24, 15, .82),
    inset 0 0 0 1px rgba(255,226,157,.13),
    inset 0 -9px rgba(20,12,9,.18),
    0 24px 70px rgba(4, 9, 6, .7);
  scrollbar-color: #a87543 #2f2018;
}

.journal-header {
  align-items: center;
  margin: 0 2px 15px;
  padding: 3px 2px 14px;
  border-bottom: 2px solid rgba(222, 177, 96, .46);
}

.journal-header h2 {
  color: #fff0c5;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  text-shadow: 0 2px #20130d;
}

.journal-header .modal-eyebrow { color: #e3af58; }

.journal-modal .modal-close {
  border-color: #291910;
  background: linear-gradient(#f1db9e, #c3924f);
  color: #4a2e1d;
  box-shadow: inset 0 0 0 1px rgba(255,248,212,.44), 0 3px #1e130d;
}

.journal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.journal-modal .panel-card {
  position: relative;
  min-height: 202px;
  padding: 16px;
  overflow: hidden;
  border: 3px solid #5b3a27;
  border-radius: 4px;
  background:
    linear-gradient(rgba(255,255,255,.16), transparent 28%),
    repeating-linear-gradient(0deg, transparent 0 13px, rgba(103,69,38,.025) 13px 14px),
    linear-gradient(145deg, #fff0c4, #e0bb78);
  box-shadow:
    0 0 0 1px #dcae67,
    inset 0 0 0 1px rgba(255,252,225,.62),
    inset 0 -6px rgba(127,78,38,.08),
    0 6px 0 rgba(25,15,10,.28);
}

.journal-modal .panel-card::before,
.journal-modal .panel-card::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border: 1px solid #78502f;
  border-radius: 50%;
  background: #c9914d;
  box-shadow: inset 1px 1px rgba(255,255,255,.35);
}

.journal-modal .panel-card::before { top: 7px; left: 7px; }
.journal-modal .panel-card::after { right: 7px; bottom: 7px; }

.journal-modal .panel-heading h2,
.journal-modal .panel-title-row h2 {
  color: #344631;
  font-size: 1rem;
}

.journal-modal .panel-heading small { color: #a14f30; }
.journal-modal .guide-card > p { margin: 1rem 0 .8rem; font-size: .78rem; }
.journal-modal .progress-track { height: 9px; }
.journal-modal .inspect-empty { min-height: 115px; justify-content: center; }
.journal-modal .inspect-empty p { font-size: .75rem; }
.journal-modal .market-headline { margin: 1rem 0; font-size: .86rem; }
.journal-modal .inventory-list { margin-top: 1rem; }

.inventory-heading { align-items: flex-start; }
.journal-card-actions { display: flex; align-items: center; gap: .4rem; }

.journal-card-actions .text-button {
  padding: .38rem .52rem;
  border: 1px solid #815839;
  border-radius: 3px;
  background: rgba(255, 249, 220, .45);
  color: #755033;
  text-decoration: none;
  box-shadow: inset 0 1px rgba(255,255,255,.4);
}

.journal-card-actions .text-button:hover { background: #fff4cc; color: #3e633c; }

.journal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 2px;
}

.journal-footer .help-button,
.journal-footer .journal-return {
  width: auto;
  min-height: 42px;
  margin: 0;
}

.journal-footer .help-button {
  border-color: #24170f;
  background: linear-gradient(#68452d, #3c281c);
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 3px #1d120c;
}

.journal-return { padding-inline: 1.4rem; }

/* Other menus share the same intentional pixel-paper finish. */
.modal:not(.journal-modal) {
  border-width: 3px;
  border-radius: 5px;
  background:
    repeating-linear-gradient(0deg, transparent 0 13px, rgba(100,67,36,.025) 13px 14px),
    linear-gradient(#fff2c9, #ddb36d);
  box-shadow:
    0 0 0 3px rgba(87,55,34,.96),
    0 0 0 5px rgba(222,172,88,.62),
    inset 0 0 0 1px rgba(255,255,255,.58),
    0 22px 60px rgba(6,13,8,.6);
}

.modal-backdrop {
  background:
    radial-gradient(circle at 50% 45%, rgba(57, 81, 52, .16), transparent 40%),
    rgba(10, 17, 12, .76);
  backdrop-filter: blur(6px) saturate(.78);
}

.toast-stack { top: max(78px, calc(env(safe-area-inset-top) + 68px)); bottom: auto; }

/* Touch controls float over the world instead of reserving a lower dashboard. */
@media (max-width: 820px), (pointer: coarse) {
  .game-screen { padding: 0; }

  .topbar {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    align-items: flex-start;
  }

  .hud-cluster { min-height: 45px; padding: 4px; }
  .farm-mark { min-height: 33px; padding-right: .35rem; }
  .farm-mark-leaf { width: 29px; height: 29px; }
  .farm-mark small { display: none; }
  .farm-mark strong { max-width: 112px; font-size: .74rem; }
  .day-strip { gap: .32rem; padding-inline: .2rem .35rem; font-size: .64rem; }
  .strip-divider,
  #weatherLabel { display: none; }
  .season-chip { padding: .23rem .34rem; font-size: .62rem; }
  #timeLabel { min-width: 2.8rem; }

  .resource-strip { gap: 3px; }
  .resource-item { min-height: 33px; padding: .25rem .4rem; font-size: .67rem; }
  .icon-button { min-width: 34px; height: 33px; padding-inline: .42rem; }
  .journal-button .button-label { display: none; }
  .journal-glyph { width: 13px; height: 16px; }

  .toolbar-wrap {
    bottom: max(118px, calc(env(safe-area-inset-bottom) + 108px));
  }

  .context-prompt {
    bottom: max(178px, calc(env(safe-area-inset-bottom) + 168px));
    gap: 8px;
    max-width: calc(100vw - 24px);
    padding: 7px 9px 7px 11px;
  }

  .toolbar {
    width: auto;
    max-width: calc(100vw - 20px);
    justify-content: center;
    gap: 3px;
    overflow: visible;
    padding: 5px;
  }

  .tool-slot {
    flex: 0 0 46px;
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
  }

  .tool-slot .tool-pixel { transform: scale(.92); }
  .tool-slot > span:last-of-type { font-size: .61rem; }

  .touch-controls {
    position: fixed;
    z-index: 45;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    pointer-events: none;
  }

  .dpad,
  .touch-action-stack { pointer-events: auto; }

  .dpad {
    display: grid;
    grid-template: repeat(3, 43px) / repeat(3, 43px);
    gap: 3px;
    filter: drop-shadow(0 6px 10px rgba(5,11,7,.36));
  }

  .dpad button,
  .touch-action,
  .touch-seed-cycle {
    border: 2px solid #2a1a12;
    border-radius: 3px;
    background: linear-gradient(rgba(246,218,157,.92), rgba(181,128,68,.94));
    color: #47301f;
    box-shadow: inset 0 0 0 1px rgba(255,247,208,.34), 0 2px #1d120c;
    backdrop-filter: blur(4px);
    touch-action: none;
  }

  .dpad button[data-direction="up"] { grid-column: 2; }
  .dpad button[data-direction="left"] { grid-row: 2; grid-column: 1; }
  .dpad button[data-direction="down"] { grid-row: 2; grid-column: 2; }
  .dpad button[data-direction="right"] { grid-row: 2; grid-column: 3; }
  .touch-action { width: 68px; height: 68px; border-radius: 50%; }
  .touch-action-stack { display: grid; justify-items: center; gap: .45rem; }
  .touch-seed-cycle { min-width: 82px; min-height: 34px; padding: .3rem .5rem; font-size: .64rem; }

  .journal-modal {
    width: min(calc(100vw - 20px), 720px);
    max-height: calc(100dvh - 20px);
    padding: 14px;
  }

  .journal-grid { grid-template-columns: 1fr; }
  .journal-modal .panel-card { min-height: 180px; }
  .journal-footer { position: sticky; bottom: -14px; padding: 12px 0 2px; background: linear-gradient(transparent, #332117 25%); }
}

@media (max-width: 620px) {
  .hud-cluster-left { max-width: calc(100vw - 145px); }
  .farm-mark-leaf { display: none; }
  .farm-mark { border-right: 0; }
  .farm-mark strong { max-width: 88px; }
  .day-strip { position: absolute; top: 46px; left: 0; padding: 5px 7px; border: 2px solid #2d1c13; border-radius: 3px; background: rgba(46,30,21,.88); box-shadow: 0 0 0 1px rgba(211,157,79,.64); }
  #dateLabel { display: none; }
  .energy-item { display: none; }

  .toolbar { gap: 2px; padding: 4px; }
  .tool-slot {
    flex-basis: min(44px, calc((100vw - 52px) / 4));
    width: min(44px, calc((100vw - 52px) / 4));
    min-width: min(44px, calc((100vw - 52px) / 4));
    height: 44px;
    min-height: 44px;
  }
  .tool-slot .tool-pixel { transform: scale(.82); }

  .journal-header h2 { font-size: 1.22rem; }
  .journal-modal .panel-card { padding: 13px; }
  .journal-footer { flex-direction: column; }
  .journal-footer .help-button,
  .journal-footer .journal-return { width: 100%; }

  .shop-grid,
  .build-grid,
  .help-grid { grid-template-columns: 1fr; }

  .management-modal { width: calc(100vw - 14px); max-height: calc(100dvh - 14px); min-height: 0; padding: 11px; }
  .management-header h2 { font-size: 1.15rem; }
  .management-balance { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-tabs { overflow-x: auto; }
  .management-tabs button { min-width: 98px; }
  .technology-grid,
  .owned-facility-grid,
  .equipment-grid,
  .supply-grid { grid-template-columns: 1fr; max-height: none; }
  .management-section-heading { align-items: start; flex-direction: column; }
  .management-section-heading p { text-align: left; }
  .selected-facility-summary,
  .facility-plan-row,
  .zone-card,
  .zone-plan-row,
  .route-create-row,
  .manual-carry-row,
  .storage-lot-list,
  .route-card,
  .compost-start-row,
  .compost-apply-row,
  .compost-batch-list,
  .commerce-overview,
  .commerce-card-grid,
  .shipment-create-row,
  .shipment-quality-row,
  .forward-sale-form,
  .finance-summary,
  .finance-actions,
  .ledger-month-grid,
  .ledger-detail-summary,
  .ledger-detail-columns,
  .intelligence-grid,
  .records-settings { grid-template-columns: 1fr; }
  .codex-section .codex-grid,
  .codex-tabs,
  .codex-entry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-month-picker { width: 100%; grid-template-columns: 1fr; }
  .ledger-month-caption { align-items: flex-start; flex-direction: column; }
  .ledger-category-list article { grid-template-columns: 1fr auto; }
  .ledger-category-list article > span { display: none; }
  .shipment-action-row { align-items: stretch; flex-direction: column; }
  .shipment-action-row label { grid-template-columns: 1fr; }
  .sale-selector-grid,
  .stock-detail-grid { grid-template-columns: 1fr; }
  .stock-detail-grid strong { text-align: left; }
  .sale-selection-preview { grid-template-columns: 1fr; }
  .sale-selection-preview strong,
  .sale-selection-preview b { text-align: left; }
  .notification-record { grid-template-columns: 1fr; }
  .notification-record button { width: 100%; }
  .forecast-grid { grid-template-columns: repeat(4, minmax(58px, 1fr)); overflow-x: auto; }
  .commerce-heading { align-items: flex-start; flex-direction: column; }
  .commerce-heading small { text-align: left; }
  .finance-actions { align-items: stretch; }
  .finance-actions label { grid-template-columns: 1fr; }
  .zone-create-actions { justify-content: flex-start; }
  .facility-transfer-grid,
  .facility-recipe-grid,
  .workshop-order-controls,
  .workshop-order-list article,
  .animal-status-grid,
  .animal-shop-grid { grid-template-columns: 1fr; }
  .facility-block-heading { align-items: flex-start; flex-direction: column; }
  .livestock-top-actions { justify-content: flex-start; }
  .equipment-automation-card { grid-column: span 1; }
  .equipment-automation > header,
  .equipment-zone-row { align-items: stretch; grid-template-columns: 1fr; flex-direction: column; }
  .equipment-automation > header button { width: 100%; }
  .equipment-capacity { grid-template-columns: 1fr; }
  .equipment-zone-row > div:last-child { justify-content: stretch; }
  .equipment-zone-row button { flex: 1 1 120px; }
  .equipment-existing-zone { grid-template-columns: 1fr; }
  .land-planning-heading,
  .land-zone-card,
  .facility-existing-zone { grid-template-columns: 1fr; }
  .land-planning-heading > button { width: 100%; }
  .zone-card-actions { justify-content: stretch; }
  .zone-card-actions button { flex: 1 1 110px; }
  .facility-plan-transfer { grid-template-columns: 1fr; }
  .automation-chain-grid { grid-template-columns: 1fr; }
  .smart-farm-runtime-status { grid-template-columns: 1fr 1fr; }
  .smart-farm-runtime-status strong,
  .smart-farm-runtime-status small { grid-column: 1 / -1; }
}

@media (min-width: 621px) and (max-width: 980px) {
  .technology-grid,
  .owned-facility-grid,
  .equipment-grid,
  .supply-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .build-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .codex-entry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-height: 640px) and (pointer: coarse) {
  .toolbar-wrap { bottom: max(66px, calc(env(safe-area-inset-bottom) + 56px)); }
  .dpad { grid-template: repeat(3, 35px) / repeat(3, 35px); }
  .touch-action { width: 58px; height: 58px; }
  .touch-seed-cycle { display: none; }
}

@media (pointer: fine) and (min-width: 821px) {
  .touch-controls { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Final multiplayer HUD placement follows the full-screen HUD overrides above. */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
}

.hud-cluster-left { justify-self: start; }
.resource-strip { justify-self: end; }
.multiplayer-hud {
  justify-self: center;
  min-height: 54px;
  padding: 6px 10px;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
  }

  .hud-cluster-left { grid-column: 1; grid-row: 1; }
  .resource-strip { grid-column: 2; grid-row: 1; }
  .multiplayer-hud {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    min-height: 42px;
    padding: 3px 9px;
  }
}

@media (max-width: 560px) {
  .multiplayer-hud {
    min-height: 38px;
    padding: 3px 7px;
  }
}

/* Multiplayer chat stays visually quiet until the player presses Enter. */
.multiplayer-chat {
  position: absolute;
  z-index: 29;
  bottom: max(104px, calc(env(safe-area-inset-bottom) + 94px));
  left: max(20px, env(safe-area-inset-left));
  display: flex;
  width: min(560px, calc(100vw - 40px));
  max-height: min(390px, 48dvh);
  flex-direction: column;
  gap: 7px;
  color: #fff9e8;
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: clamp(.78rem, 1.05vw, .94rem);
  line-height: 1.45;
  pointer-events: none;
}

.multiplayer-chat-heading,
.multiplayer-chat-form {
  display: none;
}

.multiplayer-chat-log {
  display: flex;
  min-height: 0;
  max-height: 174px;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  overflow: hidden;
  scrollbar-color: rgba(239, 211, 142, .62) transparent;
  scrollbar-width: thin;
  pointer-events: none;
}

.multiplayer-chat-line {
  display: grid;
  grid-template-columns: auto minmax(0, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  color: rgba(255, 252, 237, .97);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, .98),
    1px 0 1px rgba(0, 0, 0, .88),
    -1px 0 1px rgba(0, 0, 0, .88);
}

.multiplayer-chat:not(.is-open) .multiplayer-chat-line:nth-last-child(n + 7),
.multiplayer-chat:not(.is-open) .multiplayer-chat-line.is-stale {
  display: none;
}

.multiplayer-chat-time {
  color: rgba(232, 238, 218, .66);
  font-size: .72em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.multiplayer-chat-name {
  max-width: 150px;
  overflow: hidden;
  color: var(--chat-name-color, #f3d37e);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: isolate;
}

.multiplayer-chat-name::after { content: ":"; color: rgba(255, 255, 255, .75); }

.multiplayer-chat-text {
  min-width: 0;
  overflow-wrap: anywhere;
  line-break: strict;
  white-space: pre-wrap;
  word-break: keep-all;
  unicode-bidi: plaintext;
}

.multiplayer-chat-open {
  align-self: flex-start;
  padding: 2px 3px;
  border: 0;
  background: transparent;
  color: rgba(255, 249, 226, .78);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .01em;
  text-shadow: 0 1px 3px #000, 1px 0 2px #000;
  pointer-events: auto;
}

.multiplayer-chat-open:hover,
.multiplayer-chat-open:focus-visible { color: #fff6cf; }

.multiplayer-chat.is-open {
  z-index: 50;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(235, 210, 147, .3);
  border-radius: 12px;
  background: rgba(13, 25, 18, .72);
  box-shadow: 0 14px 38px rgba(2, 8, 4, .34), inset 0 1px rgba(255, 255, 255, .06);
  backdrop-filter: blur(8px) saturate(.78);
  pointer-events: auto;
}

.multiplayer-chat.is-open .multiplayer-chat-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 25px;
  color: rgba(255, 248, 224, .76);
}

.multiplayer-chat-heading strong {
  color: #fff2c7;
  font-size: .8rem;
  letter-spacing: .02em;
}

.multiplayer-chat-heading span { font-size: .68rem; }

.multiplayer-chat-close {
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 248, 224, .72);
  font-size: 1.25rem;
  line-height: 1;
}

.multiplayer-chat-close:hover,
.multiplayer-chat-close:focus-visible { background: rgba(255, 255, 255, .09); color: white; }

.multiplayer-chat.is-open .multiplayer-chat-log {
  max-height: min(250px, 30dvh);
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 3px 5px 3px 1px;
  pointer-events: auto;
}

.multiplayer-chat.is-open .multiplayer-chat-line {
  padding: 2px 3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.multiplayer-chat.is-open .multiplayer-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  padding: 5px 5px 5px 11px;
  border: 1px solid rgba(238, 216, 161, .34);
  border-radius: 8px;
  background: rgba(3, 10, 6, .48);
}

#multiplayerChatInput {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fffdf4;
  font-family: inherit;
  font-size: max(16px, .88rem);
  line-height: 1.35;
}

#multiplayerChatInput::placeholder { color: rgba(234, 239, 220, .48); }
#multiplayerChatInput:disabled { cursor: wait; opacity: .58; }

.multiplayer-chat-counter {
  color: rgba(230, 235, 218, .55);
  font-size: .66rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.multiplayer-chat-counter.is-over { color: #ff9f91; font-weight: 900; }
.multiplayer-chat-counter.is-cooling-down { color: #f2cf72; font-weight: 900; }

.multiplayer-chat-send {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(244, 219, 150, .44);
  border-radius: 6px;
  background: rgba(94, 132, 72, .72);
  color: #fff8dc;
  font-size: .72rem;
  font-weight: 900;
}

.multiplayer-chat-send:hover { background: rgba(112, 153, 86, .88); }
.multiplayer-chat-send:disabled { cursor: not-allowed; opacity: .45; }
.multiplayer-chat.is-open .multiplayer-chat-open { display: none; }

.game-screen.chat-is-open .toolbar-wrap,
.game-screen.chat-is-open .toolbar,
.game-screen.chat-is-open .touch-controls,
.game-screen.chat-is-open .dpad,
.game-screen.chat-is-open .touch-action-stack { pointer-events: none; }

.game-screen.chat-is-open .context-prompt,
.game-screen.chat-is-open .toolbar-wrap,
.game-screen.chat-is-open .touch-controls { opacity: 0; }

@media (max-width: 820px), (pointer: coarse) {
  .multiplayer-chat {
    bottom: max(184px, calc(env(safe-area-inset-bottom) + 174px));
    left: max(12px, env(safe-area-inset-left));
    width: min(500px, calc(100vw - 24px));
    max-height: min(350px, 43dvh);
  }

  .multiplayer-chat-log { max-height: 132px; }
  .multiplayer-chat.is-open { padding: 10px; }
  .multiplayer-chat.is-open {
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .multiplayer-chat.is-open .multiplayer-chat-log { max-height: min(180px, 22dvh); }
  .multiplayer-chat-time { display: none; }
  .multiplayer-chat-name { max-width: 105px; }
}

@media (max-height: 640px) and (pointer: coarse) {
  .multiplayer-chat {
    bottom: max(126px, calc(env(safe-area-inset-bottom) + 116px));
    max-height: 45dvh;
  }

  .multiplayer-chat.is-open .multiplayer-chat-log { max-height: 18dvh; }
}
