:root {
  --ink: #3a2717;
  --ink-soft: #7a5c43;
  --cream: #fff8ea;
  --card: #fdf0d8;
  --edge: #e3c79c;
  --wood: #8b5a33;
  --wood-dark: #5e3a1f;
  --leaf: #4caf50;
  --leaf-dark: #2f7d32;
  --gold: #f5b82e;
  --gold-dark: #c98a0c;
  --red: #e5533d;
  --red-dark: #a83524;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-display: "Bitter", Georgia, serif; /* logo and headings */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2c4a26;
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
}

/* The whole game is laid out at 1280 by 720 and scaled to fit the window in main.js. */
#stage {
  touch-action: manipulation;
  position: fixed; /* fixed, so the wide game can't stretch a phone's page */
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  transform-origin: 0 0;
  overflow: hidden;
  background: #8fcd63;
}

#farm {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* Effects canvas and the item that follows the mouse sit above the menus. */
#fx {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  pointer-events: none;
}

#held {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.3));
  display: none;
}

/* ---------- Top bar ---------- */

#topbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(#9a6539, #7c4d2a);
  border-bottom: 4px solid var(--wood-dark);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 32px;
  font-weight: 700;
  color: #fff4d6;
  letter-spacing: 0.5px;
  text-shadow:
    2px 2px 0 #4a2d16, -2px 2px 0 #4a2d16, 2px -2px 0 #4a2d16, -2px -2px 0 #4a2d16,
    0 5px 0 #4a2d16;
}

.logo::before {
  content: "";
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #8be04e, #3f8f35);
  border: 3px solid #4a2d16;
  border-radius: 0 100% 0 100%;
  transform: rotate(-10deg);
}

/* Weather badge in the middle of the top bar */
.weather {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 4px 18px 4px 6px;
  font: inherit;
  color: #fff4d6;
  background: rgba(74, 45, 22, 0.75);
  border: 2px solid #4a2d16;
  border-radius: 999px;
  cursor: pointer;
}

.weather:hover { background: rgba(74, 45, 22, 0.95); }
.weather.bump { animation: bump-center 0.4s ease-out; }
.weather img { width: 38px; height: 38px; }
.weather-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.weather-text b { font-size: 17px; font-weight: 600; }
.weather-text span { font-size: 13px; color: #e8cfa8; }

.coins {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
  padding: 6px 20px 6px 8px;
  border-radius: 999px;
  background: #4a2d16;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3);
  color: #ffe08a;
  font-size: 24px;
  font-weight: 600;
}

.coins.bump { animation: bump 0.3s ease-out; }

.coin-icon {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe680, #f5b82e 60%, #c98a0c);
  border: 2px solid #8a5a06;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.coin-icon::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 2px solid rgba(138, 90, 6, 0.45);
}

.coin-icon.small { width: 16px; height: 16px; border-width: 1.5px; }
.coin-icon.small::after { display: none; }

/* ---------- Side menu ---------- */

#dock {
  position: absolute;
  left: 920px;
  top: 76px;
  width: 348px;
  height: 632px;
  display: flex;
  flex-direction: column;
}

#tabs {
  display: flex;
  gap: 3px;
  padding: 0 6px;
}

#tabs button {
  position: relative;
  top: 3px;
  flex: 1;
  padding: 8px 0 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--cream);
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
}

#tabs button:hover { background: #9c6a40; }
#tabs button.active { z-index: 1; background: var(--card); color: var(--ink); }
#tabs button.pulse { animation: tab-pulse 0.35s ease-out; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 5px;
  font-size: 12px;
  color: #fff;
  background: var(--red);
  border-radius: 10px;
  vertical-align: 1px;
}

.badge[hidden] { display: none; }

#panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--card);
  border: 3px solid var(--wood-dark);
  border-radius: 16px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
}

#panel::-webkit-scrollbar { width: 10px; }
#panel::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 5px; border: 2px solid var(--card); }

