:root {
  --bg: #f3efe6;
  --ink: #2b2b28;
  --muted: #777166;
  --line: #ded3bd;
  --wood: #c99558;
  --wood-dark: #8a5a33;
  --green: #9ebd8d;
  --blue: #7ea1b4;
  --orange: #f2b15d;
  --bear-x: 51%;
  --bear-y: 58%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 24% 10%, rgba(255, 220, 147, 0.38), transparent 28%),
    linear-gradient(180deg, #f6ead7 0%, #d9e4d3 100%);
}

button {
  font: inherit;
}

button {
  border: 0;
  appearance: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid rgba(46, 95, 80, 0.45);
  outline-offset: 4px;
}

.app {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.room-shell {
  border: 1px solid rgba(130, 104, 70, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
  box-shadow: 0 16px 40px rgba(90, 73, 45, 0.12);
}

.room-shell {
  padding: 18px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

h2 {
  font-size: 18px;
}

.clock-card {
  min-width: 116px;
  border: 1px solid #decba6;
  border-radius: 8px;
  background: #fff7de;
  padding: 10px 12px;
  text-align: center;
}

.clock-card span {
  display: block;
  font-size: 26px;
  font-weight: 700;
}

.clock-card small {
  color: var(--muted);
}

.room {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: auto;
  border: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.18), rgba(11, 19, 32, 0.08)),
    url("assets/states/idle.png") center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(63, 39, 22, 0.22);
  isolation: isolate;
}

.room[data-period="night"][data-state="idle"] {
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.1), rgba(11, 19, 32, 0.04)),
    url("assets/states/idle.png") center / cover no-repeat;
}

.room[data-period="night"][data-state="sleep"] {
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.08), rgba(11, 19, 32, 0.04)),
    url("assets/states/sleep.png") center / cover no-repeat;
}

.room[data-period="night"][data-state="eat"] {
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.08), rgba(11, 19, 32, 0.04)),
    url("assets/states/eat.png") center / cover no-repeat;
}

.room[data-period="night"][data-state="exercise"] {
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.08), rgba(11, 19, 32, 0.04)),
    url("assets/states/exercise.png") center / cover no-repeat;
}

.room[data-period="night"][data-state="work"] {
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.08), rgba(11, 19, 32, 0.04)),
    url("assets/states/work.png") center / cover no-repeat;
}

.room[data-period="night"][data-state="tv"] {
  background:
    linear-gradient(180deg, rgba(11, 19, 32, 0.08), rgba(11, 19, 32, 0.04)),
    url("assets/states/tv.png") center / cover no-repeat;
}

.room[data-period="day"][data-state="idle"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 228, 0.12), rgba(255, 252, 228, 0.04)),
    url("assets/states/day/idle.png") center / cover no-repeat;
}

.room[data-period="day"][data-state="sleep"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 228, 0.12), rgba(255, 252, 228, 0.04)),
    url("assets/states/day/sleep.png") center / cover no-repeat;
}

.room[data-period="day"][data-state="eat"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 228, 0.12), rgba(255, 252, 228, 0.04)),
    url("assets/states/day/eat.png") center / cover no-repeat;
}

.room[data-period="day"][data-state="exercise"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 228, 0.12), rgba(255, 252, 228, 0.04)),
    url("assets/states/day/exercise.png") center / cover no-repeat;
}

.room[data-period="day"][data-state="work"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 228, 0.12), rgba(255, 252, 228, 0.04)),
    url("assets/states/day/work.png") center / cover no-repeat;
}

.room[data-period="day"][data-state="tv"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 228, 0.12), rgba(255, 252, 228, 0.04)),
    url("assets/states/day/tv.png") center / cover no-repeat;
}

.room.is-switching {
  animation: stateSwitch 0.42s ease;
}

.room-button {
  display: block;
  color: inherit;
  transition: filter 0.2s ease;
}

.room-button:hover,
.room-button:focus-visible {
  outline: 0;
  filter: brightness(1.05) saturate(1.04);
}

