/* Gentle Harvest prototype. Colours follow Gentle Mahjong's palette: an
   evening (dark) table by default and a daylight (light) one. */
:root, body[data-theme="evening"] {
  --paper: #14201c; --panel: #1f302a; --panel-strong: #29403a; --ink: #f8f2e7; --muted: #c3cec8;
  --card: #fffdf6; --card-ink: #24302b; --card-muted: #56625b; --edge: #b99a62;
  --accent: #62cfb5; --accent-ink: #10201b; --focus: #fff1a8; --shadow: rgba(0, 0, 0, .45);
  color-scheme: dark;
}
body[data-theme="daylight"] {
  --paper: #f4ecdc; --panel: #fffaf0; --panel-strong: #efe4cd; --ink: #24302b; --muted: #56625b;
  --card: #fffdf6; --card-ink: #24302b; --card-muted: #56625b; --edge: #c8ad7f;
  --accent: #176b5b; --accent-ink: #ffffff; --focus: #bd4b26; --shadow: rgba(50, 43, 31, .2);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { font-family: Georgia, serif; line-height: 1.2; }
main { max-width: 1120px; margin: 0 auto; padding: 16px 16px 48px; }
button, select, input { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 16px; top: -60px; padding: 10px 16px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 800; z-index: 10; }
.skip-link:focus { top: 12px; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 8px 0 16px; }
.topbar h1 { margin: 0; font-size: clamp(30px, 5vw, 40px); }
.eyebrow { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.round-button, .quiet-button, .primary-button {
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--accent);
  background: transparent; color: var(--ink); font-weight: 700; cursor: pointer;
}
.primary-button { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.round-button:hover, .quiet-button:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
button:disabled { opacity: .55; cursor: not-allowed; }
/* A pile you can't take from right now keeps its card crisp; only the words dim. */
.pile:disabled { opacity: 1; }
.pile:disabled .pile-label { opacity: .7; }

.intro { max-width: 640px; margin: 32px auto; padding: 32px; border-radius: 24px; background: var(--panel); text-align: center; }
.intro h2 { margin-top: 0; font-size: 30px; }
.intro-season { color: var(--muted); }

.table { display: flex; flex-direction: column; gap: 20px; }
.status-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.status-row p { margin: 0; }
.course-label { font-weight: 800; }
.season-label { color: var(--muted); }

/* The round table, seen from above: four quarters, one per seat, around
   the hotpot. Each quarter has its own soft tint; you sit at the bottom. */
.round-table {
  --q-north: color-mix(in srgb, #6fa862 30%, var(--panel));
  --q-east: color-mix(in srgb, #8e4a86 30%, var(--panel));
  --q-south: color-mix(in srgb, #d9822b 32%, var(--panel));
  --q-west: color-mix(in srgb, #3e5c82 34%, var(--panel));
  --q-line: color-mix(in srgb, var(--edge) 70%, var(--paper));
  /* A true circle: its height is set from the same length as its width, so the
     seats' contents can never stretch it into an oval. */
  --size: min(calc(100vw - 32px), 760px);
  position: relative; width: var(--size); height: var(--size); margin: 0 auto; box-sizing: border-box; padding: 7%;
  border-radius: 50%; border: 10px solid var(--q-line); box-shadow: 0 10px 30px var(--shadow), inset 0 0 0 3px color-mix(in srgb, var(--edge) 40%, transparent);
  background: conic-gradient(from -45deg, var(--q-north) 0 89deg, var(--q-line) 89deg 91deg, var(--q-east) 91deg 179deg, var(--q-line) 179deg 181deg, var(--q-south) 181deg 269deg, var(--q-line) 269deg 271deg, var(--q-west) 271deg 359deg, var(--q-line) 359deg 360deg);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
  grid-template-areas: ". north ." "west centre east" ". south ."; align-items: center; justify-items: center;
}
.seats { display: contents; margin: 0; padding: 0; list-style: none; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.seat--north { grid-area: north; align-self: start; }
.seat--south { grid-area: south; align-self: end; flex-direction: column-reverse; }
.seat--west { grid-area: west; justify-self: start; }
.seat--east { grid-area: east; justify-self: end; }
.seat p { margin: 0; }
.seat-plate { padding: 6px 12px; border-radius: 14px; background: color-mix(in srgb, var(--paper) 80%, transparent); border: 2px solid transparent; text-align: center; max-width: 100%; }
.seat--active .seat-plate { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.seat-compass { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.seat-name { font-weight: 800; }
.seat-detail { font-size: 14px; color: var(--muted); }
/* A companion's face-down hand: a row of overlapping card backs. */
.seat-backs { display: flex; padding-left: 14px; }
.seat-back { width: 22px; height: 31px; margin-left: -14px; border-radius: 4px; border: 2px solid var(--card); background: repeating-linear-gradient(45deg, var(--accent) 0 4px, color-mix(in srgb, var(--accent) 65%, var(--paper)) 4px 8px); box-shadow: 0 1px 3px var(--shadow); }
.seat-discard { display: flex; align-items: center; gap: 8px; padding: 4px; min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; text-align: left; }
button.seat-discard:not(:disabled) { cursor: pointer; box-shadow: 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--paper) 50%, transparent); }
button.seat-discard:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
button.seat-discard:disabled { opacity: 1; cursor: default; }
.seat-discard-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.card.card--mini { width: 66px; height: 84px; border-width: 1.5px; border-radius: 8px; flex: none; }
.card--mini .card-band { padding: 3px 2px; }
.card--mini .card-icon { width: 14px; height: 14px; }
.card--mini .card-family { font-size: 10.5px; letter-spacing: 0; }
.card--mini .card-name { font-size: 12px; padding: 0 2px; }
.card--mini .card-season { display: none; }

/* The hotpot in the middle, with the draw pile resting on it. */
.centre { grid-area: centre; position: relative; display: grid; place-items: center; width: 100%; height: 100%; }
.centre > .pot, .centre > .pile { grid-area: 1 / 1; }
.piles { display: flex; gap: 20px; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px; border: 0; border-radius: 16px; background: transparent; color: var(--ink); cursor: pointer; }
.pile:not(:disabled):hover .pile-back, .pile:not(:disabled):hover .pile-face { transform: translateY(-3px); }
.pile-label { display: flex; flex-direction: column; align-items: center; font-weight: 700; font-size: 15px; }
.pile-count { font-weight: 400; color: var(--muted); }
.pile-back {
  width: 104px; height: 140px; border-radius: 12px; border: 3px solid var(--card);
  background: repeating-linear-gradient(45deg, var(--accent) 0 8px, color-mix(in srgb, var(--accent) 70%, var(--paper)) 8px 16px);
  box-shadow: 0 4px 12px var(--shadow); transition: transform .15s ease;
}
.pile-face { transition: transform .15s ease; }
.pile-face--empty { width: 104px; height: 140px; border: 2px dashed var(--muted); border-radius: 12px; }

/* The timer: a pot comes to a simmer as the turn runs on. */
.timer-area { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.timer-area[hidden] { display: none; }
.pot { --simmer: .3; width: 100%; height: 100%; max-width: 260px; max-height: 260px; }
.pot-rim { fill: #34403b; stroke: var(--ink); stroke-width: 3; }
body[data-theme="daylight"] .pot-rim { fill: #5a6660; }
.pot-handle { fill: #34403b; stroke: var(--ink); stroke-width: 3; }
.pot-broth { fill: #d9822b; }
.pot-bits circle { fill: #6fa862; }
.pot-bits circle:nth-child(2n) { fill: #b8462f; }
/* Bubbles rise as the turn's timer runs on: barely there, then rolling. */
.pot-bubbles circle { fill: none; stroke: #fff1d6; stroke-width: 2; opacity: calc(.15 + var(--simmer) * .85); transform-box: fill-box; transform-origin: center; transform: scale(calc(.6 + var(--simmer) * .8)); }
.pile--draw { z-index: 1; padding: 4px; gap: 2px; }
.pile--draw .pile-back { width: 76px; height: 104px; }
.pile--draw .pile-label { padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--paper) 80%, transparent); font-size: 13px; line-height: 1.3; }
.pile--draw .pile-count { font-size: 12px; }
.timer-area { margin-top: 10px; }
.timer-text { margin: 0; font-weight: 700; }

.turn-prompt { margin: 0; min-height: 1.5em; font-size: 19px; font-weight: 700; text-align: center; }

.hand-area { display: flex; flex-direction: column; gap: 8px; }
.hand-title { margin: 0; font-size: 22px; }
.hand { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; border-radius: 24px; background: var(--panel); min-height: 200px; }
.hand:focus { outline: none; }
.hand-group { display: flex; flex-direction: column; gap: 6px; }
.hand-group-title { margin: 0; font-size: 14px; font-weight: 800; color: var(--muted); }
.hand-group--set .hand-group-cards { padding: 6px; border-radius: 16px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.hand-group-cards { display: flex; flex-wrap: wrap; gap: 8px; }

/* A card: family band (colour + symbol + name), then the ingredient. */
.card {
  position: relative; display: flex; flex-direction: column; width: 104px; height: 140px; padding: 0; overflow: hidden;
  border-radius: 12px; border: 2px solid var(--edge); background: var(--card); color: var(--card-ink);
  box-shadow: 0 3px 8px var(--shadow); text-align: center; transition: transform .15s ease, box-shadow .15s ease;
}
button.card { cursor: pointer; }
.card-band { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; background: var(--fam); color: var(--fam-ink); }
.card-icon { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-family { font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.card-name { flex: 1; display: grid; place-items: center; padding: 0 6px; font-family: Georgia, serif; font-size: 17px; font-weight: 700; line-height: 1.15; }
.card-season { padding: 0 4px 6px; font-size: 12px; color: var(--card-muted); }
.card-tag { position: absolute; top: 4px; right: 4px; padding: 1px 6px; border-radius: 999px; background: var(--card-ink); color: var(--card); font-size: 11px; font-weight: 800; }
.card[aria-pressed="true"] { transform: translateY(-10px); box-shadow: 0 0 0 4px var(--accent), 0 8px 16px var(--shadow); }
.card--new { box-shadow: 0 0 0 3px var(--focus), 0 3px 8px var(--shadow); }
.card--resting { cursor: default; }
button.card:not(.card--resting):hover { transform: translateY(-4px); }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.progress-text { margin: 0; text-align: center; color: var(--muted); }

.log summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.log-list { margin: 0; padding-left: 20px; color: var(--muted); font-size: 15px; }

/* Dialogs */
.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 24px; background: var(--panel); color: var(--ink); box-shadow: 0 16px 48px var(--shadow); }
.dialog--wide { width: min(900px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 16, 14, .6); }
.dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dialog-body h2 { margin: 0; font-size: 26px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
fieldset { margin: 0; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--muted) 50%, transparent); border-radius: 16px; display: flex; flex-direction: column; gap: 8px; }
fieldset[hidden], .companion-field[hidden] { display: none; }
legend { padding: 0 6px; font-weight: 800; }
.choice { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding-top: 10px; }
.choice input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
.field select { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--muted); background: var(--paper); color: var(--ink); font-weight: 400; }
/* Drawn by hand so every browser shows the same thing: the filled part of the
   track is exactly the volume the label says (--fill, set by the game). */
.field input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; }
.field input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--fill, 20%), var(--panel-strong) var(--fill, 20%)); border: 1px solid var(--muted); }
.field input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--fill, 20%), var(--panel-strong) var(--fill, 20%)); border: 1px solid var(--muted); }
.field input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--accent); border: 3px solid var(--ink); }
.field input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--ink); }
.field input[type="range"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.field output { font-weight: 400; color: var(--muted); }
.settings-note { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.rules { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.keys dt { font-weight: 800; }
.keys dd { margin: 0; }
.result-list, .result-recipes { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.recipe-families { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.recipe-family { padding: 12px 16px; border-radius: 16px; background: var(--panel-strong); border-top: 6px solid var(--fam); }
.recipe-family h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 18px; }
.recipe-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.recipe-family ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.recipe { color: var(--muted); }
.recipe--cooked { color: var(--ink); font-weight: 700; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .card, .pile-back, .pile-face--empty { width: 74px; height: 108px; }
  .card-band { padding: 6px 2px 4px; }
  .card-name { font-size: 14px; padding: 0 3px; }
  .card-season { font-size: 11px; }
  .hand-group-cards { gap: 6px; }
  .card-icon { width: 22px; height: 22px; }
  .card-family { font-size: 11px; letter-spacing: 0; }
  .hand { padding: 12px; gap: 12px; }
  .round-table { padding: 6%; border-width: 6px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); }
  .seat { gap: 3px; }
  .seat-plate { padding: 3px 6px; }
  .seat-name { font-size: 14px; }
  .seat-detail, .seat-compass { display: none; }
  .seat-back { width: 14px; height: 20px; margin-left: -10px; border-width: 1.5px; }
  .seat-backs { padding-left: 10px; }
  .seat-discard { padding: 2px; gap: 4px; min-height: 0; }
  .seat-discard-label { display: none; }
  .pile--draw .pile-back { width: 44px; height: 60px; border-width: 2px; }
  .pile--draw .pile-label { font-size: 11px; }
  .card.card--mini { width: 48px; height: 62px; }
  .card--mini .card-band { padding: 2px 1px; }
  .card--mini .card-icon { width: 11px; height: 11px; }
  .card--mini .card-family { font-size: 8.5px; }
  .card--mini .card-name { font-size: 10px; line-height: 1.05; }
  .round-button { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  body:not([data-motion="full"]) * { transition: none !important; animation: none !important; }
}
body[data-motion="reduced"] * { transition: none !important; animation: none !important; }
