:root { color-scheme: dark; --purple: #7448d1; --purple-light: #b292f2; --yellow: #ffaa01; --ink: #09090e; --muted: #8d8999; font-family: Arial, Helvetica, sans-serif; color: #f6f3fc; background: var(--ink); }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button, .weather-option { touch-action: manipulation; }
button, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.app-shell { max-width: 1800px; margin: auto; }
.masthead { padding: 30px clamp(24px, 4.7vw, 76px); display: flex; align-items: center; justify-content: space-between; gap: 24px; position: relative; z-index: 5; }
.wordmark { display: block; width: clamp(150px, 15vw, 195px); height: auto; }
.header-tools { display: flex; align-items: center; gap: 24px; }
.edition { font-size: 12px; text-transform: uppercase; letter-spacing: .15em; font-weight: 600; color: #bab4c7; }
.edition span { color: #635b74; margin-left: 12px; }
.motion-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 8px; background: transparent; color: #9c95ae; border: 1px solid #302c3b; border-radius: 50%; transition: color .2s, border-color .2s; }
.motion-button .icon { width: 18px; height: 18px; }
.motion-button:hover { border-color: var(--purple-light); color: white; }
.sound-button { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; color: #a69eb5; padding: 8px 0; font-size: 12px; }
.sound-button .icon { width: 20px; height: 20px; }
.sound-button[aria-pressed="true"] { color: var(--yellow); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--yellow); outline-offset: 5px; }
.habitat { position: relative; isolation: isolate; height: clamp(340px, calc(100svh - 355px), 840px); min-height: 340px; display: grid; place-items: center; overflow: hidden; }
.scene { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; isolation: isolate; touch-action: pan-y; }
.ambient { position: absolute; z-index: -2; width: min(100%, 980px); height: 100%; background: radial-gradient(ellipse at 50% 48%, #40246b52 0%, #291b4540 30%, #09090e00 68%); transition: background 1.7s; }
.sunlight { position: absolute; inset: -30% -20%; z-index: -1; opacity: 0; background: radial-gradient(ellipse at 78% 8%, #ffca7944, #b95d141a 30%, transparent 62%); transform: rotate(-12deg); transition: opacity 2s; }
body[data-weather="sun"] .sunlight { opacity: 1; animation: warm-light 7s ease-in-out infinite alternate; }
body[data-weather="rain"] .ambient, body[data-weather="storm"] .ambient { background: radial-gradient(ellipse at 50% 45%, #223e594a, #15233330 42%, transparent 70%); }
.character { position: relative; width: min(94vw, calc((100svh - 365px) * 1.5), 1170px); min-width: 495px; aspect-ratio: 3 / 2; }
.character-canvas, .character-fallback { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.character-canvas { opacity: 0; }
.character.is-ready .character-canvas { opacity: 1; }
.character.is-ready .character-fallback { visibility: hidden; }
.weather-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.weather-canvas.foreground { z-index: 2; }
.lightning-glow { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at 72% 4%, #bdd8ff68, #897ad928 40%, transparent 78%); pointer-events: none; z-index: 3; }
.mood { position: absolute; left: clamp(24px, 4.7vw, 76px); bottom: 40px; z-index: 4; pointer-events: none; text-shadow: 0 2px 25px #09090e; max-width: 230px; }
.mood-eyebrow { display: block; color: var(--purple-light); font-size: 12px; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; margin-bottom: 10px; transition: color .5s; }
body[data-weather="sun"] .mood-eyebrow { color: #f9c56b; }
body[data-weather="rain"] .mood-eyebrow, body[data-weather="storm"] .mood-eyebrow { color: #9eceed; }
.mood p { margin: 0; font-weight: 500; font-size: clamp(20px, 2vw, 28px); line-height: 1.22; letter-spacing: -.025em; }
.scene-caption { position: absolute; bottom: 42px; right: clamp(24px, 4.7vw, 76px); font-size: 12px; line-height: 1.65; color: #777181; text-align: right; letter-spacing: .02em; }
.control-deck { position: relative; z-index: 5; display: flex; align-items: stretch; justify-content: center; gap: 28px; padding: 8px 24px 0; margin: 0 auto; width: fit-content; max-width: 100%; }
.weather-control { border: 0; padding: 0; margin: 0; min-width: 0; }
.weather-control legend, .control-label { display: block; margin: 0 0 12px; padding: 0; font-size: 12px; color: var(--muted); letter-spacing: .045em; }
.weather-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; border: 1px solid #2b2536; border-radius: 18px; padding: 5px; background: #15111d; }
.weather-option { position: relative; cursor: pointer; }
.weather-option input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.weather-face { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px 20px; border-radius: 12px; color: #a59cab; font-size: 14px; font-weight: 500; min-height: 60px; transition: background .25s, color .25s, box-shadow .25s; }
.weather-face .icon { width: 26px; height: 26px; }
.weather-option:hover .weather-face { background: #261e33; color: #eee7f8; }
.weather-option input:checked + .weather-face { background: #7448d12d; color: #e8daff; box-shadow: inset 0 0 0 1px #946ce970; }
.weather-option input:checked + .weather-face .icon { color: #b594ff; }
.weather-option input:focus-visible + .weather-face { outline: 2px solid var(--yellow); outline-offset: 2px; }
.weather-option input:disabled + .weather-face { opacity: .45; cursor: wait; }
.feeding-control { padding-left: 28px; border-left: 1px solid #24202c; display: flex; flex-direction: column; }
.feed-button { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 20px; min-height: 72px; border-radius: 18px; border: 1px solid #ffd172; color: #1e1400; background: var(--yellow); font-size: 14px; font-weight: 600; transition: transform .2s, background .2s; }
.feed-button:hover { background: #ffbd3b; transform: translateY(-2px); }
.feed-button:active { transform: translateY(1px); }
.feed-button:disabled { cursor: wait; opacity: .65; transform: none; }
.plus { font-size: 23px; font-weight: 400; margin-left: 6px; }
.hint { min-height: 18px; padding: 0 24px; margin: 19px 0 22px; font-size: 12px; line-height: 1.5; color: #807889; text-align: center; }
.food-delivery { position: absolute; width: 18%; left: 50%; top: 50%; opacity: 0; z-index: 2; pointer-events: none; transform-origin: 25% 80%; }
.food-delivery img { display: block; width: 100%; height: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript-message { text-align: center; padding: 20px; }
body.is-paused *, body.is-paused *::before, body.is-paused *::after { animation-play-state: paused !important; }
@keyframes warm-light { to { opacity: .65; transform: rotate(-8deg) scale(1.04); } }
@media (min-width: 1600px) { .mood { bottom: 65px; } }
@media (max-width: 1000px) { .control-deck { gap: 16px; } .feeding-control { padding-left: 16px; } .weather-face { padding: 16px 13px; gap: 8px; } .feed-button { padding: 20px 16px; gap: 9px; } .mood { bottom: 22px; max-width: 160px; } .scene-caption { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; } }
/* Secondary actions stay below the primary weather and food controls. */
.action-deck { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 16px 20px 0; }
.action-button { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 10px 16px; border: 1px solid #30283e; border-radius: 12px; background: #131019; color: #bbb2cb; font-size: 13px; transition: background .2s, color .2s, border-color .2s; }
.action-button .icon { width: 18px; height: 18px; }
.action-button:hover { color: #f7f2ff; background: #251a36; border-color: #745391; }
.action-button:disabled { opacity: .5; cursor: default; }
.action-button.is-active { opacity: 1; color: var(--yellow); border-color: #ffaa0170; }
.food-delivery { width: 13%; transform-origin: 94% 6%; }
.food-delivery canvas { display: block; width: 100%; height: auto; }
.play-leaf { position: absolute; width: 12%; opacity: 0; pointer-events: none; z-index: 3; transform-origin: center; }
.play-leaf img { display: block; width: 100%; }
.hint { margin-top: 13px; }
.branch-rest { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: calc(1 - var(--seated-opacity, 1)); pointer-events: none; }
.character.is-ready .character-canvas, .character:not(.is-ready) .character-fallback { opacity: var(--seated-opacity, 1); }
.toilet-scene { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.toilet-scene[hidden] { display: none; }
.portable-toilet { position: absolute; perspective: 700px; opacity: 0; filter: drop-shadow(9px 14px 14px #0009); }
.wc-shell { position: absolute; inset: 5% 0 4%; border-radius: 9px 10px 5px 5px; background: linear-gradient(90deg,#493177 0%,#8763c4 6%,#634199 13%,#51337e 87%,#3b255f 100%); border: 1px solid #b291d357; box-shadow: inset 2px 0 4px #d0b4f857, inset -5px 0 4px #160c375c; }
.wc-interior { position: absolute; inset: 5% 12% 4%; border-radius: 8px 8px 2px 2px; background: linear-gradient(90deg,#09080e,#1b1428 65%,#100c18); box-shadow: inset 0 7px 12px #000; overflow: hidden; }
.wc-seat { position: absolute; width: 54%; height: 12%; left: 25%; bottom: 16%; border-radius: 40% 40% 15% 15%; background: #92908a; box-shadow: inset 0 5px 0 #ddd8ca, 0 8px 0 #4c4852, 0 23px 0 -2px #554d63; }
.wc-roof { position: absolute; left: -4%; right: -4%; top: 0; height: 9%; border: 1px solid #e4dfd3; border-radius: 48% 48% 10% 10% / 60% 60% 20% 20%; background: linear-gradient(#f3efdf,#c4c1b6 60%,#99989b); box-shadow: 0 3px 3px #1c112cc9, inset 0 2px 2px #fff; z-index: 3; }
.wc-base { position: absolute; left: -3%; right: -3%; bottom: 0; height: 7%; background: repeating-linear-gradient(90deg,#28232e 0 12%,#1b1723 13% 17%); border: 1px solid #605369; border-radius: 4px 4px 7px 7px; box-shadow: inset 0 4px 0 #4f445e; z-index: 3; }
.wc-door { position: absolute; left: 10%; width: 77%; top: 10%; height: 83%; border: 1px solid #b499d8; border-radius: 8px 8px 3px 3px; background: linear-gradient(100deg,#9875d3,#734db0 21%,#744bb2 66%,#583388); box-shadow: inset 3px 0 4px #c4a3ee5c,inset -3px 0 5px #341849,3px 0 5px #0d081faa; transform-origin: 0 50%; transform: rotateY(var(--door-angle, 0deg)); backface-visibility: visible; z-index: 4; }
.wc-door::before,.wc-door::after { content: ''; position: absolute; left: -5%; width: 8%; height: 7%; background: linear-gradient(90deg,#c0b8bc,#625671); border: 1px solid #5c536a; border-radius: 2px; }
.wc-door::before { top: 14%; } .wc-door::after { bottom: 16%; }
.wc-vent { position: absolute; left: 20%; right: 20%; top: 7%; height: 8%; border-radius: 5px; background: repeating-linear-gradient(#29133f 0 2px,#9d77ce 3px 5px); border: 3px solid #9267c0; box-shadow: 0 1px 0 #b496d2; }
.wc-sign { position: absolute; top: 23%; left: 27%; width: 46%; padding: 8% 0; border-radius: 6px; background: #f6edda; color: #48256c; box-shadow: 0 2px 2px #25103570; text-align: center; font-size: clamp(15px,2vw,24px); font-weight: 800; letter-spacing: .08em; }
.wc-panels { position: absolute; left: 15%; right: 15%; top: 50%; bottom: 10%; border-radius: 5px; background: repeating-linear-gradient(90deg,#55307f44 0 17%,#a37bd22e 18% 22%,#6c439900 23% 27%); box-shadow: inset 1px 1px 3px #38204a7a,1px 1px 1px #bc96e273; }
.wc-handle { position: absolute; right: 8%; top: 47%; height: 13%; width: 7%; border-radius: 4px; background: linear-gradient(90deg,#16101c,#625066,#d4c8ce,#3f3046); border: 1px solid #251331; box-shadow: 2px 1px 2px #351949; }
.wc-status { position: absolute; right: 7%; top: 41%; width: 43%; padding: 3% 1%; text-align: center; border-radius: 3px; color: #122d22; background: #9bdfb7; border: 2px solid #e0d8d4; font-size: clamp(5px,.55vw,7px); font-weight: 800; letter-spacing: .025em; }
.is-occupied .wc-status { color: #4a1708; background: #ffab60; }
.walking-koala { position: absolute; opacity: 0; transform: translate(-50%,-90%); z-index: 6; }
.walking-shadow { position: absolute; height: 12px; transform: translate(-50%,-50%); border-radius: 50%; background: #000; filter: blur(5px); opacity: 0; }

/* A phone gets a complete scene, its own caption row and thumb-sized controls. */
@media (max-width: 760px), (max-width: 960px) and (max-height: 500px) {
  .app-shell { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) max(12px, env(safe-area-inset-bottom, 0px)) env(safe-area-inset-left, 0px); }
  .masthead { padding: 12px 16px 6px; gap: 16px; }
  .wordmark { width: 146px; }
  .header-tools { gap: 8px; }
  .motion-button, .sound-button { width: 44px; height: 44px; min-height: 44px; display: grid; place-items: center; padding: 10px; border: 1px solid #302c3b; border-radius: 50%; }
  .sound-button span { display: none; }
  .sound-button[aria-pressed="true"] { border-color: #ffaa0170; background: #ffaa010c; }
  .motion-button .icon, .sound-button .icon { width: 20px; height: 20px; }
  main { max-width: 600px; margin: 0 auto; }
  .habitat { --stage-height: clamp(190px, min(64vw, calc(100svh - 310px)), 390px); height: auto; min-height: 0; display: block; overflow: visible; }
  .scene { position: relative; inset: auto; width: 100%; height: var(--stage-height); }
  .character { width: min(calc(100% - 16px), calc(var(--stage-height) * 1.5)); min-width: 0; flex-shrink: 0; }
  .mood { position: relative; inset: auto; width: 100%; max-width: none; min-height: 64px; padding: 8px 16px 12px; text-align: center; text-shadow: none; }
  .mood-eyebrow { margin-bottom: 5px; font-size: 11px; letter-spacing: .13em; }
  .mood p { font-size: 19px; line-height: 1.3; letter-spacing: -.02em; }
  .control-deck { flex-direction: column; width: 100%; max-width: none; gap: 10px; padding: 6px 16px 0; }
  .weather-control legend { margin-bottom: 8px; font-size: 12px; }
  .weather-options { gap: 4px; padding: 4px; border-radius: 16px; }
  .weather-face { min-height: 64px; padding: 9px 4px; flex-direction: column; gap: 6px; font-size: 14px; border-radius: 11px; }
  .weather-face .icon { width: 23px; height: 23px; }
  .feeding-control { padding: 0; border: 0; }
  .feeding-control .control-label { display: none; }
  .feed-button { width: 100%; min-height: 48px; padding: 11px 16px; gap: 10px; font-size: 15px; border-radius: 14px; }
  .feed-button .icon { width: 22px; height: 22px; }
  .feed-button:hover { transform: none; }
  .action-deck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding: 10px 16px 0; }
  .action-button { min-width: 0; min-height: 46px; justify-content: center; gap: 6px; padding: 10px 5px; font-size: 13px; border-radius: 12px; }
  .action-button .icon { width: 17px; height: 17px; }
  .hint { min-height: 18px; margin: 12px 0 0; padding: 0 20px; font-size: 12px; line-height: 1.5; }
}
@media (max-width: 359px) {
  .masthead { padding-inline: 12px; }
  .wordmark { width: 134px; }
  .control-deck, .action-deck { padding-inline: 12px; }
  .weather-face { font-size: 13px; }
  .action-button { font-size: 12px; gap: 4px; }
}
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .masthead { padding-top: 8px; padding-bottom: 4px; }
  main { max-width: none; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(290px, .9fr); grid-template-rows: auto auto 1fr; align-items: start; padding: 0 12px; column-gap: 8px; }
  .habitat { --stage-height: max(155px, calc(100svh - 128px)); grid-column: 1; grid-row: 1 / 4; }
  .mood { min-height: 52px; padding: 4px 8px 8px; }
  .mood p { font-size: 17px; }
  .mood-eyebrow { font-size: 10px; }
  .control-deck { grid-column: 2; grid-row: 1; padding: 4px 0 0; }
  .weather-face { min-height: 58px; padding-block: 6px; }
  .action-deck { grid-column: 2; grid-row: 2; padding: 8px 0 0; }
  .hint { grid-column: 2; grid-row: 3; padding: 0 4px; margin-top: 8px; }
}
