/* Nesting Cats: bedtime (Bri, 2026-11-26: "a sleepy time theme to match the name"): a night sky with the moon and
   stars, the day's sentence on a moonlit page on a card of paper whose ink and paper the unlocks change, and
   our own keys under it. The title screen and the sheets are shared/mainmenu.js (menu.css, loaded after this); only
   their colors are set here. */
:root {
  --bg: #141a3a; --bg-hi: #2b2f6e; --ink: #eef0ff; --ink-soft: #aab2dc; --line: rgba(200, 210, 255, 0.2);
  --accent: #f4d27a; --accent-ink: #231f4a; --accent-dark: #f7dc8e; --sheet: #f4f2fc;
  --ink-c: #4b4fb5; --wash: #e6e4fb; --ink-deep: #2a2c78; --ans: #4b4fb5;
  --paper: #fbf5e6; --paper-text: #2f2a3c; --paper-soft: #8a8299;
  --key: #2d3470; --kedge: #11153a; --kink: #eef0ff; --pad: rgba(9, 11, 34, 0.62);
  --moon: #f4d27a; --night: #0e1330;
  color-scheme: dark;
}
* { box-sizing: border-box; }
* { touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif; color: var(--ink);
  background: url(night.webp) center top / cover no-repeat, var(--sky);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
/* the night sky under the painted backdrop (night.webp): the moon's glow and a few stars, so it reads before the
   picture loads; a second layer of stars twinkles (still with reduced motion) */
:root {
  --sky: radial-gradient(circle at 92% 4%, rgba(244, 210, 122, 0.22), transparent 26%),
    radial-gradient(1.5px 1.5px at 12% 14%, #fff, transparent), radial-gradient(1px 1px at 33% 7%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 58% 18%, #fff8d8, transparent), radial-gradient(1px 1px at 72% 30%, #fff, transparent),
    radial-gradient(1px 1px at 22% 38%, #fff, transparent), radial-gradient(1.5px 1.5px at 90% 44%, #fff, transparent),
    linear-gradient(180deg, #10153a 0%, #1c2156 55%, #2b2a68 100%);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(2px 2px at 18% 24%, #fff, transparent), radial-gradient(2px 2px at 66% 9%, #fff6d0, transparent),
    radial-gradient(1.6px 1.6px at 44% 31%, #fff, transparent), radial-gradient(2px 2px at 8% 52%, #fff, transparent),
    radial-gradient(1.6px 1.6px at 94% 22%, #fff, transparent);
  animation: twinkle 3.6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.25; } to { opacity: 1; } }
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: calc(var(--sg-corner-top) - 2px) 10px 0;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.app > * { width: 100%; max-width: 560px; }

/* ---- top bar ---- */
.bar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; flex: none; }
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 16px;
  background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 0 0 1px rgba(200, 210, 255, 0.18); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(0.94); }
.sub { margin: 0; text-align: center; font-weight: 800; font-size: 16px; line-height: 1.2; color: var(--ink-soft); min-width: 0; }
.sub b { color: var(--ink); font-size: 18px; }
.sub .tag { display: inline-block; margin-left: 6px; padding: 1px 8px 0; border-radius: 999px; background: #e3d6f5; color: #4d2f80; font-size: 13px; }

/* ---- the score strip ---- */
.strip { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.strip p { margin: 0; }
.score-box { display: flex; align-items: baseline; gap: 8px; font-weight: 800; }
.score-box b { min-width: 46px; padding: 2px 10px 0; border-radius: 12px; background: var(--ink-c); color: #fff; font-size: 24px; line-height: 1.25; text-align: center; font-variant-numeric: tabular-nums; }
.score-box span { font-size: 17px; color: var(--ink); }
.count { font-weight: 700; font-size: 15px; color: var(--ink-soft); }

/* ---- the card and its sentence ---- */
.card {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 16px 16px 16px 38px; border-radius: 20px; background: var(--paper); color: var(--paper-text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 0 46px -6px rgba(244, 210, 122, 0.28), 0 14px 30px -12px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; justify-content: center;
}
.text { margin: 0; font-weight: 600; font-size: var(--fs, 22px); line-height: 1.6; overflow-wrap: break-word; }
.cl { color: var(--paper-soft); border-radius: 8px; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.cl .br { font-weight: 800; color: var(--paper-soft); opacity: 0.8; padding: 0 1px; }
.cl.open {
  color: var(--ink-deep); background: var(--wash); padding: 1px 2px; cursor: pointer; -webkit-box-decoration-break: clone; box-decoration-break: clone;
  -webkit-tap-highlight-color: transparent;
}
.cl.open .br { color: var(--ink-c); opacity: 1; }
.cl.open.sel { box-shadow: 0 0 0 2.5px var(--ink-c); }
.cl.glow { animation: glow 0.9s ease-out; }
.ans { color: var(--ans); font-weight: 800; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ans) 35%, transparent); text-decoration-thickness: 2px; text-underline-offset: 4px; display: inline; }
.ans.shown { color: var(--paper-soft); text-decoration-style: dashed; }
.ans.pop { display: inline-block; animation: unfold 0.42s cubic-bezier(.3, 1.4, .5, 1); transform-origin: 50% 60%; }
.hint-chip { display: inline-block; margin: 0 3px; padding: 0 7px; border-radius: 8px; background: var(--ink-c); color: #fff; font-style: normal; font-weight: 800; font-size: 0.8em; line-height: 1.35; }
.hint-chip.pop { animation: pop 0.45s ease-out; }
.card.won { box-shadow: 0 0 0 3px var(--moon), 0 0 50px -4px rgba(244, 210, 122, 0.6); }
.card.won .ans { text-decoration-color: transparent; }

/* ---- the guess line ---- */
.guess-row { flex: none; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: stretch; }
.hint {
  min-width: 96px; min-height: 52px; display: flex; align-items: center; gap: 6px; padding: 4px 12px 2px 8px; border: 2px solid var(--line);
  border-radius: 16px; background: var(--paper); color: var(--paper-text); cursor: pointer; -webkit-tap-highlight-color: transparent; text-align: left;
}
.hint svg { flex: none; width: 24px; height: 24px; fill: none; stroke: var(--paper-soft); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint-text b { display: block; font-size: 16px; line-height: 1.1; }
.hint-text small { display: block; font-weight: 700; font-size: 12px; line-height: 1.15; color: var(--paper-soft); }
.hint.ready { border-color: var(--ink-c); }
.hint.ready svg { stroke: var(--ink-c); fill: var(--wash); }
.hint:active { transform: scale(0.96); }
.guess {
  min-height: 52px; display: flex; align-items: center; padding: 4px 14px 0; border-radius: 16px; background: var(--paper); color: var(--paper-text);
  box-shadow: inset 0 0 0 2px var(--ink-c); font-weight: 800; font-size: 24px; letter-spacing: 0.08em; text-transform: uppercase; overflow: hidden;
}
.typed { white-space: nowrap; overflow: hidden; text-overflow: clip; direction: rtl; text-align: left; unicode-bidi: plaintext; }
.typed::after { content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -0.12em; background: var(--ink-c); animation: blink 1s steps(1) infinite; }
.guess.empty .typed::before { content: attr(data-ph); color: var(--paper-soft); font-weight: 700; font-size: 17px; letter-spacing: 0; text-transform: none; }
.guess.off { box-shadow: inset 0 0 0 2px var(--line); }
.guess.off .typed::after { display: none; }
.guess.shake { animation: shake 0.42s ease-in-out; box-shadow: inset 0 0 0 2px #d4443b; }

/* ---- the keys ---- */
.kb {
  flex: none; max-width: none !important; margin: 0 -10px; width: calc(100% + 20px) !important; padding: 6px 3px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--pad); box-shadow: 0 -1px 0 rgba(200, 210, 255, 0.12); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); touch-action: none;
}
.kb.off { display: none; }
.kb-row { display: flex; max-width: 560px; margin: 0 auto; }
.kb-row.r2 { padding: 0 5%; }
.key { flex: 1 1 0; min-width: 0; height: 52px; border: 0; padding: 3px 2.5px; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none; }
.key.wide { flex: 1.55 1 0; }
.key span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 9px; padding-top: 3px; font-weight: 800; font-size: 21px; text-transform: uppercase;
  background: var(--key); color: var(--kink); box-shadow: 0 3px 0 var(--kedge); transition: transform 0.05s;
}
.key.enter span { font-size: 14px; text-transform: none; background: var(--moon); color: var(--accent-ink); box-shadow: 0 3px 0 #a9862f; }
.key svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.key.down span { transform: translateY(3px); box-shadow: 0 0 0 var(--kedge); filter: brightness(1.08); }
.app.no-kb { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }

/* ---- messages and effects ---- */
.toast {
  position: fixed; left: 50%; top: 34%; z-index: 5; width: auto; margin: 0; max-width: calc(100% - 32px);
  padding: 9px 16px 7px; border-radius: 14px; background: var(--sheet); color: #262347; font-weight: 800; font-size: 17px; line-height: 1.25;
  text-align: center; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: var(--moon); color: var(--accent-ink); }
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.spark { position: absolute; color: var(--moon); font-size: 16px; font-weight: 800; transform: translate(-50%, -50%); animation: spark 0.65s ease-out forwards; }
.float { position: absolute; transform: translate(-50%, 0); color: #ff8a7a; font-weight: 800; font-size: 22px; animation: rise 0.85s ease-out forwards; }
@keyframes spark { from { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.6); } }
@keyframes rise { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -34px); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(5px); } }
@keyframes unfold { 0% { transform: scaleX(0.12) scaleY(0.8); opacity: 0.2; } 60% { transform: scaleX(1.08) scaleY(1.02); opacity: 1; } 100% { transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 55% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 var(--ink-c); } 40% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ink-c) 35%, transparent); } 100% { box-shadow: 0 0 0 2.5px var(--ink-c); } }
@keyframes blink { 50% { opacity: 0; } }

/* ---- sheets (results, stats, archive, inks and papers) ---- */
.ct-result { text-align: center; }
.ct-result .big { margin: 0; font-weight: 800; font-size: 28px; line-height: 1.1; color: var(--accent-dark); }
.ct-result .line { margin: 2px 0 0; font-weight: 700; font-size: 16px; color: var(--ink-soft); }
.ct-marks { margin: 10px 0 4px; font-size: 26px; line-height: 1.3; letter-spacing: 2px; }
.ct-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 2px; }
.ct-words span { padding: 3px 10px 1px; border-radius: 999px; background: var(--theme); color: #fff; font-weight: 800; font-size: 15px; }
.ct-words span.span { background: var(--span); color: #4a3200; }
.ct-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 6px; }
.ct-num { text-align: center; }
.ct-num b { display: block; font-size: 28px; line-height: 1.05; }
.ct-num span { display: block; font-size: 13px; font-weight: 700; line-height: 1.15; color: var(--ink-soft); }
.ct-h { margin: 10px 0 4px; font-weight: 800; font-size: 17px; }
.ct-next { margin: 10px 0 0; text-align: center; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.ct-share { width: 100%; min-height: 50px; margin-top: 8px; border: 0; border-radius: 16px; background: var(--accent); color: #fff; font-weight: 800; font-size: 18px; cursor: pointer; }
.ct-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ct-day {
  width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px 4px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff; text-align: left; cursor: pointer; font-weight: 800; font-size: 16px;
}
.ct-day small { display: block; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.ct-day .chip { flex: none; padding: 3px 10px 1px; border-radius: 999px; font-size: 14px; background: rgba(52, 64, 44, 0.08); }
.ct-day .chip.good { background: var(--accent); color: #fff; }
.ct-more { min-height: 48px; width: 100%; margin-top: 8px; border: 0; border-radius: 14px; background: rgba(52, 64, 44, 0.09); font-weight: 800; font-size: 16px; cursor: pointer; }
.ct-ach { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ct-ach li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.8); font-weight: 700; font-size: 15px; line-height: 1.25; }
.ct-ach li b { display: block; font-size: 16px; }
.ct-ach li.no { opacity: 0.55; }
.ct-ach .medal { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f4c44e; color: #6b4a0c; font-weight: 800; }
.ct-ach li.no .medal { background: rgba(52, 64, 44, 0.14); color: transparent; }
.ct-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ct-pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 112px; padding: 6px 4px 4px; border: 2px solid transparent;
  border-radius: 16px; background: rgba(255, 255, 255, 0.8); cursor: pointer; font-weight: 700; font-size: 13px; line-height: 1.1; text-align: center;
}
.ct-pick .swatch { width: 80px; height: 72px; border-radius: 14px; display: block; overflow: hidden; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); }
.ct-pick .swatch svg { width: 100%; height: 100%; display: block; }
.ct-pick[aria-pressed="true"] { border-color: var(--accent); background: #fff; }
.ct-pick.locked { cursor: default; background: rgba(52, 64, 44, 0.06); color: var(--ink-soft); }
.ct-pick.locked .q { width: 60px; height: 60px; margin: 6px 0; display: grid; place-items: center; border-radius: 50%; border: 2px dashed rgba(52, 64, 44, 0.3); font-weight: 800; font-size: 26px; color: rgba(52, 64, 44, 0.4); }
.ct-gold { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ct-demo { display: block; width: 220px; height: auto; margin: 2px auto 0; }

.ct-pick .swatch { width: 80px; height: 64px; border-radius: 14px; display: block; overflow: hidden; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); }
.ct-pick .swatch svg { width: 100%; height: 100%; display: block; }
.ct-pick[aria-pressed="true"] { border-color: var(--accent); background: #fff; }
.ct-pick.locked { cursor: default; background: rgba(30, 40, 90, 0.06); color: var(--ink-soft); }
.ct-pick.locked .q { width: 56px; height: 56px; margin: 4px 0; display: grid; place-items: center; border-radius: 50%; border: 2px dashed rgba(30, 40, 90, 0.3); font-weight: 800; font-size: 26px; color: rgba(30, 40, 90, 0.4); }
.ct-gold { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bc-score { margin: 0; font-weight: 800; color: var(--accent-dark); }
.bc-score b { font-size: 56px; line-height: 1; }
.bc-score span { font-size: 22px; color: var(--ink-soft); }
.bc-final { margin: 8px 0 0; padding: 10px 12px 8px; border-radius: 14px; background: #fff; font-weight: 700; font-size: 18px; line-height: 1.35; color: var(--ink); }
.bc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bc-row .ct-share, .bc-row .ct-more { margin-top: 8px; }
.ct-share.danger { background: #b9472f; }
.bc-demo { padding: 8px 12px 6px; border-radius: 14px; background: #fffdf6; box-shadow: inset 0 0 0 1px var(--line); }
.bc-demo p { margin: 0; font-weight: 600; font-size: 16px; line-height: 1.7; color: #8b8175; }
.demo-open { padding: 1px 3px; border-radius: 6px; background: #e3e7fb; color: #2b3590; }
.demo-ans { color: #4f5fd8; font-weight: 800; }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: url(/bracket/night.webp) center top / cover no-repeat, var(--sky);
  --sg-ink: var(--ink); --sg-ink-soft: #c3c9ec;
  --sg-title: #f7dc8e; --sg-title-shadow: 0 0 18px rgba(244, 210, 122, 0.45), 0 2px 0 rgba(0, 0, 0, 0.35);
  --sg-accent: var(--moon); --sg-accent-ink: var(--accent-ink);
  --sg-card: rgba(20, 24, 64, 0.72); --sg-card-ink: var(--ink); --sg-line: rgba(200, 210, 255, 0.2);
}
#mm .bc-title-art { width: 146px; height: 146px; border-radius: 22px; overflow: hidden; box-shadow: 0 0 0 2px rgba(244, 210, 122, 0.55), 0 0 34px rgba(244, 210, 122, 0.3); }
#mm .bc-title-art img { display: block; width: 100%; height: 100%; }
.sg-sheet {
  --ink: #262347; --ink-soft: #5f5a85; --line: rgba(40, 30, 90, 0.16); --accent: #4b4fb5; --accent-dark: #2a2c78; --bg-hi: #fff;
  --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--ink); --sg-accent: var(--accent); --sg-accent-ink: #fff; --sg-ink-soft: #5f5a85;
}

@media (max-height: 700px) {
  .key { height: 46px; }
  .key span { font-size: 19px; }
  .guess, .hint { min-height: 46px; }
  .card { padding: 10px 12px 10px 34px; }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; opacity: 0.7; }
  .guess.shake, .ans.pop, .hint-chip.pop, .cl.glow { animation: none; }
  .typed::after { animation: none; }
  .toast { transition: none; }
}

/* today's time and its i bubble (the working stays out of sight until asked: the disclosure rule) */
.bc-time { margin: 4px 0 0; display: flex; align-items: center; justify-content: center; gap: 2px; font-weight: 800; font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.bc-i { width: 44px; height: 44px; margin: -8px -10px -8px 0; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.bc-i i { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink-soft); color: var(--ink-soft); font: italic 800 15px/20px Georgia, serif; text-align: center; }
.bc-i:focus-visible { outline: 3px solid var(--accent); outline-offset: -4px; border-radius: 10px; }
.bc-pop { margin: 6px auto 0; max-width: 300px; padding: 8px 12px; border-radius: 12px; background: var(--bg-hi); border: 1px solid var(--line); font-weight: 700; font-size: 15px; line-height: 1.35; color: var(--ink); }
.bc-pop[hidden] { display: none; }
