/* Visual theme: light pastel page, cream cards with firm black outlines and hard shadows,
   pill buttons and a rounded sans. Loaded last, so it restyles the existing class names
   without changing any behaviour. */
:root {
  --bg: #a9d3f5;
  --card: #fffdf6;
  --card-2: #ffffff;
  --line: #111111;
  --line-strong: #111111;
  --rule: rgba(17, 17, 17, 0.14);
  --ink: #111111;
  --ink-soft: #222222;
  --muted: #4d4d4d;
  --accent: #f7d3fb;
  --accent-deep: #eaa6f2;
  --accent-ink: #111111;
  --accent-soft: #fbe6fd;
  --accent-glow: rgba(17, 17, 17, 0.9);
  --ok: #1d6b45;
  --ok-bg: #d9f5e4;
  --bad: #a3202a;
  --bad-bg: #fde0e2;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 4px 4px 0 #111111;
  --shadow-sm: 3px 3px 0 #111111;
  --serif: "Sansita", "Mulish", system-ui, sans-serif;
  --sans: "Mulish", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: var(--sans);
}

html { background: var(--bg); }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Header: sits on the page colour, separated by a firm rule. */
.top {
  background: var(--bg);
  border-bottom: 3px solid var(--line);
  padding: 14px 20px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2.5px solid var(--line);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.wordmark { font-family: var(--serif); font-size: 28px; line-height: 1; font-weight: 400; color: var(--ink); }
.meta { font-family: var(--sans); font-size: 12px; line-height: 1.5; letter-spacing: 0; color: var(--ink-soft); font-weight: 600; }
.meta strong { color: var(--ink); font-weight: 800; }
.meta .count {
  color: var(--ink);
  font-weight: 800;
  background: var(--accent);
  padding: 0 5px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  font-variant-numeric: tabular-nums;
}

main { gap: 22px; padding: 24px 16px 8px; }

/* Cards: cream surface, firm outline, hard offset shadow. */
.card {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* The clue card leads the page. */
.clue-card { padding: 24px 22px 22px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 14px;
}
.eyebrow::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--line);
}
.clue {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(28px, 7.4vw, 38px);
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin: 0 0 26px;
  color: var(--ink);
  text-wrap: balance;
}

/* Answer tiles: white squares, firm outline, a clear focus state. */
.answer { gap: 8px; margin-bottom: 18px; }
.box {
  width: 50px;
  height: 58px;
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  background: var(--card-2);
  border: 2.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease;
}
.box:focus { outline: none; background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent); }
.box.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); box-shadow: none; }
.box.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); box-shadow: none; }

.msg { font-size: 15px; font-weight: 700; min-height: 1.4em; margin-bottom: 12px; color: var(--ink-soft); }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--bad); }

