/* Baloo 2 and Nunito: SIL Open Font License 1.1, served from this site instead of Google */
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/baloo2.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(fonts/baloo2.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/nunito.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(fonts/nunito.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Layout: one-screen toy. A 3D bamboo glade fills the screen; a name bar floats on top, needs + action buttons sit in a sturdy tray at the bottom. Single deliberate look (sky world), not theme-dependent. */
  :root {
    --sky-top: #bfe6f6;
    --sky-bottom: #eef8e2;
    --night-top: #232c5c;
    --night-bottom: #4a4f8c;
    --ink: #2f3a2c;
    --ink-soft: #5d6b58;
    --leaf: #4f9e46;
    --leaf-deep: #2f7a35;
    --paper: #fffdf6;
    --paper-edge: #e4ecd6;
    --blush: #ff8fae;
    --sun: #ffc94a;
    --water: #59b8f0;
    --plum: #9a7cf2;
    --fever: #ef6f7a;
    --teal: #2fb39f;
    --font-display: "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
    --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: light;
  }
  html, body { height: 100%; }
  body { margin: 0; overscroll-behavior: none; touch-action: manipulation; }
  input { -webkit-user-select: text; user-select: text; }
  [hidden] { display: none !important; }
  body {
    margin: 0; overflow: hidden;
    background: linear-gradient(var(--sky-top), var(--sky-bottom));
    color: var(--ink); font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  }
  #night {
    position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s ease;
    background: linear-gradient(var(--night-top), var(--night-bottom));
  }
  #night.on { opacity: 1; }
  #stars { position: absolute; inset: 0 0 50% 0; }
  #stars i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff7c8; opacity: .8; }
  canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

  .app {
    position: fixed; inset: 0; pointer-events: none;
    display: flex; flex-direction: column; justify-content: space-between;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-block: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 14px);
  }
  .app > * { pointer-events: auto; width: 100%; max-width: 560px; margin-inline: auto; box-sizing: border-box; }

  .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .nameplate {
    background: var(--paper); border: 3px solid var(--paper-edge); border-radius: 18px;
    padding: 6px 14px 4px; box-shadow: 0 4px 0 rgba(47,58,44,.12); min-width: 0;
  }
  .nameplate h1 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; line-height: 1.1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nameplate .friend { font-size: .82rem; font-weight: 800; color: var(--ink-soft); letter-spacing: .02em; }
  .nameplate .friend b { color: var(--blush); }
  .round {
    width: 46px; height: 46px; flex: none; border-radius: 50%; border: 3px solid var(--paper-edge);
    background: var(--paper); font-size: 1.3rem; cursor: pointer; box-shadow: 0 4px 0 rgba(47,58,44,.12);
    display: grid; place-items: center; padding: 0; color: var(--ink);
  }
  .round:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(47,58,44,.12); }
  .topbtns { display: flex; gap: 8px; }

  .tray {
    background: var(--paper); border: 3px solid var(--paper-edge); border-radius: 26px;
    padding: 12px; box-shadow: 0 6px 0 rgba(47,58,44,.14); display: grid; gap: 12px;
  }
  .needs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .need { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px; min-width: 0; }
  .need .ic { font-size: 1.15rem; grid-row: span 2; }
  .need .lbl { font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
  .bar { height: 12px; border-radius: 99px; background: #edf1e6; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
  .bar > span { display: block; height: 100%; width: 50%; border-radius: inherit; transition: width .6s ease, background-color .6s; }
  .actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .act {
    border: 0; border-radius: 18px; padding: 10px 4px 8px; cursor: pointer; font-family: var(--font-display);
    font-weight: 800; font-size: 1rem; color: #fff; display: grid; justify-items: center; gap: 0; line-height: 1.1;
    box-shadow: 0 5px 0 rgba(0,0,0,.18); transition: transform .08s, filter .2s;
  }
  .act .e { font-size: 1.7rem; line-height: 1.2; }
  .act:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
  .act:disabled { filter: grayscale(.7) opacity(.55); cursor: default; }
  .act:focus-visible, .round:focus-visible, .btn:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }
  #feed { background: var(--leaf); } #play { background: var(--sun); color: #5a3e00; }
  #sleep { background: var(--plum); } #bath { background: var(--water); }
  .actions.more { grid-template-columns: repeat(3, 1fr); }
  .act.mini { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 4px; font-size: .95rem; border-radius: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
  .act.mini .e { font-size: 1.25rem; line-height: 1; }
  #med { background: var(--fever); white-space: nowrap; } #dance { background: var(--blush); } #game { background: var(--teal); }
  #med.pulse { animation: pulse 1.1s ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scale(1.07); box-shadow: 0 0 0 6px rgba(239,111,122,.35), 0 4px 0 rgba(0,0,0,.18); } }
  .round.off { opacity: .45; }
  .namerow { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .chip { flex: none; background: var(--fever); color: #fff; font-weight: 800; font-size: .78rem; border-radius: 99px; padding: 2px 9px; letter-spacing: .03em; }
  .hud {
    position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 84px);
    background: var(--paper); border: 3px solid var(--paper-edge); border-radius: 99px; padding: 6px 18px;
    font: 800 1.3rem var(--font-display); color: var(--ink); box-shadow: 0 4px 0 rgba(47,58,44,.14); white-space: nowrap; font-variant-numeric: tabular-nums;
  }
  .hud span { color: var(--ink-soft); font-size: 1rem; }

  .bubble {
    position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); max-width: min(260px, 70vw);
    background: #fff; color: var(--ink); border-radius: 18px; padding: 8px 14px; font-weight: 800; font-size: 1.02rem;
    text-align: center; box-shadow: 0 4px 0 rgba(47,58,44,.15); pointer-events: none; opacity: 0;
    transition: opacity .3s; text-wrap: balance;
  }
  .bubble::after { content: ""; position: absolute; left: 50%; bottom: -9px; margin-left: -9px; border: 9px solid transparent; border-bottom: 0; border-top-color: #fff; }
  .bubble.show { opacity: 1; }
  .float { position: fixed; pointer-events: none; font-size: 1.6rem; animation: rise 1.4s ease-out forwards; }
  .zzz { position: fixed; pointer-events: none; font-family: var(--font-display); font-weight: 800; color: #fff7c8; font-size: 1.6rem; animation: zz 2.6s ease-out forwards; }
  @keyframes rise { from { transform: translate(-50%, 0) scale(.6); opacity: 1; } to { transform: translate(calc(-50% + var(--dx, 0px)), -110px) scale(1.2); opacity: 0; } }
  @keyframes zz { from { transform: translate(0,0) scale(.6); opacity: 0; } 20% { opacity: 1; } to { transform: translate(40px,-90px) scale(1.3); opacity: 0; } }

  /* Setup + dressing card */
  .sheet {
    position: fixed; inset: 0; display: grid; place-items: center; background: rgba(35,44,92,.35);
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
    z-index: 5;
  }
  .card {
    width: 100%; max-width: 400px; box-sizing: border-box; background: var(--paper); border-radius: 28px;
    border: 3px solid var(--paper-edge); padding: 22px 20px 20px; display: grid; gap: 14px; box-shadow: 0 8px 0 rgba(47,58,44,.18);
  }
  .card h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; line-height: 1.1; text-align: center; text-wrap: balance; }
  .card p { margin: 0; text-align: center; color: var(--ink-soft); font-size: 1rem; }
  .card label { font-weight: 800; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); display: grid; gap: 6px; }
  .card input {
    font: 800 1.2rem var(--font-body); padding: 10px 14px; border-radius: 14px; border: 3px solid var(--paper-edge);
    background: #fff; color: var(--ink); text-transform: none; letter-spacing: 0; width: 100%; box-sizing: border-box;
  }
  .card input:focus { outline: none; border-color: var(--leaf); }
  .btn { border: 0; border-radius: 16px; padding: 12px; font: 800 1.2rem var(--font-display); color: #fff; background: var(--leaf); cursor: pointer; box-shadow: 0 5px 0 var(--leaf-deep); }
  .btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--leaf-deep); }
  .btn.ghost { background: #edf1e6; color: var(--ink); box-shadow: 0 5px 0 #d5dccb; }
  .wardrobe { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .wardrobe button {
    border: 3px solid var(--paper-edge); background: #fff; border-radius: 16px; padding: 10px 6px; cursor: pointer;
    font: 800 .95rem var(--font-body); color: var(--ink); display: grid; gap: 2px; justify-items: center;
  }
  .wardrobe button .e { font-size: 1.8rem; }
  .wardrobe button.on { border-color: var(--leaf); background: #eef8e2; }
  .wardrobe button:disabled { opacity: .45; cursor: default; }
  .wardrobe small { color: var(--ink-soft); font-weight: 600; }

  @media (max-height: 700px) {
    .act .e { font-size: 1.35rem; } .act { padding: 6px 4px; font-size: .9rem; }
    .act.mini { padding: 6px 4px; } .act.mini .e { font-size: 1.1rem; }
    .tray { padding: 10px; gap: 8px; } .nameplate h1 { font-size: 1.3rem; }
  }
  @media (prefers-reduced-motion: reduce) { .float, .zzz { animation-duration: .01s; } }
