/* Tamagochi: a yolk-yellow toy on a grape blister card. */

@font-face { font-family: 'Baloo 2'; src: url('/fonts/baloo-2-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('/fonts/baloo-2-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('/fonts/baloo-2-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('/fonts/pixelify-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('/fonts/pixelify-sans-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --grape: #5b3fd8;
  --grape-deep: #3b23a3;
  --grape-night: #26136f;
  --ink: #1f1150;
  --ink-soft: rgba(31, 17, 80, 0.64);
  --ink-faint: rgba(31, 17, 80, 0.12);
  --yolk: #ffc734;
  --yolk-hi: #ffe89a;
  --yolk-lo: #e0920c;
  --yolk-ink: #7a3e00;
  --albumen: #fff8ea;
  --lcd: #c8d4a4;
  --lcd-ink: #25301b;
  --tomato: #ff5b37;
  --tomato-hi: #ff8f70;
  --tomato-lo: #b8361a;
  --mint: #4fd39a;
  --font-ui: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
  --font-px: 'Pixelify Sans', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.45;
  color: var(--albumen);
  background-color: var(--grape);
  background-image: radial-gradient(rgba(255, 255, 255, 0.085) 1.3px, transparent 1.7px);
  background-size: 14px 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img, canvas, svg { display: block; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; border-radius: 10px; }

/* ---------- top bar ---------- */

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  font-size: 27px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand img { image-rendering: pixelated; }
.top-links { display: flex; align-items: center; gap: 8px; }
.chip-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: var(--albumen);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.chip-link:hover { background: rgba(255, 255, 255, 0.18); }
.chip-link[aria-pressed='true'] { background: var(--albumen); color: var(--ink); border-color: var(--albumen); }

/* ---------- layout ---------- */

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 4px clamp(16px, 4vw, 40px) 40px;
  display: grid;
  gap: 30px;
}
.toy-col { display: flex; flex-direction: column; align-items: center; padding-top: 40px; }

@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 470px); align-items: start; gap: 56px; }
  .toy-col { position: sticky; top: 28px; padding-top: 52px; }
  .device { width: min(42vw, 470px); }
}

/* ---------- the egg device ---------- */

.device {
  position: relative;
  width: min(88vw, 410px);
  aspect-ratio: 100 / 118;
  border-radius: 50% 50% 47% 47% / 57% 57% 43% 43%;
  background:
    radial-gradient(circle at 21% 74%, rgba(176, 96, 0, 0.2) 0 1.9%, transparent 2.3%),
    radial-gradient(circle at 81% 63%, rgba(176, 96, 0, 0.18) 0 1.4%, transparent 1.8%),
    radial-gradient(circle at 73% 13%, rgba(176, 96, 0, 0.16) 0 1.2%, transparent 1.6%),
    radial-gradient(circle at 13% 43%, rgba(176, 96, 0, 0.15) 0 1%, transparent 1.4%),
    radial-gradient(circle at 88% 38%, rgba(176, 96, 0, 0.14) 0 0.9%, transparent 1.3%),
    radial-gradient(120% 95% at 30% 18%, var(--yolk-hi) 0%, var(--yolk) 42%, var(--yolk-lo) 100%);
  box-shadow:
    inset -14px -24px 36px rgba(150, 70, 0, 0.34),
    inset 12px 14px 26px rgba(255, 255, 255, 0.55),
    0 16px 0 -4px var(--grape-deep),
    0 44px 64px rgba(20, 6, 70, 0.45);
}
.device.shake { animation: shake 0.11s linear 4; }

