/* Kento Box: Kento's bento box seen from above, the day's twelve letters round its rim, yarn strung between them, the words you build in a row above it. The
   title screen and the sheets are shared/mainmenu.js (menu.css, loaded after this); only their colors are set here. */
:root {
  --bg: #f6efe2; --bg-hi: #fffaf0; --ink: #3a2f26; --ink-soft: #7a6a5a; --line: rgba(70, 50, 30, 0.16);
  --accent: #c8642a; --accent-dark: #8f4316; --sheet: #fffaf2;
  --ink-c: #d06a1f; --ink-deep: #8a3f0b; --wall: #f6efe2;
  color-scheme: light;
}
* { 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: radial-gradient(ellipse 110% 60% at 50% 0%, var(--bg-hi), transparent 70%), var(--wall);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: calc(var(--sg-corner-top) - 2px) 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.app > * { width: 100%; max-width: 520px; }

/* ---- 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.85); box-shadow: 0 2px 0 rgba(70, 50, 30, 0.12); 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 tally: words so far, par, letters to go ---- */
.strip { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 0 4px; }
.strip p { margin: 0; }
.tally { display: flex; align-items: baseline; gap: 6px; font-weight: 800; }
.tally b { min-width: 40px; 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; transition: transform 0.2s; }
.tally b.bump { animation: pop 0.4s ease-out; }
.tally span { font-size: 16px; color: var(--ink); }
.par { padding: 3px 12px 1px; border-radius: 999px; background: rgba(255, 255, 255, 0.85); box-shadow: inset 0 0 0 2px var(--line); font-weight: 800; font-size: 16px; }
.left { text-align: right; font-weight: 700; font-size: 15px; color: var(--ink-soft); }

/* ---- the words so far ---- */
.chain { flex: none; min-height: 34px; max-height: 76px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 5px 6px; align-content: flex-start; padding: 2px 2px; }
.chip {
  display: inline-flex; align-items: baseline; padding: 3px 11px 1px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 2px var(--ink-c);
  font-weight: 800; font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink);
}
.chip i { font-style: normal; color: var(--ink-c); }
.chip.new { animation: pop 0.45s cubic-bezier(.3, 1.6, .5, 1); }
.chip.shown { box-shadow: inset 0 0 0 2px var(--line); color: var(--ink-soft); border-style: dashed; }
.chain .hint { margin: 6px 0 0; font-weight: 700; font-size: 15px; color: var(--ink-soft); }

