/* Green Thumb: a calm, fixed garden palette (same in light and dark OS modes).
   One accent colour (leaf green) marks "your action": choices, glowing squares, Plant. */
:root {
  color-scheme: light;
  --bg: #eef2e3;
  --card: #fbfcf6;
  --ink: #1f2a1a;
  --muted: #69765c;
  --soft: rgba(31, 42, 26, .06);
  --accent: #2f7d3a;
  --accent-soft: rgba(47, 125, 58, .18);
  --bad: #c63a2e;
  --soil-dark: #4b321e;
  --sun: #d9a21b;
  --cell: 38px;
  --mini: min(26px, calc((100vw - 80px) / 9));
  /* tutorial kit (tutorial.css) */
  --tut-accent: #d9a21b;
  --tut-accent-ink: #1f2a1a;
  --tut-bubble: #fbfcf6;
  --tut-ink: #1f2a1a;
  --tut-muted: #69765c;
  --tut-dim: rgba(31, 42, 26, .55);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
svg { display: block; }

/* ------------------------------------------------------------- top bar */
.topbar {
  display: flex; align-items: center; gap: 4px;
  max-width: 1040px; margin: 0 auto; height: 50px;
  padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
}
.back, .icon-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  text-decoration: none; font-size: 22px; line-height: 1; cursor: pointer;
}
.back:hover, .icon-btn:hover { background: var(--soft); }
.icon-btn.small { width: 36px; height: 36px; font-size: 20px; color: var(--muted); }
.brand { flex: 1; margin: 0; text-align: center; font-size: 18px; font-weight: 750; letter-spacing: .02em; }
.back:focus-visible, .icon-btn:focus-visible, .btn:focus-visible, .pchip:focus-visible,
.card:focus-visible, .seg button:focus-visible, .menu button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ------------------------------------------------------------- buttons */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0;
  background: var(--soft); cursor: pointer; font-weight: 650; line-height: 1.1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(31, 42, 26, .18); }
.btn.warn { background: var(--bad); color: #fff; }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; }
.btn.icon { min-width: 44px; padding: 0 10px; }
.btn .ico { font-size: 20px; line-height: 1; }
.btn .lbl { font-size: 14px; }

/* ------------------------------------------------------------- layout */
.app {
  max-width: 1040px; margin: 0 auto;
  padding: 0 max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr);
}
.side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.board-area { position: relative; min-width: 0; }
@media (min-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; padding-top: 8px; }
  .board-area { grid-column: 1; grid-row: 1; }
  .side { grid-column: 2; grid-row: 1; gap: 16px; }
}

