/* Fox Tamagotchi device — 653×383 design px, scaled to its grid cell by --gs */
.gamecell { position: relative; width: 100%; aspect-ratio: 645 / 383; }
.device {
  position: absolute; left: 0; top: 0; width: 653px; height: 383px;
  transform: scale(var(--gs, 1)); transform-origin: 0 0; outline: none;
}
/* the exported bezel has a flat white screen hole, so the hole is cut out with a mask that matches the LCD exactly */
.device__bezel {
  position: absolute; left: -7px; top: -3.2px; width: 667.5px; height: 397.5px; max-width: none; z-index: 2; pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 667.5 397.5'%3E%3Cpath fill-rule='evenodd' d='M0 0H667.5V397.5H0Z M52 24.2H616A16 16 0 0 1 632 40.2V251.2A16 16 0 0 1 616 267.2H52A16 16 0 0 1 36 251.2V40.2A16 16 0 0 1 52 24.2Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 667.5 397.5'%3E%3Cpath fill-rule='evenodd' d='M0 0H667.5V397.5H0Z M52 24.2H616A16 16 0 0 1 632 40.2V251.2A16 16 0 0 1 616 267.2H52A16 16 0 0 1 36 251.2V40.2A16 16 0 0 1 52 24.2Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.device:focus-visible { outline: 2px solid #6c8fc1; outline-offset: 10px; border-radius: 20px; }

/* screen */
.lcd {
  position: absolute; left: 29px; top: 21px; width: 596px; height: 243px; border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, #eaf0f8, #e3eaf4); z-index: 1; color: #3a3a3a;
}
.scene { position: absolute; inset: 0; transition: filter 0.6s, opacity 0.4s; }
.scene[data-lights="off"] { filter: brightness(0.5) contrast(1.1); }
.screen { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 0.35s var(--ease-out); }
.scene[data-screen="title"] .screen--title,
.scene[data-screen="main"] .screen--main,
.scene[data-screen="status"] .screen--status,
.scene[data-screen="play"] .screen--play { opacity: 1; }
.scene[data-screen="status"] .screen--main { opacity: 0; }

/* title */
.screen--title { display: grid; place-items: center; cursor: pointer; pointer-events: auto; }
.screen--title .play { position: absolute; left: 338px; top: 73px; width: 62px; height: 58px; transition: transform 0.5s var(--spring); animation: pulse 2.4s ease-in-out infinite; }
.screen--title:hover .play { transform: scale(1.1); }
.screen--title .tap { position: absolute; left: 195px; top: 150px; width: 206px; text-align: center; font-family: var(--font-pixel); font-weight: 700; font-size: 22px; letter-spacing: 0; color: #707070; text-transform: uppercase; }
.screen--title .play { left: 267px; top: 66px; rotate: 90deg; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.screen--title .play { width: 58px; height: 62px; }

/* main scene */
.ico { position: absolute; display: block; opacity: 0.92; transition: transform 0.35s var(--spring); }
.ico img { width: 100%; height: 100%; display: block; }
.scene[data-screen="main"] .screen--main .ico { pointer-events: auto; cursor: pointer; }
.ico::before {
  content: attr(data-label); position: absolute; left: 50%; transform: translateX(-50%) translateY(3px); z-index: 6; pointer-events: none;
  padding: 3px 7px; border-radius: 5px; background: rgba(58, 58, 58, 0.92); color: #eef3fa; white-space: nowrap;
  font-family: var(--font-pixel); font-weight: 700; font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  opacity: 0; transition: opacity 0.2s ease, transform 0.25s var(--ease-out);
}
.ico--top::before { top: calc(100% + 11px); }
.ico--bot::before { bottom: calc(100% + 11px); }
.ico:hover::before, .ico.is-sel::before { opacity: 1; transform: translateX(-50%); }
.ico::after { content: ""; position: absolute; inset: -6px -8px; border: 2px solid transparent; border-radius: 9px; transition: border-color 0.2s; }
.ico.is-sel { transform: scale(1.1); opacity: 1; }
.ico.is-sel::after { border-color: #3a3a3a; animation: blink 0.9s steps(2) infinite; }
.ico.is-hint { animation: hint 0.5s ease-in-out 6; }
@keyframes blink { 50% { border-color: transparent; } }
@keyframes hint { 50% { transform: scale(1.35); } }

.fox { position: absolute; image-rendering: pixelated; max-width: none; transition: left 2.4s ease-in-out; will-change: left; }
.fox.is-flip { transform: scaleX(-1); }
.fox.is-hop { animation: hop 0.44s steps(2) infinite; }
.fox.is-shake { animation: shake 0.35s steps(4) 2; }
.fox.is-sick { animation: sick 1.2s steps(2) infinite; }
@keyframes hop { 50% { margin-top: -12px; } }
@keyframes shake { 25% { margin-left: -6px; } 75% { margin-left: 6px; } }
@keyframes sick { 50% { margin-left: 3px; } }
.px { position: absolute; image-rendering: pixelated; }
.msg { z-index: 3; position: absolute; left: 0; right: 0; top: 98px; text-align: center; font-family: var(--font-pixel); font-weight: 700; font-size: 17px; color: #3a3a3a; letter-spacing: 0.02em; text-transform: uppercase; opacity: 0; transition: opacity 0.2s; }
.msg.is-on { opacity: 1; }
.call { position: absolute; right: 60px; top: 62px; width: 24px; height: 30px; opacity: 0; }
.call.is-on { opacity: 1; animation: blink2 0.7s steps(2) infinite; }
@keyframes blink2 { 50% { opacity: 0; } }
.poop { position: absolute; width: 30px; height: 30px; image-rendering: pixelated; }
.zzz { position: absolute; font-family: var(--font-pixel); font-weight: 700; font-size: 20px; color: #3a3a3a; opacity: 0; }
.zzz.is-on { opacity: 1; animation: zzz 1.6s steps(4) infinite; }
@keyframes zzz { 0% { transform: translate(0, 0); } 100% { transform: translate(10px, -14px); opacity: 0.2; } }

/* status */
.screen--status { padding: 26px 70px; font-family: var(--font-pixel); font-weight: 700; text-transform: uppercase; }
.screen--status h4 { font-size: 15px; letter-spacing: 0.08em; margin: 0 0 12px; text-align: center; }
.stat { display: flex; align-items: center; gap: 14px; height: 30px; font-size: 14px; }
.stat b { width: 118px; font-weight: 700; }
.stat .hearts { display: flex; gap: 8px; }
.hearts svg { width: 20px; height: 18px; }
.hearts .off { opacity: 0.2; }
.stat--meta { justify-content: space-between; font-size: 13px; opacity: 0.85; margin-top: 4px; }

/* mini game */
.screen--play { font-family: var(--font-pixel); font-weight: 700; text-transform: uppercase; }
.play__title { position: absolute; left: 0; right: 0; top: 14px; text-align: center; font-size: 15px; letter-spacing: 0.08em; }
.play__score { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 14px; letter-spacing: 0.35em; }
.play__hint { position: absolute; left: 24px; right: 24px; bottom: 40px; display: flex; justify-content: space-between; font-size: 11px; opacity: 0.7; }

/* CRT glass */
.crt { position: absolute; inset: 0; pointer-events: none; z-index: 4; border-radius: 16px; overflow: hidden; }
.crt::before {
  content: ""; position: absolute; inset: 0; opacity: 0.85;
  background:
    repeating-linear-gradient(0deg, rgba(20, 30, 50, 0.1) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(255, 60, 60, 0.07) 0 1px, rgba(60, 255, 90, 0.05) 1px 2px, rgba(60, 100, 255, 0.07) 2px 3px);
}
.crt::after {
  content: ""; position: absolute; inset: 0; border-radius: 16px;
  box-shadow: inset 0 0 46px rgba(20, 40, 70, 0.22), inset -3px -3px 5px rgba(64, 214, 236, 0.75), inset 3px 2px 4px rgba(255, 150, 150, 0.28);
}
.crt__roll { display: none; }
@keyframes roll { to { top: 243px; } }
@keyframes flick { 0% { opacity: 0.85; } 50% { opacity: 0.7; } }

/* buttons */
.gbtn { position: absolute; z-index: 3; border-radius: 50%; cursor: pointer; transition: transform 0.18s var(--spring), filter 0.25s; -webkit-tap-highlight-color: transparent; }
.gbtn::before {
  content: ""; position: absolute; inset: -8px; background: url(../assets/game/buttons.svg) no-repeat;
  background-size: 205.4px 51.4px; pointer-events: none;
}
.gbtn--y { left: 231px; top: 301px; width: 34px; height: 34px; }
.gbtn--y::before { background-position: calc(-4.2px + 8px) calc(-1.2px + 8px); }
.gbtn--r { left: 308px; top: 301px; width: 45px; height: 45px; }
.gbtn--r::before { background-position: calc(-81.2px + 8px) calc(-1.2px + 8px); }
.gbtn--b { left: 396px; top: 301px; width: 34px; height: 34px; }
.gbtn--b::before { background-position: calc(-169.2px + 8px) calc(-1.2px + 8px); }
.gbtn:hover { filter: brightness(1.07) saturate(1.1); }
.gbtn:active, .gbtn.is-press { transform: translateY(2px) scale(0.93); }
.gbtn:focus-visible { outline: 2px solid #6c8fc1; outline-offset: 5px; }

/* hover labels */
.gtip {
  position: absolute; z-index: 5; padding: 8px 16px; border-radius: 39px; white-space: nowrap; pointer-events: none;
  background: rgba(255, 255, 255, 0.72); border: 1px solid #e5e5e5; font-size: 16px; font-weight: 500; letter-spacing: -0.02em; color: #4e4e4e;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(6px) scale(0.94); transition: opacity 0.25s var(--ease-out), transform 0.4s var(--spring);
}
.gtip--y { left: 118px; top: 336px; }
.gtip--r { left: 295px; top: 362px; }
.gtip--b { left: 455px; top: 296px; }
.gbtn--y:hover ~ .gtip--y, .gbtn--r:hover ~ .gtip--r, .gbtn--b:hover ~ .gtip--b,
.gbtn--y:focus-visible ~ .gtip--y, .gbtn--r:focus-visible ~ .gtip--r, .gbtn--b:focus-visible ~ .gtip--b { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .crt::before, .crt__roll { animation: none; }
}
