:root {
  color-scheme: light;
  --page: #f8f2e9;
  --ink: #442f25;
  --muted: #6b574b;
  --accent: #af633b;
  --edge: #cfad8c;
  --line: #e6d7c8;
  --paper: #fff9f0;
  --glass: #fff6e8e8;
  --button: #fbf5ec;
  --button-hover: #f2e6d8;
  --shadow: #6f3e2730;
  --contact: #582c13;
  --duration: 1.45s;
  --pad: clamp(15px, 2.2vw, 37px);
  font: 16px/1.4 "Segoe UI", system-ui, sans-serif;
  background: var(--page);
  color: var(--ink);
}

:root[data-theme="night"] {
  color-scheme: dark;
  --page: #211f2c;
  --ink: #f2e2d4;
  --muted: #c5b4b7;
  --accent: #e69b72;
  --edge: #656071;
  --line: #514956;
  --paper: #302a3a;
  --glass: #302a3aed;
  --button: #2b2635;
  --button-hover: #413548;
  --shadow: #08061365;
  --contact: #171019;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; background: var(--page); transition: background var(--duration), color var(--duration); }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }
button:not(:disabled), a { cursor: pointer; }
button:disabled { opacity: .5; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }

.icon-library, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) clamp(86px, 13vh, 124px);
  width: 100%;
  height: 100%;
  padding: var(--pad) var(--pad) 0;
  background: var(--page);
  transition: background var(--duration), color var(--duration);
}
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
  border-radius: clamp(17px, 1.9vw, 29px);
  background: #eaca9f;
  box-shadow: 0 10px 36px -20px var(--shadow);
  user-select: none;
  touch-action: none;
}
.room, .stage-edge, #cat, .interaction-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.room { background-position: center; background-size: 100% 100%; pointer-events: none; }
.room--day { background-image: url('./assets/room/day.jpg'); }
.room--night { background-image: url('./assets/room/night.jpg'); opacity: 0; transition: opacity var(--duration) ease-in-out; }
[data-theme="night"] .room--night { opacity: 1; }
.stage-edge { z-index: 5; border: 1px solid var(--edge); border-radius: inherit; pointer-events: none; transition: border-color var(--duration); }
.light-label, .scene-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 40px;
  background: var(--glass);
  color: var(--ink);
  box-shadow: 0 3px 10px -6px var(--shadow);
  transition: background var(--duration), border-color var(--duration), color var(--duration);
}
.light-label { position: absolute; z-index: 3; top: clamp(15px, 2.3vw, 28px); left: clamp(15px, 2.3vw, 28px); padding: 7px 13px; font-size: .81rem; pointer-events: none; }
.light-label .icon, .scene-hint .icon { width: 16px; height: 16px; color: var(--accent); }
.scene-hint {
  position: absolute;
  z-index: 4;
  bottom: clamp(11px, 2.3vh, 23px);
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 15px 8px;
  white-space: nowrap;
  font-size: .875rem;
}
.scene-hint:hover { background: var(--paper); }
.scene-hint:active { transform: translateX(-50%) scale(.98); }
.scene-message {
  position: absolute;
  z-index: 4;
  top: 23px;
  right: 26px;
  margin: 0;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--glass);
  color: var(--ink);
  font-size: .875rem;
}
.contact-shadow {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--contact) 8%, transparent 71%);
  opacity: .54;
  filter: blur(4px);
  pointer-events: none;
  transition: background var(--duration), opacity var(--duration);
}
[data-theme="night"] .contact-shadow { opacity: .75; }
#cat { z-index: 2; pointer-events: none; transition: filter var(--duration) ease-in-out; }
[data-theme="night"] #cat { filter: brightness(.76) saturate(.74) sepia(.06) hue-rotate(-9deg); }
.interaction-layer { z-index: 3; pointer-events: none; transition: filter var(--duration); }
[data-theme="night"] .interaction-layer { filter: brightness(.79) saturate(.76); }
.interaction-layer img, .interaction-layer canvas { position: absolute; left: 0; top: 0; object-fit: contain; will-change: transform; }
[data-theme="night"] #fur-fringe { filter: brightness(.97) saturate(.97); }
#held-food, #offered-food { width: clamp(35px, 6vh, 65px); height: clamp(31px, 5vh, 53px); filter: drop-shadow(1px 3px 3px #542b1454); }
.stage[data-cursor="petting"] { cursor: none; }
.night-only, [data-theme="night"] .day-only { display: none; }
[data-theme="night"] .night-only { display: inline; }

