/* Sunny Clover play app. Colors copied from brands/sunny_clover/site/tokens.css. */
:root {
  --coral: #e85d75; --coral-dark: #c94a61; --teal: #4ec5c1; --teal-dark: #3aa8a4;
  --mango: #ffc857; --mint: #a8e6cf; --clover: #2f9e44; --peach: #f4a261;
  --paper: #fff7e8; --paper-alt: #ffe9c7; --ink: #2b211a; --ink-muted: #5c4d40;
  --line: #f0d4a8; --error: #a3341f; --good: #2f9e44;
  --card: #ffffff; --radius: 18px; --shadow: 0 6px 18px rgba(43, 33, 26, .1);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --bar-h: 56px; --foot-h: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); background: var(--paper); color: var(--ink);
  font-size: 17px; line-height: 1.5; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- top bar + dots ---------- */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px; background: var(--coral); color: var(--paper);
  min-height: var(--bar-h);
}
.bar-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--paper);
  display: grid; place-items: center; flex: none; text-decoration: none; color: var(--coral-dark); font-size: 22px;
}
.bar-title { flex: 1; min-width: 0; }
.bar-series { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.bar-case { font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 6px; justify-content: center; padding: 10px 12px 4px; flex-wrap: wrap; }
.dot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--card);
  font-size: 13px; font-weight: 800; color: var(--ink-muted); display: grid; place-items: center; padding: 0;
}
.dot.done { background: var(--teal); border-color: var(--teal-dark); color: #fff; }
.dot.here { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(232, 93, 117, .25); }

/* ---------- main ---------- */
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 16px 24px; outline: none; }
h1, h2 { line-height: 1.15; margin: 8px 0 6px; }
h1 { font-size: 28px; } h2 { font-size: 24px; }
.lede { color: var(--ink-muted); margin: 0 0 14px; }
.page-ref { font-size: 13px; color: var(--ink-muted); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 12px 0; }
.looking {
  background: var(--mango); border-radius: 14px; padding: 10px 14px; font-weight: 700; margin: 10px 0;
}
.looking small { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 800; }

.btn {
  border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 800; background: var(--coral); color: #fff;
  min-height: 48px; box-shadow: 0 3px 0 var(--coral-dark);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--coral-dark); }
.btn.alt { background: var(--teal); box-shadow: 0 3px 0 var(--teal-dark); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: 0 0 0 2px var(--line) inset; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.pill {
  border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 700; min-height: 44px;
}
.pill.on { background: var(--teal); border-color: var(--teal-dark); color: #fff; }
.msg { min-height: 1.5em; font-weight: 700; margin: 6px 0; }
.msg.good { color: var(--good); } .msg.bad { color: var(--error); }

/* ---------- case file (home) ---------- */
.hero { display: grid; gap: 14px; grid-template-columns: 120px 1fr; align-items: center; }
.hero img { width: 120px; border-radius: 10px; box-shadow: var(--shadow); }
.steps { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.steps button {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; border: 0; background: var(--card);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); min-height: 56px;
}
.steps .num {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-alt);
  font-weight: 800; flex: none;
}
.steps .done .num { background: var(--teal); color: #fff; }
.steps .lbl { flex: 1; font-weight: 700; }
.steps .st { font-size: 13px; color: var(--ink-muted); }
.badge {
  display: grid; place-items: center; width: 150px; height: 150px; margin: 10px auto; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--mango), var(--peach)); color: var(--ink);
  border: 6px dashed #fff; box-shadow: 0 0 0 6px var(--mango), var(--shadow); text-align: center;
  font-weight: 900; font-size: 20px; line-height: 1.1; transform: rotate(-6deg);
}
.badge span { display: block; font-size: 13px; letter-spacing: .1em; }
.privacy { font-size: 13px; color: var(--ink-muted); margin-top: 24px; }

