@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/fredoka-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/fredoka-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #5c3a45;
  --muted: #a56b7d;
  --pink: #ff6fa8;
  --line: #efd0de;
  --card: #fff;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: Fredoka, "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: #fff3f8;
  background-image: radial-gradient(#ffd3e6 1.3px, transparent 1.3px);
  background-size: 22px 22px;
}

button, a { font: inherit; color: inherit; }
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.shell {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
}

header > div { flex: 1; min-width: 0; }

h1, h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

h1 { font-size: clamp(1.45rem, 4vw, 2rem); }
h2 { font-size: clamp(1.8rem, 5vw, 2.6rem); }

.sub, .end-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.round {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line);
  text-decoration: none;
  font-size: 26px;
}

.round:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.round[aria-pressed="false"] { filter: grayscale(1); }

.stats { display: flex; align-items: center; gap: 10px; }

.track {
  flex: 1;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid #fff;
  box-shadow: inset 0 0 0 2px var(--line);
  overflow: hidden;
}

#bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb3d1, #7ec8ff);
}

.coins {
  margin: 0;
  min-width: 92px;
  text-align: right;
  font-weight: 700;
  font-size: 1.15rem;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(180deg, #b7e7ff 0%, #fff7fb 55%, #d9f5e4 100%);
  box-shadow: inset 0 -16px 0 rgba(255, 143, 184, 0.12);
}

.person, #house {
  width: 100%;
  height: 100%;
  display: block;
}

.person { animation: arrive 0.45s ease-out; }

@keyframes arrive {
  from { transform: translateX(-28px); }
  to { transform: none; }
}

.hair, .glasses, .hat, .bit { display: none; }
.person[data-hair="short"] .hair-short,
.person[data-hair="bob"] .hair-bob,
.person[data-hair="curl"] .hair-curl,
.person[data-glasses="1"] .glasses,
.person[data-hat="1"] .hat,
.bit.on { display: inline; }

.arm.l { transform-origin: 78px 168px; transform-box: view-box; }
.arm.r { transform-origin: 142px 168px; transform-box: view-box; }

.person.clap .arm.l { animation: clap-l 0.34s ease-in-out infinite; }
.person.clap .arm.r { animation: clap-r 0.34s ease-in-out infinite; }

@keyframes clap-l {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(26deg); }
}

@keyframes clap-r {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-26deg); }
}

.say, .wish, .unlock {
  margin: 0;
  font-weight: 700;
}

.say {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  top: 12px;
  background: #fff;
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: 0 6px 0 rgba(92, 58, 69, 0.08);
  text-align: center;
  line-height: 1.25;
  white-space: pre-line;
}

#screen-ask .person {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 82%;
}

.wish {
  background: #fff;
  border-radius: 16px;
  padding: 8px 10px;
  text-align: center;
  box-shadow: 0 4px 0 var(--line);
  white-space: pre-line;
  line-height: 1.25;
}

#ask-stage[data-lines="3"] .person { height: 74%; }
#ask-stage[data-lines="4"] .person,
#ask-stage[data-lines="5"] .person { height: 68%; }

.tab.asked::before { content: "★ "; color: #e6a317; }

#screen-pay .stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 12px;
}

#screen-pay .person {
  flex: 1;
  height: auto;
  min-height: 0;
}

#screen-pay .say,
#screen-pay .up,
#screen-pay .gain,
#screen-pay .unlock {
  position: static;
  transform: none;
  width: min(100%, 420px);
}

.up, .gain, .unlock { text-align: center; }

.up {
  margin: 0 0 8px;
  background: #ffe08a;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  box-shadow: 0 5px 0 #e6c15a;
}

.gain {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 700;
  color: #e6a317;
  text-shadow: 0 4px 0 #fff;
}

.unlock {
  margin-top: 6px;
  background: #fff;
  border-radius: 14px;
  padding: 8px 10px;
  white-space: pre-line;
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.tab, .choice, .go {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--line);
  font-weight: 700;
}

.tab { padding: 8px 4px; font-size: 0.95rem; }
.tab.on { background: #e7f4ff; border-color: #7ec8ff; }
.tab:active, .choice:active, .go:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }

.choices {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scroll-snap-type: x mandatory;
}

.choices::-webkit-scrollbar { height: 0; }

.choice {
  position: relative;
  flex: 0 0 92px;
  scroll-snap-align: start;
  min-height: 96px;
  padding: 8px 6px;
}