/* Buttons: pill shapes in the pink accent, pressed in on tap. */
.actions { gap: 12px; }
.btn {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  min-height: 52px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 2.5px solid var(--line);
  color: var(--ink);
  background: var(--card-2);
  box-shadow: var(--shadow-sm);
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.15s ease;
}
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: 0.45; box-shadow: none; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn.ghost { background: var(--card-2); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn.small { min-height: 38px; font-size: 14px; padding: 6px 16px; box-shadow: 2px 2px 0 #111; }
.btn:focus-visible, .chip:focus-visible, .link-btn:focus-visible, .how summary:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.link-btn { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.link-btn:hover:not(:disabled) { background: var(--accent-soft); border-radius: 6px; }
.link-btn:disabled { color: var(--muted); }

/* Section headings: bold sans, tracked caps. */
.section-title {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 14px;
}
.muted { color: var(--muted); font-size: 15px; line-height: 1.5; font-weight: 500; }

/* Hint pills */
.hooks { padding: 22px; }
.chips { gap: 10px; }
.chip {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card-2);
  border: 2.5px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 42px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.15s ease;
}
.chip:hover:not(:disabled) { background: var(--accent-soft); }
.chip:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #111; }
.chip:disabled { opacity: 0.5; box-shadow: none; }
.chip.revealed { background: var(--accent); }
.chip .n { color: var(--ink); font-family: var(--sans); font-weight: 800; font-size: 13px; }
.hint-out { margin-top: 14px; }
.hint-out .hint-line {
  border: 2.5px solid var(--line);
  background: var(--card-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 16px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.hint-out .hint-line + .hint-line { margin-top: 10px; }
.hint-out .hint-label {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Solution */
.solution { background: var(--card); border-color: var(--line); }
.solution[hidden] { display: none; }
.parts div { border-bottom: 2px solid var(--rule); padding-bottom: 10px; grid-template-columns: 150px 1fr; }
.parts div:last-child { border-bottom: 0; }
.parts dt { font-family: var(--sans); font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.parts dd { font-size: 16px; color: var(--ink); font-weight: 500; }
.parts .answer-word { font-family: var(--serif); font-size: 24px; color: var(--ink); }
.tomorrow { font-size: 13px; color: var(--muted); margin-top: 14px; font-weight: 600; }

/* How-it-works disclosure */
.how { padding: 0; }
.how summary { font-size: 16px; font-weight: 800; color: var(--ink); padding: 18px 22px; }
.how summary::before { color: var(--ink); }
.how-body { color: var(--ink-soft); font-size: 16px; line-height: 1.6; padding: 0 22px 20px; font-weight: 500; }
.how-body strong { color: var(--ink); font-weight: 800; }

/* Forum and proposals */
.forum, .propose { padding: 22px; }
.post {
  background: var(--card-2);
  border: 2.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.post.reply { margin-left: 20px; box-shadow: 2px 2px 0 #111; }
.post.mine { background: var(--accent-soft); }
.author { font-size: 15px; font-weight: 800; color: var(--ink); }
.you { color: var(--ink-soft); font-weight: 700; }
.solve-badge { color: var(--muted); font-weight: 700; font-size: 12px; }
.solve-badge.ok { color: var(--ok); }
.kind-chip {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.kind-chip.full { background: var(--accent); color: var(--ink); }
.post-body { font-size: 16px; line-height: 1.55; color: var(--ink); font-weight: 500; }
.post-body.spoiler { color: var(--ink-soft); }
.post-body.muted, .muted.post-body { font-style: normal; color: var(--muted); }
.edited { font-size: 12px; color: var(--muted); font-weight: 600; }
.post-actions { gap: 16px; }
.edit-area { background: var(--card-2); border: 2.5px solid var(--line); border-radius: var(--radius-sm); }
.reply-box { background: var(--accent-soft); border: 2px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); font-weight: 700; }

.field { color: var(--ink); font-weight: 700; font-size: 14px; }
.field input, .field select, .field textarea {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--card-2);
  border: 2.5px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; box-shadow: 0 0 0 4px var(--accent); }
.check { color: var(--ink); font-weight: 600; }
.check input { accent-color: var(--ink); }
.divider { color: var(--muted); font-weight: 700; }
.divider::before, .divider::after { background: var(--rule); }
.proposal { background: var(--card-2); border: 2.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 12px 14px; margin-bottom: 10px; }
.proposal-title { font-weight: 700; }
.proposal-status { color: var(--muted); font-weight: 700; }
.proposal.approved .proposal-status { color: var(--ok); }
.proposal.rejected .proposal-status { color: var(--bad); }
.sub-title { color: var(--ink); font-weight: 800; }
.admin-link { font-weight: 800; color: var(--ink); }
.nudge { margin: 16px 0 0; text-align: center; font-size: 14px; color: var(--ink-soft); }
.nudge .link-btn { color: var(--ink); font-weight: 700; text-decoration: underline; }
.nudge[hidden] { display: none; }

.foot {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 22px 16px 34px;
}

/* Sign-in dialog */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 17, 17, 0.35); }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: 6px 6px 0 #111111;
  padding: 24px 22px 22px;
  animation: modal-in 0.18s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--ink); }
.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }
.modal-card .muted { margin: 0 0 16px; font-size: 14px; }
.modal-card .auth-form { gap: 4px; }
.modal-card .field { margin-bottom: 14px; }
.modal-card .btn.primary { min-height: 52px; }
.modal-card .btn.wide + .btn.wide { margin-top: 10px; }
.modal-card #authToggle { align-self: center; margin-top: 6px; font-size: 14px; color: var(--ink); }
.modal-card #authMagic { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.modal-card #authMagic:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.modal-card .divider { margin: 16px 0 12px; }
.modal-card .social { gap: 10px; }
.modal-card .auth-msg { margin: 12px 0 0; min-height: 0; }
.modal-card .profile { margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--rule); }
.modal-card .signed-in { color: var(--ink); }

/* Admin page */
.admin-wrap h1 { font-family: var(--serif); font-weight: 400; font-size: 32px; color: var(--ink); }
.row-card { background: var(--card-2); border: 2.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.row-card .facts { color: var(--muted); font-weight: 600; }
.row-card .clue-line { color: var(--ink); font-weight: 700; }
.row-card input, .row-card select { background: var(--card); border: 2px solid var(--line); border-radius: 10px; color: var(--ink); }
.row-card label { color: var(--ink-soft); font-weight: 700; }
.empty { color: var(--muted); font-weight: 600; }

/* Phone header: brand on its own row, status and sign-in beneath. */
#authOpen { white-space: nowrap; }
@media (max-width: 480px) {
  .top { flex-wrap: wrap; row-gap: 10px; }
  .top .brand { flex: 0 0 auto; }
  .top .top-right { order: 3; width: 100%; justify-content: space-between; align-items: center; }
  .meta { font-size: 12px; white-space: normal; text-align: left; }
  .box { width: 42px; height: 52px; font-size: 21px; }
  .answer { gap: 6px; }
  .modal { place-items: end center; padding: 0; }
  .modal-card {
    max-width: none;
    border-radius: 22px 22px 0 0;
    max-height: 90vh;
    padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
    animation: sheet-in 0.2s ease-out;
    box-shadow: 0 -4px 0 #111111;
  }
}
@keyframes sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (min-width: 640px) {
  main { padding-top: 36px; gap: 26px; }
  .clue { font-size: 46px; }
  .box { width: 56px; height: 66px; font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Owner review page: keep every control inside its card on phones, with even spacing. */
.admin-wrap {
  box-sizing: border-box;
  width: 100%;
  max-width: 760px;
  padding: 18px 16px calc(56px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
.admin-wrap > section,
.admin-wrap > div { min-width: 0; }
.admin-wrap h1 { font-size: 28px; line-height: 1.15; margin: 4px 0 6px; overflow-wrap: anywhere; }
.admin-wrap .card { box-sizing: border-box; min-width: 0; }
.admin-wrap .stack { display: grid; gap: 18px; min-width: 0; }
.row-card {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 14px;
  margin: 0;
  box-shadow: 3px 3px 0 #111111;
  display: grid;
  gap: 10px;
}
.row-card > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
.row-card .facts, .row-card .clue-line { overflow-wrap: anywhere; }
.row-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.row-card label { display: grid; gap: 4px; min-width: 0; }
.row-card input,
.row-card select {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  display: block;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}
.row-card input[type="date"] { padding-right: 10px; }
.row-card select { background-image: linear-gradient(45deg, transparent 50%, #111 50%), linear-gradient(135deg, #111 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.row-card .btns {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.row-card .btns .btn {
  flex: 1 1 120px;
  min-height: 46px;
  min-width: 0;
  max-width: 100%;
  box-shadow: 2px 2px 0 #111111;
  white-space: nowrap;
}
.row-card .btns .btn.primary { flex-basis: 130px; }
.row-card .empty { margin: 0; }
@media (min-width: 480px) {
  .row-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Mode switch: two pill segments, the chosen one filled. */
.mode {
  display: flex;
  gap: 0;
  width: fit-content;
  margin: 0 auto 20px;
  padding: 4px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--card-2);
  box-shadow: var(--shadow-sm);
}
.mode-btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 38px;
  cursor: pointer;
}
.mode-btn[aria-pressed="true"] { background: var(--accent); box-shadow: inset 0 0 0 2px var(--line); }
.mode-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Scribble Space tray */
.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 10px;
}
.tray-head[hidden] { display: none; }
.tray-hint { font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1.4; }
.tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 14px;
  min-height: 84px;
  padding: 14px 8px 8px;
  margin-bottom: 18px;
  border: 2.5px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.tray[hidden] { display: none; }
.tile {
  width: 50px;
  height: 50px;
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  background: var(--card-2);
  border: 2.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover:not(:disabled) { background: var(--accent-soft); }
.tile:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #111; }
.tile.used { opacity: 0.25; box-shadow: none; cursor: default; }
.tile:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Scribble Space boxes are filled by tapping, so they read as tiles, not text fields */
.answer .box[readonly] { cursor: pointer; caret-color: transparent; }
@media (max-width: 360px) {
  .tile { width: 44px; height: 44px; font-size: 19px; }
}