.toolbar {
  position: relative;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 20px;
  padding: 0 clamp(0px, 1vw, 16px);
  color: var(--ink);
}
.pet-picker { display: flex; align-items: center; gap: 10px; justify-self: start; }
.pet {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 30px;
  background: transparent;
  padding: 0;
  text-align: left;
}
.pet-portrait {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(46px, 7vh, 61px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--accent);
  padding: 3px;
  transition: transform .2s, border-color var(--duration);
}
.pet:hover .pet-portrait { transform: translateY(-2px); }
.pet:active .pet-portrait { transform: scale(.96); }
.pet-portrait img { width: 100%; height: 100%; min-width: 0; border-radius: 50%; background: #edccaa; }
.pet-check {
  position: absolute;
  display: grid;
  place-items: center;
  right: -3px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--page);
  background: var(--accent);
  color: var(--page);
}
.pet-check .icon { width: 10px; height: 10px; stroke-width: 2.5; }
.pet:not([aria-pressed="true"]) .pet-check { display: none; }
.pet-name { display: block; font-size: .95rem; font-weight: 650; }
.pet-detail { display: block; font-size: .77rem; color: var(--muted); }
.credit { justify-self: center; text-align: center; }
.credit h1 {
  margin: 0 0 4px;
  font: 400 italic clamp(31px, 4.65vh, 51px)/.98 Georgia, serif;
  letter-spacing: -.067em;
  white-space: nowrap;
}
.credit h1 span { color: var(--accent); }
.socials { display: flex; justify-content: center; align-items: center; gap: 11px; }
.socials a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: .77rem;
  line-height: 1.5;
  white-space: nowrap;
  transition: color .2s;
}
.socials .icon { width: 13px; height: 13px; }
.socials a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.social-divider { width: 1px; height: 11px; background: var(--line); }
.controls { justify-self: end; display: flex; align-items: center; gap: clamp(6px, .8vw, 12px); }
.control {
  width: clamp(42px, 6.3vh, 55px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--button);
  box-shadow: 0 3px 9px -7px var(--shadow);
  padding: 0;
  transition: transform .2s ease, background .25s ease, border-color .25s ease, box-shadow .2s ease;
}
.control:hover, .control[aria-expanded="true"] { background: var(--button-hover); border-color: var(--edge); }
.control:hover { transform: translateY(-2px); box-shadow: 0 6px 10px -7px var(--shadow); }
.control:active { transform: scale(.94); }
.control--food img { width: 76%; height: 76%; object-fit: contain; filter: drop-shadow(1px 2px 1px #613b372b); }
.food-control { position: relative; }
.food-menu {
  position: absolute;
  bottom: calc(100% + 13px);
  right: -2px;
  min-width: 242px;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 12px;
  background: var(--paper);
  box-shadow: 0 9px 34px -12px var(--shadow);
  animation: open-menu .18s ease-out;
}
@keyframes open-menu { from { opacity: 0; transform: translateY(5px); } }
.food-menu p { margin: 0 2px 9px; font-size: .875rem; font-weight: 650; }
.food-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.food-option { position: relative; display: grid; justify-items: center; grid-template-rows: 36px auto; gap: 4px; border: 1px solid var(--line); background: var(--button); border-radius: 10px; padding: 5px 7px; font-size: .8rem; }
.food-option:hover, .food-option[aria-pressed="true"] { background: var(--button-hover); border-color: var(--accent); }
.food-option img { width: 49px; height: 35px; object-fit: contain; }
.food-option[aria-disabled="true"] { cursor: help; color: var(--muted); }
.food-option[aria-disabled="true"] img { opacity: .49; filter: saturate(.62); }
.food-lock { position: absolute; inset: 3px 3px auto auto; background: var(--paper); border-radius: 50%; display: grid; place-items: center; width: 17px; height: 17px; }
.food-lock .icon { width: 11px; height: 11px; }
.food-option.new-item { animation: item-unlock 1.4s ease-out both; }
@keyframes item-unlock {
  0%, 35% { box-shadow: 0 0 0 2px var(--accent); transform: translateY(-2px); }
  100% { box-shadow: none; transform: none; }
}

.debug-canvas { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; pointer-events: none; }
.debug-info { position: absolute; left: 14px; bottom: 14px; z-index: 5; margin: 0; color: #fff; background: #1e1621eb; padding: 10px; border-radius: 7px; font: 12px/1.4 monospace; pointer-events: none; }

.app:fullscreen { display: block; padding: 0; background: var(--page); }
.app:fullscreen .stage { width: 100%; height: 100%; border-radius: 0; }
.app:fullscreen .stage-edge { display: none; }
.app:fullscreen .toolbar {
  position: absolute;
  inset: 15px clamp(16px, 3vw, 48px) auto;
  min-height: 59px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  animation: open-menu .28s ease-out;
}
.app:fullscreen .pet-portrait { width: 42px; }
.app:fullscreen .credit h1 { font-size: 30px; margin-bottom: 1px; }
.app:fullscreen .control { width: 38px; border-radius: 11px; }
.app:fullscreen .control .icon { width: 19px; height: 19px; }
.app:fullscreen .food-menu { bottom: auto; top: calc(100% + 11px); }
.app:fullscreen .light-label, .app:fullscreen .scene-message { top: 87px; }

@media (max-height: 550px) {
  .app { grid-template-rows: minmax(0, 1fr) 67px; padding-top: 12px; }
  .scene-hint { bottom: 6px; padding-block: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --duration: .01s; }
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