.click-flash {
  position: absolute;
  left: var(--flash-x);
  top: var(--flash-y);
  width: clamp(64px, 8vw, 110px);
  height: clamp(64px, 8vw, 110px);
  border-radius: 50%;
  pointer-events: none;
  z-index: 44;
  transform: translate(-50%, -50%) scale(0.3);
  background: radial-gradient(circle, rgba(255, 245, 185, 0.86) 0 16%, rgba(255, 219, 105, 0.42) 38%, transparent 72%);
  mix-blend-mode: screen;
  animation: clickFlash 0.62s ease-out forwards;
}

.room::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 40% 27%, rgba(255, 199, 96, 0.18), transparent 13%),
    radial-gradient(circle at 88% 33%, rgba(255, 206, 110, 0.18), transparent 18%);
  z-index: 28;
}

.room[data-period="night"]::after {
  background:
    radial-gradient(circle at 38% 26%, rgba(255, 197, 97, 0.2), transparent 15%),
    radial-gradient(circle at 88% 34%, rgba(255, 204, 107, 0.2), transparent 18%),
    linear-gradient(180deg, rgba(8, 15, 34, 0.02), rgba(8, 15, 34, 0.1));
}

.room[data-period="day"]::after {
  background:
    radial-gradient(circle at 20% 19%, rgba(255, 246, 176, 0.18), transparent 20%),
    linear-gradient(180deg, rgba(255, 252, 228, 0.08), rgba(255, 252, 228, 0));
}

.back-wall,
.side-wall,
.floor {
  display: none;
}

.back-wall {
  left: 16%;
  top: 6%;
  width: 70%;
  height: 22%;
  transform: skewX(-18deg);
  background: #f4e7ce;
  border: 1px solid #dbc6a4;
}

.side-wall {
  left: 8%;
  top: 13%;
  width: 16%;
  height: 54%;
  transform: skewY(-18deg);
  background: #ead8ba;
  border: 1px solid #dbc6a4;
}

.floor {
  left: 10%;
  top: 27%;
  width: 78%;
  height: 62%;
  transform: skewX(-18deg) rotate(0deg);
  background:
    repeating-linear-gradient(90deg, rgba(122, 82, 43, 0.08) 0 2px, transparent 2px 54px),
    linear-gradient(135deg, #d9a56b, #bf7f43);
  border: 2px solid #9b6639;
  box-shadow: inset 0 0 0 8px rgba(255, 239, 208, 0.16);
}

.furniture {
  position: absolute;
  z-index: 18;
}

.window {
  display: none;
}

.window span {
  position: absolute;
  left: 46%;
  top: 0;
  width: 4px;
  height: 100%;
  background: #caa66d;
}

.wardrobe {
  display: none;
}

.wardrobe::before,
.wardrobe::after {
  content: "";
  position: absolute;
  top: 46%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e7c075;
}

.wardrobe::before {
  left: 42%;
}

.wardrobe::after {
  right: 42%;
}

.bed {
  left: 9.4%;
  top: 32.4%;
  width: 26%;
  height: 22%;
  transform: rotate(0deg);
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}

.pillow {
  display: none;
}

.blanket {
  display: none;
}

.blanket-flap {
  position: absolute;
  left: 44%;
  top: 45%;
  width: 38%;
  height: 42%;
  border-radius: 14px 4px 18px 5px;
  background: transparent;
  opacity: 0;
  transform-origin: left top;
  box-shadow: 0 10px 24px rgba(21, 22, 48, 0.28);
}

.room.enter-sleep .blanket-flap,
.room.active-sleep .blanket-flap {
  opacity: 0;
  animation: blanketLift 1.3s ease-in-out infinite alternate;
}

.desk {
  left: 37%;
  top: 24%;
  width: 18%;
  height: 15%;
  transform: none;
  background: transparent;
  box-shadow: none;
}

.laptop {
  position: absolute;
  left: 38%;
  top: 24%;
  width: 23%;
  height: 30%;
  border-radius: 4px;
  background: rgba(24, 31, 36, 0.6);
  opacity: 0;
  transform: skewX(-10deg);
}

.laptop span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, #84d5ec, #d7f5f2);
  opacity: 0;
}

.room.enter-work .laptop span,
.room.active-work .laptop span {
  opacity: 0;
  box-shadow: 0 0 18px rgba(118, 218, 232, 0.7);
}

.room.enter-work .laptop,
.room.active-work .laptop {
  opacity: 0;
}

