:root {
  color-scheme: light;
  --ink: #554b5e;
  --muted: #8c8194;
  --cream: #fffaf6;
  --pink: #f49aa7;
  --yellow: #f8cf6b;
  --mint: #79cdb5;
  --purple: #aaa0df;
  --shadow: 0 16px 42px rgba(104, 82, 104, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 9%, rgba(255, 215, 221, 0.55) 0 4%, transparent 12%),
    radial-gradient(circle at 88% 23%, rgba(205, 236, 224, 0.6) 0 5%, transparent 14%),
    #fff9f3;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { touch-action: manipulation; }

.app {
  width: min(100% - 28px, 580px);
  margin: 0 auto;
  padding: 30px 0 40px;
}

.app-header { text-align: center; margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; color: #b09aaa; font: 700 0.65rem/1.2 Arial, sans-serif; letter-spacing: 0.24em; }
h1 { margin: 0; color: #5c5265; font-size: clamp(1.8rem, 8vw, 2.5rem); letter-spacing: 0.04em; }
.subtitle { margin: 5px 0 0; color: var(--muted); font-size: 0.82rem; }
.coin-badge { width: fit-content; margin: 11px auto 0; padding: 7px 13px; border-radius: 99px; color: #756274; background: rgba(255,255,255,.78); box-shadow: 0 5px 16px rgba(104,82,104,.08); font-size: .72rem; }
.coin-badge strong { color: #c58b2f; font-size: .88rem; font-variant-numeric: tabular-nums; }

.pet-card, .status-card {
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.pet-card {
  position: relative;
  overflow: hidden;
  min-height: 400px;
  padding: 22px 24px 18px;
  border-radius: 32px;
  background: linear-gradient(160deg, #fffdfb 0%, #fff2e7 100%);
}
.pet-card.room-theme-mint { background: linear-gradient(160deg, #fbfffc 0%, #dcf4e8 100%); }
.pet-card.room-theme-night { background: radial-gradient(circle at 18% 32%, rgba(255,255,255,.8) 0 2px, transparent 3px), radial-gradient(circle at 82% 25%, rgba(255,238,160,.8) 0 2px, transparent 3px), linear-gradient(160deg, #7772a9 0%, #b9afd8 100%); }
.room-theme-night .cloud { opacity: .32; }
.room-theme-night .pet-name-display { color: white; text-shadow: 0 2px 7px rgba(57,48,89,.25); }
.room-theme-night .name-form label { color: #f4efff; }

.name-form { position: relative; z-index: 3; display: flex; align-items: center; gap: 10px; }
.name-form label { color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.name-row { display: flex; flex: 1; gap: 7px; }
.name-row input {
  width: 100%; min-width: 0; padding: 9px 12px; border: 1.5px solid #eadfe2; border-radius: 12px;
  outline: none; color: var(--ink); background: rgba(255,255,255,.85); font-weight: 700;
}
.name-row input:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(244,154,167,.16); }
.name-button { border: 0; border-radius: 12px; padding: 0 14px; color: white; background: #9287bb; font-size: .78rem; font-weight: 800; cursor: pointer; }

.speech {
  position: relative; z-index: 3; width: fit-content; max-width: 80%; min-height: 42px; margin: 18px auto 0;
  padding: 11px 18px; border-radius: 18px; background: white; box-shadow: 0 6px 20px rgba(106,78,84,.09);
  text-align: center; font-size: .88rem; font-weight: 700;
}
.speech::after { content: ""; position: absolute; bottom: -8px; left: calc(50% - 8px); border: 8px solid transparent; border-top-color: white; border-bottom: 0; }

.pet-stage { position: relative; z-index: 2; height: 215px; display: grid; place-items: center; }
.pet-shadow { position: absolute; bottom: 21px; width: 142px; height: 25px; border-radius: 50%; background: rgba(132,102,97,.13); filter: blur(2px); }
.pet { position: relative; width: 170px; height: 165px; transform-origin: 50% 100%; animation: breathe 2.6s ease-in-out infinite; }
.pet-body {
  position: absolute; z-index: 2; left: 14px; top: 25px; width: 142px; height: 137px;
  border: 2px solid #eee6df; border-radius: 48% 48% 43% 43%; background: linear-gradient(145deg, #fff, #f6f1ec);
  box-shadow: inset -8px -10px 0 rgba(187,170,157,.06), 0 10px 20px rgba(132,112,103,.14);
}
.pet-accessory { display: none; position: absolute; z-index: 7; pointer-events: none; }
.pet.accessory-ribbon .pet-accessory { display: block; top: -12px; right: 4px; width: 34px; height: 24px; border-radius: 50% 8px 8px 50%; background: #ef8ca0; transform: rotate(13deg); box-shadow: 16px 0 0 #ef8ca0; }
.pet.accessory-ribbon .pet-accessory::after { content: ""; position: absolute; left: 12px; top: 7px; width: 12px; height: 12px; border-radius: 50%; background: #f8bcc7; }
.pet.accessory-crown .pet-accessory { display: block; top: -21px; left: 42px; width: 57px; height: 39px; background: #f2c34c; clip-path: polygon(0 18%, 25% 52%, 50% 0, 75% 52%, 100% 18%, 88% 100%, 12% 100%); filter: drop-shadow(0 4px 3px rgba(104,75,37,.18)); }
.pet-ear { position: absolute; z-index: 3; top: 24px; width: 55px; height: 88px; background: linear-gradient(160deg, #e8d7c8, #cdb29f); box-shadow: 0 5px 10px rgba(116,91,80,.1); }
.pet-ear::after { content: ""; position: absolute; inset: 15px 13px 17px; border-radius: 50%; background: #dfb8ad; opacity: .48; }
.pet-ear-left { left: 0; border-radius: 65% 35% 62% 48%; transform: rotate(15deg); }
.pet-ear-right { right: 0; border-radius: 35% 65% 48% 62%; transform: rotate(-15deg); }
.pet-eyes { position: absolute; top: 55px; left: 31px; display: flex; gap: 43px; }
.pet-eyes span { width: 13px; height: 17px; border-radius: 50%; background: #57434b; box-shadow: inset 3px 2px 0 rgba(255,255,255,.68); transition: .2s; }
.pet-muzzle { position: absolute; left: 48px; top: 75px; width: 46px; height: 34px; border-radius: 50%; background: #eee6dc; }
.pet-nose { position: absolute; z-index: 2; left: 63px; top: 78px; width: 16px; height: 12px; border-radius: 55% 55% 48% 48%; background: #51444a; box-shadow: inset 3px 2px 0 rgba(255,255,255,.25); }
.pet-mouth { position: absolute; z-index: 2; left: 64px; top: 91px; width: 14px; height: 9px; border-bottom: 3px solid #7c555b; border-radius: 0 0 50% 50%; transition: .2s; }
.pet-collar { display: none; position: absolute; z-index: 3; left: 28px; bottom: 16px; width: 86px; height: 12px; border-radius: 99px; background: #8bcbb8; box-shadow: 0 3px 0 rgba(72,126,111,.15); }
.pet-collar::after { content: ""; position: absolute; left: 37px; top: 7px; width: 13px; height: 13px; border-radius: 50%; background: #f4cc5c; box-shadow: inset 2px 2px 0 rgba(255,255,255,.45); }
.pet-blush { position: absolute; top: 82px; width: 24px; height: 11px; border-radius: 50%; background: #f3999c; opacity: .5; }
.pet-blush-left { left: 16px; } .pet-blush-right { right: 16px; }
.pet-paw { position: absolute; bottom: -5px; width: 48px; height: 31px; border: 1px solid #eee5de; border-radius: 50%; background: #faf6f2; }
.pet-paw-left { left: 10px; transform: rotate(-7deg); } .pet-paw-right { right: 10px; transform: rotate(7deg); }
.pet-name-display { position: relative; z-index: 2; margin: -2px 0 0; text-align: center; font-size: 1.35rem; font-weight: 900; }
.pet-tags { position: relative; z-index: 2; display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.pet-mood, .pet-stage-label { width: fit-content; margin: 0; padding: 4px 12px; border-radius: 99px; font-size: .72rem; font-weight: 800; }
.pet-mood { color: #8d7384; background: #f8e4e2; }
.pet-stage-label { color: #668e83; background: #e1f3ed; }
.pet.stage-1 .pet-collar, .pet.stage-2 .pet-collar { display: block; }
.pet.stage-2 .pet-collar { background: #9c92d2; }
.pet.stage-2 .pet-collar::after { width: 16px; height: 16px; left: 35px; background: #f1be3f; }
.pet.stage-2 .pet-body { box-shadow: inset -8px -10px 0 rgba(187,170,157,.06), 0 10px 25px rgba(132,112,103,.18), 0 0 0 5px rgba(255,255,255,.32); }

.cloud { position: absolute; width: 74px; height: 24px; border-radius: 30px; background: rgba(255,255,255,.72); }
.cloud::before, .cloud::after { content: ""; position: absolute; bottom: 6px; border-radius: 50%; background: inherit; }
.cloud::before { left: 12px; width: 27px; height: 27px; } .cloud::after { right: 10px; width: 34px; height: 34px; }
.cloud-one { left: -12px; top: 105px; } .cloud-two { right: -18px; top: 160px; transform: scale(.75); }
.sparkle { position: absolute; color: #efc96b; opacity: .75; animation: twinkle 1.8s ease-in-out infinite alternate; }
.sparkle-one { top: 133px; left: 20%; } .sparkle-two { right: 17%; top: 110px; animation-delay: .5s; }

.daily-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; margin-top: 14px; padding: 15px 17px; border: 1px solid rgba(255,255,255,.9); border-radius: 21px; background: linear-gradient(120deg, #fff0c8, #ffe5d9); box-shadow: 0 8px 24px rgba(104,82,104,.09); }
.daily-icon { display: grid; place-items: center; width: 41px; height: 41px; border-radius: 14px; background: rgba(255,255,255,.65); font-size: 1.35rem; }
.daily-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.daily-copy strong { font-size: .79rem; }
.daily-copy span { overflow: hidden; color: #938080; font-size: .67rem; white-space: nowrap; text-overflow: ellipsis; }
.streak-badge { padding: 6px 9px; border-radius: 99px; color: white; background: #e89a82; font-size: .68rem; font-weight: 900; white-space: nowrap; }
.daily-card.claimed { animation: bonus-glow .7s ease 2; }
.status-card { margin-top: 14px; padding: 20px 22px; border-radius: 24px; background: rgba(255,255,255,.82); }
.status-row + .status-row { margin-top: 16px; }
.status-label { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 5px; margin-bottom: 7px; font-size: .8rem; font-weight: 800; }
.status-label strong { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.gauge { overflow: hidden; height: 11px; border-radius: 99px; background: #eee9e7; }
.gauge-fill { width: 0; height: 100%; border-radius: inherit; transition: width .45s ease; }
.gauge-hunger { background: linear-gradient(90deg, #ef8f9d, #f7b0b7); }
.gauge-energy { background: linear-gradient(90deg, #e8b942, #f7d879); }
.gauge-affection { background: linear-gradient(90deg, #79cbb1, #a1dfcb); }
.gauge-growth { background: linear-gradient(90deg, #9288d0, #c2baf0); }
.growth-row { padding-top: 15px; border-top: 1px dashed #e9e0e0; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.action-button {
  min-height: 104px; border: 0; border-radius: 22px; padding: 12px 6px; color: var(--ink); box-shadow: 0 8px 20px rgba(98,75,93,.1);
  font-weight: 900; cursor: pointer; transition: transform .15s, filter .15s; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.action-button:hover { transform: translateY(-2px); filter: brightness(1.025); }
.action-button:active { transform: translateY(1px) scale(.98); }
.action-button:focus-visible, .reset-button:focus-visible, .name-button:focus-visible { outline: 3px solid rgba(128,109,180,.35); outline-offset: 2px; }
.action-button small { margin-top: 3px; color: rgba(78,65,82,.58); font-size: .62rem; }
.action-icon { display: block; margin-bottom: 4px; font-size: 1.75rem; line-height: 1; }
.food-button { background: #ffdfe3; } .play-button { background: #fff0bd; } .sleep-button { background: #dcd8f7; }
.feature-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.feature-button { min-height: 72px; border: 0; border-radius: 19px; padding: 11px 14px; color: var(--ink); background: white; box-shadow: 0 8px 20px rgba(98,75,93,.09); cursor: pointer; display: flex; align-items: center; gap: 10px; text-align: left; transition: transform .15s; }
.feature-button:hover { transform: translateY(-2px); }
.feature-button > span:first-child { font-size: 1.65rem; }
.feature-button > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.feature-button strong { font-size: .78rem; }
.feature-button small { color: var(--muted); font-size: .61rem; }
.game-button { background: #dff4ed; } .shop-button { background: #eee9fa; }
.reset-button { display: block; margin: 22px auto 0; border: 0; padding: 10px 16px; color: #9a8d98; background: transparent; font-size: .76rem; font-weight: 700; cursor: pointer; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 18px; border-radius: 99px; color: white; background: rgba(76,65,80,.9); opacity: 0; pointer-events: none; transition: .25s; font-size: .8rem; font-weight: 700; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal[hidden] { display: none; }
.modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(70,58,74,.38); backdrop-filter: blur(5px); }
.modal-panel { position: relative; overflow-y: auto; width: min(100%, 430px); max-height: calc(100vh - 36px); padding: 27px 22px 22px; border-radius: 28px; background: #fffaf6; box-shadow: 0 24px 60px rgba(59,43,59,.25); text-align: center; }
.modal-close { position: absolute; top: 13px; right: 15px; width: 35px; height: 35px; border: 0; border-radius: 50%; color: #8e818c; background: #f0e9e7; font-size: 1.35rem; cursor: pointer; }
.modal-eyebrow { margin: 0 0 4px; color: #ad97aa; font: 800 .6rem/1 Arial,sans-serif; letter-spacing: .2em; }
.modal h2 { margin: 0; font-size: 1.35rem; }
.modal-description { margin: 7px 0 14px; color: var(--muted); font-size: .75rem; line-height: 1.7; }
.game-info { display: flex; justify-content: space-between; margin-bottom: 9px; padding: 0 4px; font-size: .75rem; font-weight: 700; }
.game-info strong { color: #da8776; font-size: 1rem; }
.game-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; border-radius: 22px; background: #e7f3ed; }
.game-cell { aspect-ratio: 1; border: 0; border-radius: 17px; background: rgba(255,255,255,.8); font-size: 2rem; cursor: pointer; transition: transform .1s; }
.game-cell.target { animation: cookie-pop .25s ease; }
.game-cell.target:active { transform: scale(.88); }
.game-result { min-height: 20px; margin: 13px 0 9px; color: #8b7d88; font-size: .75rem; font-weight: 700; }
.primary-modal-button { width: 100%; min-height: 48px; border: 0; border-radius: 15px; color: white; background: #8bc8b5; font-weight: 900; cursor: pointer; }
.primary-modal-button:disabled { opacity: .55; cursor: default; }
.shop-wallet { width: fit-content; margin: 9px auto 15px; padding: 7px 13px; border-radius: 99px; background: #fff0c8; color: #826b45; font-size: .73rem; }
.shop-heading { margin: 16px 0 8px; text-align: left; font-size: .78rem; font-weight: 900; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.shop-item { padding: 12px 8px 9px; border: 1px solid #eee5e5; border-radius: 17px; background: white; display: flex; flex-direction: column; align-items: center; }
.item-preview, .room-preview { display: grid; place-items: center; height: 47px; font-size: 2rem; }
.room-preview { width: 58px; margin-bottom: 3px; border-radius: 13px; color: white; font-size: 1.4rem; }
.mint-preview { background: linear-gradient(145deg,#b9e8d5,#73bea5); }
.night-preview { background: linear-gradient(145deg,#7772a9,#bab0d9); }
.shop-item strong { font-size: .72rem; }
.shop-item small { margin: 2px 0 7px; color: var(--muted); font-size: .61rem; }
.shop-item button { width: 100%; min-height: 33px; border: 0; border-radius: 10px; color: white; background: #a59bd4; font-size: .66rem; font-weight: 800; cursor: pointer; }
.shop-item button.equipped { color: #887d88; background: #e9e5e7; }
.remove-item-button { margin: 7px 0 0; border: 0; padding: 5px; color: #958793; background: transparent; font-size: .65rem; text-decoration: underline; cursor: pointer; }
.shop-message { min-height: 18px; margin: 9px 0 0; color: #d27b71; font-size: .7rem; font-weight: 800; }
@keyframes cookie-pop { 50% { transform: scale(1.16) rotate(8deg); } }

.pet.happy { animation: happy-jump .55s ease, breathe 2.6s ease-in-out .55s infinite; }
.pet.playing { animation: wiggle .55s ease, breathe 2.6s ease-in-out .55s infinite; }
.pet.sleeping { animation: sleep-bob 1.1s ease-in-out 2; }
.pet.sleeping .pet-eyes span, .pet.tired .pet-eyes span { height: 4px; margin-top: 10px; border-radius: 50%; box-shadow: none; }
.pet.sad .pet-mouth { border-top: 3px solid #7c555b; border-bottom: 0; border-radius: 50% 50% 0 0; top: 96px; }
.pet.excited .pet-mouth { top: 91px; height: 15px; border: 3px solid #7c555b; background: #bd6972; border-radius: 50%; }

@keyframes breathe { 0%,100% { transform: translateY(2px) scale(1); } 50% { transform: translateY(-3px) scale(1.015); } }
@keyframes happy-jump { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-23px) rotate(3deg); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes sleep-bob { 0%,100% { transform: rotate(0) translateY(2px); } 50% { transform: rotate(3deg) translateY(5px); } }
@keyframes twinkle { to { transform: scale(1.5) rotate(25deg); opacity: .3; } }
@keyframes bonus-glow { 50% { transform: scale(1.015); box-shadow: 0 8px 30px rgba(232,154,130,.25); } }

@media (max-width: 420px) {
  .app { width: min(100% - 20px, 580px); padding-top: 20px; }
  .pet-card { min-height: 390px; padding-inline: 17px; border-radius: 27px; }
  .name-form { align-items: flex-start; }
  .name-form label { padding-top: 10px; }
  .actions { gap: 7px; }
  .action-button { min-height: 96px; border-radius: 18px; font-size: .86rem; }
  .action-button small { font-size: .56rem; }
  .feature-button { padding-inline: 10px; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
