:root {
  --sat: env(safe-area-inset-top, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --ink: #5b4636;
  --apple: #c8463d;
  --paper: #f7f1e3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  overscroll-behavior: none;
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#paper {
  position: fixed; inset: 0; pointer-events: none;
  mix-blend-mode: multiply; opacity: .5;
  background-size: 256px 256px;
}
#vignette {
  position: fixed; inset: 0; pointer-events: none; mix-blend-mode: multiply;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(150, 110, 70, .18) 100%);
}

.overlay {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity .6s ease, visibility .6s;
}
.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

#start {
  background: rgba(247, 241, 227, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  gap: 1vmin;
  padding: 16px;
}
#start h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(40px, 11vmin, 112px);
  line-height: 1;
  color: var(--apple);
  text-shadow: 0 3px 0 rgba(255, 255, 255, .75);
  transform: rotate(-3deg);
}
#play {
  border: 0; background: none; padding: 0; cursor: pointer;
  width: 40vmin; height: 40vmin;
  animation: bob 2.4s ease-in-out infinite;
}
#play canvas { width: 100%; height: 100%; display: block; }
#play:active { scale: .92; }
#start p { margin: 0; font-size: clamp(18px, 3.6vmin, 30px); opacity: .75; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-2.5vmin) rotate(3deg); }
}

#grownup {
  position: fixed;
  left: calc(10px + var(--sal));
  bottom: calc(10px + var(--sab));
  width: 46px; height: 46px;
  border: 0; background: none; padding: 0;
  color: var(--ink); opacity: .3; cursor: pointer;
  touch-action: none;
}
#grownup svg { width: 100%; height: 100%; }
#grownup .ring { stroke-dasharray: 126; stroke-dashoffset: 126; transition: stroke-dashoffset .15s; }
#grownup.holding { opacity: .8; }
#grownup.holding .ring { stroke-dashoffset: 0; transition: stroke-dashoffset 1.2s linear; }

#panel { background: rgba(80, 60, 40, .3); padding: 16px; }
.card {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #fffaf0;
  border-radius: 28px;
  padding: 22px 24px 18px;
  box-shadow: 0 20px 60px rgba(60, 40, 20, .25);
}
.card h2 { margin: 0; font-size: 28px; color: var(--apple); }
.stats { margin: 0 0 10px; opacity: .7; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px dashed rgba(91, 70, 54, .2);
  font-size: 20px; font-weight: 600;
}
.row input {
  appearance: none; -webkit-appearance: none;
  width: 54px; height: 32px; border-radius: 99px;
  background: #e2d6c2; position: relative; cursor: pointer; transition: background .2s;
}
.row input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s;
}
.row input:checked { background: #7cb15a; }
.row input:checked::after { transform: translateX(22px); }
.seg { display: flex; background: #efe5d3; border-radius: 99px; padding: 3px; }
.seg button {
  border: 0; background: none; font: inherit; font-weight: 800; font-size: 18px;
  width: 52px; height: 34px; border-radius: 99px; color: var(--ink); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--apple); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.actions button {
  border: 0; font: inherit; font-weight: 800; font-size: 18px;
  padding: 10px 18px; border-radius: 99px; cursor: pointer; white-space: nowrap;
  background: var(--apple); color: #fff;
}
.actions button.ghost { background: none; color: var(--ink); opacity: .7; }
.tip { font-size: 14px; opacity: .6; margin: 14px 0 0; }

.topics { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 4px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 6px 12px; border-radius: 99px;
  background: #efe5d3; color: var(--ink); font-weight: 600; font-size: 16px;
  opacity: .55; transition: background .15s, opacity .15s;
}
.chip input:checked + span { background: #ffe9b8; opacity: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.chip input:focus-visible + span { outline: 2px solid var(--apple); }

.row .hint { display: block; font-size: 13px; font-weight: 600; opacity: .6; }