.keyboard-sparks {
  position: absolute;
  left: 44%;
  top: 8%;
  color: #e8fbff;
  text-shadow: 0 0 8px rgba(113, 221, 242, 0.9);
  opacity: 0;
  animation: floatMarks 1.2s ease-in-out infinite;
}

.room.active-work .keyboard-sparks {
  opacity: 0;
}

.desk-chair {
  left: 43.5%;
  top: 37%;
  width: 7%;
  height: 8%;
  border-radius: 7px;
  background: rgba(91, 121, 84, 0.72);
  transition: transform 0.5s ease;
  opacity: 0;
}

.room.enter-work .desk-chair,
.room.active-work .desk-chair {
  transform: translate(12px, 16px);
  opacity: 0;
}

.dining-table {
  left: 28%;
  top: 73%;
  width: 24%;
  height: 22%;
  transform: skewX(-8deg);
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  z-index: 30;
}

.plate {
  position: absolute;
  left: 42%;
  top: 20%;
  width: 28%;
  height: 25%;
  border-radius: 50%;
  background: #fff4dc;
  opacity: 0;
  box-shadow: inset 0 0 0 6px #c88542, 0 7px 14px rgba(61, 37, 18, 0.22);
}

.steam {
  position: absolute;
  left: 43%;
  top: -9%;
  display: flex;
  gap: 8px;
  opacity: 0;
}

.steam span {
  width: 5px;
  height: 18px;
  border-radius: 50%;
  border-left: 2px solid rgba(255, 247, 222, 0.9);
  animation: steamRise 1.4s ease-in-out infinite;
}

.steam span + span {
  animation-delay: 0.4s;
}

.room.enter-eat .plate,
.room.active-eat .plate,
.room.enter-eat .steam,
.room.active-eat .steam {
  opacity: 0;
}

.dining-chair {
  left: 37%;
  top: 79%;
  width: 6%;
  height: 8%;
  border-radius: 7px;
  background: rgba(96, 125, 77, 0.72);
  transition: transform 0.5s ease;
  opacity: 0;
}

.room.enter-eat .dining-chair,
.room.active-eat .dining-chair {
  transform: translate(10px, 16px);
  opacity: 0;
}

.tv {
  left: 73.1%;
  top: 34.2%;
  width: 15.4%;
  height: 13.2%;
  border-radius: 5px;
  background: transparent;
  border: 0;
}

.tv::after {
  display: none;
}

.tv-screen {
  overflow: hidden;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: transparent;
}

