@import url("brand.css");

:root {
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --ar: .75;
}
svg.i {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app {
  position: relative;
  width: min(var(--site-width), calc(100% - 56px));
  margin-inline: auto;
  padding-block: 16px calc(var(--bottom) + 22px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(285px, .7fr);
  grid-template-areas: "top top" "stage side" "strip strip";
  gap: 16px;
  align-items: start;
}
.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  background: var(--mint);
  border-radius: 999px;
}
.top .brand { flex: 1; min-width: 0; text-align: center; }
.top .brand > .gi, .top .brand p { display: none; }
.top .brand h1 { font-size: clamp(1.13rem, 3vw, 2rem); line-height: 1.1; margin: 0; }
.top .home-link { font-size: .86rem; font-weight: 900; }
.is-sample .top .home-link { display: none; }
.count { white-space: nowrap; font-weight: 900; }
.top .story-return { order: -1; }
.top button, .act, .nav, .tool-row button, .reward-button {
  border: 1px solid var(--plum);
  border-radius: 12px;
  min-height: 40px;
  background: var(--white);
  color: var(--ink);
  font-weight: 900;
  padding: 6px 12px;
}
.top button { border-radius: 999px; white-space: nowrap; font-size: .87rem; }
.sound-toggle[aria-pressed="true"] { background: var(--butter); }
.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(12px, 2.4vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fce4e6;
}
.steps { display: flex; flex-wrap: wrap; gap: 5px; list-style: none; padding: 0; margin: 0; }
.steps li { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 4px 7px; font-size: .87rem; background: var(--white); border-radius: 999px; }
.steps li.on, .steps li.done { background: var(--mint); }
.steps li small, .app:has(.card.coloring) .steps { display: none; }
.steps .i { width: 15px; height: 15px; }
.msg { margin-bottom: 6px; }
.bar { height: 9px; border-radius: 999px; background: white; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--plum); }

