/* Pet Rocko. Rocko's World palette: navy ink, cream, Rocko red, gold. The room is CSS stand-in art
   (a cozy "diorama" den) until Ron's DALL·E rooms arrive (ART-PROMPTS.md); then .wall/.floor become one
   painted backdrop per room and the CSS here just frames it. */
:root {
  --ink: #1c2434; --cream: #fff8ec; --red: #d83a34; --gold: #FFC93C;
  --wall: #f3d9b8; --wall2: #e9c79e; --floor: #b9825a; --floor2: #a56f4a; --rug: #d83a34;
  --soft: #fde9cf; --mint: #7fcfa0; --sky: #8fd0f0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #2b3656, var(--ink) 70%);
  color: var(--ink); font-family: 'Nunito', ui-rounded, system-ui, sans-serif; font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* Custom icon set (sprite in index.html). Sizes to the surrounding font and takes the text colour,
   so one set reads right on the navy bar (cream) and on the cream cards (ink). No emoji anywhere. */
.ic { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; fill: currentColor; flex: none; }

.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); gap: 10px; }

/* --- top bar ------------------------------------------------------------------------------------ */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--cream); }
.friend { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.lvl { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1.05rem; }
.lvl::before { content: ""; display: inline-block; width: .95em; height: .95em; vertical-align: -0.1em; margin-right: .32em;
  background: var(--gold);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20.6C4 15 2.4 10.8 2.4 7.9 2.4 5.3 4.5 3.4 7 3.4c1.9 0 3.7 1.1 5 2.9 1.3-1.8 3.1-2.9 5-2.9 2.5 0 4.6 1.9 4.6 4.5 0 2.9-1.6 7.1-9.6 12.7Z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20.6C4 15 2.4 10.8 2.4 7.9 2.4 5.3 4.5 3.4 7 3.4c1.9 0 3.7 1.1 5 2.9 1.3-1.8 3.1-2.9 5-2.9 2.5 0 4.6 1.9 4.6 4.5 0 2.9-1.6 7.1-9.6 12.7Z'/%3E%3C/svg%3E") center/contain no-repeat; }
.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; max-width: 220px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ffdf7e); border-radius: 99px; transition: width .6s; }
.chips { display: flex; gap: 6px; }
.chip { background: rgba(255,255,255,.1); border-radius: 99px; padding: 6px 10px; font-size: .95rem; white-space: nowrap; }

/* --- the room (stand-in diorama) ----------------------------------------------------------------- */
.room { position: relative; flex: 1; min-height: 340px; border-radius: 26px; overflow: hidden;
  box-shadow: 0 10px 0 rgba(0,0,0,.25), inset 0 0 0 4px rgba(255,255,255,.35); isolation: isolate; }
.wall { position: absolute; inset: 0 0 34% 0;
  background: repeating-linear-gradient(90deg, var(--wall) 0 34px, var(--wall2) 34px 36px); }
