/* So Clover! — the box is white and clover-green with a hand-lettered feel. */
:root {
  --green: #3faa35;
  --green-deep: #2b7a24;
  --green-soft: #d8f0d2;
  --green-pale: #eef9ec;
  --ink: #13301a;
  --muted: #5c7a60;
  --paper: #ffffff;
  --shade: #f3faf1;
  --red: #d8442f;
  --gold: #e8a317;
  --line: #bcdcb4;
  --radius: 14px;
  --font: 'Nunito', 'Trebuchet MS', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--green-pale);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(63, 170, 53, 0.10) 0 3%, transparent 3.2%),
    radial-gradient(circle at 78% 12%, rgba(63, 170, 53, 0.08) 0 2.4%, transparent 2.6%),
    radial-gradient(circle at 62% 84%, rgba(63, 170, 53, 0.09) 0 3.4%, transparent 3.6%),
    radial-gradient(circle at 26% 72%, rgba(63, 170, 53, 0.07) 0 2%, transparent 2.2%);
}

h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); color: var(--green-deep); }
h2 { font-size: clamp(1.1rem, 2.4vw, 1.5rem); }
p { line-height: 1.55; }

.wrap { max-width: 1180px; margin: 0 auto; padding: clamp(12px, 2.5vw, 28px); }

.card-panel {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(14px, 2.2vw, 22px);
  box-shadow: 0 2px 0 rgba(43, 122, 36, 0.10);
}

