  :root {
    color-scheme: light; /* keep forced-dark modes off the native widgets */
    --cream: #faf6ec;
    --ink: #33302a;
    --soil: #b08968;
    --soil-dark: #8f6f52;
    --leaf: #4f7952; /* white button text needs 4.5:1; #588157 measured 4.47 */
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { background: var(--cream); }
  body {
    font-family: ui-rounded, "Segoe UI", system-ui, sans-serif;
    background: var(--cream);
    color: var(--ink);
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center;
    padding: 28px 12px 56px;
  }
  header { text-align: center; margin-bottom: 18px; }
  h1 { font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.02em; transform: rotate(-0.4deg); }
  header p { opacity: .78; margin-top: 4px; font-size: 15px; }
  #meta { font-size: 13px; opacity: .78; margin-top: 6px; }
  /* mirrors #meta; shown only when JavaScript is off (see the <noscript> block) */
  .noscript-note { font-size: 13px; opacity: .78; margin-top: 6px; }
  #garden-wrap { width: min(94vmin, 640px); max-width: 100%; }
  #garden {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    width: 100%;
    /* reserve the square even before the skeleton tiles are built, or the
       arriving grid pushes the footer down on slow connections */
    aspect-ratio: 1;
    background: var(--soil-dark);
    padding: 8px;
    border-radius: 10px;
    box-shadow: 6px 6px 0 rgba(51,48,42,.15);
  }
  .tile {
    appearance: none;
    aspect-ratio: 1;
    background: var(--soil);
    border: none;
    border-radius: 3px;
    padding: 0;
    font: inherit;
    color: inherit;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(10px, 2.4vmin, 20px);
    cursor: pointer;
    user-select: none;
    /* rapid taps on neighbouring tiles must not double-tap-zoom the page */
    touch-action: manipulation;
    transition: filter .12s;
    line-height: 1;
  }
  .tile:hover { filter: brightness(1.15); outline: 1px solid rgba(255,255,255,.35); }
  .tile:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 1; position: relative; }
  .tile.mine { box-shadow: inset 0 0 0 2px rgba(51,48,42,.55); } /* plants under your name */
  @media (max-width: 520px), (pointer: coarse) {
    /* The whole 24×24 world stays available as a pannable map. At this zoom,
       each plot is at least 44px instead of an error-prone 22px target. */
    #garden-wrap {
      width: 100%; height: min(calc(100vw - 24px), 440px);
      overflow: auto; overscroll-behavior: contain; padding-bottom: 6px;
    }
    #garden { width: 1120px; }
  }
  footer { margin-top: 20px; font-size: 13px; opacity: .78; text-align: center; }
  .mobile-hint { display: none; }
  @media (max-width: 520px), (pointer: coarse) { .mobile-hint { display: inline; } }

  /* visually hidden live region for plant/water confirmations */
  .sr-only {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip-path: inset(50%); overflow: hidden; white-space: nowrap;
  }

  /* modals */
  .modal-backdrop {
    position: fixed; inset: 0; background: rgba(51,48,42,.45);
    display: none; align-items: center; justify-content: center; z-index: 10;
    overflow-y: auto; padding: 16px;
  }
  .modal-backdrop.open { display: flex; }
  .modal {
    background: var(--cream); border-radius: 14px; padding: 22px;
    width: min(100%, 380px); max-height: calc(100vh - 32px); overflow-y: auto;
    box-shadow: 8px 8px 0 rgba(51,48,42,.25);
    border: 2px solid var(--ink);
  }
  .modal h2 { font-size: 18px; margin-bottom: 12px; }
.modal h2 small { font-weight: normal; opacity: .78; }
.dim { opacity: .78; } /* muted body text; kept as a class so CSP can stay strict */
  .species-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .species-btn {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 2px solid rgba(51,48,42,.2); border-radius: 10px;
    padding: 10px 12px; cursor: pointer; font-size: 15px; text-align: left;
  }
  .species-btn:hover { border-color: var(--ink); }
  .species-btn.selected { border-color: var(--leaf); box-shadow: inset 0 0 0 1px var(--leaf); }
  .species-btn:focus-visible { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 2px; }
  .species-btn .e { font-size: 22px; }
  .species-btn small { display: block; opacity: .78; font-size: 12px; }
  .row { display: flex; gap: 8px; margin-top: 12px; }
  fieldset { border: 0; }
  .name-field { margin-top: 14px; }
  .name-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
  .name-field label span, .name-field small { font-weight: normal; opacity: .78; }
  .name-field small { display: block; font-size: 12px; margin-top: 4px; }
  input[type=text] {
    width: 100%; min-width: 0; padding: 9px 12px; border-radius: 8px;
    border: 2px solid rgba(51,48,42,.2); font-size: 16px; background: #fff;
    /* 16px so iOS Safari doesn't zoom the viewport on focus */
  }
  button.primary {
    padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer;
    background: var(--leaf); color: #fff; font-weight: 600; font-size: 14px;
  }
  button.primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
  button.primary:disabled { opacity: .45; cursor: default; }
  button.ghost {
    padding: 9px 14px; border-radius: 8px; cursor: pointer;
    background: transparent; border: 2px solid rgba(51,48,42,.25); font-size: 14px;
  }
  button.ghost:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
  .form-msg { margin-top: 10px; font-size: 13px; color: #9d3b3b; }
  .form-msg[hidden] { display: none; }
  #plant-info p { margin: 6px 0; font-size: 15px; }
  #plant-info .stage { font-size: 34px; margin: 8px 0; }
  @media (prefers-reduced-motion: reduce) {
    .tile { transition: none; }
  }