.tv-screen span {
  display: block;
  width: 170%;
  height: 100%;
  opacity: 0;
  background: linear-gradient(90deg, #5bb5d1, #f4d172, #de7a86, #5679c9);
}

.room.enter-tv .tv-screen span,
.room.active-tv .tv-screen span {
  opacity: 0;
  animation: tvPan 2.8s linear infinite;
}

.room.enter-tv .tv,
.room.active-tv .tv {
  box-shadow: none;
}

.sofa {
  display: none;
}

.sofa::before,
.sofa::after {
  content: "";
  position: absolute;
  top: 18%;
  width: 20%;
  height: 64%;
  border-radius: 12px;
  background: #7495a3;
}

.sofa::before {
  left: -6%;
}

.sofa::after {
  right: -6%;
}

.rug {
  left: 15%;
  top: 68%;
  width: 20%;
  height: 14%;
  transform: rotate(-8deg);
  border-radius: 14px;
  background: transparent;
  opacity: 1;
  z-index: 20;
}

.exercise-mat {
  left: 12%;
  top: 65%;
  width: 23%;
  height: 18%;
  transform: rotate(-8deg);
  border-radius: 14px;
  background: transparent;
  z-index: 26;
}

.dumbbell-rack {
  left: 18%;
  top: 78%;
  display: flex;
  gap: 8px;
  align-items: center;
  opacity: 0;
}

.dumbbell-rack span,
.rug-dumbbell {
  width: 32px;
  height: 9px;
  border-radius: 6px;
  background: #4f5357;
  box-shadow: -8px 0 0 #383c3f, 8px 0 0 #383c3f;
}

.rug-dumbbell {
  position: absolute;
  opacity: 0;
  transition: transform 0.55s ease, opacity 0.35s ease;
}

.rug-dumbbell-a {
  left: 33%;
  top: 40%;
}

.rug-dumbbell-b {
  left: 51%;
  top: 54%;
  transform: rotate(-12deg);
}

.room.enter-exercise .rug-dumbbell-a,
.room.enter-exercise .rug-dumbbell-b {
  opacity: 0;
  transform: translate(-42px, 18px);
}

.room.active-exercise .rug-dumbbell-a,
.room.active-exercise .rug-dumbbell-b {
  opacity: 0;
}

.floor-lamp {
  display: none;
}

.lamp-glow {
  position: absolute;
  left: 82%;
  top: 40%;
  width: 14%;
  height: 22%;
  border-radius: 50%;
  background: rgba(245, 185, 83, 0.25);
  filter: blur(12px);
  z-index: 8;
  pointer-events: none;
}

.bear {
  display: none;
  position: absolute;
  left: var(--bear-x);
  top: var(--bear-y);
  width: clamp(58px, 6.2vw, 92px);
  height: clamp(70px, 7.4vw, 110px);
  z-index: 34;
  transform: translate(-50%, -72%);
  transition: left 1.4s ease-in-out, top 1.4s ease-in-out;
}

.bear.walking .bear-body {
  animation: walkBob 0.34s ease-in-out infinite alternate;
}

.bear-body {
  position: absolute;
  inset: 0;
  animation: breathe 2.2s ease-in-out infinite;
}

.bear-shadow {
  position: absolute;
  left: 16%;
  bottom: -2%;
  width: 68%;
  height: 16%;
  border-radius: 50%;
  background: rgba(68, 45, 32, 0.18);
}

.ear,
.head,
.torso,
.arm,
.leg {
  position: absolute;
  background: #bf7b3d;
  box-shadow: inset -5px -6px 0 rgba(96, 48, 22, 0.12);
}

.ear {
  top: 3%;
  width: 24%;
  height: 24%;
  border-radius: 50%;
}

.ear-left {
  left: 16%;
}

.ear-right {
  right: 16%;
}

.head {
  left: 14%;
  top: 8%;
  width: 72%;
  height: 56%;
  border-radius: 48% 48% 44% 44%;
  z-index: 3;
  box-shadow: inset -7px -7px 0 rgba(94, 48, 24, 0.14);
}

.eye {
  position: absolute;
  top: 40%;
  width: 8px;
  height: 10px;
  border-radius: 50%;
  background: #2c211a;
  animation: blink 4.8s infinite;
}

.eye-left {
  left: 30%;
}

.eye-right {
  right: 30%;
}

.snout {
  position: absolute;
  left: 33%;
  bottom: 15%;
  width: 34%;
  height: 25%;
  border-radius: 50%;
  background: #e9c79b;
}

.snout::after {
  content: "";
  position: absolute;
  left: 42%;
  top: 28%;
  width: 9px;
  height: 7px;
  border-radius: 50%;
  background: #31231c;
}

.torso {
  left: 24%;
  top: 51%;
  width: 52%;
  height: 40%;
  border-radius: 45% 45% 42% 42%;
  z-index: 2;
  box-shadow: inset -7px -6px 0 rgba(94, 48, 24, 0.13);
}

.arm {
  top: 58%;
  width: 18%;
  height: 28%;
  border-radius: 14px;
  z-index: 1;
}

.arm span {
  display: none;
  position: absolute;
  left: -12px;
  top: 70%;
  width: 34px;
  height: 9px;
  border-radius: 6px;
  background: #4f5357;
  box-shadow: -8px 0 0 #383c3f, 8px 0 0 #383c3f;
}

.arm-left {
  left: 13%;
  transform: rotate(18deg);
}

.arm-right {
  right: 13%;
  transform: rotate(-18deg);
}

.leg {
  bottom: 0;
  width: 18%;
  height: 19%;
  border-radius: 14px;
  z-index: 1;
}

.leg-left {
  left: 30%;
}

.leg-right {
  right: 30%;
}

.sleep-marks {
  position: absolute;
  right: -20px;
  top: -12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #6d8fba;
  font-weight: 800;
  opacity: 0;
  z-index: 5;
}

.sleep-marks span {
  animation: floatMarks 1.8s ease-in-out infinite;
}

.sleep-marks span + span {
  animation-delay: 0.45s;
}

.bear.state-sleep .sleep-marks {
  opacity: 1;
}

.bear.state-sleep {
  transform: translate(-50%, -62%) rotate(-10deg) scale(0.96);
}

.bear.state-eat .arm-left {
  animation: tinyNibble 0.9s ease-in-out infinite;
}

.bear.state-exercise .arm-left,
.bear.state-exercise .arm-right {
  animation: liftDumbbells 0.9s ease-in-out infinite alternate;
}

.bear.state-exercise .arm span {
  display: block;
}

.bear.state-work .arm-left,
.bear.state-work .arm-right {
  animation: typingPaws 0.42s ease-in-out infinite alternate;
}

.bear.state-tv {
  transform: translate(-50%, -68%) scale(0.98);
}

.panel {
  margin-top: 18px;
  border: 1px solid rgba(130, 104, 70, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: 0 14px 34px rgba(90, 73, 45, 0.1);
  padding: 18px;
}

.control-section + .control-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title button,
.schedule-form button,
.item-actions button {
  border: 1px solid #d8ccb5;
  border-radius: 8px;
  background: #fff8e8;
  color: var(--ink);
  padding: 9px 12px;
}

.section-title button:hover,
.schedule-form button:hover,
.item-actions button:hover {
  background: #fff1d1;
}

.time-control,
.schedule-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.time-control input,
.schedule-form input,
.schedule-form select {
  width: 100%;
  border: 1px solid #d8ccb5;
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: 10px 11px;
}

.schedule-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.schedule-form .label-field,
.schedule-form .primary {
  grid-column: span 2;
}

.schedule-form .primary {
  background: #2e5f50;
  color: #fffdf4;
  border-color: #2e5f50;
}

.schedule-form .primary:hover {
  background: #254d42;
}

.schedule-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.schedule-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #dfd1b8;
  border-radius: 8px;
  background: #fffdf7;
  padding: 10px;
}

.schedule-item.active {
  border-color: #91aa7d;
  box-shadow: 0 0 0 2px rgba(145, 170, 125, 0.18);
}

.schedule-item strong {
  display: block;
}

.schedule-item span {
  color: var(--muted);
  font-size: 13px;
}

.item-actions {
  display: flex;
  gap: 6px;
}

.item-actions button {
  padding: 7px 9px;
}

@media (max-width: 1120px) {
  .room {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100vw - 20px, 680px);
    padding: 12px 0;
  }

  .status-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .room {
    aspect-ratio: 16 / 10;
    min-height: 0;
  }

  .bear {
    width: clamp(46px, 10vw, 64px);
    height: clamp(56px, 12vw, 76px);
  }

  .schedule-form {
    grid-template-columns: 1fr;
  }

  .schedule-form .label-field,
  .schedule-form .primary {
    grid-column: auto;
  }
}