.panel-head { margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 25px; font-weight: 700; }
.sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 15px; }

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  background: var(--cream);
  border: 2px solid var(--edge);
  border-left: 6px solid var(--rarity, var(--edge));
  border-radius: 12px;
}

.row.sold { opacity: 0.5; }

.icon {
  flex: none;
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: #f3e1c0;
}

.info { flex: 1; min-width: 0; }
.name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 13px; color: var(--ink-soft); line-height: 1.35; }
.tag { margin-right: 6px; color: var(--rarity); font-weight: 600; }
.buy { text-align: right; }
.stock { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }

.card {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--cream);
  border: 2px solid var(--edge);
  border-radius: 12px;
}

.card-title { font-size: 18px; font-weight: 600; }
.card p { margin: 4px 0 10px; font-size: 15px; line-height: 1.4; color: var(--ink-soft); }

.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 6px 0 0; font-size: 15px; }
.stats dt { color: var(--ink-soft); }
.stats dd { margin: 0; font-weight: 600; text-align: right; }

.empty { padding: 36px 12px; text-align: center; font-size: 16px; line-height: 1.45; color: var(--ink-soft); }
.version { margin: 4px 0 0; text-align: center; font-size: 13px; color: var(--ink-soft); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--leaf);
  border: none;
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--leaf-dark);
  cursor: pointer;
  transition: transform 0.06s, filter 0.1s;
}

.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--leaf-dark); }