.window { position: absolute; left: 10%; top: 14%; width: 28%; aspect-ratio: 1; border-radius: 14px 14px 6px 6px;
  background: linear-gradient(var(--sky), #d7f0fb); box-shadow: inset 0 0 0 6px var(--cream), 0 4px 0 rgba(0,0,0,.08); }
.window::after { content: ""; position: absolute; inset: 0; background:
  linear-gradient(90deg, transparent 47%, var(--cream) 47% 53%, transparent 53%),
  linear-gradient(transparent 47%, var(--cream) 47% 53%, transparent 53%); }
.frame { position: absolute; right: 12%; top: 18%; width: 18%; aspect-ratio: 4/5; background: var(--gold);
  border-radius: 6px; box-shadow: inset 0 0 0 5px #b8862a; }
.floor { position: absolute; inset: 66% 0 0 0;
  background: repeating-linear-gradient(90deg, var(--floor) 0 60px, var(--floor2) 60px 62px); }
.rug { position: absolute; left: 50%; top: 32%; width: 62%; height: 52%; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(var(--rug) 55%, #b52a25 56% 62%, var(--rug) 63%); opacity: .9; }
.room[data-night="1"] .window { background: linear-gradient(#20294a, #3a4677); }

.rocko { position: absolute; left: 50%; bottom: 7%; width: min(62%, 300px); aspect-ratio: 1; transform: translateX(-50%);
  border: 0; padding: 0; background: none; touch-action: manipulation; z-index: 2; }
.rocko img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none;
  filter: drop-shadow(0 10px 10px rgba(0,0,0,.25)); transform-origin: 50% 95%; animation: idle 3.2s ease-in-out infinite; }
@keyframes idle { 50% { transform: scale(1.015, .985); } }
.rocko.boing img { animation: boing .45s cubic-bezier(.3,1.8,.5,1); }
@keyframes boing { 40% { transform: scale(1.06, .92); } 70% { transform: scale(.97, 1.04); } }
.room[data-mood="bouncy"] .rocko img { animation: hop 1.1s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-10px); } }

.bubble { position: absolute; left: 50%; top: 7%; transform: translateX(-50%) scale(.9); max-width: 80%;
  background: #fff; border-radius: 18px; padding: 10px 16px; font-size: 1.05rem; text-align: center;
  box-shadow: 0 4px 0 rgba(0,0,0,.12); opacity: 0; transition: opacity .2s, transform .2s; z-index: 3; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -9px; margin-left: -9px;
  border: 9px solid transparent; border-bottom: 0; border-top-color: #fff; }
.bubble.on { opacity: 1; transform: translateX(-50%) scale(1); }

/* --- today card: the daily ritual (share the jar, today's wish, what's next) --------------------- */
.today { display: flex; flex-direction: column; gap: 8px; }
.jar { border: 0; text-align: left; width: 100%; background: var(--cream); color: var(--ink); border-radius: 16px;
  padding: 11px 14px; font-size: .95rem; box-shadow: 0 4px 0 #d9c3a3; transition: transform .08s, box-shadow .08s; }
.jar b { color: var(--red); }
.jar:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9c3a3; }
.jar.done { background: var(--gold); box-shadow: 0 4px 0 #cfa233; }
.wish { background: rgba(255,255,255,.92); border-radius: 16px; padding: 8px 14px; font-size: .9rem; color: var(--ink);
  box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.wish::before { content: "Today’s wish"; display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #8a6a3e; }
.wish-dots { display: block; margin-top: 2px; letter-spacing: 2px; }
.wish.done { background: var(--gold); }
.soon-line { margin: 0; padding: 0 6px; font-size: .8rem; color: rgba(255,248,236,.75); }
.soon-line em { font-style: normal; color: var(--gold); font-weight: 800; }

/* top-bar icon buttons (sound toggle + Rocko's Book) */
.sound-btn, .book-btn { border: 0; line-height: 1; }
.sound-btn[aria-pressed="false"] { opacity: .5; }   /* muted reads as dimmed, same navy-bar colour */

/* --- Rocko's Book sheet (keepsakes + collection) ------------------------------------------------- */
.sheet { position: fixed; inset: 0; background: rgba(12,16,32,.55); z-index: 20; display: flex;
  align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }                 /* `display:flex` above would otherwise beat the hidden attribute */
.sheet-card { position: relative; background: var(--cream); color: var(--ink); width: 100%; max-width: 560px;
  max-height: 86vh; overflow-y: auto; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 0 rgba(0,0,0,.2);
  padding: 20px 18px max(18px, env(safe-area-inset-bottom)); animation: sheetUp .28s cubic-bezier(.3,1.4,.5,1); }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-x { position: absolute; right: 14px; top: 14px; border: 0; background: rgba(0,0,0,.07); border-radius: 99px;
  width: 34px; height: 34px; font-size: 1rem; }
.sheet-card h2 { font-family: 'Fredoka', sans-serif; font-weight: 600; margin: 2px 0 6px; }
.sheet-card h3 { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1rem; margin: 16px 0 6px; }
.book-stats { margin: 0 0 10px; font-size: .95rem; }
.book-stickers { display: flex; flex-wrap: wrap; gap: 4px; font-size: 1.4rem; min-height: 1.6rem; align-items: center; }
.book-stickers .muted { font-size: .85rem; color: #8a6a3e; }
.book-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.book-list li { display: flex; justify-content: space-between; gap: 8px; background: #fff; border-radius: 12px; padding: 7px 10px; font-size: .85rem; }
.book-list li.locked { opacity: .5; background: rgba(0,0,0,.05); }
.book-list li em { font-style: normal; color: #8a6a3e; white-space: nowrap; }
.book-list li.got em { color: var(--mint); }

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.fx span { position: absolute; font-size: 1.6rem; color: var(--gold); animation: float 1.2s ease-out forwards; }
@keyframes float { to { transform: translateY(-90px) scale(1.3); opacity: 0; } }

.dim { position: absolute; inset: 0; background: rgba(18,24,38,.6); opacity: 0; pointer-events: none;
  transition: opacity .8s; z-index: 3; }
.dim.on { opacity: 1; }
.dim span { position: absolute; left: 60%; top: 40%; font-family: 'Fredoka', sans-serif; font-size: 2rem; color: var(--gold);
  opacity: 0; animation: z 3s ease-out infinite; }
.dim span:nth-child(2) { animation-delay: 1s; } .dim span:nth-child(3) { animation-delay: 2s; }
@keyframes z { 25% { opacity: 1; } 100% { opacity: 0; transform: translate(30px, -70px) scale(1.4); } }

/* --- needs: soft "wishes", never alarms (no red, no flashing, no empty bars) --------------------- */
.needs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.need { background: var(--cream); border-radius: 16px; padding: 8px 10px; display: grid;
  grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
.need .ico { grid-row: span 2; font-size: 1.5rem; }
.meter { height: 10px; border-radius: 99px; background: #eadcc6; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--mint); transition: width .6s; }
.need .word { font-size: .78rem; color: #6b5a44; }

/* --- actions ------------------------------------------------------------------------------------- */
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.actions button { border: 0; border-radius: 18px; background: var(--cream); padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .85rem;
  box-shadow: 0 5px 0 #d9c3a3; transition: transform .08s, box-shadow .08s; }
.actions button span { font-size: 1.6rem; line-height: 1.1; }
.actions button:active { transform: translateY(4px); box-shadow: 0 1px 0 #d9c3a3; }
.actions button.soon { opacity: .55; }
.actions button[aria-pressed="true"] { background: var(--gold); }

.tray { display: flex; gap: 8px; overflow-x: auto; padding: 2px; }
.tray button { flex: none; border: 0; border-radius: 16px; background: #fff; padding: 8px 12px; font-size: .9rem;
  box-shadow: 0 4px 0 #d9c3a3; display: flex; align-items: center; gap: 6px; }
.tray button span { font-size: 1.4rem; }

.toast { position: fixed; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 54px)); transform: translateX(-50%); background: var(--gold); color: var(--ink);
  border-radius: 18px; padding: 12px 18px; font-size: 1rem; box-shadow: 0 6px 0 rgba(0,0,0,.25); max-width: 92vw;
  text-align: center; z-index: 10; animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

.foot { display: flex; justify-content: space-between; color: rgba(255,248,236,.6); font-size: .8rem; padding: 0 4px; }
.foot a { color: rgba(255,248,236,.8); }

/* --- kids' edition (same game, set by data-edition) ---------------------------------------------- */
html[data-edition="kids"] .actions button { padding: 14px 4px 10px; font-size: .95rem; }
html[data-edition="kids"] .actions button span { font-size: 2rem; }
html[data-edition="kids"] .foot .out { display: none; }          /* no links out on the kids' side */
html[data-edition="kids"] .need .word { display: none; }         /* fewer words: icons + bars */

@media (max-width: 380px) { .actions button { font-size: .75rem; } .chip { padding: 5px 8px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
