:root {
  color-scheme: light;
  --ink: #3f3a45;
  --muted: #786f7f;
  --cream: #fffdf1;
  --yellow: #ffe87c;
  --yellow-dark: #e0ad48;
  --pink: #ff9fb5;
  --green: #8fce83;
  --blue: #84cbd4;
  --line: #574e5d;
  --shadow: rgba(84, 62, 64, .18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: #ffeec9;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Pretendard", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(255,255,255,.8) 0 3px, transparent 4px) 0 0 / 38px 38px,
    linear-gradient(145deg, #fff4cc, #ffd8bd 55%, #f5c7c8);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app {
  width: min(1180px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.eyebrow {
  margin: 0 0 3px;
  color: #a16570;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #8f5964;
  font-size: clamp(23px, 4vw, 34px);
  line-height: 1;
}

.top-actions {
  display: flex;
  gap: 8px;
}

button {
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

button:hover {
  filter: brightness(1.03);
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}

.icon-button {
  min-width: 60px;
  padding: 9px 11px;
  font-weight: 900;
}

.game-shell {
  display: grid;
  grid-template-columns: 230px minmax(340px, 1fr) 210px;
  gap: 12px;
  min-height: 570px;
}

.status-panel,
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-panel,
.info-card {
  border: 3px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 241, .94);
  box-shadow: 0 7px 0 var(--shadow);
}

.status-panel {
  padding: 16px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 13px;
  border-bottom: 2px dashed #d6c1ad;
}

.identity strong,
.identity small {
  display: block;
}

.identity strong {
  margin-bottom: 3px;
  font-size: 19px;
}

.identity small,
.info-card p,
.care-actions small,
.toggle-row small {
  color: var(--muted);
  font-size: 11px;
}

.stage-chip {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--yellow);
  font-size: 12px;
  font-weight: 900;
}

.meters {
  display: grid;
  gap: 13px;
  margin-top: 4px;
}

.meter-row {
  display: grid;
  grid-template-columns: 52px 1fr 25px;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 900;
}

.meter-row b {
  text-align: right;
  font-size: 11px;
}

.meter {
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: #eee7dc;
}

.meter i,
.growth-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--pink);
  transition: width .35s ease, background .35s ease;
}

.meter-row:nth-child(2) .meter i { background: var(--yellow-dark); }
.meter-row:nth-child(3) .meter i { background: var(--green); }
.meter-row:nth-child(4) .meter i { background: var(--blue); }

.quick-stats {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding-top: 13px;
  border-top: 2px dashed #d6c1ad;
  font-size: 12px;
}

.quick-stats span {
  display: flex;
  justify-content: space-between;
}

.room {
  position: relative;
  min-height: 570px;
  overflow: hidden;
  border: 4px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(90deg, transparent 48%, rgba(255,255,255,.28) 49% 51%, transparent 52%) 0 0 / 76px 76px,
    linear-gradient(#f8ddb7 0 70%, #d9a875 70% 73%, #b98256 73%);
  box-shadow: 0 9px 0 var(--shadow);
}

.room.night {
  background:
    linear-gradient(90deg, transparent 48%, rgba(255,255,255,.06) 49% 51%, transparent 52%) 0 0 / 76px 76px,
    linear-gradient(#7a7897 0 70%, #6e5d70 70% 73%, #57475d 73%);
}

.room.sick::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(131, 187, 114, .12);
}

.window {
  position: absolute;
  top: 34px;
  left: 35px;
  width: 142px;
  height: 128px;
  overflow: hidden;
  border: 8px solid #fff4da;
  border-bottom-width: 13px;
  border-radius: 68px 68px 10px 10px;
  background: linear-gradient(#82d4e3, #e9f7cc);
  box-shadow: 0 0 0 3px var(--line);
}

.night .window {
  background: linear-gradient(#323858, #68729a);
}

.sky-orb {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: #ffe55f;
  box-shadow: 0 0 16px rgba(255,229,95,.7);
}

.night .sky-orb {
  background: #fff6c5;
  box-shadow: -9px 2px 0 #323858;
}

.cloud {
  position: absolute;
  width: 45px;
  height: 15px;
  border-radius: 99px;
  background: rgba(255,255,255,.85);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: inherit;
}

.cloud::before { left: 8px; width: 21px; height: 21px; }
.cloud::after { right: 6px; width: 27px; height: 27px; }
.cloud.one { top: 70px; left: 6px; }
.cloud.two { top: 99px; right: -15px; transform: scale(.7); }

.shelf {
  position: absolute;
  top: 82px;
  right: 35px;
  width: 130px;
  height: 12px;
  border: 3px solid var(--line);
  border-radius: 5px;
  background: #aa7451;
}

.pot {
  position: absolute;
  left: 12px;
  bottom: 9px;
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-radius: 4px 4px 12px 12px;
  background: #ef9a72;
}

.pot::before,
.pot::after {
  content: "";
  position: absolute;
  bottom: 24px;
  width: 20px;
  height: 31px;
  border: 3px solid var(--line);
  border-radius: 80% 10% 80% 10%;
  background: #77b86d;
}

.pot::before { left: -7px; transform: rotate(-30deg); }
.pot::after { right: -7px; transform: scaleX(-1) rotate(-30deg); }

.books {
  position: absolute;
  right: 12px;
  bottom: 9px;
  width: 13px;
  height: 49px;
  border: 3px solid var(--line);
  background: #f6d761;
  box-shadow: -17px 4px 0 #ef8ca6, -20px 1px 0 var(--line), -34px -2px 0 #83cbd0, -37px -5px 0 var(--line);
}

.rug {
  position: absolute;
  left: 50%;
  bottom: 48px;
  width: min(72%, 460px);
  height: 125px;
  transform: translateX(-50%);
  border: 3px solid var(--line);
  border-radius: 50%;
  background: repeating-linear-gradient(90deg, #f5b5bf 0 22px, #ffe28a 22px 44px);
  box-shadow: inset 0 0 0 8px rgba(255,255,255,.35);
}

.pet-button {
  position: absolute;
  left: 50%;
  bottom: 108px;
  width: 210px;
  height: 220px;
  transform: translateX(-50%);
  border: 0;
  background: transparent;
  box-shadow: none;
  filter: none;
}

.pet-button:hover,
.pet-button:active {
  transform: translateX(-50%);
  box-shadow: none;
}

.pet {
  --body: #fff1a6;
  --accent: #f5a26f;
  position: absolute;
  left: 50%;
  bottom: 23px;
  width: 122px;
  height: 126px;
  transform: translateX(-50%);
  border: 4px solid var(--line);
  border-radius: 48% 48% 42% 42%;
  background: var(--body);
  box-shadow: inset -10px -10px 0 rgba(132, 82, 80, .1);
  animation: idle 2.1s ease-in-out infinite;
  transition: width .4s ease, height .4s ease, border-radius .4s ease, background .4s ease;
}

.pet.egg {
  width: 102px;
  height: 130px;
  border-radius: 50% 50% 46% 46%;
}

.pet.egg .face,
.pet.egg .ear {
  display: none;
}

.pet.baby {
  width: 105px;
  height: 100px;
}

.pet.child {
  width: 125px;
  height: 118px;
}

.pet.teen {
  width: 137px;
  height: 132px;
}

.pet.adult {
  width: 150px;
  height: 145px;
}

.pet.curious { --body: #f9dc79; --accent: #ef8c70; }
.pet.gentle { --body: #aee3c0; --accent: #f8a7ba; }
.pet.playful { --body: #f5a8bf; --accent: #ffe277; }
.pet.calm { --body: #9ed7e1; --accent: #eee3a2; }
.pet.lonely { --body: #bdb7dc; --accent: #8c88b3; }

.ear {
  position: absolute;
  top: -37px;
  width: 48px;
  height: 70px;
  border: 4px solid var(--line);
  border-radius: 70% 20% 55% 30%;
  background: var(--body);
  z-index: -1;
}

.ear.left { left: 4px; transform: rotate(-23deg); }
.ear.right { right: 4px; transform: scaleX(-1) rotate(-23deg); }

.playful .ear {
  top: -25px;
  width: 58px;
  height: 53px;
  border-radius: 50%;
}

.calm .ear {
  top: -15px;
  width: 61px;
  height: 38px;
  border-radius: 50%;
}

.face {
  position: absolute;
  inset: 0;
}

.eye {
  position: absolute;
  top: 42%;
  width: 12px;
  height: 17px;
  border-radius: 50%;
  background: var(--line);
}

.eye::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: white;
}

.eye.left { left: 28%; }
.eye.right { right: 28%; }

.mouth {
  position: absolute;
  top: 61%;
  left: 50%;
  width: 19px;
  height: 10px;
  transform: translateX(-50%);
  border-bottom: 4px solid var(--line);
  border-radius: 50%;
}

.sick .mouth,
.pet.sad .mouth {
  transform: translateX(-50%) rotate(180deg);
}

.pet.sleeping .eye {
  top: 48%;
  height: 7px;
  border-radius: 0;
  background: transparent;
  border-bottom: 4px solid var(--line);
}

.spot {
  position: absolute;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
}

.spot.one { left: 13px; bottom: 22px; width: 25px; height: 20px; transform: rotate(24deg); }
.spot.two { right: 9px; top: 18px; width: 20px; height: 25px; transform: rotate(-18deg); }

.shadow {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 125px;
  height: 25px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(83, 59, 59, .22);
}

.pet-button.pet-animate .pet {
  animation: celebrate .55s ease;
}

.poop {
  position: absolute;
  right: 23%;
  bottom: 105px;
  display: none;
  color: #714b39;
  font-size: 40px;
  transform: rotate(45deg);
  text-shadow: 2px 2px 0 var(--line);
}

.poop.show {
  display: block;
  animation: pop .3s ease;
}

.speech {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 340px;
  max-width: 230px;
  padding: 10px 13px;
  transform: translateX(-50%);
  border: 3px solid var(--line);
  border-radius: 16px;
  background: white;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 4px 0 var(--shadow);
}

.speech::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 15px;
  height: 15px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 3px solid var(--line);
  border-bottom: 3px solid var(--line);
  background: white;
}

.hidden {
  display: none !important;
}

.room-message {
  position: absolute;
  left: 50%;
  bottom: 21px;
  width: min(90%, 460px);
  transform: translateX(-50%);
  padding: 9px 13px;
  border: 2px solid rgba(87,78,93,.7);
  border-radius: 99px;
  background: rgba(255,253,241,.87);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  backdrop-filter: blur(5px);
}

.event-toast {
  position: absolute;
  z-index: 8;
  top: 18px;
  left: 50%;
  padding: 10px 14px;
  transform: translate(-50%, -20px);
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.event-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.info-card {
  padding: 16px;
}

.info-card span,
.info-card strong {
  display: block;
}

.info-card span {
  margin-bottom: 6px;
  color: #a16570;
  font-size: 11px;
  font-weight: 900;
}

.info-card strong {
  margin-bottom: 5px;
  font-size: 17px;
}

.info-card p {
  margin-bottom: 0;
  line-height: 1.5;
}

.next-card {
  margin-top: auto;
}

.growth-track {
  height: 12px;
  overflow: hidden;
  margin-top: 12px;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: #eee7dc;
}

.growth-track i {
  width: 0;
  background: var(--green);
}

.care-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 9px;
  margin-top: 13px;
}

.care-actions button {
  min-height: 86px;
  padding: 8px 5px;
}

.care-actions span,
.care-actions b,
.care-actions small {
  display: block;
}

.care-actions span {
  margin-bottom: 2px;
  font-size: 24px;
}

.care-actions b {
  margin-bottom: 2px;
  font-size: 13px;
}

.care-actions button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: .5;
}

.modal {
  width: min(440px, calc(100% - 24px));
  max-height: 86dvh;
  overflow: auto;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 0 9px 0 rgba(63,58,69,.28);
}

.modal::backdrop {
  background: rgba(61, 47, 63, .56);
  backdrop-filter: blur(4px);
}

.modal h2 {
  margin-bottom: 8px;
  color: #8f5964;
}

.modal p {
  color: var(--muted);
  line-height: 1.55;
}

.modal label {
  display: grid;
  gap: 7px;
  margin: 17px 0;
  font-size: 13px;
  font-weight: 900;
}

.modal input,
.modal select {
  width: 100%;
  padding: 11px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: white;
}

.modal-mascot {
  margin-bottom: 5px;
  font-size: 48px;
  text-align: center;
}

.primary,
.secondary,
.danger {
  width: 100%;
  padding: 12px;
  font-weight: 900;
}

.primary { background: var(--yellow); }
.secondary { background: #c7e6e3; }
.danger { background: #ffd1d8; }

.wide {
  width: min(680px, calc(100% - 24px));
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.close-button {
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
}

.collection {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin: 15px 0;
}

.collection span {
  padding: 10px 4px;
  border: 2px solid #d6c1ad;
  border-radius: 11px;
  color: #a79ca5;
  background: #f0eae0;
  font-size: 11px;
  text-align: center;
}

.collection span.found {
  border-color: var(--line);
  color: var(--ink);
  background: var(--yellow);
  font-weight: 900;
}

.journal-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.journal-list li {
  padding: 11px;
  border: 2px solid #d6c1ad;
  border-radius: 12px;
  background: white;
  font-size: 12px;
}

.journal-list time {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.toggle-row {
  grid-template-columns: 1fr auto !important;
  align-items: center;
}

.toggle-row span,
.toggle-row b,
.toggle-row small {
  display: block;
}

.toggle-row input {
  width: 22px;
  height: 22px;
}

.game-modal {
  width: min(590px, calc(100% - 18px));
}

#miniGame {
  display: block;
  width: 100%;
  aspect-ratio: 13 / 9;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #8ed4db;
  touch-action: none;
}

.game-score,
.game-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.game-score {
  font-size: 13px;
}

.game-controls button {
  flex: 1;
  padding: 11px;
  font-weight: 900;
}

@keyframes idle {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1deg); }
  50% { transform: translateX(-50%) translateY(-8px) rotate(1deg); }
}

@keyframes celebrate {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  40% { transform: translateX(-50%) translateY(-28px) scale(1.08) rotate(5deg); }
  70% { transform: translateX(-50%) translateY(-5px) scale(.96) rotate(-4deg); }
}

@keyframes pop {
  from { transform: rotate(45deg) scale(0); }
  to { transform: rotate(45deg) scale(1); }
}

@media (max-width: 900px) {
  .game-shell {
    grid-template-columns: 190px 1fr;
  }

  .info-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .next-card {
    margin-top: 0;
  }
}

@media (max-width: 650px) {
  .app {
    padding-inline: 9px;
  }

  .topbar {
    margin-bottom: 8px;
  }

  .game-shell {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .room {
    order: -1;
    min-height: 58dvh;
  }

  .status-panel {
    padding: 11px;
  }

  .meters {
    grid-template-columns: 1fr 1fr;
    gap: 8px 13px;
  }

  .identity {
    padding-bottom: 9px;
  }

  .quick-stats {
    grid-template-columns: 1fr 1fr;
    margin-top: 7px;
    padding-top: 9px;
  }

  .info-panel {
    display: none;
  }

  .care-actions {
    position: sticky;
    bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 10;
    grid-template-columns: repeat(3, 1fr);
    padding: 7px;
    border: 3px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 253, 241, .94);
    box-shadow: 0 5px 0 var(--shadow);
    backdrop-filter: blur(8px);
  }

  .care-actions button {
    min-height: 64px;
  }

  .care-actions span {
    display: inline;
    margin-right: 4px;
    font-size: 18px;
  }

  .care-actions b {
    display: inline;
  }

  .care-actions small {
    margin-top: 2px;
    font-size: 9px;
  }

  .window {
    top: 28px;
    left: 25px;
    transform: scale(.8);
    transform-origin: top left;
  }

  .shelf {
    top: 77px;
    right: 28px;
    transform: scale(.8);
    transform-origin: top right;
  }

  .collection {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-height: 700px) and (max-width: 650px) {
  .room { min-height: 430px; }
}