/* ---------- book pages ---------- */
.book-page { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow); background: #fff; margin: 12px 0; cursor: zoom-in; border: 0; padding: 0; }
.book-page img { width: 100%; display: block; border-radius: 6px; }
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(43, 33, 26, .92); display: flex; flex-direction: column; }
.viewer-bar { display: flex; gap: 8px; justify-content: flex-end; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px; }
.viewer-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.viewer-scroll img { display: block; width: 100%; max-width: none; margin: 0 auto; background: #fff; }

/* ---------- clue list ---------- */
.clues { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.clues label {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 0 0 2px var(--line) inset; min-height: 48px; cursor: pointer;
}
.clues input { width: 24px; height: 24px; accent-color: var(--teal-dark); flex: none; margin-top: 1px; }
.clues .ticked span { text-decoration: line-through; color: var(--ink-muted); }
details.clue-box { margin: 12px 0; }
details.clue-box summary { font-weight: 800; cursor: pointer; padding: 8px 0; min-height: 44px; }

/* ---------- letter soup ---------- */
.bowl {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 18px 16px; border-radius: 34px;
  background: var(--paper-alt); box-shadow: inset 0 0 0 3px var(--line), inset 0 -10px 0 rgba(240, 212, 168, .6);
  max-width: 820px; margin: 0 auto;
}
.tile {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; font-weight: 900;
  font-size: 18px; display: grid; place-items: center; padding: 0; position: relative;
}
.tile.used { opacity: .35; border-style: dashed; }
.tile.used::after { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; border-top: 2px solid var(--ink); transform: rotate(-35deg); }
.slots { display: grid; gap: 10px; margin-top: 14px; }
.slot { background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: 0 0 0 2px var(--line) inset; cursor: pointer; }
.slot.active { box-shadow: 0 0 0 3px var(--coral) inset; }
.slot.right { box-shadow: 0 0 0 3px var(--good) inset; }
.slot.wrong { box-shadow: 0 0 0 3px var(--error) inset; }
.slot .clue { font-size: 15px; margin-bottom: 6px; }
.slot .tag { font-size: 12px; color: var(--ink-muted); font-weight: 700; }
.boxes { display: flex; gap: 4px; flex-wrap: wrap; }
.box {
  width: 34px; height: 38px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; font-weight: 900;
  font-size: 19px; display: grid; place-items: center; padding: 0;
}
.box.cursor { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral); }
.box.fixed { background: var(--paper-alt); }

/* ---------- word search ---------- */
.ws-wrap {
  position: relative; margin: 10px auto; width: min(100%, max(300px, calc(100dvh - 230px)), 900px);
  touch-action: none; user-select: none; -webkit-user-select: none; container-type: inline-size;
}
.ws-grid { display: grid; border: 3px solid var(--ink); background: #fff; border-radius: 4px; }
.ws-cell {
  aspect-ratio: 1; display: grid; place-items: center; font-weight: 900; font-size: calc(100cqw / var(--n) * .52);
  border-right: 1px solid #d9cbb5; border-bottom: 1px solid #d9cbb5;
}
.ws-cell.start { background: var(--mango); }
.ws-svg { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); pointer-events: none; }
.ws-words { user-select: none; -webkit-user-select: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.ws-word { padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: 0 0 0 2px var(--line) inset; font-weight: 800; letter-spacing: .06em; border: 0; font-size: inherit; min-height: 40px; }
button.ws-word { cursor: pointer; }
.ws-word.found { background: var(--mint); text-decoration: line-through; }

/* ---------- sudoku ---------- */
.sd { display: grid; margin: 6px auto; width: min(100%, max(280px, calc(100dvh - 330px)), 720px); border: 3px solid var(--ink); background: #fff; container-type: inline-size; }
.sd-top { display: flex; justify-content: center; min-height: 1.6em; font-weight: 800; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.sd-cell {
  aspect-ratio: 1; border: 1px solid #bfae95; background: #fff; display: grid; place-items: center; padding: 0;
  font-size: calc(100cqw / var(--n) * .55); font-weight: 800; position: relative;
}
.sd-cell.bR { border-right: 3px solid var(--ink); } .sd-cell.bB { border-bottom: 3px solid var(--ink); }
.sd-cell.given { color: var(--ink); }
.sd-cell.started { color: #8c8c8c; }
.sd-cell.user { color: var(--teal-dark); }
.sd-cell.peer { background: #fff3dc; }
.sd-cell.same { background: #ffe2a8; }
.sd-cell.sel { background: var(--mango); }
.sd-cell.bad { color: var(--error); background: #fde3dd; }
.notes { position: absolute; inset: 2px; display: grid; font-size: calc(100cqw / var(--n) * .22); color: var(--ink-muted); font-weight: 700; }
.notes span { display: grid; place-items: center; }
.notes span.hl { color: var(--ink); background: var(--mango); border-radius: 4px; }
.sd-cell.clash { color: var(--error); text-decoration: underline wavy var(--error); text-underline-offset: 4px; }
.pad { display: grid; gap: 6px; width: min(100%, max(280px, calc(100dvh - 330px)), 720px); margin: 10px auto; }
.pad button { min-height: 56px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 24px; font-weight: 900; display: grid; place-items: center; line-height: 1; padding: 4px 0; }
.pad button small { font-size: 11px; font-weight: 700; color: var(--ink-muted); }
.pad button.doneDigit { opacity: .45; }
.pad-tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.pill:disabled { opacity: .4; }

/* ---------- logic grid (joined, like the book) ---------- */
.lg-layout { display: grid; gap: 16px; align-items: start; }
.lg-wrap { container-type: inline-size; min-width: 0; }
.lg-scroll { overflow-x: auto; padding: 2px; }
.lg {
  --lab: 22px;
  --cell: clamp(30px, min(calc((100cqw - var(--lab) - 4px) / (var(--cols) + 1.6)), calc((100dvh - 120px) / (var(--rows) + 1.9))), 104px);
  --side: calc(var(--cell) * 1.6); --head: calc(var(--cell) * 1.3);
  display: grid; width: max-content; margin: 0 auto;
  grid-template-columns: var(--lab) var(--side) repeat(var(--cols), var(--cell));
  grid-template-rows: auto var(--head) repeat(var(--rows), var(--cell));
}
.lg-cat { font-size: clamp(9px, calc(var(--cell) * .26), 13px); line-height: 1.1; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); display: flex; align-items: flex-end; justify-content: center; text-align: center; padding-bottom: 3px; }
.lg-cat-side { align-items: center; padding: 0; }
.lg-cat-side span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.lg-head, .lg-side {
  background: #fff; border: 1px solid var(--ink); margin: 0 -1px -1px 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 3px 2px; text-align: center; overflow: hidden; min-width: 0;
  font-size: clamp(8px, calc(var(--cell) * .19), 15px); line-height: 1.05; font-weight: 700;
}
.lg-head .lg-ico { height: calc(var(--head) - 2.6em); max-width: 90%; object-fit: contain; }
.lg-side .lg-ico { height: calc(var(--cell) - 2.5em); max-width: 80%; object-fit: contain; }
.lg-cell {
  border: 1px solid var(--ink); margin: 0 -1px -1px 0; background: #fff; padding: 0; font-size: calc(var(--cell) * .62);
  font-weight: 900; display: grid; place-items: center; line-height: 1; position: relative;
}
.lg-cell.bL { border-left-width: 3px; } .lg-cell.bR { border-right-width: 3px; }
.lg-cell.bT { border-top-width: 3px; } .lg-cell.bB { border-bottom-width: 3px; }
.lg-cell.x { color: #4a4a4a; }
.lg-cell.auto { color: #b9aea0; }
.lg-cell.ok { color: var(--ink); background: #e6f7ec; }
.lg-cell.bad { background: #fde3dd; box-shadow: inset 0 0 0 3px var(--error); }
.lg-corner {
  border: 0; background: transparent; text-align: left; padding: 8% 6% 0 10%; display: flex; flex-direction: column; justify-content: flex-start;
  gap: 6%; font-size: clamp(10px, calc(var(--cell) * .24), 20px);
}
.ans-line { border-bottom: 2px solid var(--ink); padding-bottom: 2px; display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.ans-line b { font-weight: 900; } .ans-line span { color: var(--teal-dark); font-weight: 800; }
.lg-clues { display: none; }
.lg-clues h3 { margin: 0 0 8px; }
.clue-fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(var(--foot-h) + 18px + env(safe-area-inset-bottom)); z-index: 30;
  border: 0; border-radius: 999px; background: var(--teal); color: #fff; font-weight: 900; padding: 12px 18px; box-shadow: var(--shadow); min-height: 48px;
}
.clue-drawer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--foot-h) + env(safe-area-inset-bottom)); z-index: 31; max-height: 46dvh; overflow: auto;
  background: var(--paper); border-top: 3px solid var(--teal); box-shadow: 0 -8px 24px rgba(43, 33, 26, .18); padding: 12px 16px;
}
@media (min-width: 980px) {
  .lg-layout { grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); }
  .lg-clues { display: block; position: sticky; top: 80px; }
  .clue-fab, .clue-drawer { display: none !important; }
}
.answer { display: grid; gap: 10px; }
.answer .field b { display: block; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- footer ---------- */
.foot {
  position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 8px; background: var(--paper);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); border-top: 2px solid var(--line);
}
.nav-btn { border: 0; border-radius: 999px; min-height: 48px; padding: 0 18px; font-weight: 800; background: var(--paper-alt); }
.nav-next { background: var(--coral); color: #fff; }
.nav-btn:disabled { opacity: .35; }
.foot-mid { flex: 1; text-align: center; font-size: 13px; color: var(--ink-muted); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--foot-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800; opacity: 0;
  transition: opacity .25s, transform .25s; pointer-events: none; z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes pop { 0% { transform: scale(.6) rotate(-6deg); opacity: 0 } 70% { transform: scale(1.08) rotate(-6deg) } 100% { transform: scale(1) rotate(-6deg); opacity: 1 } }
.badge.pop { animation: pop .6s var(--ease, ease-out); }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-6px) } 75% { transform: translateX(6px) } }
.shake { animation: shake .3s; }

/* tablet / desktop */
@media (min-width: 700px) {
  body { font-size: 18px; }
  .tile { width: 46px; height: 46px; font-size: 20px; }
  .box { width: 38px; height: 42px; }
  .slots { grid-template-columns: 1fr 1fr; }
  .book-pages-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* embedded in a website: no sticky bars fighting the host page */
.embed .bar { padding-top: 6px; }

/* ---------- shelf: unlock card, devices, case list ---------- */
.unlock { display: grid; gap: 10px; }
.unlock .lede { margin: 0; }
.field-in {
  width: 100%; min-height: 48px; border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px;
  font: inherit; font-size: 17px; background: var(--paper); color: var(--ink);
}
.field-in:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(78, 197, 193, .3); }
#unlockCode { text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 700; min-height: 44px; }
.check input { width: 24px; height: 24px; accent-color: var(--teal); flex: none; }
.msg:empty { display: none; }
.msg { font-weight: 700; }
.msg a { color: var(--coral-dark); }
.devices { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.devices li { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--paper); border-radius: 12px; padding: 8px 12px; }
.devices small { color: var(--ink-muted); font-weight: 400; }
.cases { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.privacy { font-size: 13px; color: var(--ink-muted); text-align: center; margin: 18px 0 8px; }

/* ---------- logic grid help ---------- */
.lg-cell.given { background: #d9f2ef; cursor: default; }
.lg-cell.given::after { content: "Clue 1"; position: absolute; left: 2px; bottom: 1px; font-size: 9px; font-weight: 800; color: var(--teal-dark); letter-spacing: 0; }
.lg-cell { position: relative; }
.lg-cell.hint { outline: 4px solid var(--mango); outline-offset: -4px; z-index: 2; animation: hintPulse 1s ease-in-out 3; }
@keyframes hintPulse { 50% { background: #fff1c9; } }
@media (prefers-reduced-motion: reduce) { .lg-cell.hint { animation: none; } }
.msg.hint-msg { background: #fff6df; border: 2px solid var(--mango); border-radius: 14px; padding: 10px 12px; font-weight: 600; color: var(--ink); }
.msg.hint-msg b { font-weight: 800; }
.clues .order-note { list-style: none; background: var(--paper-alt); border-radius: 12px; padding: 8px 12px; font-size: 15px; }
.howto ol { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 6px; }
.howto { background: var(--card); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); margin: 12px 0; }
.howto summary { font-weight: 800; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