/* ---- the word being built ---- */
.word {
  flex: none; min-height: 52px; display: flex; align-items: center; justify-content: center; padding: 4px 14px 0; border-radius: 16px; background: #fff;
  box-shadow: inset 0 0 0 2px var(--ink-c); font-weight: 800; font-size: 28px; letter-spacing: 0.1em; text-transform: uppercase; overflow: hidden;
}
.typed { white-space: nowrap; overflow: hidden; }
.typed .lock { color: var(--ink-c); }
.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; }
.word.empty .typed::before { content: attr(data-ph); color: var(--ink-soft); font-weight: 700; font-size: 17px; letter-spacing: 0; text-transform: none; }
.word.off { box-shadow: inset 0 0 0 2px var(--line); }
.word.off .typed::after { display: none; }
.word.shake { animation: shake 0.42s ease-in-out; box-shadow: inset 0 0 0 2px #d4443b; }

/* ---- the box (svg #flap) ---- */
.board { flex: 1; min-height: 0; display: grid; place-items: center; }
.flap { display: block; height: 100%; max-height: 100%; max-width: 100%; aspect-ratio: 1; touch-action: none; -webkit-tap-highlight-color: transparent; }
.flap .dot { cursor: pointer; }
.flap .dot circle { transition: fill 0.15s, stroke 0.15s; }
.flap .dot.used circle { fill: var(--ink-c); stroke: var(--ink-deep); }
.flap .dot.used text { fill: #fff; }
.flap .dot.cur circle { stroke: var(--ink-c); stroke-width: 6; }
.flap .dot.end circle { stroke: var(--ink-c); stroke-width: 5; filter: drop-shadow(0 0 5px var(--ink-c)); }
.flap .dot.end { animation: glow-end 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes glow-end { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.flap.ate .bx-food { opacity: 0; }
.flap .dot.cur { animation: bob 0.3s ease-out; transform-box: fill-box; transform-origin: center; }
.flap .dot.no circle { animation: nope 0.3s ease-in-out; }
.flap .trail path { fill: none; stroke: var(--ink-c); stroke-linecap: round; stroke-linejoin: round; }
.flap .trail path.old { stroke-width: 7; opacity: 0.38; }
.flap .trail path.now { stroke-width: 10; opacity: 0.95; }
.flap .trail path.last { stroke-width: 7; opacity: 0.6; }
.flap .trail path.ply { stroke: #fff; stroke-opacity: 0.4; stroke-width: 2.5; stroke-dasharray: 2 6; }
.flap .trail path.now.ply { stroke-width: 3.5; stroke-dasharray: 3 7; }
.flap.won.ate .bx-cat { opacity: 1 !important; animation: hop 0.9s ease-out; transform-box: fill-box; transform-origin: center; }

/* ---- controls ---- */
.controls { flex: none; display: grid; grid-template-columns: 1fr 1fr 1fr 1.5fr; gap: 6px; }
.pill {
  min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 3px 6px 1px; border: 0; border-radius: 16px;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 3px 0 rgba(70, 50, 30, 0.14); font-weight: 800; font-size: 15px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pill svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pill:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(70, 50, 30, 0.14); }
.pill.primary { background: var(--ink-c); color: #fff; font-size: 19px; box-shadow: 0 3px 0 var(--ink-deep); }
.pill.off { opacity: 0.45; }

/* ---- messages and effects ---- */
.toast {
  position: fixed; left: 50%; top: 30%; z-index: 5; width: auto; margin: 0; max-width: calc(100% - 32px);
  padding: 9px 16px 7px; border-radius: 14px; background: var(--ink); color: #fff; 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(--accent-dark); }
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.spark { position: absolute; color: var(--ink-c); font-size: 16px; font-weight: 800; transform: translate(-50%, -50%); animation: spark 0.65s 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 shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(5px); } }
@keyframes pop { 0% { transform: scale(0.6); } 55% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes bob { 0% { transform: scale(0.82); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes nope { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes hop { 0% { transform: translateY(14px) scale(0.9); } 50% { transform: translateY(-10px) scale(1.08); } 100% { transform: none; } }
@keyframes blink { 50% { opacity: 0; } }

/* ---- sheets (results, stats, archive, frames, how to play) ---- */
.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-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0 4px; }
.ct-words span { padding: 3px 12px 1px; border-radius: 999px; background: var(--ink-c); color: #fff; font-weight: 800; font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase; }
.ct-words.way span { background: rgba(70, 50, 30, 0.1); color: var(--ink); }
.ct-marks { margin: 8px 0 4px; font-size: 14px; line-height: 1.15; white-space: pre-line; }
.bx-score { margin: 0; font-weight: 800; color: var(--accent-dark); }
.bx-score b { font-size: 56px; line-height: 1; }
.bx-score span { font-size: 22px; color: var(--ink-soft); }
.ct-note { margin: 6px 0 0; font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--ink-soft); }
.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-share.danger { background: #b9472f; }
.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 .chip2 { flex: none; padding: 3px 10px 1px; border-radius: 999px; font-size: 14px; background: rgba(52, 64, 44, 0.08); }
.ct-day .chip2.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: 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(70, 50, 30, 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(70, 50, 30, 0.3); font-weight: 800; font-size: 26px; color: rgba(70, 50, 30, 0.4); }
.ct-gold { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bx-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bx-row .ct-share, .bx-row .ct-more { margin-top: 8px; }
.bx-demo { padding: 8px 12px 6px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; font-size: 16px; line-height: 1.6; }
.bx-demo b { color: var(--ink-c); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: radial-gradient(ellipse 100% 70% at 50% 25%, var(--bg-hi), transparent 75%), var(--wall);
  --sg-ink: var(--ink); --sg-ink-soft: #7a6a5a;
  --sg-title: var(--accent-dark); --sg-title-shadow: 0 2px 0 #fff;
  --sg-accent: var(--accent); --sg-accent-ink: #fff;
  --sg-card: #fff; --sg-card-ink: var(--ink); --sg-line: rgba(70, 50, 30, 0.16);
}
#mm .bx-title-art { width: 264px; height: 150px; }
#mm .bx-title-art svg { display: block; width: 100%; height: 100%; }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--ink); --sg-accent: var(--accent); --sg-accent-ink: #fff; --sg-ink-soft: #7a6a5a; }

@media (max-height: 700px) {
  .pill, .word { min-height: 46px; }
  .word { font-size: 24px; }
  .chain { max-height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .word.shake, .chip.new, .tally b.bump, .flap .dot.cur, .flap .dot.no circle, .flap.won .bx-cat, .flap .dot.end { animation: none; }
  .typed::after { animation: none; }
  .toast { transition: none; }
}
