/* Sound Garden: cut paper on cobalt. Flat shapes, hard offset shadows, no gradients. */
:root {
  --field: #2A36B8;
  --field-deep: #2230A0;
  --ink: #14185A;
  --paper: #FFF4D6;
  --paper-dim: #F3E4BC;
  --marigold: #FFB627;
  --leaf: #177A4A;
  --wilt: #B3261E;
  --display: Futura, "Trebuchet MS", "Century Gothic", "Avenir Next", sans-serif;
  --body: "Gill Sans", "Gill Sans MT", Optima, Candara, "Segoe UI", sans-serif;
  --cut: 16px 22px 14px 24px / 22px 14px 24px 16px;
  --cut-small: 9px 13px 8px 14px / 13px 8px 14px 9px;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--field);
  /* Two cut leaves that run off the page edges, so no shape ever shows a clipped side. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cpath fill='%233542C8' d='M0 0H250C270 40 200 60 225 110C170 90 165 150 115 130C125 190 60 180 70 235C40 225 20 250 0 240Z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cpath fill='%233542C8' d='M300 300H60C30 260 95 240 75 195C125 210 130 150 180 170C170 110 235 120 225 65C255 75 280 50 300 60Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left top, right bottom;
  background-size: min(46vw, 420px), min(46vw, 420px);
  background-attachment: fixed;
  color: var(--paper);
  font: 400 1rem/1.45 var(--body);
}

h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0; }
p { margin: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 1px;
  box-shadow: 0 0 0 7px var(--marigold);
}

/* ---- paper parts ---- */

.sheet {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--cut);
  box-shadow: 5px 6px 0 var(--ink);
  padding: 14px;
}

