@font-face {
  font-family: "Young Serif";
  src: url("assets/young-serif.woff2") format("woff2");
  font-display: swap;
}
:root {
  color-scheme: light;
  --page: #f8f5ef; --ink: #302e28; --quiet: #635f54; --edge: #d7d3c7;
  --switch: #ede9de; --selected: #fffdf7; --active: #394c3e;
  --on-active: #fffaf0; --hover: #e5e6d8; --focus: #88613b;
}
:root[data-light="night"] {
  color-scheme: dark;
  --page: #252724; --ink: #f1eadc; --quiet: #c2bdae; --edge: #50544b;
  --switch: #343731; --selected: #606454; --active: #d6ddbd;
  --on-active: #27362b; --hover: #3c4339; --focus: #e9bb75;
}
* { box-sizing: border-box; }
body { min-height: 100svh; margin: 0; color: var(--ink); background: var(--page); font: 400 1rem/1.35 "DM Sans", system-ui, sans-serif; }
body, .light-switch, .cats button, #sound { transition: color .35s, background-color .35s, border-color .35s; }
.room { width: min(100%, 1480px); margin: 0 auto; padding: clamp(12px,2.8vw,42px); padding-top: max(clamp(12px,2.3vw,34px),env(safe-area-inset-top)); padding-bottom: max(16px,env(safe-area-inset-bottom)); }
.bar, .tray, .switches, .light-switch, .cats, .feedback, .cats button, h1 { display: flex; align-items: center; }
.bar, .tray { justify-content: space-between; gap: 16px; }
.bar { margin-bottom: clamp(14px,1.7vw,25px); }
h1 { margin: 0; gap: 10px; font: 400 clamp(1.65rem,3.2vw,2.85rem)/1.14 "Young Serif", Georgia, serif; letter-spacing: -.065em; }
h1 canvas { width: clamp(32px,3.4vw,47px); height: auto; aspect-ratio: 1; }
.switches canvas { width: 21px; height: 21px; }
#sound canvas { width: 22px; height: 22px; }
.feedback canvas { width: 20px; height: 20px; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, #pad:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.switches { gap: clamp(8px,1.3vw,18px); }
.light-switch { padding: 2px; border: 1px solid var(--edge); border-radius: 40px; background: var(--switch); }
.switches button { display: grid; place-items: center; border: none; background: transparent; color: var(--quiet); width: 43px; height: 40px; border-radius: 30px; }
.audio-controls { display: flex; align-items: center; gap: 3px; }
.audio-controls button { display: flex; justify-content: center; align-items: center; gap: 5px; width: auto; min-width: 44px; height: 44px; padding: 0 10px; font-size: .82rem; font-weight: 600; }
.audio-controls button[aria-pressed="true"] { color: var(--active); background: var(--switch); }
.light-switch button[aria-pressed="true"] { color: var(--ink); background: var(--selected); box-shadow: 0 1px 4px #211c161f; }
#pad { position: relative; isolation: isolate; width: 100%; height: clamp(295px,min(73svh,52vw),790px); overflow: hidden; contain: layout paint; border-radius: clamp(15px,2vw,31px); background: #b9bb8c; touch-action: none; user-select: none; -webkit-user-select:none; -webkit-touch-callout:none; -webkit-tap-highlight-color: transparent; }
#pad[data-hover="true"] { cursor: grab; }
#pad[data-hand="true"] { cursor: none; }
#pad > * { position: absolute; pointer-events: none; }
.cushion, .moonlight { inset: 0; width: 100%; height: 100%; }
.cushion { object-fit: cover; object-position: 50% 50%; transition: filter .7s; }
.moonlight { opacity: 0; background: linear-gradient(125deg, #b6c7e32b, #344b6a22 38%, #0c192f54); transition: opacity .7s; }
#cat-surface { left: 50%; top: 50%; width: 73%; aspect-ratio: 2; transform: translate(-50%,-50%); filter: drop-shadow(3px 11px 8px rgb(44 39 22 / 26%)) drop-shadow(0 2px 2px rgb(46 37 22 / 22%)); transition: filter .7s; }
#poster, #pelt { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.pose-layer { position: absolute; inset: 0; opacity: 0; visibility: hidden; pointer-events: none; }
[data-pose="loaf"] #loaf, [data-pose="side"] #side, [data-pose="belly"] #belly { visibility: visible; opacity: 1; }
#side-photo, #side-fur, #belly-photo, #belly-fur { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#tail { position: absolute; display: none; pointer-events: none; }
#eyes { position: absolute; left: calc(100% * 103 / 1440); top: calc(100% * 201 / 720); width: calc(100% * 296 / 1440); height: calc(100% * 150 / 720); }
#hand { left: 0; top: 0; width: 155px; max-width: none; opacity: 0; transform-origin: 25% 10.5%; will-change: transform; filter: drop-shadow(3px 6px 4px #493a2a38); transition: opacity .14s, filter .65s; }
#pad[data-hand="true"] #hand { opacity: 1; }
#hand { mask-image: linear-gradient(to bottom, #000 76%, transparent 100%); }
[data-light="night"] .cushion { filter: brightness(.49) saturate(.58) hue-rotate(35deg); }
[data-light="night"] .moonlight { opacity: 1; }
[data-light="night"] #cat-surface { filter: brightness(.74) saturate(.69) drop-shadow(3px 12px 9px #111b23aa) drop-shadow(0 2px 2px #12182288); }
[data-light="night"] #hand { filter: brightness(.76) saturate(.7) drop-shadow(3px 6px 4px #11182365); }
.tray { margin-top: clamp(13px,1.7vw,26px); }
.cats { gap: clamp(5px,1vw,15px); }
.cats button { gap: 9px; border: 1px solid transparent; border-radius: 40px; padding: 4px 15px 4px 5px; min-height: 48px; background: transparent; font-size: .94rem; font-weight: 600; }
.cats img { width: clamp(34px,3.4vw,44px); height: auto; border-radius: 50%; object-fit: cover; background: #ded3b9; }
.cats button[aria-pressed="true"] { background: var(--active); color: var(--on-active); border-color: var(--active); }
.feedback { color: var(--quiet); gap: 8px; font-size: .91rem; flex-shrink: 0; min-height: 26px; }
.bars { display: none; align-items: center; justify-content: center; gap: 2px; width: 20px; height: 18px; }
.bars i { display: block; width: 2px; height: 8px; border-radius: 5px; background: currentColor; animation: hum .65s ease-in-out infinite alternate; }
.bars i:nth-child(2) { height: 14px; animation-delay: -.3s; }
.bars i:nth-child(3) { height: 11px; animation-delay: -.47s; }
.bars i:nth-child(4) { height: 6px; animation-delay: -.18s; }
.feedback[data-purring="true"] canvas { display: none; }
.feedback[data-purring="true"] .bars { display: flex; }
@keyframes hum { to { transform: scaleY(.42); } }
@media(hover:hover) { #sound:hover, .light-switch button:not([aria-pressed="true"]):hover, .cats button:not([aria-pressed="true"]):hover { background: var(--hover); } }
@media(max-aspect-ratio:1/1) {
  #pad { height: clamp(350px,min(72svh,143vw),920px); }
  #cat-surface { transform: translate(-50%,-50%) rotate(-65deg); }
}
@media(max-width:640px) {
  .room { padding-left: max(12px,env(safe-area-inset-left)); padding-right: max(12px,env(safe-area-inset-right)); }
  .bar { margin-bottom: 12px; }
  .tray { flex-direction: column; align-items: center; gap: 10px; }
  .cats { justify-content: center; }
  .cats button { gap: 6px; padding-right: clamp(9px,3vw,14px); font-size: .9rem; }
  .switches { gap: 3px; }
  .feedback { font-size: .875rem; }
}
@media(max-height:510px) and (min-aspect-ratio:1/1) {
  .room { padding: 6px max(12px,env(safe-area-inset-right)) 6px max(12px,env(safe-area-inset-left)); }
  .bar { margin-bottom: 5px; }
  h1 { font-size: 1.6rem; } h1 canvas { width: 29px; }
  #pad { height: max(180px,calc(100svh - 119px)); }
  .tray { flex-direction: row; margin-top: 5px; }
  .cats button { min-height: 43px; }
}
@media(max-width:520px) {
  .audio-controls { gap: 0; }
  .audio-controls button { flex-direction: column; gap: 1px; padding: 2px; border-radius: 12px; font-size: .65rem; line-height: 1; }
  .audio-controls canvas, #sound canvas { width: 17px; height: 17px; }
  .switches .light-switch button { width: 38px; }
  .bar { gap: 4px; }
}
@media(prefers-reduced-motion:reduce) {
  *, *::after, *::before { transition-duration: 0s !important; animation: none !important; }
}