button {
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  border: none;
  border-bottom: 3px solid var(--green-deep);
  border-radius: 999px;
  padding: 0.7em 1.4em;
  cursor: pointer;
  min-height: 44px;
}
button:hover:not(:disabled) { background: var(--green-deep); }
button:disabled { background: #b9cdb6; border-bottom-color: #9bb398; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--green-deep); border: 2px solid var(--line); border-bottom-width: 2px; }
button.ghost:hover:not(:disabled) { background: var(--green-soft); color: var(--green-deep); }
button.danger { background: var(--red); border-bottom-color: #a33222; }

input[type="text"], input[type="number"] {
  font: inherit;
  padding: 0.6em 0.8em;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  min-height: 44px;
  width: 100%;
}
input:focus-visible, button:focus-visible, [role="button"]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.stack > * + * { margin-top: 14px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- the clover board ---------- */

.clover {
  position: relative;
  width: min(92vw, 640px);
  aspect-ratio: 1;
  margin: 0 auto;
}
/* On a table screen the board is the whole point, so let it grow into the room. */
@media (min-width: 900px) {
  .clover { width: min(78vh, 760px); }
}

.lobe {
  position: absolute;
  background: var(--green-soft);
  border: 2px solid var(--line);
  border-radius: 46% 46% 46% 46% / 52% 52% 52% 52%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  text-align: center;
}
.lobe-n, .lobe-s { left: 15%; width: 70%; height: 23%; }
.lobe-w, .lobe-e { top: 15%; height: 70%; width: 23%; }
.lobe-n { top: 0; }
.lobe-s { bottom: 0; }
.lobe-w { left: 0; }
.lobe-e { right: 0; }

.clue {
  font-weight: 800;
  font-size: clamp(0.85rem, 2.4vw, 1.35rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green-deep);
  word-break: break-word;
  line-height: 1.1;
}
.clue.empty { color: #a8c6a2; }
.lobe-pair {
  font-size: clamp(0.55rem, 1.3vw, 0.74rem);
  color: var(--muted);
  line-height: 1.2;
  max-width: 94%;
  max-height: 94%;
  overflow: hidden;
}
.lobe-w .clue, .lobe-e .clue, .lobe-w .lobe-pair, .lobe-e .lobe-pair { writing-mode: vertical-rl; }
.lobe-w .clue, .lobe-w .lobe-pair { rotate: 180deg; }

.grid {
  position: absolute;
  inset: 25%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3%;
}

.slot {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: var(--shade);
  display: grid;
  place-items: center;
}
.slot.empty .slot-hint { color: #a8c6a2; font-size: 0.72rem; }
.slot.selected { border-style: solid; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232, 163, 23, 0.3); }
.slot.locked { border-style: solid; border-color: var(--green); background: #e8f7e4; }
.slot.mark-ok { border-color: var(--green); }
.slot.mark-bad { border-color: var(--red); }
.slot[role="button"] { cursor: pointer; }

.card {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.word {
  position: absolute;
  font-size: clamp(0.5rem, 1.45vw, 0.82rem);
  font-weight: 700;
  line-height: 1;
  max-width: 88%;
  overflow-wrap: anywhere;
  text-align: center;
}
.word.top { top: 5%; }
.word.bottom { bottom: 5%; }
.word.left { left: 5%; writing-mode: vertical-rl; rotate: 180deg; max-height: 84%; }
.word.right { right: 5%; writing-mode: vertical-rl; max-height: 84%; }
.word.live { color: var(--ink); }
.word.dead { color: #b3c9ae; }

.rotate {
  position: absolute;
  right: -8px; bottom: -8px;
  width: 34px; height: 34px; min-height: 34px;
  padding: 0;
  font-size: 1rem;
  border-radius: 50%;
  display: grid; place-items: center;
}
.mark {
  position: absolute;
  top: -12px; left: -12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900;
  background: var(--paper);
  border: 2px solid currentColor;
}
.mark-ok .mark { color: var(--green); }
.mark-bad .mark { color: var(--red); }

/* ---------- loose cards, face up in the middle of the table ---------- */

.pool { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.loose {
  position: relative;
  width: clamp(92px, 15vw, 132px);
  aspect-ratio: 1;
  cursor: pointer;
}
.loose .card { border-color: var(--line); box-shadow: 0 2px 0 rgba(43, 122, 36, 0.12); }
.loose.selected .card { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232, 163, 23, 0.35); }
.loose.dimmed { opacity: 0.35; }
.loose .word { font-size: clamp(0.52rem, 1.5vw, 0.74rem); color: var(--ink); }

/* ---------- lists, scores, badges ---------- */

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 8px;
  background: var(--shade);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
}
.players li.away { opacity: 0.5; }
.players li.spectator { border-color: var(--gold); background: #fdf6e6; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c6d9c2; }
.dot.ready { background: var(--green); }
.pill {
  background: var(--green-deep); color: #fff;
  border-radius: 999px; padding: 2px 10px;
  font-size: 0.78rem; font-weight: 800;
}

.code {
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--green-deep);
  line-height: 1;
}
.qr { background: #fff; padding: 10px; border-radius: 10px; border: 2px solid var(--line); }
.qr img { display: block; width: clamp(120px, 18vw, 190px); height: auto; image-rendering: pixelated; }

.scoreboard { width: 100%; border-collapse: collapse; }
.scoreboard th, .scoreboard td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.scoreboard td.num { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.big-score { font-size: clamp(2.4rem, 9vw, 5rem); font-weight: 900; color: var(--green-deep); line-height: 1; }
.record { color: var(--gold); font-weight: 800; }

.notes { margin: 0; padding-left: 1.1em; }
.notes li { margin: 0.25em 0; }
.warn-text { color: #8a6100; }
.bad-text { color: var(--red); }

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 700;
  border: 2px solid var(--line);
  background: var(--shade);
}
.banner.good { border-color: var(--green); background: #e8f7e4; }
.banner.bad { border-color: var(--red); background: #fdeeec; }
.banner.hush { border-color: var(--gold); background: #fdf6e6; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .clover { width: min(96vw, 460px); }
  .wrap { padding: 10px; }
}

@media (prefers-reduced-motion: no-preference) {
  .slot, .loose, .lobe { transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease; }
}

/* ---------- writing clues on a phone ---------- */

/*
 * The clue inputs used to sit inside the clover's lobes, which put a text box
 * a thumb-width wide inside a vertical oval. The clover stays as the picture
 * of the board; typing happens in a plain stack underneath it.
 */
.clue-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.clue-row:last-child { border-bottom: none; }
.clue-row .zone {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  border: 2px solid var(--line);
  font-weight: 900; color: var(--green-deep);
}
.clue-row .pair {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 6px;
}
.clue-row .pair .plus { color: var(--muted); font-weight: 600; margin: 0 6px; }
.clue-row input { text-transform: uppercase; font-weight: 800; }
.clue-row.bad input { border-color: var(--red); background: #fdeeec; }
.clue-row.warn input { border-color: var(--gold); background: #fdf6e6; }
.clue-row .msg { font-size: 0.8rem; margin-top: 5px; line-height: 1.35; }