.btn-gold { color: #4a2d06; background: var(--gold); box-shadow: 0 3px 0 var(--gold-dark); }
.btn-gold:active { box-shadow: 0 1px 0 var(--gold-dark); }
.btn-red { background: var(--red); box-shadow: 0 3px 0 var(--red-dark); }
.btn-red:active { box-shadow: 0 1px 0 var(--red-dark); }

.btn.poor { color: #fff8ec; background: #cdbb9f; box-shadow: 0 3px 0 #a8977d; }
.btn:disabled { color: #fff8ec; background: #cdbb9f; box-shadow: 0 3px 0 #a8977d; cursor: default; filter: none; transform: none; }

.btn.wide { width: 100%; padding: 10px; font-size: 17px; }

/* ---------- Seed bar ---------- */

#hotbar {
  position: absolute;
  left: 12px;
  top: 632px;
  width: 896px;
  height: 76px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px; /* no vertical padding, so a raised slot and its count badge have room */
  background: rgba(74, 45, 22, 0.9);
  border: 3px solid var(--wood-dark);
  border-radius: 16px;
}

#slots {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 100%;
  padding: 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
}

#slots::-webkit-scrollbar { height: 0; }

.slot {
  position: relative;
  flex: none;
  width: 54px;
  height: 54px;
  padding: 0;
  background: #f3e1c0;
  border: 3px solid #c9a676;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s;
}

.slot:hover { transform: translateY(-2px); }
.slot img { display: block; width: 100%; height: 100%; border-radius: 9px; }
.slot.pulse { animation: bump 0.3s ease-out; }
.slot.selected { border-color: #ffe066; box-shadow: 0 0 0 3px rgba(255, 224, 102, 0.55); transform: translateY(-3px); }

.slot .count {
  position: absolute;
  right: -6px;
  bottom: -6px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--wood-dark);
  border: 2px solid #f3e1c0;
  border-radius: 11px;
}

.slot .key {
  position: absolute;
  left: 4px;
  top: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

.slot-divider { flex: none; width: 2px; height: 42px; background: rgba(255, 255, 255, 0.15); }
.hint { padding-left: 4px; font-size: 15px; color: #f3e1c0; white-space: nowrap; }

#harvest-all { flex: none; height: 52px; padding: 0 18px; font-size: 17px; }

/* ---------- Messages ---------- */

#toasts {
  position: absolute;
  left: 460px;
  top: 86px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  font-size: 16px;
  color: var(--cream);
  white-space: nowrap;
  background: rgba(43, 29, 18, 0.92);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.4s;
}

.toast.out { opacity: 0; }

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes bump { 50% { transform: scale(1.08); } }
@keyframes bump-center { 50% { transform: translateX(-50%) scale(1.1); } }
@keyframes tab-pulse { 40% { transform: translateY(-4px) scale(1.06); } }

/* ---------- Phase 3 menus ---------- */

.seg {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  background: #ecd7b4;
  border-radius: 12px;
}

.seg button {
  flex: 1;
  padding: 6px 0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
}

.seg button.on { color: var(--ink); background: var(--cream); box-shadow: 0 2px 0 var(--edge); }

.mods { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 3px 0; font-size: 14px; line-height: 1.5; }

.mod {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  color: var(--ink);
  background: color-mix(in srgb, var(--mod, #999) 22%, #fff);
  border: 1.5px solid color-mix(in srgb, var(--mod, #999) 70%, #000);
  border-radius: 999px;
  white-space: nowrap;
}

.mod::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mod, #999); }
.mod.rainbow { background: linear-gradient(90deg, #ffd6d6, #fff2c2, #d6f5d6, #d6ecff, #ead6ff); border-color: #8a6cff; }
.mod.rainbow::before { background: conic-gradient(#ff5a5a, #ffe14d, #6ee36e, #4bb8ff, #e07cff, #ff5a5a); }
.mod.unknown { color: var(--ink-soft); background: #eee3d0; border: 1.5px dashed #b89f7c; }
.mod.unknown::before { display: none; }

.card-title .level { float: right; margin-top: 2px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.pips { display: flex; gap: 4px; margin: 6px 0 2px; }
.pips i { flex: 1; height: 7px; border-radius: 4px; background: #ecd7b4; }
.pips i.on { background: var(--gold); }

.card.now { display: flex; align-items: center; gap: 12px; }
.card.now p { margin-bottom: 0; }
.icon.small { width: 40px; height: 40px; background: none; }
.row.slim { padding: 6px 10px; }
.section { margin: 16px 2px 8px; font-size: 18px; }
.count-note { float: right; margin-top: 3px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.guide-note { margin: 0 2px 10px; font-size: 14px; line-height: 1.4; color: var(--ink-soft); }

.slot.tool { background: #e3eef5; border-color: #9cb8cc; }
.toast.special { background: linear-gradient(90deg, #6a3fb5, #b5408f); font-weight: 600; }

/* ---------- Phase 4: workers ---------- */

.popup {
  position: absolute;
  left: 0;
  top: 0;
  width: 270px;
  padding: 12px 14px;
  background: var(--card);
  border: 3px solid var(--wood-dark);
  border-top: 6px solid var(--rarity, var(--wood-dark));
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.popup[hidden] { display: none; }
.popup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.popup-head b { font-size: 18px; }
.popup-head span { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.popup p { margin: 6px 0; font-size: 14px; line-height: 1.4; }
.popup .meta { font-size: 13px; }
.popup .next { color: #6a8a3a; }
.popup-actions { display: flex; gap: 8px; margin-top: 10px; }
.popup-actions .btn { flex: 1; }

.btn-plain { color: var(--ink); background: #ecd7b4; box-shadow: 0 3px 0 #c9ad83; }
.btn-plain:active { box-shadow: 0 1px 0 #c9ad83; }
.slot.building { background: #f5e3ff; border-color: #b99ad6; }
.seg button { font-size: 14px; }

/* The farm is wide, so phones held upright get asked to turn sideways. */
#rotate { display: none; }

@media (orientation: portrait) and (max-width: 900px) {
  #rotate {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    color: #fff4d6;
    background: #2c4a26;
  }
}

/* ---------- Phase 5 and 6: goals, options, tutorial ---------- */

.top-right { display: flex; align-items: center; gap: 10px; }

.gear {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: #fff4d6;
  background: #4a2d16;
  border: none;
  border-radius: 50%;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s;
}

.gear:hover, .gear.active { color: #ffe08a; transform: rotate(30deg); }

.goals { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }

.goal {
  padding: 10px 12px;
  background: var(--cream);
  border: 2px solid var(--edge);
  border-radius: 12px;
}

.goal.ready { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 184, 46, 0.3); }
.goal.claimed { opacity: 0.55; }
.goal-text { font-size: 16px; font-weight: 600; }
.goal .bar { height: 8px; margin: 7px 0 6px; background: #ecd7b4; border-radius: 4px; overflow: hidden; }
.goal .bar i { display: block; height: 100%; background: var(--leaf); border-radius: 4px; }
.goal-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.goal-foot .btn { padding: 4px 14px; }
.goal-count { white-space: nowrap; }

.setting { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 15px; }
.setting input[type="range"] { flex: 1; accent-color: var(--leaf); }
.setting.check { align-items: flex-start; font-size: 14px; line-height: 1.35; color: var(--ink-soft); }
.setting.check input { margin-top: 2px; accent-color: var(--leaf); }

.tip {
  position: absolute;
  left: 460px;
  top: 82px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 820px;
  padding: 10px 12px 10px 16px;
  font-size: 16px;
  color: var(--ink);
  background: #fffbe9;
  border: 3px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.25s ease-out;
}

.tip[hidden] { display: none; }
.tip-step { flex: none; padding: 2px 8px; font-size: 12px; font-weight: 600; color: #4a2d06; background: var(--gold); border-radius: 999px; }
.tip-text { line-height: 1.35; }
.tip .btn { flex: none; }
.tip-skip { flex: none; font: inherit; font-size: 13px; color: var(--ink-soft); background: none; border: none; text-decoration: underline; cursor: pointer; }

/* Messages move down while a tutorial tip is showing. */
.tip:not([hidden]) ~ #toasts { top: 150px; }

/* Headings and the logo use the display font. */
.logo, .panel-head h2, .section, .card-title, .popup-head b, .weather-text b, .goal-text { font-family: var(--font-display); }

/* ---------- Phase 7: clock ---------- */
.clock-divider { width: 2px; height: 30px; margin: 0 4px; background: rgba(255, 244, 214, 0.25); }
#clock-icon { width: 34px; height: 34px; }

/* ---------- Phase 8: levels and the black hole ---------- */

.top-left { display: flex; align-items: center; gap: 14px; }

.level-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  font: inherit;
  color: #fff4d6;
  background: rgba(74, 45, 22, 0.75);
  border: 2px solid #4a2d16;
  border-radius: 999px;
  cursor: pointer;
}

.level-chip:hover { background: rgba(74, 45, 22, 0.95); }
.level-chip.bump { animation: bump 0.4s ease-out; }
.level-chip > b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-family: var(--font-display);
  font-size: 17px;
  color: #4a2d06;
  background: radial-gradient(circle at 35% 35%, #ffe680, #f5b82e 70%);
  border: 2px solid #8a5a06;
  border-radius: 50%;
}
.level-text { display: flex; flex-direction: column; gap: 4px; font-size: 13px; text-align: left; }
.xp { display: block; width: 90px; height: 6px; background: rgba(0, 0, 0, 0.35); border-radius: 3px; overflow: hidden; }
.xp i { display: block; height: 100%; width: 0; background: #8be04e; transition: width 0.3s; }

.row.locked { opacity: 0.6; background: #f3e6cf; }
.row.locked .icon { filter: grayscale(1) brightness(0.9); }
.lock-note { font-size: 13px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }

.unlock-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; }
.unlock-list li { display: flex; gap: 8px; padding: 4px 0; border-top: 1px dashed var(--edge); }
.unlock-list li b { flex: none; width: 58px; color: var(--ink-soft); }
.card.rebirth { background: linear-gradient(135deg, #2a1640, #120a22); border-color: #6b3fd0; color: #f0e6ff; }
.card.rebirth p { color: #cbb8ee; }
.btn-void { color: #fff; background: #7b4ae0; box-shadow: 0 3px 0 #4b2a92; }
.btn-void:active { box-shadow: 0 1px 0 #4b2a92; }

#void { position: absolute; inset: 0; z-index: 20; overflow: hidden; background: #000; }
#void[hidden] { display: none; }
#void-canvas { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; }
#void-lines { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; pointer-events: none; }
#void-nodes, #void-info, .void-top, #void-lines { transition: opacity 0.6s; }
#void.intro #void-nodes, #void.intro #void-info, #void.intro .void-top, #void.intro #void-lines { opacity: 0; pointer-events: none; }

.skill {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 118px;
  padding: 7px 12px;
  font: inherit;
  color: #e9defc;
  background: rgba(20, 10, 40, 0.85);
  border: 2px solid color-mix(in srgb, var(--branch) 45%, transparent);
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.skill b { font-size: 14px; white-space: nowrap; }
.skill:hover { transform: translate(-50%, -50%) scale(1.06); }
.skill.owned { border-color: var(--branch); box-shadow: 0 0 14px color-mix(in srgb, var(--branch) 50%, transparent); }
.skill.ready { color: #fff; }
.skill.ready::after { content: ""; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; background: var(--branch); border-radius: 50%; }
.skill.picked { outline: 3px solid #fff4d6; outline-offset: 2px; }
.skill-pips { display: flex; gap: 3px; }
.skill-pips i { width: 9px; height: 5px; background: rgba(255, 255, 255, 0.18); border-radius: 2px; }
.skill-pips i.on { background: var(--branch); }

.void-top { position: absolute; left: 24px; right: 24px; top: 18px; display: flex; align-items: center; justify-content: space-between; }
.void-points { font-size: 18px; color: #e9defc; }
.void-points b { font-family: var(--font-display); font-size: 30px; color: #c9a2ff; margin-right: 4px; }
#void-rebirths { margin-left: 14px; font-size: 14px; color: #9f8cc4; }

#void-info {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: 560px;
  padding: 12px 16px;
  color: #e9defc;
  background: rgba(20, 10, 40, 0.92);
  border: 2px solid var(--branch);
  border-radius: 14px;
}
.void-info-head { display: flex; justify-content: space-between; align-items: baseline; }
.void-info-head b { font-family: var(--font-display); font-size: 19px; color: #fff; }
.void-info-head span { font-size: 13px; color: #9f8cc4; }
#void-info p { margin: 6px 0 10px; font-size: 15px; line-height: 1.4; }
.void-why { margin-left: 10px; font-size: 13px; color: #c9a2ff; }
.card .bar { height: 8px; margin: 7px 0 4px; background: #ecd7b4; border-radius: 4px; overflow: hidden; }
.card .bar i { display: block; height: 100%; background: var(--leaf); border-radius: 4px; }
#toasts { z-index: 30; }
/* On the black hole screen, messages sit in the empty bottom left corner so they don't cover skills. */
#void:not([hidden]) ~ #toasts { left: 24px; top: auto; bottom: 24px; transform: none; align-items: flex-start; }
#void:not([hidden]) ~ #toasts .toast { max-width: 320px; white-space: normal; border-radius: 14px; }

/* ---------- Phase 9: the Town ---------- */

#town { position: absolute; inset: 0; z-index: 20; overflow: hidden; background: #8fd0ff; }
#town[hidden] { display: none; }
#town-canvas { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; }
.town-top { position: absolute; left: 24px; right: 24px; top: 16px; display: flex; align-items: center; justify-content: space-between; }
.town-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 40px;
  color: #fff4d6;
  text-shadow: 2px 2px 0 #4a2d16, -2px 2px 0 #4a2d16, 2px -2px 0 #4a2d16, -2px -2px 0 #4a2d16, 0 4px 0 #4a2d16;
}

#town-modal { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20, 12, 6, 0.55); }
#town-modal[hidden] { display: none; }
.modal-box {
  width: 640px;
  max-height: 640px;
  overflow-y: auto;
  padding: 16px 20px 20px;
  background: var(--card);
  border: 4px solid var(--wood-dark);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.modal-box.modal-casino { border-color: #7a2a4a; }
.modal-box.modal-weather { border-color: #2f5f8f; }
.modal-box.shake { animation: shake 0.15s linear 10; }
@keyframes shake { 25% { transform: translate(-3px, 1px); } 75% { transform: translate(3px, -1px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 28px; }
.modal-close { font: inherit; font-size: 14px; color: var(--ink-soft); background: none; border: none; text-decoration: underline; cursor: pointer; }
.modal-sub { margin: 6px 0 12px; font-size: 15px; line-height: 1.4; color: var(--ink-soft); }

.crop-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 360px; overflow-y: auto; padding: 2px; }
.crop-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--edge);
  border-left: 6px solid var(--rarity);
  border-radius: 12px;
  cursor: pointer;
}
.crop-pick:hover { background: #fff; border-color: var(--gold); border-left-color: var(--rarity); }
.crop-pick img { width: 40px; height: 40px; flex: none; }
.crop-name { flex: 1; font-weight: 600; font-size: 15px; }
.crop-name .mods { margin: 2px 0 0; }
.crop-value { display: flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }

.bet-line { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--cream); border: 2px solid var(--edge); border-radius: 12px; font-size: 16px; }
.bet-line img { width: 40px; height: 40px; }
.bet-line .coin-icon { display: inline-block; vertical-align: -2px; margin: 0 3px; }
.game-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.game-pick { display: flex; flex-direction: column; gap: 4px; padding: 12px; font: inherit; text-align: left; color: var(--ink); background: #fff3f8; border: 2px solid #e8b6cc; border-radius: 12px; cursor: pointer; }
.game-pick:hover { border-color: #7a2a4a; }
.game-pick b { font-family: var(--font-display); font-size: 17px; }
.game-pick span { font-size: 13px; line-height: 1.35; color: var(--ink-soft); }

.game-area { margin-top: 12px; text-align: center; }
.moves { display: flex; justify-content: center; gap: 10px; margin: 10px 0; }
.moves .btn { min-width: 110px; padding: 10px 16px; font-size: 16px; }
.score { display: flex; justify-content: center; gap: 40px; font-size: 18px; }
.score b { font-family: var(--font-display); font-size: 30px; margin-left: 6px; }

.coin-flip { display: grid; place-items: center; height: 120px; }
.coin-face {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  font-family: var(--font-display);
  font-size: 18px;
  color: #4a2d06;
  background: radial-gradient(circle at 35% 35%, #ffe680, #f5b82e 65%, #c98a0c);
  border: 4px solid #8a5a06;
  border-radius: 50%;
}
.coin-flip.flipping .coin-face { animation: flip 0.25s linear infinite; }
@keyframes flip { 50% { transform: scaleX(0.05); } }

.table { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: #2f7d32; border: 4px solid #7a4e2d; border-radius: 16px; }
.hand { display: flex; align-items: center; justify-content: center; gap: 8px; }
.hand-label { width: 90px; text-align: right; font-weight: 600; color: #e8f5d8; }
.pcard {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 72px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #222;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.pcard i { font-style: normal; font-size: 18px; }
.pcard.red { color: #d7263d; }
.pcard.back { background: repeating-linear-gradient(45deg, #7a2a4a, #7a2a4a 6px, #a0405f 6px, #a0405f 12px); border-color: #4a1428; }

.reels { display: flex; justify-content: center; gap: 12px; margin: 8px 0; }
.reel { display: grid; place-items: center; width: 96px; height: 96px; background: #fff; border: 4px solid #7a2a4a; border-radius: 14px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.08); }
.reel img { width: 74px; height: 74px; }

.result { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; padding: 12px; border-radius: 12px; }
.result b { font-family: var(--font-display); font-size: 20px; }
.result.win { background: #e3f7d8; border: 2px solid #4caf50; }
.result.lose { background: #fde4e0; border: 2px solid #e5533d; }
.result.push { background: #f3ead8; border: 2px solid var(--edge); }
.result .coin-icon { display: inline-block; vertical-align: -2px; margin: 0 3px; }

.weatherman { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.weatherman canvas { width: 140px; height: 140px; flex: none; }
.speech { position: relative; margin: 0; padding: 12px 14px; font-size: 15px; line-height: 1.4; background: #fff; border: 2px solid #9cb8cc; border-radius: 14px; }
.forecast { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; padding: 10px 12px; background: #e6f2ff; border: 2px solid #4b8bff; border-radius: 12px; }
.forecast img { width: 56px; height: 56px; }
.forecast b { display: block; font-family: var(--font-display); font-size: 19px; }
.forecast span { font-size: 14px; color: var(--ink-soft); }

#town:not([hidden]) ~ #toasts { top: 80px; left: 640px; }

/* ---------- Test tools (only with ?dev in the address) ---------- */
#dev { position: fixed; left: 8px; bottom: 8px; z-index: 100; display: flex; flex-direction: column; align-items: flex-start; max-width: 300px; font-size: 13px; }
.dev-toggle { padding: 6px 12px; font: inherit; font-weight: 600; color: #fff; background: #d7263d; border: 2px solid #8a1424; border-radius: 10px; cursor: pointer; }
.dev-body { max-height: 70vh; overflow-y: auto; margin-bottom: 6px; padding: 10px; background: rgba(255, 248, 234, 0.97); border: 2px solid #8a1424; border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.dev-body[hidden] { display: none; }
#dev:has(.dev-body:not([hidden])) { flex-direction: column-reverse; }
.dev-note { margin: 0 0 8px; color: #8a1424; line-height: 1.35; }
.dev-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 8px; }
.dev-group b { width: 100%; }
.dev-group button, .dev-group select { padding: 4px 8px; font: inherit; background: #fff; border: 1px solid #c9ad83; border-radius: 6px; cursor: pointer; }
.dev-group button:hover { background: #ffe9a8; }

.modal-box.modal-fountain { border-color: #2f8fb0; }
.fountain-total { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 8px 0; padding: 14px; background: #e6f6ff; border: 2px solid #5ab0e8; border-radius: 14px; }
.fountain-total b { font-family: var(--font-display); font-size: 40px; color: #24507a; }
.fountain-total span { font-size: 14px; color: var(--ink-soft); }
.moves.toss { flex-wrap: wrap; }
.moves.toss .btn { min-width: 0; }
.modal-sub .coin-icon { display: inline-block; vertical-align: -2px; margin: 0 3px; }
.wish { display: block; width: 100%; height: auto; aspect-ratio: 600 / 340; border: 3px solid #2f8fb0; border-radius: 14px; }
.modal-sub.center { text-align: center; }

/* ---------- Phase 10: farm floors ---------- */
/* In the strip left of the farm, under the Town sign */
.floors {
  position: absolute;
  left: 34px;
  top: 440px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  background: rgba(74, 45, 22, 0.92);
  border: 3px solid var(--wood-dark);
  border-radius: 14px;
}
.floors[hidden] { display: none; }
.floors button {
  position: relative;
  width: 34px;
  height: 34px;
  font-size: 15px;
  color: #4a2d06;
  background: var(--gold);
  border: none;
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--gold-dark);
  cursor: pointer;
}
.floors button:disabled { color: #8a7a60; background: #cdbb9f; box-shadow: 0 3px 0 #a8977d; cursor: default; }
.floors button .badge { position: absolute; top: -8px; right: -10px; margin: 0; }
#floor-label { font-family: var(--font-display); font-size: 12px; line-height: 1.1; text-align: center; color: #fff4d6; width: 38px; }
.void-top { pointer-events: none; }
.void-top button { pointer-events: auto; }

/* ---------- Phase 11: Seed Shop and Green House ---------- */
.modal-box.modal-seedshop { border-color: #2f7d32; }
.shop-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 10px 8px 8px; background: var(--cream); border: 2px solid var(--edge); border-left: 6px solid var(--rarity, var(--edge)); border-radius: 12px; }
.shop-row img { width: 46px; height: 46px; flex: none; }
.shop-info { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-soft); line-height: 1.35; }
.shop-info b { font-size: 16px; color: var(--ink); }
.shop-info .quest { color: #7a4e2d; font-weight: 600; }
.shop-row.locked-seed img { filter: grayscale(0.7); }
.shop-row .btn { flex: none; }
#gh-modal { position: absolute; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(20, 12, 6, 0.55); }
#gh-modal[hidden] { display: none; }
.modal-box.modal-greenhouse { width: 680px; border-color: #3f8f6b; }
.gh-layout { display: flex; gap: 16px; align-items: flex-start; }
.gh-grid { display: grid; grid-template-columns: repeat(3, 116px); gap: 8px; padding: 10px; background: #cfe9d6; border: 3px solid #8fc4a5; border-radius: 14px; }
.gh-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 116px; padding: 6px; font: inherit; font-size: 12px; color: var(--ink); background: #a8744a; border: 2px solid #7a4e2d; border-radius: 10px; cursor: pointer; }
.gh-cell img { width: 54px; height: 54px; }
.gh-cell span { color: #fff4d6; font-weight: 600; text-align: center; line-height: 1.2; }
.gh-cell.empty { justify-content: center; background: #b98a5c; }
.gh-cell.empty span { color: #f3e1c0; font-weight: 500; }
.gh-cell.ripe { border-color: #ffe066; box-shadow: 0 0 0 3px rgba(255, 224, 102, 0.5); }
.gh-cell.wait { background: #8a7a6a; }
.gh-cell.wait img { filter: grayscale(0.6); }
.gh-bar { display: block; width: 86px; height: 6px; background: rgba(0, 0, 0, 0.35); border-radius: 3px; overflow: hidden; }
.gh-bar i { display: block; height: 100%; background: #8be04e; }
.gh-controls { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.gh-seg { margin-bottom: 6px; }

/* ---------- Phase 12: Request Board ---------- */
.modal-box.modal-requests { width: 680px; border-color: #a0703f; }
.notes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; background: #c99a5b; border: 4px solid #7a4e2d; border-radius: 12px; }
.note { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px 12px; background: #fffbe9; border-radius: 4px; box-shadow: 0 4px 8px rgba(40, 20, 8, 0.3); transform: rotate(var(--tilt, 0deg)); }
.note::before { content: ""; position: absolute; top: 5px; left: 50%; width: 10px; height: 10px; margin-left: -5px; background: #e5533d; border-radius: 50%; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.note-top { display: flex; align-items: center; gap: 8px; }
.note-top img { width: 40px; height: 40px; }
.note-top div { display: flex; flex-direction: column; }
.note-top b { font-family: var(--font-display); font-size: 17px; }
.note-pay { font-size: 14px; font-weight: 700; color: #2f7d32; }
.note p { margin: 0; font-size: 14px; line-height: 1.35; }
.note-time { font-size: 12px; color: var(--ink-soft); }
.note .btn { align-self: flex-start; }
.note .btn .coin-icon { display: inline-block; }
.empty-note { justify-content: center; min-height: 150px; background: rgba(255, 251, 233, 0.6); }
.empty-note p { color: var(--ink-soft); text-align: center; }