.choice.on { border-color: var(--pink); background: #fff5fa; }
.choice.on::after {
  content: "✓";
  position: absolute;
  top: 2px;
  right: 6px;
  color: var(--pink);
}

.choice .star {
  position: absolute;
  top: 2px;
  left: 6px;
  color: #e6a317;
}

.swatch {
  display: block;
  height: 42px;
  border-radius: 14px;
  background: var(--c);
  border: 2px solid rgba(92, 58, 69, 0.08);
}

.choice .emoji { display: block; font-size: 32px; line-height: 1.2; }
.choice .name { display: block; margin-top: 4px; font-size: 13px; text-align: center; }

.go {
  border: 0;
  min-height: 64px;
  font-size: 1.35rem;
  background: #ffe08a;
  box-shadow: 0 6px 0 #e6c15a;
}

.go:active { box-shadow: 0 2px 0 #e6c15a; }
.go.ghost { background: #fff; box-shadow: 0 6px 0 var(--line); }

.end-copy { text-align: center; padding-top: 4px; }

.crowd {
  flex: 1;
  min-height: 180px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  align-content: start;
  overflow: auto;
  padding: 4px;
}

.fan {
  position: relative;
  height: 58px;
  animation: cheer 0.7s ease-in-out infinite;
  animation-delay: var(--d);
}

.fan i { position: absolute; display: block; left: 50%; }
.fan .hd {
  width: 22px;
  height: 22px;
  margin-left: -11px;
  top: 8px;
  border-radius: 50%;
  background: var(--skin);
  box-shadow: 0 -8px 0 2px var(--hair);
}
.fan .bd {
  width: 24px;
  height: 18px;
  margin-left: -12px;
  top: 30px;
  border-radius: 10px 10px 8px 8px;
  background: var(--shirt);
}
.fan::after {
  content: "👏";
  position: absolute;
  right: 0;
  bottom: 0;
  font-size: 12px;
}

@keyframes cheer {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-6px); }
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

button:focus-visible, a:focus-visible {
  outline: 3px solid #3d7eff;
  outline-offset: 2px;
}

@media (min-width: 900px) {
  #screen-decor {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    grid-template-rows: auto auto auto auto;
    gap: 10px 16px;
    align-content: stretch;
  }
  #screen-decor .stage { grid-row: 1 / span 4; min-height: 0; }
  #screen-decor .wish { grid-column: 2; }
  .crowd { grid-template-columns: repeat(10, 1fr); }
  .fan { height: 72px; }
}

.angry-brow, .angry-mouth { display: none; }
.person.angry .smile { display: none; }
.person.angry .angry-brow,
.person.angry .angry-mouth { display: inline; }
.person.angry .blush { fill: #ff5a6a; opacity: .85; }
.person.angry { animation: mad .35s ease-in-out 3; }

@keyframes mad {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

#screen-pay .say.mad {
  background: #ffe4ea;
  color: #c43b55;
}

.hub {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(108px, 1fr);
  gap: 10px;
  align-content: stretch;
  overflow: auto;
}

#screen-home #play { order: 2; flex: 0 0 auto; }

.hub-card {
  min-height: 108px;
  border-radius: 24px;
  border: 3px solid #fff;
  background: #fff;
  box-shadow: 0 6px 0 var(--line);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 10px 8px;
}

.hub-card.wide { grid-column: 1 / -1; }
.hub-card .emoji { display: block; font-size: 36px; line-height: 1.1; }
.hub-card .name { display: block; margin-top: 2px; font-size: 1.15rem; }
.hub-card .lock { display: block; color: var(--muted); font-size: .9rem; font-weight: 600; }
.hub-card.locked { filter: grayscale(.35); opacity: .8; }
.hub-card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }

.pair { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
.pair .go { font-size: 1.15rem; min-height: 60px; padding: 8px; }

#hero-tabs {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
#hero-tabs .tab { min-width: 0; min-height: 46px; }

.choice .mini { display: block; width: 48px; height: 36px; margin: 4px auto 0; }

#hero-choices {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  overflow: hidden;
}
#hero-choices .choice {
  width: auto;
  min-width: 0;
  min-height: 84px;
}

#office, #pet-preview { width: 100%; height: 100%; display: block; }

#screen-hero .person {
  width: auto;
  height: 100%;
  margin: 0 auto;
}

#screen-office .stage {
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.office-fit {
  position: relative;
  width: min(100cqw, calc(100cqh * 1.25));
  aspect-ratio: 5 / 4;
  max-height: 100cqh;
}

#screen-office .person {
  position: absolute;
  z-index: 1;
  width: auto;
  height: 88%;
  right: 3%;
  bottom: 0;
  left: auto;
}

#pet-art {
  position: absolute;
  z-index: 2;
  width: 28%;
  height: auto;
  left: 5%;
  bottom: 3%;
}

@media (min-width: 900px) {
  .hub-card { min-height: 140px; font-size: 1.35rem; }
  .hub-card .emoji { font-size: 48px; }
}

@media (max-height: 500px) and (min-width: 700px) {
  #screen-decor,
  #screen-office,
  #screen-hero,
  #screen-pet {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 8px 12px;
  }
  #screen-decor { grid-template-rows: auto auto auto auto; }
  #screen-decor .stage { grid-row: 1 / span 4; min-height: 0; }
  #screen-decor .wish,
  #screen-decor .tabs,
  #screen-decor .choices,
  #screen-decor .go { grid-column: 2; }

  #screen-office,
  #screen-hero,
  #screen-pet { grid-template-rows: auto auto 1fr; }
  #screen-office .stage,
  #screen-hero .stage,
  #screen-pet .stage { grid-column: 1; grid-row: 1 / span 3; min-height: 0; }
  #screen-office .wish,
  #screen-hero .tabs,
  #screen-pet .choices { grid-column: 2; grid-row: 1; }
  #screen-office .choices,
  #screen-hero .choices { grid-column: 2; grid-row: 2; }
  #screen-office .go,
  #screen-hero .go,
  #screen-pet .go { grid-column: 2; grid-row: 3; align-self: end; }
}

@media (max-height: 500px) {
  .shell {
    height: 100dvh;
    overflow: hidden;
    gap: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .round { width: 46px; height: 46px; font-size: 22px; }
  h1 { font-size: 1.25rem; }
  .choice { min-height: 64px; flex-basis: 72px; }
  .swatch { height: 26px; }
  .choice .emoji { font-size: 22px; }
  .go { min-height: 48px; font-size: 1.1rem; }
  .hub { gap: 6px; grid-auto-rows: minmax(0, 1fr); }
  .hub-card { min-height: 0; padding: 4px 6px; font-size: 1rem; }
  .hub-card .emoji { font-size: 24px; }
  .say, .wish { padding: 6px 8px; }
  #hero-choices .choice { min-height: 56px; }
  #hero-tabs .tab { min-height: 36px; padding: 4px 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .person, .person.angry, .person.clap .arm.l, .person.clap .arm.r, .fan { animation: none !important; }
}
