/* The chick lives in a shoebox; the page is the inside of a bigger box. Cut-out cardboard buttons with a thick ink
   outline and a solid offset shadow, paper cards for anything you read, crayon yolk for the bars. */
@font-face { font-family: 'Gluten'; src: url('fonts/gluten-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Gluten'; src: url('fonts/gluten-latin-900-normal.woff2') format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Andika'; src: url('fonts/andika-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Andika'; src: url('fonts/andika-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #2a2247; --kraft: #c8975a; --kraft-deep: #8e6233; --kraft-dark: #6e4a24; --kraft-light: #ddb57e;
  --paper: #fffdf6; --yolk: #ffc928; --yolk-deep: #f29f05; --fern: #2f9e5b; --sea: #3fb6d9; --blush: #ff8fa3;
  --display: 'Gluten', 'Comic Sans MS', 'Chalkboard SE', system-ui, sans-serif;
  --body: 'Andika', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 14px; --pad: max(10px, env(safe-area-inset-left));
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--kraft-deep);
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.06) 0 3px, transparent 3px 11px);
  color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.4;
  overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

#app {
  height: 100%; height: 100dvh; max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "stage" "side";
  padding: max(6px, env(safe-area-inset-top)) var(--pad) max(8px, env(safe-area-inset-bottom));
  gap: 8px;
}

/* ---------- top strip ---------- */
#top { grid-area: top; display: flex; align-items: center; gap: 6px; min-width: 0; }
#top .grow { flex: 1 1 0; min-width: 0; }
.name {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 60%;
  background: none; border: 0; padding: 2px 6px; border-radius: 10px; text-align: left; color: var(--paper);
}
#cName { font-family: var(--display); font-weight: 900; font-size: 1.45rem; line-height: 1.05; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 2px 0 var(--ink); }
#cDay { font-size: 0.85rem; font-weight: 700; color: #ffe9c2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon, .chip {
  flex: 0 0 auto; min-width: 42px; height: 42px; border-radius: 12px; border: 2.5px solid var(--ink);
  background: var(--paper); box-shadow: 0 3px 0 var(--ink); display: inline-grid; place-items: center; padding: 0;
}
.chip { padding: 0 9px; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em; }
.icon svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.icon:active, .chip:active, .act:active, .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.icon.small { min-width: 36px; height: 36px; }

/* ---------- the stage ---------- */
#stageWrap {
  grid-area: stage; position: relative; min-height: 0; border-radius: 18px; overflow: hidden;
  border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); background: var(--kraft);
}
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage:focus-visible { outline: none; }
#stageWrap:has(#stage:focus-visible) { outline: 3px solid var(--sea); outline-offset: 2px; }
#bubble {
  position: absolute; left: 0; top: 0; max-width: min(78%, 300px); padding: 7px 12px 8px;
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 16px; box-shadow: 0 3px 0 rgba(42,34,71,0.35);
  font-family: var(--display); font-weight: 700; font-size: 1.02rem; line-height: 1.2; text-align: center;
  pointer-events: none; transform-origin: 50% 100%; animation: pop 0.22s ease-out;
}
#bubble::after {
  content: ''; position: absolute; left: var(--tail, 50%); bottom: -11px; width: 16px; height: 16px; margin-left: -8px;
  background: var(--paper); border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: rotate(45deg);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#hint {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100% - 16px);
  padding: 4px 12px; border-radius: 999px; background: rgba(42,34,71,0.78); color: var(--paper); font-size: 0.92rem; text-align: center;
  pointer-events: none;
}
#hint:empty { display: none; }
#huntHud { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
#huntHud > * { pointer-events: auto; }
#huntScore { font-family: var(--display); font-weight: 900; font-size: 1.3rem; color: var(--paper); text-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
#huntTime { flex: 1; height: 12px; border: 2.5px solid var(--ink); border-radius: 99px; background: var(--paper); overflow: hidden; }
#huntTime i { display: block; height: 100%; width: 100%; background: var(--fern); transform-origin: left; }
#overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(42,34,71,0.35); }
#overlay .card { max-height: 100%; overflow: auto; }