.keyring {
  position: absolute;
  left: 50%;
  top: -40px;
  width: 50px;
  height: 50px;
  margin-left: -25px;
  border-radius: 50%;
  border: 7px solid #ddd9ee;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.1), 0 3px 0 rgba(20, 6, 70, 0.35);
}
.keyring::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -19px;
  width: 16px;
  height: 18px;
  margin-left: -8px;
  border-radius: 6px 6px 3px 3px;
  background: var(--yolk-lo);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.device-brand {
  position: absolute;
  top: 8.5%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-weight: 800;
  font-size: clamp(15px, 4.4vw, 20px);
  letter-spacing: 0.03em;
  color: var(--yolk-ink);
  opacity: 0.72;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.bezel {
  position: absolute;
  left: 13.5%;
  right: 13.5%;
  top: 17.5%;
  padding: 9px 11px 12px;
  border-radius: 26px 26px 34px 34px;
  background: var(--albumen);
  box-shadow:
    inset 0 -5px 0 rgba(170, 110, 30, 0.18),
    0 3px 0 rgba(255, 255, 255, 0.55),
    0 -2px 0 rgba(120, 60, 0, 0.22);
}
.icons {
  list-style: none;
  margin: 0 0 7px;
  padding: 0 6px;
  display: flex;
  justify-content: space-between;
}
.icons li { width: 17px; height: 17px; display: grid; place-items: center; color: var(--lcd-ink); opacity: 0.18; transition: opacity 0.2s; }
.icons li svg { max-width: 100%; max-height: 100%; }
.icons li.on { opacity: 0.95; }
.icons li.blink { animation: blink 0.9s steps(1) infinite; }

.lcd {
  position: relative;
  aspect-ratio: 48 / 32;
  border-radius: 12px;
  overflow: hidden;
  background: var(--lcd);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.34), inset 0 0 0 2px rgba(0, 0, 0, 0.16);
}
.lcd canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.lcd::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 40%);
  pointer-events: none;
}
.lcd-overlay { position: absolute; inset: 0; pointer-events: none; }
.lcd-badge {
  position: absolute;
  top: 5px;
  left: 8px;
  font: 600 11px/1 var(--font-px);
  color: var(--lcd-ink);
  opacity: 0.66;
}
.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  font: 600 clamp(11px, 3.2vw, 15px)/1 var(--font-px);
  color: var(--lcd-ink);
  white-space: nowrap;
  animation: float-up 1.7s ease-out forwards;
}

.device-buttons { position: absolute; left: 0; right: 0; bottom: 6.5%; height: 22%; }
.dbtn {
  position: absolute;
  width: 16.5%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 34% 28%, var(--tomato-hi), var(--tomato) 55%, var(--tomato-lo));
  box-shadow: 0 6px 0 var(--tomato-lo), 0 11px 14px rgba(90, 30, 0, 0.32);
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.dbtn:hover { filter: brightness(1.05); }
.dbtn:active, .dbtn.pressed { transform: translateY(5px); box-shadow: 0 1px 0 var(--tomato-lo), 0 3px 6px rgba(90, 30, 0, 0.3); }
.dbtn-a { left: 21%; top: 0; }
.dbtn-b { left: 41.75%; top: 17%; }
.dbtn-c { left: 62.5%; top: 0; }
.dbtn-label {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  color: var(--yolk-ink);
  opacity: 0.85;
  pointer-events: none;
}

.live-pill {
  margin: 40px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(20, 8, 70, 0.34);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
}
.live-pill .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--yolk); }
.live-pill[data-state='live'] .dot { background: var(--mint); animation: pulse 2s infinite; }
.live-pill[data-state='error'] .dot { background: var(--tomato); }

/* ---------- the care sheet ---------- */

.sheet {
  position: relative;
  padding: clamp(24px, 4vw, 32px) clamp(20px, 4vw, 32px) clamp(24px, 4vw, 30px);
  border-radius: 28px;
  background: var(--albumen);
  color: var(--ink);
  box-shadow: 0 12px 0 var(--grape-deep);
}
.sheet::before {
  /* the hang hole of a blister card */
  content: '';
  position: absolute;
  top: 13px;
  left: 50%;
  width: 56px;
  height: 13px;
  margin-left: -28px;
  border-radius: 999px;
  background: var(--grape);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.35);
}
.sheet-block + .sheet-block { margin-top: 22px; padding-top: 20px; border-top: 2px dashed rgba(31, 17, 80, 0.16); }
.status { padding-top: 12px; }