/* ------------------------------------------------------------- chips */
.chips { display: flex; gap: 6px; min-width: 0; }
.pchip {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 12px 0 6px; border: 0; border-radius: 22px;
  background: transparent; cursor: pointer; min-width: 0;
  transition: background .2s, box-shadow .2s;
}
.pchip:hover { background: var(--soft); }
.pchip.turn { background: var(--card); box-shadow: 0 0 0 2px color-mix(in srgb, var(--pc) 45%, transparent), 0 1px 4px rgba(31, 42, 26, .08); }
.pchip.won .pts::after { content: " \2654"; color: var(--accent); }
.av {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--pc, #888); color: #fff; font-size: 13px; font-weight: 800;
}
.av.sm { width: 12px; height: 12px; vertical-align: -1px; margin-right: 4px; }
.pchip .nm { font-size: 14px; color: var(--muted); white-space: nowrap; }
.pchip .pts { display: inline-flex; align-items: center; gap: 3px; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pchip .pts svg { width: 15px; height: 15px; }
.bonus-badge { font-size: 11px; font-weight: 800; color: #7a5a06; background: #f7e3a6; border-radius: 8px; padding: 1px 6px; }
.pchip.bump .av { animation: bump 1.1s ease-out 1 both; }
.pchip .delta {
  position: absolute; right: 2px; top: -6px; font-size: 12px; font-weight: 800; color: var(--pc);
  animation: rise 1.1s ease-out 1 both; pointer-events: none;
}
@keyframes bump { 0% { box-shadow: 0 0 0 0 var(--pc); } 30% { box-shadow: 0 0 0 7px transparent; transform: scale(1.12); } 100% { box-shadow: none; transform: none; } }
@keyframes rise { 0% { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }

/* ------------------------------------------------------------- status */
.status { display: flex; align-items: center; gap: 9px; min-height: 26px; font-size: 16px; font-weight: 650; padding: 0 2px; }
.status .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.status.mine .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.status.err .msg { color: var(--bad); }
.status.thinking .msg { color: var(--muted); }
.status.thinking .msg::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }


/* ------------------------------------------------------------- slim season track */
.track { position: relative; height: 42px; cursor: pointer; }
.rail { position: absolute; left: 9px; right: 9px; top: 19px; height: 4px; border-radius: 2px; background: rgba(31, 42, 26, .12); }
.rail-fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(100% * var(--x)); border-radius: 2px; background: rgba(47, 125, 58, .35); transition: width .6s ease; }
.tick { position: absolute; left: calc(100% * var(--x)); transform: translateX(-50%); }
.tick.harvest { top: -4px; width: 3px; height: 12px; border-radius: 2px; background: var(--sun); }
.tick.sprout { top: -3px; width: 10px; height: 10px; border-radius: 50%; background: #74c05a; box-shadow: 0 0 0 2px var(--bg); }
.pawn {
  position: absolute; left: calc(9px + (100% - 18px) * var(--x)); transform: translateX(-50%);
  width: 18px; height: 18px; border-radius: 50%; background: var(--pc);
  color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center;
  transition: left .7s cubic-bezier(.3, .7, .3, 1), box-shadow .2s; z-index: 1;
}
.pawn.p0 { top: 0; }
.pawn.p1 { top: 24px; }
.pawn.turn { box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 30%, transparent); }

/* ------------------------------------------------------------- choices */
.offers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.card {
  position: relative; min-width: 0; min-height: 88px; border: 0; border-radius: 12px; padding: 8px 4px 6px;
  background: var(--card); box-shadow: 0 1px 3px rgba(31, 42, 26, .12);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 4px;
  transition: transform .15s, box-shadow .15s, opacity .2s; text-align: center; cursor: default; font: inherit;
}
.card .shape { flex: 1; display: grid; place-items: center; min-height: 40px; }
.card .stats { display: flex; gap: 6px; justify-content: center; font-size: 12.5px; font-weight: 700; }
.stat { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.stat svg { width: 12px; height: 12px; }
.stat.poor { color: var(--bad); }
.card .inc {
  position: absolute; top: 4px; right: 4px; font-size: 10.5px; font-weight: 800; color: #2d6a33;
  background: #e1f0d7; border-radius: 7px; padding: 0 5px; line-height: 16px;
}
.card.live { cursor: pointer; box-shadow: 0 0 0 2px var(--accent-soft), 0 2px 6px rgba(31, 42, 26, .12); }
.card.live:hover { transform: translateY(-2px); }
.card.selected { box-shadow: 0 0 0 3px var(--accent), 0 4px 10px rgba(31, 42, 26, .18); transform: translateY(-3px); }
.card.blocked { cursor: pointer; }
.card.blocked .shape { opacity: .35; filter: grayscale(.7); }
.card.blocked .stat.days { opacity: .45; }
.card.ph { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(31, 42, 26, .1); }
.card.wait { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(31, 42, 26, .16); justify-content: center; gap: 2px; }
.card.wait.live { cursor: pointer; box-shadow: inset 0 0 0 2px var(--accent-soft); }
.card.wait.live:hover { background: var(--card); }
.wait-title { font-weight: 750; font-size: 15px; }
.wait-gain { display: inline-flex; align-items: center; gap: 2px; font-weight: 750; color: var(--accent); }
.wait-gain svg { width: 13px; height: 13px; }
.wait-day { font-size: 11.5px; color: var(--muted); }
.card.slide { animation: slide .5s ease-out 1 both; }
@keyframes slide { from { transform: translateX(14px); opacity: .2; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------- gardens */
.garden-box { width: 100%; display: flex; justify-content: center; }
.garden {
  display: grid; gap: 0;
  grid-template-columns: repeat(9, var(--cell)); grid-auto-rows: var(--cell);
  padding: 4px; border-radius: 12px; background: var(--soil-dark);
  box-shadow: 0 3px 10px rgba(40, 25, 5, .18);
}
.cell { position: relative; overflow: hidden; }
.cell.soil {
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .07) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #8a6243, #735036);
  box-shadow: inset 0 0 0 .5px rgba(40, 20, 5, .4);
}
.cell.bed {
  background:
    radial-gradient(circle at 28% 30%, rgba(255, 255, 255, .5) 0 9%, transparent 10%),
    radial-gradient(circle at 72% 62%, rgba(255, 255, 255, .35) 0 8%, transparent 9%),
    var(--fc, #8bc34a);
  border: 0 solid rgba(25, 20, 10, .6);
}
.cell.e-t { border-top-width: 2px; }
.cell.e-r { border-right-width: 2px; }
.cell.e-b { border-bottom-width: 2px; }
.cell.e-l { border-left-width: 2px; }
.cell.seedling { background: radial-gradient(circle at 50% 60%, #a3d77f 0 40%, #6fae52 70%); }
.cell .seed { position: absolute; inset: 22%; width: 56%; height: 56%; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .3)); }
.cell .sprout-ico { position: absolute; inset: 12%; width: 76%; height: 76%; }
.garden.interactive .cell { cursor: pointer; }
.cell.soil.hint::after {
  content: ""; position: absolute; inset: 36%; border-radius: 50%;
  background: rgba(190, 240, 150, .8); box-shadow: 0 0 6px rgba(190, 240, 150, .7);
}
.garden.previewing .cell.soil.hint::after { opacity: .4; }
.cell.ghost { z-index: 1; animation: ghostin .15s ease-out; }
.cell.ghost.ok { background: color-mix(in srgb, var(--fc, #8bc34a) 80%, #fff); box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px var(--accent); }
.cell.ghost.bad { background: color-mix(in srgb, var(--fc, #8bc34a) 55%, #fff); box-shadow: inset 0 0 0 3px var(--bad); }
.cell.ghost.bad::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(198, 58, 46, .45) 0 5px, transparent 5px 10px);
}
.cell.ghost.pivot::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .45); z-index: 2;
}
@keyframes ghostin { from { opacity: .4; } to { opacity: 1; } }
.cell.recent { animation: grow 1.1s ease-out 1 both; }
@keyframes grow { 0% { filter: brightness(1.6) saturate(.6); } 100% { filter: none; } }
.cell.lastp::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7); }
.garden.bonus-win { box-shadow: 0 0 0 3px var(--sun), 0 3px 10px rgba(40, 25, 5, .18); }

.garden.mini { grid-template-columns: repeat(9, var(--mini)); grid-auto-rows: var(--mini); padding: 3px; border-radius: 8px; }
.garden.mini .cell.e-t { border-top-width: 1px; }
.garden.mini .cell.e-r { border-right-width: 1px; }
.garden.mini .cell.e-b { border-bottom-width: 1px; }
.garden.mini .cell.e-l { border-left-width: 1px; }
.viewer-garden { display: flex; justify-content: center; margin-bottom: 12px; }

/* ------------------------------------------------------------- action bar */
.actionbar {
  /* In flow under the board, but sticky: on short screens it stays on screen. */
  position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 5;
  width: fit-content; max-width: 100%; margin: 8px auto 0; min-height: 54px;
  display: flex; gap: 6px; align-items: center; padding: 5px;
  background: var(--card); border-radius: 18px; white-space: nowrap;
  box-shadow: 0 4px 18px rgba(31, 42, 26, .16);
  animation: barin .18s ease-out;
}
.actionbar:empty { visibility: hidden; animation: none; }
@keyframes barin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 359px) { .actionbar .lbl { display: none; } }

/* ------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(20, 32, 16, .42); padding: 14px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 420px; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow-y: auto;
  background: var(--card); border-radius: 20px; padding: 18px;
  box-shadow: 0 12px 40px rgba(15, 25, 10, .28);
  animation: pop .18s ease-out;
}
.modal.wide { max-width: 600px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 12px; font-size: 20px; text-align: center; }
.modal-head { display: flex; align-items: center; gap: 8px; margin: -6px -6px 8px 0; }
.modal-head h2 { flex: 1; margin: 0; text-align: left; }
.modal .lede { margin: -4px 0 14px; text-align: center; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .btn { flex: 1 1 auto; }

.menu-overlay { background: rgba(20, 32, 16, .12); place-items: start end; padding: 50px 10px 0; }
.menu {
  min-width: 210px; background: var(--card); border-radius: 16px; padding: 6px;
  box-shadow: 0 10px 30px rgba(15, 25, 10, .22); animation: pop .15s ease-out; display: grid;
}
.menu button {
  min-height: 48px; padding: 0 14px; border: 0; background: transparent; text-align: left;
  border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 550;
}
.menu button:hover { background: var(--soft); }
@media (min-width: 1060px) { .menu-overlay { padding-right: calc((100vw - 1040px) / 2 + 8px); } }

.field { margin: 14px 0; }
.field-label { font-weight: 650; margin-bottom: 6px; font-size: 14px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--soft); }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 650; }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }

/* info + viewer */
.info-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.info-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 4px; }
.rows, .rival-stats { display: grid; gap: 2px; font-size: 13.5px; }
.row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.row span { color: var(--muted); }
.row.hl span, .row.hl b { color: var(--ink); font-weight: 750; }
.sub-title { margin: 20px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.season { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 2px; }
.day {
  position: relative; aspect-ratio: 1 / 1; border-radius: 4px; background: #ebe8d6; min-width: 0;
  display: grid; place-items: center; font-size: 9px; color: #8a8062; font-weight: 700; line-height: 1;
}
.day.harvest { background: #f2cf6b; color: #6d4c0c; }
.day.sprout { background: #b5de9c; color: #2c5a22; }
.day.taken { background: #e4e9d8; }
.day .ico { position: absolute; inset: 14%; width: 72%; height: 72%; }
.day .num { position: relative; z-index: 1; }
.day.end { background: linear-gradient(135deg, #f2cf6b, #e59b3b); color: #5a3508; }
.dpawn { position: absolute; z-index: 3; width: 64%; height: 64%; border-radius: 50%; background: var(--pc); border: 2px solid #fff; top: 18%; left: 18%; }
.dpawn.two-a { left: -4%; top: 4%; }
.dpawn.two-b { left: 40%; top: 32%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; }
.key-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.key-dot.harvest { background: #f2cf6b; }
.key-dot.sprout { background: #b5de9c; }
.later { display: flex; flex-wrap: wrap; gap: 6px; }
.lcard { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; border-radius: 10px; background: var(--soft); min-width: 64px; }
.lcard .stats { display: flex; gap: 5px; font-size: 11.5px; font-weight: 700; }
.lcard .stat.inc { color: #2d6a33; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 13px; max-height: 36vh; overflow-y: auto; }
.log li { display: flex; gap: 7px; align-items: flex-start; }
.log li .av { width: 18px; height: 18px; font-size: 10px; margin-top: 1px; }
.log li.sys { color: var(--muted); font-style: italic; }

/* help */
.help-body h3 { margin: 16px 0 4px; font-size: 15px; }
.help-body h3:first-child { margin-top: 0; }
.help-body p, .help-body li { font-size: 14px; }
.help-body ul, .help-body ol { padding-left: 20px; margin: 4px 0; }
.help-body .formula { text-align: center; font-weight: 700; background: var(--accent-soft); border-radius: 10px; padding: 8px; }
.plot-key { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.plot-key .card { width: 88px; flex: none; }
.plot-key ul { flex: 1 1 200px; margin: 0; }
.plot-key .stat { font-weight: 700; }

/* game over */
.go-table { display: grid; gap: 6px; }
.go-row { border-radius: 12px; padding: 10px 12px; }
.go-row.win { background: var(--accent-soft); }
.go-head { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.go-head .total { margin-left: auto; font-size: 22px; }
.go-lines { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.go-lines span:nth-child(even) { text-align: right; font-weight: 700; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Online play (online.js): a presence line under the status, in the same grid row. */
.status-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.status-row .net { color: var(--muted); justify-content: flex-start; padding: 0 3px; }
body.is-online #btn-new { display: none; }
/* The online row sits above How to play and carries the menu's one divider (online, Leave is the
   first row, so it has none). */
.menu #menu-online { border-top: 1px solid rgba(31, 42, 26, .12); border-radius: 0 0 10px 10px; margin-top: 4px; }
#over-leave { display: flex; width: 100%; margin-top: 8px; }