@keyframes blanketLift {
  from {
    transform: rotate(-12deg) translateY(2px);
  }
  to {
    transform: rotate(-28deg) translateY(-3px);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes walkBob {
  from {
    transform: translateY(0) rotate(-1deg);
  }
  to {
    transform: translateY(-4px) rotate(1deg);
  }
}

@keyframes blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.12);
  }
}

@keyframes floatMarks {
  from {
    transform: translateY(4px);
    opacity: 0.45;
  }
  to {
    transform: translateY(-8px);
    opacity: 1;
  }
}

@keyframes steamRise {
  from {
    transform: translateY(5px);
    opacity: 0.2;
  }
  to {
    transform: translateY(-8px);
    opacity: 0.9;
  }
}

@keyframes tvPan {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-40%);
  }
}

@keyframes tinyNibble {
  from,
  to {
    transform: rotate(18deg);
  }
  50% {
    transform: rotate(5deg) translateY(-5px);
  }
}

@keyframes liftDumbbells {
  from {
    transform: rotate(24deg) translateY(4px);
  }
  to {
    transform: rotate(-38deg) translateY(-18px);
  }
}

@keyframes typingPaws {
  from {
    transform: rotate(10deg) translateY(0);
  }
  to {
    transform: rotate(-8deg) translateY(3px);
  }
}

@keyframes stateSwitch {
  0% {
    filter: brightness(0.94) saturate(0.96);
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}

@keyframes clickFlash {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.3);
  }
  70% {
    opacity: 0.58;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}