#status-title {
  margin: 0;
  font-weight: 800;
  font-size: clamp(32px, 6.6vw, 44px);
  line-height: 1.02;
  letter-spacing: -0.015em;
}
.status-sub { margin: 9px 0 0; max-width: 38ch; color: var(--ink-soft); }

.last-fed { margin: 6px 0 0; font: 400 14px/1.3 var(--font-px); color: var(--ink-soft); }
.last-fed:empty { display: none; }
.game-score { margin: 0; font: 400 14px/1.3 var(--font-px); color: var(--ink-soft); }
.game-score:empty { display: none; }
.device.in-game .dbtn-a, .device.in-game .dbtn-c { filter: brightness(1.12); }
.device.in-game .dbtn-b { filter: saturate(0.4); }

.meters { margin-top: 18px; display: grid; gap: 9px; }
.meter { display: grid; grid-template-columns: 62px 1fr 46px; align-items: center; gap: 12px; }
.meter-label { font-weight: 700; font-size: 15px; }
.meter-bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; height: 16px; }
.meter-bar i { background: var(--ink-faint); border-radius: 2px; }
.meter-bar i.on { background: var(--ink); }
.meter-bar.low i.on { background: var(--tomato); }
.meter-value { font: 600 15px/1 var(--font-px); text-align: right; }
.meter-mess { grid-column: span 2; display: flex; align-items: center; gap: 7px; min-height: 16px; font-weight: 700; font-size: 15px; color: var(--ink-soft); }
.meter-mess svg { width: 19px; height: 14px; color: var(--ink); }

.actions { display: grid; gap: 10px; }
.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 12px 20px;
  border-radius: 18px;
  background: var(--tomato);
  color: #fff;
  font-weight: 800;
  font-size: 21px;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 6px 0 var(--tomato-lo);
  transition: transform 0.08s, box-shadow 0.08s;
}
.cta:hover { background: #ff6c4c; }
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--tomato-lo); }
.cta[aria-disabled='true'] { background: var(--ink-faint); color: var(--ink-soft); box-shadow: none; pointer-events: none; }
.cta-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  font-weight: 800;
  text-decoration: none;
}
.cta-secondary:hover { background: rgba(31, 17, 80, 0.06); }

.stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.stats div { display: flex; flex-direction: column-reverse; gap: 2px; }
.stats dt { font-weight: 700; font-size: 14px; color: var(--ink-soft); }
.stats dd { margin: 0; font: 600 25px/1.1 var(--font-px); }
.stats dd.up { color: #16804f; }
.stats dd.down { color: #c4351a; }
.stats-note { margin: 14px 0 0; }

h2 { margin: 0 0 8px; font-weight: 800; font-size: 22px; line-height: 1.15; letter-spacing: -0.01em; }
.hint { margin: -2px 0 12px; color: var(--ink-soft); font-size: 15px; }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 312px; overflow: auto; overscroll-behavior: contain; }
.log li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.log li.fresh { animation: fresh 2.4s ease-out; }
.log .ico { width: 20px; height: 17px; display: grid; place-items: center; }
.log .ico svg { max-width: 100%; max-height: 100%; }
.log .what { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.log .usd { margin-left: 6px; font-weight: 600; color: var(--ink-soft); }
.log .tag { margin-left: 6px; padding: 2px 5px; border-radius: 5px; background: var(--ink-faint); font: 600 11px/1 var(--font-px); vertical-align: 2px; }
.log .when { font: 400 13px/1 var(--font-px); color: var(--ink-soft); white-space: nowrap; }
.log .log-empty { display: block; padding: 4px 0; font-weight: 500; color: var(--ink-soft); }

.arena { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; }
.fighter { display: grid; gap: 4px; }
.fighter.rival { text-align: right; }
.f-name { font-weight: 800; font-size: 16px; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.f-name:hover { text-decoration: underline; }
.f-score { font: 600 30px/1 var(--font-px); }
.f-bar { display: block; height: 14px; border-radius: 4px; background: var(--ink-faint); overflow: hidden; }
.f-bar i { display: block; height: 100%; width: 0; background: var(--tomato); transition: width 0.6s; }
.fighter.rival .f-bar i { margin-left: auto; background: var(--grape); }
.fighter.winner .f-score { color: #16804f; }
.vs { font-weight: 800; font-size: 15px; color: var(--ink-soft); padding-bottom: 24px; }
.arena-verdict { margin: 12px 0 0; font-weight: 700; }
.arena-btn { margin-top: 12px; }

.growth { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.growth button {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px 10px;
  border-radius: 16px;
  border: 2px solid var(--ink-faint);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.growth button:hover { border-color: rgba(31, 17, 80, 0.35); }
.growth canvas { width: 70px; height: 65px; image-rendering: pixelated; margin-bottom: 4px; }
.growth .g-name { font-weight: 800; font-size: 15px; line-height: 1.1; }
.growth .g-at { font: 400 12.5px/1.15 var(--font-px); color: var(--ink-soft); }
.growth .now button { background: var(--yolk); border-color: var(--ink); }
.growth .now .g-at { color: var(--ink); }
.growth .locked .g-name { color: var(--ink-soft); }

.wardrobe { display: flex; flex-wrap: wrap; gap: 8px; }
.outfit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid rgba(31, 17, 80, 0.18);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.outfit:hover:not(:disabled) { border-color: var(--ink); }
.outfit[aria-pressed='true'] { background: var(--ink); color: var(--albumen); border-color: var(--ink); }
.outfit:disabled { opacity: 0.45; cursor: not-allowed; }
.outfit small { font: 400 12px/1 var(--font-px); }

/* ---------- about ---------- */

.about {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px clamp(16px, 4vw, 40px) 64px;
  display: grid;
  gap: 12px;
}
.about h2 { color: var(--albumen); }
.about p { margin: 0; max-width: 64ch; color: rgba(255, 248, 234, 0.86); }
.about h3 { margin: 8px 0 0; font-weight: 800; font-size: 19px; color: var(--albumen); }
.idea { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 640px; }
.idea li { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(20, 8, 70, 0.28); font-size: 15px; color: rgba(255, 248, 234, 0.8); }
.idea li span { font-weight: 800; color: var(--albumen); }
.idea li.live { background: rgba(79, 211, 154, 0.16); }
.idea li.live span::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--mint); vertical-align: 2px; }
@media (max-width: 420px) { .idea li { grid-template-columns: 1fr; gap: 2px; } }

.contract {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  max-width: 640px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 8, 70, 0.35);
}
.contract-label { font-weight: 700; font-size: 15px; }
.contract code { font: 400 15px/1.25 var(--font-px); word-break: break-all; }
.copy-btn {
  margin-left: auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 0;
  background: var(--albumen);
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}
.fineprint { font-size: 14px; opacity: 0.78; }

/* ---------- motion ---------- */

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -60%); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -190%); }
}
@keyframes blink { 50% { opacity: 0.18; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 211, 154, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(79, 211, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 211, 154, 0); }
}
@keyframes fresh { 0% { background: rgba(255, 199, 52, 0.6); } 100% { background: transparent; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px) rotate(-0.8deg); }
  75% { transform: translateX(3px) rotate(0.8deg); }
}

@media (max-width: 420px) {
  body { font-size: 16px; }
  .brand { font-size: 24px; }
  .chip-link { padding: 0 11px; font-size: 14px; }
  .meter { grid-template-columns: 54px 1fr 42px; gap: 10px; }
  .growth { gap: 8px; }
  .dbtn-label { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
}
