@font-face {
  font-family: 'Fredoka';
  src: url('fonts/fredoka.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* the notch and the home bar, read once here so tools/shots.mjs can pretend to have them */
  --sa-top: env(safe-area-inset-top, 0px); --sa-right: env(safe-area-inset-right, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px); --sa-left: env(safe-area-inset-left, 0px);
  --ink: #3a2416;
  --ink-2: #7a5a45;
  --cream: #fffaf0;
  --orange: #ff8a14;
  --orange-d: #d9620a;
  --red: #ff3b4e;
  --green: #4fbf3a;
  --shadow: 0 8px 0 rgba(58, 36, 22, .16), 0 18px 40px rgba(58, 36, 22, .22);
  --font: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #ffb52e; }
body {
  font-family: var(--font); color: var(--ink); font-size: 17px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 6px rgba(58, 36, 22, .55); }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* ── while playing ──────────────────────────────────────────────────────── */

#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 3; pointer-events: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px;
  padding: calc(12px + var(--sa-top)) calc(14px + var(--sa-right)) 0 calc(14px + var(--sa-left));
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start;
  background: var(--cream); border-radius: 999px; padding: 7px 16px 7px 10px;
  font-weight: 600; font-size: 20px; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 0 rgba(58, 36, 22, .18), 0 8px 18px rgba(58, 36, 22, .16);
}
.pill svg { width: 28px; height: 28px; }
.pill b { font-weight: 700; min-width: 1.2ch; text-align: right; }
.pill span { color: var(--ink-2); font-weight: 500; }
.pill.bump { animation: bump .22s ease-out; }
/* the counters show when something changes and then leave the picture alone; the pause button stays, faintly */
#hud .pill, #hud .stars, #hud .combo { transition: opacity .5s ease .1s; }
#hud.quiet .pill, #hud.quiet .stars, #hud.quiet .combo { opacity: 0; transition-delay: 0s; }
#hud .round { opacity: .72; }
.pill.full { background: #fff3b0; }
@keyframes bump { 40% { transform: scale(1.14); } }
.combo {
  position: absolute; left: calc(14px + var(--sa-left)); top: calc(62px + var(--sa-top));
  background: var(--orange); color: #fff; font-weight: 700; font-size: 18px; padding: 3px 12px; border-radius: 999px;
  box-shadow: 0 3px 0 var(--orange-d); transform-origin: left center;
}
.combo.hot { background: var(--red); box-shadow: 0 3px 0 #b3202f; }
.combo.bump { animation: combo-bump .26s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes combo-bump { 0% { transform: scale(1.35) rotate(-4deg); } }
#hud .right { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.round {
  pointer-events: auto; width: 46px; height: 46px; border-radius: 50%; background: var(--cream);
  display: grid; place-items: center; box-shadow: 0 4px 0 rgba(58, 36, 22, .18), 0 8px 18px rgba(58, 36, 22, .16);
}
.round svg { width: 22px; height: 22px; fill: var(--ink); }
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(58, 36, 22, .18); }

.stars { display: inline-flex; gap: 4px; align-items: center; }
.stars svg { width: 34px; height: 34px; filter: drop-shadow(0 3px 0 rgba(58, 36, 22, .2)); }
.stars svg path { fill: rgba(255, 250, 240, .55); stroke: rgba(58, 36, 22, .35); stroke-width: 1.4; stroke-linejoin: round; }
.stars svg.on path { fill: #ffd21a; stroke: #b97a00; }
.stars svg.pop { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.2) rotate(-80deg); } 100% { transform: none; } }

/* the island's name, over the start, for a moment */
#caption {
  position: fixed; left: 50%; top: 26%; transform: translateX(-50%); z-index: 3; pointer-events: none; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff8e8; padding: 10px 26px 12px; border-radius: 26px;
  background: rgba(58, 30, 12, .3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  text-shadow: 0 2px 0 rgba(58, 30, 12, .55), 0 0 24px rgba(58, 30, 12, .45);
  animation: caption-in .35s cubic-bezier(.2, 1.3, .4, 1); transition: opacity .45s ease-in;
}
#caption small { font-size: 14px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; opacity: .85; }
#caption b { font-size: clamp(34px, 7vw, 54px); font-weight: 700; line-height: 1.05; white-space: nowrap; }
#caption.out { opacity: 0; }
@keyframes caption-in { from { opacity: 0; transform: translate(-50%, 10px) scale(.94); } }

#toast {
  position: fixed; left: 50%; top: calc(74px + var(--sa-top)); transform: translateX(-50%); z-index: 3; pointer-events: none;
  background: var(--ink); color: #fff8e8; font-weight: 600; padding: 8px 18px; border-radius: 999px; white-space: nowrap;
  animation: toast-in .25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

#hint {
  position: fixed; left: 50%; bottom: calc(34px + var(--sa-bottom)); transform: translateX(-50%); z-index: 3; pointer-events: none;
  background: var(--cream); padding: 12px 22px; border-radius: 18px; font-weight: 500; font-size: 19px; text-align: center;
  max-width: min(520px, calc(100vw - 40px)); box-shadow: var(--shadow);
  animation: hint-in .3s cubic-bezier(.2, 1.3, .4, 1);
}
#hint b { font-weight: 700; color: var(--orange-d); }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } }

/* a word from Pip, under the HUD: a speech card with a little name tag */
#say {
  position: fixed; left: 50%; top: calc(76px + var(--sa-top)); transform: translateX(-50%); z-index: 3; pointer-events: none;
  background: var(--cream); padding: 14px 18px 11px; border-radius: 18px; font-weight: 500; font-size: 17px; line-height: 1.3; text-align: center;
  max-width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); animation: hint-in-top .3s cubic-bezier(.2, 1.3, .4, 1);
}
#say b { position: absolute; left: 14px; top: -11px; background: var(--who, var(--orange)); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; box-shadow: 0 2px 0 rgba(58, 36, 22, .3); }
#say span { font-style: italic; }

#stick {
  position: fixed; z-index: 3; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; pointer-events: none;
  background: rgba(255, 250, 240, .22); border: 3px solid rgba(255, 250, 240, .7);
}
#knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--cream); box-shadow: 0 4px 0 rgba(58, 36, 22, .25);
}
#jump {
  position: fixed; z-index: 3; right: calc(22px + var(--sa-right)); bottom: calc(34px + var(--sa-bottom));
  width: 96px; height: 96px; border-radius: 50%; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ffb347, var(--orange) 60%, var(--orange-d));
  border: 4px solid rgba(255, 250, 240, .9); box-shadow: 0 7px 0 rgba(58, 36, 22, .3);
  display: grid; place-items: center; touch-action: none;
}
/* the thumb lands near the button more often than on it: the hit area is a good deal bigger than the picture */
#jump::before { content: ''; position: absolute; inset: -26px -26px -34px -34px; border-radius: 50%; }
#jump svg { width: 46px; height: 46px; }
#jump.down { transform: translateY(5px) scale(.96); box-shadow: 0 2px 0 rgba(58, 36, 22, .3); }
/* thumbs live at the bottom, so on a touch screen the hint goes up under the HUD, and a toast steps below it */
body.touch #hint { bottom: auto; top: calc(70px + var(--sa-top)); font-size: 16px; padding: 9px 16px; line-height: 1.3; max-width: min(460px, calc(100vw - 32px)); }
body.touch #hint:not([hidden]) + #toast { top: calc(150px + var(--sa-top)); }
@keyframes hint-in-top { from { opacity: 0; transform: translate(-50%, -10px) scale(.96); } }
body.touch #hint { animation-name: hint-in-top; }

/* ── screens ────────────────────────────────────────────────────────────── */

.screen {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; overflow-y: auto;
  padding: calc(18px + var(--sa-top)) calc(18px + var(--sa-right)) calc(18px + var(--sa-bottom)) calc(18px + var(--sa-left));
}
.screen.dim { background: rgba(58, 30, 12, .42); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }

/* the title: the name at the top, the demo in the middle, one button and the islands at the bottom */
#title {
  background: linear-gradient(180deg, rgba(255, 247, 226, .84) 0%, rgba(255, 247, 226, .5) 26%, rgba(255, 247, 226, .0) 46%, rgba(58, 30, 12, .12) 70%, rgba(58, 30, 12, .5) 100%);
  align-items: stretch;
}
.title-inner { width: min(560px, 100%); margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 100%; }
.logo {
  margin: clamp(4px, 3vh, 34px) 0 0; font-size: clamp(58px, 13.5vw, 130px); line-height: .95; font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
  filter: drop-shadow(0 8px 0 rgba(58, 36, 22, .22));
}
.logo span {
  display: inline-block; color: var(--c);
  text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 2px 2px #fff, -2px 2px #fff, 2px -2px #fff, -2px -2px #fff;
  transform: rotate(var(--r, 0deg)) translateY(var(--y, 0));
}
.logo span:nth-child(1) { --c: #ff3b4e; --r: -6deg; }
.logo span:nth-child(2) { --c: #ff8a14; --r: 3deg; --y: .04em; }
.logo span:nth-child(3) { --c: #f5b800; --r: -2deg; }
.logo span:nth-child(4) { --c: #4fbf3a; --r: 4deg; --y: -.02em; }
.logo span:nth-child(5) { --c: #12b3a2; --r: -3deg; }
.logo span:nth-child(6) { --c: #4a67f0; --r: 2deg; --y: -.03em; }
.logo span:nth-child(7) { --c: #9a4be0; --r: -4deg; --y: .03em; }
.logo span:nth-child(8) { --c: #ff5fa2; --r: 3deg; }
.logo span:nth-child(9) { --c: #ff3b4e; --r: -2deg; --y: .02em; }

.menu { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 18px; }
.play {
  width: min(320px, 100%); border-radius: 22px; padding: 14px 24px 12px; color: #fff; text-align: center;
  background: linear-gradient(180deg, #ffa53a, var(--orange)); box-shadow: 0 7px 0 var(--orange-d), 0 18px 40px rgba(58, 36, 22, .25);
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.play span { font-size: 30px; font-weight: 700; }
.play small { font-size: 15px; font-weight: 600; opacity: .9; margin-top: 2px; }
.play:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--orange-d), 0 8px 20px rgba(58, 36, 22, .25); }
.isles { display: flex; gap: 14px; justify-content: center; align-items: flex-end; }
/* the islands in their lands: a name in small capitals over each group */
.land { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.land small { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; line-height: 1.15; text-align: center; color: rgba(255, 248, 232, .92); text-shadow: 0 1px 0 rgba(58, 30, 12, .55); max-width: 72px; }
.land-isles { display: flex; gap: 10px; }
.isle {
  width: 54px; display: flex; flex-direction: column; align-items: center; gap: 4px; border-radius: 16px; padding: 5px 3px 4px;
  background: rgba(255, 250, 240, .92); box-shadow: 0 4px 0 rgba(58, 36, 22, .2); transition: transform .12s ease-out;
}
.isle .ico { width: 40px; height: 40px; display: block; }
.isle.next { box-shadow: 0 4px 0 var(--orange-d), 0 0 0 3px var(--orange); }
.isle:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(58, 36, 22, .2); }
.isle[disabled] { cursor: default; background: rgba(255, 250, 240, .4); box-shadow: none; }
.isle[disabled] .ico { filter: grayscale(1); opacity: .45; }
.dots { display: flex; gap: 3px; height: 7px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #e4d8c4; }
.dots i.on { background: #ffc400; box-shadow: 0 1px 0 #b97a00; }
.isle[disabled] .dots { visibility: hidden; }

.foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { background: rgba(255, 250, 240, .92); border-radius: 999px; padding: 6px 14px; font-size: 14.5px; font-weight: 600; box-shadow: 0 3px 0 rgba(58, 36, 22, .2); }
.chip[aria-pressed="false"] { background: rgba(255, 250, 240, .55); color: var(--ink-2); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(58, 36, 22, .2); }
.chip.warn { background: var(--red); color: #fff; }
.fine { margin: 0; font-size: 12.5px; color: rgba(255, 248, 232, .9); text-shadow: 0 1px 0 rgba(58, 30, 12, .55); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.fine .ver { display: inline-block; padding: 2px 9px; border-radius: 999px; background: rgba(58, 30, 12, .35); font-weight: 600; font-variant-numeric: tabular-nums; text-shadow: none; }
.fine .ver.old { background: var(--red); color: #fff; }
.fine .link { font-size: 12.5px; color: rgba(255, 248, 232, .8); text-decoration: underline; text-decoration-color: rgba(255, 248, 232, .4); text-shadow: 0 1px 0 rgba(58, 30, 12, .55); padding: 4px 2px; }
.fine .link.warn { color: #fff; background: var(--red); border-radius: 999px; padding: 2px 9px; text-decoration: none; text-shadow: none; }

.card {
  background: var(--cream); border-radius: 28px; padding: 26px 28px 24px; width: min(420px, 100%); text-align: center;
  box-shadow: var(--shadow); animation: card-in .32s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.card h2 { margin: 0; font-size: clamp(30px, 6vw, 42px); line-height: 1.05; font-weight: 700; }
.card .sub { margin: 8px 0 0; color: var(--ink-2); }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1 1 0; }
.big, .mid { border-radius: 16px; padding: 13px 22px; font-weight: 700; font-size: 20px; }
.big { color: #fff; background: linear-gradient(180deg, #ffa53a, var(--orange)); box-shadow: 0 6px 0 var(--orange-d); }
.mid { background: #f1e6d2; box-shadow: 0 5px 0 #d8c8ad; font-size: 18px; white-space: nowrap; }
.big:active, .mid:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--orange-d); }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.row .chip { background: #f1e6d2; }
.row .chip[aria-pressed="false"] { background: #f6efe2; color: #a48c78; }
.keys { margin: 16px 0 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.keys b { color: var(--ink); font-weight: 600; }

/* the result: three numbers, three medals, on */
.nums3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.nums3 .num { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.nums3 .num b { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.nums3 .num b.stars svg { width: 26px; height: 26px; filter: none; }
.nums3 .num b.stars svg path { fill: #eadfcd; stroke: none; }
.nums3 .num b.stars svg.on path { fill: #ffc400; }
.nums3 .num span { color: var(--ink-2); font-weight: 600; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; }
.nums3 .num i { font-style: normal; font-size: 12.5px; font-weight: 700; color: var(--green); min-height: 1.3em; }

/* medals: three seeds that light up */
.medals { display: inline-flex; gap: 10px; justify-content: center; }
.medal {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px; color: #b9ab98;
  font-size: 12.5px; font-weight: 600; width: 92px; text-align: center; line-height: 1.15;
}
.medal svg { width: 44px; height: 44px; padding: 8px; border-radius: 50%; background: #efe6d6; fill: #c9bba8; box-shadow: inset 0 0 0 2px #e4d8c4; }
.medal svg .stem, .medal svg .hand { fill: none; stroke: #c9bba8; stroke-width: 1.8; stroke-linecap: round; }
.medal.on { color: var(--ink); }
.medal.on svg { background: radial-gradient(circle at 35% 30%, #fff3b0, #ffc400 65%, #e39a00); fill: #fff; box-shadow: 0 4px 0 #b97a00; }
.medal.on svg .stem, .medal.on svg .hand { stroke: #fff; }
.medal.new svg { animation: medal-in .6s cubic-bezier(.2, 1.6, .4, 1) .9s backwards; }
.medal.new i::after { content: ' · new'; color: var(--green); }
@keyframes medal-in { 0% { transform: scale(.2) rotate(-40deg); } }
.medal i { font-style: normal; }
#res-medals { display: flex; margin-top: 16px; }

/* ── a phone ────────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  body { font-size: 16px; }
  .pill { font-size: 17px; padding: 6px 12px 6px 8px; }
  .pill svg { width: 24px; height: 24px; }
  .round { width: 42px; height: 42px; }
  .stars svg { width: 28px; height: 28px; }
  #hud { gap: 6px; padding-left: calc(10px + var(--sa-left)); padding-right: calc(10px + var(--sa-right)); }
  #hud .right { gap: 6px; }
  #hint { font-size: 16.5px; padding: 10px 16px; }
  .card { padding: 20px 18px 18px; border-radius: 24px; }
  .stack { margin-top: 14px; gap: 8px; }
  .big, .mid { padding: 11px 14px; font-size: 18px; }
  .mid { font-size: 16px; }
  .chip { font-size: 13px; padding: 5px 11px; }
  .combo { font-size: 16px; top: calc(56px + var(--sa-top)); left: calc(10px + var(--sa-left)); }
  .medal { width: 78px; font-size: 11.5px; }
  .medal svg { width: 38px; height: 38px; padding: 7px; }
  #res-medals { margin-top: 12px; }
  .nums3 { margin-top: 12px; }
  .nums3 .num b { font-size: 24px; }
  .isles { gap: 9px; }
  .land-isles { gap: 6px; }
  .land small { font-size: 9.5px; letter-spacing: .07em; max-width: 64px; }
  .isle { width: 50px; }
  .isle .ico { width: 36px; height: 36px; }
  .menu { gap: 12px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #say { top: calc(64px + var(--sa-top)); font-size: 16px; padding: 12px 16px 9px; }
  .logo { font-size: clamp(44px, 15vh, 76px); margin-top: 0; }
  .menu { gap: 8px; padding-top: 6px; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; }
  .play { width: auto; padding: 8px 26px 7px; flex-direction: row; gap: 10px; align-items: baseline; border-radius: 18px; }
  .play span { font-size: 24px; }
  .play small { font-size: 14px; margin-top: 0; }
  .isle { width: 46px; padding: 4px 2px 3px; }
  .isle .ico { width: 32px; height: 32px; }
  .foot, .fine { flex-basis: 100%; }
  .fine { margin-top: -2px; }
  #jump { width: 84px; height: 84px; bottom: calc(20px + var(--sa-bottom)); }
  #caption { top: 12%; padding: 6px 20px 8px; }
  #caption b { font-size: 36px; }
  /* the cards have to fit 390 px */
  .card { padding: 14px 22px 14px; width: min(460px, 100%); }
  .card h2 { font-size: 26px; }
  .card .sub { margin-top: 2px; font-size: 15px; }
  .nums3 { margin-top: 8px; }
  .nums3 .num b { font-size: 22px; }
  .nums3 .num i { min-height: 0; }
  .medal { width: 70px; font-size: 10.5px; gap: 2px; }
  .medal svg { width: 32px; height: 32px; padding: 6px; }
  #res-medals { margin-top: 6px; }
  .stack { margin-top: 10px; gap: 8px; }
  .big, .mid { padding: 9px 14px; font-size: 17px; }
  .keys { margin-top: 10px; font-size: 13px; }
  .row { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, #hint, #toast, #caption, .pill.bump, .stars svg.pop { animation: none; }
  .isle { transition: none; }
}