/* ---------- side: bars, job, buttons ---------- */
#side { grid-area: side; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#meters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 8px 12px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: var(--r); }
.meter { display: grid; grid-template-columns: 26px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 7px; align-items: center; min-width: 0; }
.meter svg { grid-row: 1 / 3; width: 26px; height: 26px; fill: var(--kraft-light); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.meter .lb { font-size: 0.8rem; font-weight: 700; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter .bar { height: 11px; border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; background: #f1e6d2; }
.meter .bar i { display: block; height: 100%; width: 50%; background: var(--yolk); border-right: 2px solid var(--ink); transition: width 0.5s ease; }
.meter.low .bar i { background: #ffe089; }
.meter.low svg { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 80%, 100% { transform: rotate(0); } 86% { transform: rotate(-12deg); } 92% { transform: rotate(10deg); } }
#eggNote { margin: 0; padding: 10px 12px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: var(--r); font-weight: 700; text-align: center; }

#job { display: flex; align-items: center; gap: 8px; padding: 5px 10px 6px 6px; border-radius: var(--r); background: rgba(255,253,246,0.16); border: 2px dashed rgba(255,253,246,0.55); color: var(--paper); min-width: 0; }
#jobIcon { width: 30px; height: 30px; flex: 0 0 auto; }
.jobText { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.jobHead, .jobLine { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
#jobTitle { flex: 1 1 auto; min-width: 0; font-size: 0.74rem; font-weight: 700; color: #ffe9c2; }
#jobTask { flex: 1 1 auto; min-width: 0; font-size: 0.92rem; font-weight: 700; }
#jobProg { flex: 0 0 auto; font-family: var(--display); font-weight: 900; font-size: 1.05rem; white-space: nowrap; }
#streak { flex: 0 0 auto; font-size: 0.74rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--ink); color: var(--yolk); white-space: nowrap; }
#job.done #jobProg { color: var(--yolk); }

.tray { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
#washTray { grid-template-columns: 2fr 1fr; }
#foodTray { grid-template-columns: repeat(4, minmax(0, 1fr)) 44px; }
#foodBack .lb { display: none; }
#foodBack { padding: 0; }
.act {
  min-height: 62px; min-width: 0; padding: 5px 2px 6px; border-radius: var(--r); border: 2.5px solid var(--ink);
  background: var(--yolk); box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.act svg { width: 30px; height: 30px; fill: rgba(255,255,255,0.55); stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.act canvas { width: 34px; height: 34px; }
.act .lb { font-family: var(--display); font-weight: 700; font-size: clamp(0.7rem, 3.1vw, 0.88rem); line-height: 1.05; max-width: 100%; overflow-wrap: normal; word-break: normal; hyphens: manual; text-align: center; }
.act.wide { grid-column: 1 / -1; flex-direction: row; gap: 10px; font-size: 1.15rem; }
.act.wide .lb { font-size: 1.2rem; }
#actWash { background: #9fe0f5; } #actPet { background: #ffc4d0; } #actPlay { background: #b9e7a5; } #actNap { background: #c9c2ef; }
.act.back { background: var(--paper); }
.act.food { background: var(--paper); padding-inline: 0; }
.act.food .lb { font-size: clamp(0.66rem, 2.9vw, 0.88rem); }
.act[aria-disabled="true"] { opacity: 0.55; }

/* ---------- cards: panels and stage overlays ---------- */
#panel { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 14px; background: rgba(42,34,71,0.55); }
.card {
  width: min(100%, 460px); max-height: calc(100dvh - 28px); overflow: auto; overscroll-behavior: contain;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); padding: 16px 16px 14px;
}
.card h2 { margin: 0 0 10px; font-family: var(--display); font-weight: 900; font-size: 1.5rem; line-height: 1.1; overflow-wrap: anywhere; }
.card p { margin: 0 0 10px; }
.card ul { margin: 0 0 10px; padding-left: 1.2em; }
.card li { margin-bottom: 6px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn {
  flex: 1 1 auto; min-height: 46px; padding: 8px 14px; border-radius: 12px; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  background: var(--paper); font-family: var(--display); font-weight: 700; font-size: 1.02rem; line-height: 1.1; overflow-wrap: anywhere;
}
.btn.go { background: var(--yolk); }
.btn[aria-current="true"], .btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .btn { text-align: left; }
.small { font-size: 0.86rem; color: #5a5175; }
.byline { margin-top: 14px; font-size: 0.86rem; color: #5a5175; text-align: center; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs .btn { min-height: 40px; }

.portrait { display: block; width: 100%; max-width: 260px; height: auto; aspect-ratio: 13 / 10; margin: 0 auto 8px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--kraft); }
.big { font-family: var(--display); font-weight: 900; font-size: 1.2rem; line-height: 1.15; margin: 0 0 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; padding: 0; list-style: none; }
.facts li { margin: 0; padding: 3px 10px; border-radius: 99px; background: #f3e7d1; font-size: 0.88rem; font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; min-width: 0; border-radius: 12px;
  border: 2.5px solid var(--ink); background: var(--paper); box-shadow: 0 3px 0 var(--ink); text-align: center; font-size: 0.8rem; line-height: 1.15;
  hyphens: auto; overflow-wrap: break-word;
}
.tile canvas { width: 56px; height: 56px; }
.tile b { font-weight: 700; max-width: 100%; }
.tile .need { color: #5a5175; font-size: 0.72rem; max-width: 100%; }
.tile.locked { background: #efe6d6; box-shadow: none; border-style: dashed; cursor: default; }
.tile[aria-pressed="true"] { background: var(--yolk); }
.grid.treasure .tile { box-shadow: none; cursor: default; }

.postcard { margin: 0 0 16px; }
.postcard canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 10px; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 rgba(42,34,71,0.4); }
.postcard .msg { margin: 10px 2px 0; font-weight: 700; font-size: 1rem; line-height: 1.4; }
.postcard .sign { margin: 6px 2px 0; font-family: var(--display); font-weight: 900; text-align: right; }
.postcard .meta { margin: 6px 2px 0; font-size: 0.85rem; color: #5a5175; }

.code { display: block; width: 100%; padding: 10px; border: 2.5px solid var(--ink); border-radius: 12px; background: #f6efe1; font-family: ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace; font-size: 0.95rem; letter-spacing: 0.04em; word-break: break-all; user-select: all; resize: none; color: var(--ink); }
input.code { user-select: text; }
.err { color: #b3261e; font-weight: 700; min-height: 1.4em; margin: 6px 0 0; }
hr.cut { border: 0; border-top: 2.5px dashed #c9b893; margin: 16px 0 12px; }

#toast {
  position: fixed; left: 50%; top: max(60px, calc(env(safe-area-inset-top) + 56px)); z-index: 20; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 8px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-weight: 700; text-align: center; box-shadow: 0 4px 0 rgba(0,0,0,0.25);
  animation: drop 0.3s ease-out;
}
@keyframes drop { from { transform: translate(-50%, -14px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.noscript { max-width: 34em; margin: 30px auto; padding: 16px; background: var(--paper); border-radius: 16px; }

/* ---------- wide and landscape: the box on the left, the care on the right ---------- */
@media (min-aspect-ratio: 5/4) {
  #app { grid-template-columns: minmax(0, 1fr) clamp(250px, 34%, 380px); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top top" "stage side"; }
  #side { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; justify-content: flex-start; }
  .tray { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #foodTray { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-aspect-ratio: 5/4) and (max-height: 430px) {
  #app { gap: 6px; }
  #meters { gap: 3px 10px; padding: 5px 10px; }
  .meter .lb { font-size: 0.72rem; }
  .act { min-height: 50px; padding: 3px 2px 4px; }
  .act svg { width: 24px; height: 24px; }
  .act .lb { font-size: 0.76rem; }
  #job { padding: 3px 8px 3px 4px; }
  #jobTitle { display: none; }
  .jobHead { position: absolute; right: 8px; top: -9px; }
  #job { position: relative; }
  #jobTask { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.84rem; }
  #jobIcon { width: 24px; height: 24px; }
  #cName { font-size: 1.2rem; }
  .icon, .chip { height: 38px; min-width: 38px; }
}
@media (max-width: 380px) and (max-aspect-ratio: 5/4) {
  .act { min-height: 56px; }
  .act svg { width: 26px; height: 26px; }
  .icon, .chip { min-width: 38px; height: 38px; }
  #cName { font-size: 1.25rem; }
  #top { gap: 4px; }
}
@media (max-height: 600px) and (max-aspect-ratio: 5/4) {
  #meters { padding: 5px 10px; gap: 3px 10px; }
  #job { padding: 3px 8px 3px 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.calm *, .calm *::before, .calm *::after { animation: none !important; transition: none !important; }

.toasting #hint { visibility: hidden; }