.paper-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--cut-small);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
  font: 600 0.95rem/1.15 var(--body);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.paper-btn:hover { background: #fff; }
.paper-btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.sheet .paper-btn { background: var(--paper-dim); }
.sheet .paper-btn:hover { background: #fff; }

.big-btn {
  min-height: 54px;
  padding: 10px 24px;
  background: var(--marigold);
  font: 800 1.15rem/1.1 var(--display);
}
.big-btn:hover { background: #FFC54F; }

.paper-btn:disabled { cursor: not-allowed; opacity: 1; background: #DCD3BA; color: #5A5B75; box-shadow: none; }

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  max-width: 1240px;
  margin: 0 auto;
}
.wordmark {
  font: 800 1.2rem/1 var(--display);
  white-space: nowrap;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.topbar .paper-btn { font-size: 0.88rem; padding: 6px 11px; }
#sound-toggle[aria-pressed="true"] { background: var(--marigold); }

main { max-width: 1240px; margin: 0 auto; padding: 0 12px 28px; }

/* ---- title ---- */

.title-screen {
  display: grid;
  gap: 18px;
  justify-items: center;
}
.hero-wheel { width: min(100%, 62dvh, 660px); }
.hero-wheel svg { display: block; width: 100%; height: auto; overflow: visible; }
.hero-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 128px;
  letter-spacing: 3px;
  fill: var(--paper);
}
.title-copy { max-width: 34rem; display: grid; gap: 12px; justify-items: start; }
.lede { font: 600 clamp(1.2rem, 1.05rem + 0.7vw, 1.55rem)/1.28 var(--body); }
.sub { font-size: 1.02rem; }
.title-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 4px; }

.open-garden { width: 100%; margin-top: 6px; }
.open-garden summary { cursor: pointer; font-weight: 600; min-height: 32px; padding: 4px 0; }
.saved-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.saved-list:empty { display: none; }
.saved-list .paper-btn { width: 100%; justify-content: flex-start; text-align: left; }
.open-garden label { display: block; margin: 8px 0 4px; }
.open-row { display: flex; gap: 8px; }
.open-row input { flex: 1; min-width: 0; }
input[type="text"] {
  min-height: 44px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: var(--cut-small);
  background: #fff;
  color: var(--ink);
  font: 400 0.92rem/1.2 ui-monospace, Menlo, Consolas, monospace;
}
.form-error { min-height: 1.4em; margin-top: 6px; font-weight: 600; color: var(--paper); }

/* ---- play layout: phone order is brief, wheel, editor, checks ---- */

.play-screen {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "brief" "stage" "editor" "checks";
}
/* While choosing seeds the wheel is empty, so phones show the packets first. */
.play-screen.is-planting { grid-template-areas: "brief" "editor" "stage" "checks"; }
.brief { grid-area: brief; }
.stage { grid-area: stage; display: grid; gap: 8px; justify-items: center; align-content: start; min-width: 0; }
.editor { grid-area: editor; min-width: 0; }
.checks { grid-area: checks; min-width: 0; display: grid; gap: 10px; align-content: start; }

.wheel { width: min(100%, 56dvh, 660px); min-width: 280px; }
.wheel svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.wheel .cell { cursor: pointer; }
.glyph, .sun, .wedge, .open-ring, .picked { pointer-events: none; }
.glyph, .sun { transform-box: fill-box; transform-origin: center; }
.wedge { transform-origin: 500px 500px; transition: transform 90ms linear; }
.cell.lit { fill: #4A55D8; }
.cell.cursor { stroke: var(--paper); stroke-width: 5px; }
.wedge.is-hush .wedge-shape { fill: #000; opacity: 0.55; }

.caption {
  min-height: 1.5em;
  font-weight: 600;
  text-align: center;
  font-size: 0.98rem;
}

.transport { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; width: 100%; }
#play-toggle { min-width: 92px; }
.dew { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 1.05rem; }
.dew svg { width: 18px; height: 22px; flex: none; }
.rain-btn { background: #6FD3F2; }

/* ---- bed tiles ---- */

.beds {
  width: 100%;
  max-width: 660px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.bed-tile {
  appearance: none;
  position: relative;
  display: grid;
  justify-items: center;
  gap: 1px;
  min-height: 92px;
  padding: 3px 2px 5px;
  border: 0;
  border-radius: var(--cut-small);
  background: var(--field-deep);
  color: var(--paper);
  font: 600 0.72rem/1.1 var(--body);
  cursor: pointer;
  touch-action: manipulation;
}
.bed-tile svg { display: block; width: 100%; max-width: 54px; height: 62px; overflow: visible; }
.bed-tile[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 3px 4px 0 var(--ink); }
.bed-tile.is-sounding { background: #4A55D8; color: #fff; }
.bed-tile.is-sounding[aria-pressed="true"] { background: #FFE96E; color: var(--ink); }
.bed-tile.is-closed { opacity: 0.72; cursor: default; }
.bed-tile.is-open-empty { outline: 2px dashed var(--marigold); outline-offset: -3px; }
.bed-tile .role { font-size: 0.66rem; font-weight: 400; min-height: 1.1em; }
.sprite-head { transform-box: fill-box; }

/* ---- brief and checks ---- */

.steps { list-style: none; display: flex; gap: 6px; margin: 0 0 10px; padding: 0; }
.steps li {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border-radius: var(--cut-small);
  background: var(--paper-dim);
  font: 600 0.74rem/1.15 var(--body);
  text-align: center;
}
.steps li.is-now { background: var(--ink); color: var(--paper); }
.steps li.is-grown { background: var(--leaf); color: #fff; }
.steps li.is-wilted { background: var(--wilt); color: #fff; }
.brief h2 { font-size: 1.45rem; margin-bottom: 4px; }

.check-group + .check-group { margin-top: 10px; }
.check-group h3 { font: 700 0.95rem/1.2 var(--body); margin-bottom: 4px; }
.check-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.check-group li { display: grid; grid-template-columns: 20px 1fr; gap: 6px; font-size: 0.96rem; line-height: 1.3; }
.check-group svg { width: 18px; height: 18px; margin-top: 1px; }

.zone-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 0.86rem; }
.zone-legend span { display: inline-flex; align-items: center; gap: 5px; }
.zone-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px 6px 3px 6px; border: 1.5px solid var(--ink); }

.chart-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 3px; }
.chart { display: grid; gap: 2px; align-items: end; }
.crowd-chart { grid-template-columns: repeat(16, minmax(0, 1fr)); height: 68px; }
.ladder-chart { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; height: 96px; max-width: 260px; }
.bar-col { display: grid; grid-template-rows: 1fr auto; height: 100%; justify-items: stretch; align-items: end; text-align: center; font-size: 0.72rem; gap: 2px; }
.bar { min-height: 3px; background: var(--ink); border-radius: 3px 4px 2px 4px; }
.bar-col.is-silent .bar { background: transparent; border: 2px dashed var(--ink); min-height: 12px; }
.bar-col.is-now { font-weight: 800; }
.bar-col.is-now .bar { background: #3C4AD8; }
.ladder-chart .bar { background: #C2316E; display: grid; justify-items: center; align-content: start; color: #fff; font-weight: 700; font-size: 0.85rem; min-height: 22px; }
.ladder-chart .bar.is-empty { background: transparent; border: 2px dashed var(--ink); color: var(--ink); }
.ladder-chart .bar.is-flat { background: var(--wilt); }
.charts-wrap { display: grid; gap: 10px; }

.grow-btn { width: 100%; min-height: 54px; background: var(--marigold) !important; font: 800 1.1rem/1.1 var(--display); }
.grow-btn:disabled { background: #DCD3BA !important; color: #5A5B75; font-weight: 600; }

/* ---- tray and editor ---- */

.tray h2, .bed-heading h2 { font-size: 1.25rem; }
.tray > p { margin: 2px 0 10px; font-size: 0.95rem; }
.packets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.packet {
  appearance: none;
  display: grid;
  gap: 2px;
  justify-items: center;
  align-content: start;
  padding: 6px 5px 8px;
  border: 0;
  border-top: 9px solid var(--band, var(--marigold));
  border-radius: var(--cut-small);
  background: var(--ink);
  color: var(--paper);
  font: 400 0.8rem/1.2 var(--body);
  text-align: center;
  cursor: pointer;
  box-shadow: 3px 4px 0 var(--ink);
  touch-action: manipulation;
}
.packet svg { width: 54px; height: 72px; }
.packet strong { font: 800 0.98rem/1.1 var(--display); }
.packet .maker { font-size: 0.72rem; }
.packet:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.seed-dots { display: grid; grid-template-columns: repeat(8, 7px); gap: 2px; margin-top: 4px; }
.seed-dots i { width: 7px; height: 7px; border-radius: 50%; border: 1.2px solid var(--paper); }
.seed-dots i.on { background: var(--paper); }
.tray-back { margin-top: 10px; }

.bed-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; margin-bottom: 8px; }
.bed-heading p { font-size: 0.88rem; }
.bed-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.tool-btn {
  appearance: none;
  min-height: 44px;
  padding: 4px 4px;
  border: 2px solid var(--ink);
  border-radius: var(--cut-small);
  background: transparent;
  color: var(--ink);
  font: 600 0.82rem/1.1 var(--body);
  cursor: pointer;
  touch-action: manipulation;
}
.tool-btn:hover { background: #fff; }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.strip { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.step {
  appearance: none;
  position: relative;
  min-height: 56px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 7px 10px 6px 11px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  font: 500 0.66rem/1 var(--body);
  overflow: hidden;
}
.step.q-even { background: var(--paper-dim); }
.step .num { position: absolute; top: 2px; left: 3px; }
.step .height { position: absolute; bottom: 3px; left: 3px; font: 800 0.92rem/1 var(--display); }
.step svg { position: absolute; right: 2px; width: 24px; height: 24px; overflow: visible; }
.step[data-level="0"] svg { top: 15px; }
.step[data-level="1"] svg { top: 25px; }
.step[data-level="2"] svg { top: 15px; }
.step[data-level="3"] svg { top: 4px; }
.step.is-on { background: var(--ink); color: var(--paper); }
.step.is-now { box-shadow: 0 0 0 3px #3C4AD8; }
.step.is-hush { border-style: dashed; border-color: var(--leaf); }
.step:disabled { cursor: not-allowed; }

/* ---- result ---- */

.result-screen { display: grid; gap: 18px; justify-items: center; }
.result-wheel { width: 100%; display: grid; justify-items: center; gap: 6px; }
.result-copy { width: 100%; max-width: 36rem; display: grid; gap: 10px; }
.rank { font-weight: 700; font-size: 1.05rem; }
.garden-name { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 3rem); font-weight: 800; }
.garden-name:focus, .garden-name:focus-visible { outline: none; box-shadow: none; }
.score-total { font: 800 2.6rem/1 var(--display); margin: 2px 0 8px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.score-table td { padding: 3px 0; }
.score-table td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.flourish-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.flourish-list li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.flourish-list svg { width: 20px; height: 20px; margin-top: 1px; }
.flourish-list strong { display: block; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.code-label { font-weight: 600; font-size: 0.9rem; margin-top: 4px; }
.code-field { width: 100%; }
.note { font-size: 0.9rem; min-height: 1.3em; }

/* ---- toast and dialogs ---- */

.toast {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 30rem);
  pointer-events: none;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--cut-small);
  box-shadow: 0 0 0 2px var(--paper);
  font-weight: 600;
  text-align: center;
  z-index: 5;
}

.dialog {
  width: min(94vw, 38rem);
  max-height: 88dvh;
  overflow: auto;
  border: 0;
  padding: 20px;
}
.dialog::backdrop { background: rgba(16, 20, 78, 0.72); }
.dialog h2 { font-size: 1.6rem; margin-bottom: 8px; }
.dialog h2:focus, .dialog h2:focus-visible { outline: none; box-shadow: none; }
.dialog h3 { font-size: 1.05rem; margin: 14px 0 4px; }
.dialog ol { padding-left: 1.3rem; margin: 10px 0; display: grid; gap: 8px; }
.dialog p + p { margin-top: 8px; }
.keys { margin: 6px 0 12px; display: grid; gap: 4px; }
.keys div { display: grid; grid-template-columns: 9.5rem 1fr; gap: 8px; }
.keys dt { font-weight: 700; }
.keys dd { margin: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---- laptop ---- */

@media (max-width: 519px) {
  .wordmark { display: none; }
}

@media (min-width: 960px) {
  .play-screen, .play-screen.is-planting {
    grid-template-columns: minmax(420px, 1.05fr) minmax(380px, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "stage brief" "stage editor" "stage checks";
    gap: 14px 22px;
    align-items: start;
  }
  .wheel { width: min(100%, 68dvh); }
  .charts-wrap { grid-template-columns: 1.5fr 1fr; align-items: start; }
  .crowd-chart, .ladder-chart { height: 84px; }
  .title-screen {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    align-items: center;
    gap: 36px;
    padding-top: 8px;
  }
  .hero-wheel { width: min(100%, 84dvh); justify-self: end; }
  .result-screen {
    grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
    align-items: start;
    gap: 32px;
  }
  .result-wheel .wheel { width: min(100%, 80dvh); }
}

@media (max-width: 380px) {
  .keys div { grid-template-columns: 1fr; gap: 0; }
  .topbar .paper-btn { padding: 6px 8px; font-size: 0.82rem; }
  .bed-tile { font-size: 0.66rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .paper-btn:active { transform: none; }
}