.stagearea { grid-area: stage; position: relative; min-width: 0; }
.fit { display: grid; place-items: center; }
.card {
  position: relative;
  width: min(100%, calc(clamp(210px, 67dvh, 670px) * var(--ar)));
  aspect-ratio: var(--ar);
  overflow: hidden;
  border-radius: var(--radius);
  background: white;
  outline: 1px solid var(--line);
  box-shadow: 0 6px 18px #51103518;
}
.card img, .card canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}
#paint { z-index: 1; touch-action: none; cursor: crosshair; pointer-events: none; }
.card.coloring #paint { pointer-events: auto; }
#line { z-index: 2; mix-blend-mode: multiply; pointer-events: none; }
#peek { z-index: 4; opacity: 0; pointer-events: none; transition: opacity .15s; }
#peek.show { opacity: 1; }
#scratch { z-index: 5; touch-action: none; cursor: grab; transition: opacity .5s; }
#scratch.gone { opacity: 0; pointer-events: none; }
.hint, .loading { position: absolute; z-index: 6; }
.hint {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 95%;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  pointer-events: none;
  font-weight: 900;
}
.hint.hide { visibility: hidden; }
.loading { inset: 0; display: grid; place-items: center; background: white; }
.nav { display: grid; place-items: center; position: absolute; z-index: 9; top: 48%; padding: 3px; width: 40px; border-radius: 50%; }
.nav .gi { display: grid; place-items: center; }
#prev { left: 0; }
#next { right: 0; }
.story-step { margin: 8px 0 0; text-align: center; font-size: .95rem; }
.animal-introduction { position: absolute; top: 8px; left: 8px; z-index: 8; pointer-events: none; max-width: calc(100% - 16px); padding: 5px 9px; border-radius: 999px; background: #fffdf9eb; font-size: .85rem; }
.animal-introduction span { margin-left: .35em; }
.animal-introduction span::before { content: "· "; }
.is-sample:not(.story-mode) .animal-introduction { display: none; }

.paint-tools { display: grid; gap: 10px; }
.paint-title { font-size: clamp(1.45rem, 3.4vw, 2.4rem); margin: 0; }
.paint-instruction { margin: 0; font-size: .91rem; }
.palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.swatch { width: min(100%, 58px); aspect-ratio: 1; justify-self: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--swatch); }
.swatch[aria-pressed="true"] { outline: 2px solid var(--plum); outline-offset: 3px; }
.tool-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; border-top: 1px solid var(--rule); padding-top: 10px; }
.tool-row button { padding: 7px 4px; }
.tool-row button[aria-pressed="true"] { background: var(--mint); }
.brush-label { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.brush-label input { min-width: 0; width: 100%; accent-color: var(--plum); }
.paint-next { display: grid; gap: 7px; }
#nextDrawing { order: -1; background: var(--plum); color: white; font-size: 1.25rem; }
#compare { background: transparent; }
.act { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; text-decoration: none; }
.act .gi { display: inline-grid; place-items: center; }
.act.locked { pointer-events: none; opacity: .5; }
.grownup-panel { padding: 7px 10px; border: 1px solid var(--rule); border-radius: 10px; }
.grownup-panel summary { font-weight: 900; }
.grownup-panel > button { margin: 4px 0; }
.status-note, .fact { font-size: .85rem; margin: 4px 0; color: var(--muted); }
.learning { border-top: 1px solid var(--rule); padding-top: 6px; }
.trace-label { font-size: .75rem; }
.trace-name { font-weight: 950; text-transform: uppercase; }
.food-note { margin-bottom: 5px; }
.food-note summary { font-weight: 900; }
.stripwrap { grid-area: strip; min-width: 0; }
.striphead { font-size: 1rem; margin-bottom: 6px; }
.strip { display: flex; gap: 8px; overflow: auto; padding: 4px; }
.thumb { position: relative; flex: 0 0 auto; height: 60px; aspect-ratio: var(--ar); overflow: hidden; border: 2px solid var(--line); border-radius: 8px; padding: 0; background: white; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb.on { border-color: var(--plum); }
.thumb.done::after { content: "✓"; position: absolute; bottom: 0; right: 0; font-size: .82rem; padding: 0 4px; color: var(--ink); background: var(--mint); border-radius: 6px 0 0; }

.reader-dialog { width: min(760px, 92vw); max-height: 90dvh; padding: clamp(14px, 3vw, 28px); background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius); overflow: auto; }
.reader-dialog::backdrop { background: #35122a85; }
.reader-dialog h2 { margin-right: 36px; font-size: clamp(1.6rem, 4vw, 2.6rem); }
.reader-dialog button { background: var(--white); border: 1px solid var(--plum); border-radius: 11px; min-height: 42px; padding: 6px 10px; }
.dialog-close { float: right; font-size: 1.4rem; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-grid figure { margin: 0; text-align: center; }
.compare-grid img { width: 100%; max-height: 42dvh; object-fit: contain; background: white; border-radius: 10px; }
.compare-grid figcaption { font-weight: 900; }
.score-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin-block: 14px; }
.sticker { background: var(--blush); border-radius: 12px; padding: 6px; text-align: center; font-size: .82rem; }
.sticker img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; }
.sticker strong { display: block; }
.sticker.pending { opacity: .55; }
.paper-toggle { display: flex; gap: 7px; margin: 10px 0; }
.spark, .confetti { position: fixed; z-index: 20; pointer-events: none; width: 8px; height: 10px; border-radius: 2px; }
.confetti { inset: 0 auto auto 0; }
.certificate, #printArea { display: none; }

@media (max-width: 699px) {
  .app { width: calc(100% - 24px); display: flex; flex-direction: column; gap: 8px; padding-top: 10px; }
  .app > *, .side > * { width: 100%; }
  .top { order: 0; gap: 5px; padding: 6px; flex-wrap: wrap; }
  .top button { min-height: 36px; padding-inline: 7px; font-size: .8rem; }
  .top .home-link, .count { font-size: .8rem; }
  .side { display: contents; }
  .steps { order: 1; }
  .meter { order: 2; }
  .paint-tools {
    order: 2;
    gap: 7px;
    padding: 7px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: var(--white);
  }
  .paint-title, .paint-instruction { display: none; }
  .palette { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .swatch { max-width: 35px; }
  .tool-row { padding-top: 6px; }
  .tool-row button { min-height: 37px; }
  .stagearea { order: 3; }
  .stagearea .card { width: min(100%, calc(clamp(170px, 100dvh - 290px, 550px) * var(--ar))); }
  .paint-next { order: 4; }
  .side > .actions { order: 5; }
  .grownup-panel { order: 6; }
  .learning { order: 7; }
  .collection-trigger { order: 8; }
  .stripwrap { order: 9; }
}
@media print {
  @page { margin: 8mm; }
  body { background: white; }
  body > * { display: none !important; }
  body:not(.certificate-print) #printArea { display: block !important; }
  #printArea img { display: block; width: 100%; max-height: 96vh; object-fit: contain; }
  body.certificate-print .certificate { display: grid !important; place-content: center; min-height: 90vh; border: 8px double var(--plum); padding: 30px; text-align: center; }
  .certificate h1 { font-size: 2rem; }
}

.locked-book { max-width: 680px; margin-block: clamp(24px, 8vw, 90px); padding: clamp(18px, 4vw, 42px); }
.locked-book h1 { font-size: clamp(1.8rem, 5vw, 3rem); }
