@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --ink: #1b1a22;
  --sky: #5ccafb;
  --sun: #ffd21f;
  --paper: #ffffff;
  --edge: 4px;
  --pad: clamp(16px, 3.2vw, 36px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-weight: 600;
  font-size: 20px;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#stage, #confetti {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#confetti { pointer-events: none; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui button { pointer-events: auto; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
}
.screen.on { display: flex; }

/* sticker lettering: white with a thick ink edge, like the bug art */
.sticker {
  color: var(--paper);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.01em;
  -webkit-text-stroke: 0.15em var(--ink);
  paint-order: stroke fill;
}
h1.sticker { font-size: clamp(76px, 19vw, 210px); margin-top: 3vh; }
h2.sticker { font-size: clamp(38px, 7vw, 76px); margin-top: clamp(40px, 5vh, 56px); }
h2.sticker.huge { font-size: clamp(54px, 12vw, 130px); margin-top: 5vh; }

.lead {
  margin-top: 14px;
  font-size: clamp(19px, 2.6vw, 28px);
  line-height: 1.25;
  max-width: 22em;
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
  padding: 8px 22px;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible { outline: 5px solid var(--paper); outline-offset: 3px; }

.btn {
  background: var(--sun);
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1;
  padding: 18px 44px;
  min-height: 68px;
}
.btn.big { font-size: clamp(30px, 4.6vw, 46px); padding: 22px 64px; min-height: 84px; }
.btn[disabled] { background: var(--paper); opacity: 0.55; cursor: default; }
#s-title .btn, #s-finale .btn, #s-win .btn { margin-top: auto; margin-bottom: 4vh; }

.round {
  position: absolute; z-index: 5;
  top: calc(var(--pad) * 0.7 + env(safe-area-inset-top));
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
}
.round[hidden] { display: none; }
.round svg { width: 30px; height: 30px; }
#b-back { left: calc(var(--pad) * 0.7); }
#b-mute { right: calc(var(--pad) * 0.7); }
#b-mute .cross { display: none; }
#b-mute[aria-pressed="true"] .waves { display: none; }
#b-mute[aria-pressed="true"] .cross { display: block; }

.dock {
  margin-top: auto;
  width: 100%;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(12px, 2vh, 20px);
  padding-bottom: 1vh;
}

.cards, .tiles {
  display: grid;
  gap: clamp(8px, 1.6vw, 18px);
  width: min(100%, 860px);
}
.cards { grid-template-columns: repeat(4, 1fr); }
.tiles { grid-template-columns: repeat(3, 1fr); width: min(100%, 720px); }

.card, .tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 26px;
  padding: 12px 6px 10px;
  font-weight: 700;
  font-size: clamp(15px, 2.2vw, 24px);
  line-height: 1.05;
}
.card img { width: clamp(52px, 11vw, 104px); height: clamp(52px, 11vw, 104px); object-fit: contain; pointer-events: none; }
.card[aria-pressed="true"] { background: var(--sun); }

.tile { font-size: clamp(20px, 3vw, 32px); padding: 14px 6px 12px; }
.tile .art { position: relative; width: clamp(60px, 12vw, 110px); height: clamp(60px, 12vw, 110px); display: block; }
.tile .art svg, .tile .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tile .prize { display: none; }
.tile.won { background: var(--sun); }
.tile.won svg { display: none; }
.tile.won .prize { display: block; }

/* in-game */
.hud {
  margin-top: 6px;
  min-height: 56px;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(4px, 1vw, 10px);
  width: 100%;
  padding: 0 70px;
}
.slot {
  width: clamp(24px, 6.4vw, 52px); height: clamp(24px, 6.4vw, 52px);
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
  overflow: hidden;
  display: grid; place-items: center;
  flex: none;
}
.slot img { width: 86%; height: 86%; object-fit: cover; object-position: top; transform: scale(0); }
.slot.mush img { object-fit: contain; }
.track {
  position: relative;
  width: min(100%, 560px); height: 26px;
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
}
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--sun); border-radius: 999px; }
.track .marker { position: absolute; top: 50%; left: 0; width: 54px; height: 54px; margin: -27px 0 0 -27px; object-fit: contain; }
.track .flag { position: absolute; right: -6px; top: -22px; width: 34px; height: 34px; }

.count {
  position: absolute; left: 0; right: 0; top: 30%;
  font-size: clamp(70px, 17vw, 190px);
  pointer-events: none;
}
.hint {
  margin-top: auto;
  font-size: clamp(19px, 2.8vw, 30px);
  line-height: 1.2;
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
  padding: 10px 26px;
}

.gift { display: flex; align-items: center; gap: 12px; padding: 6px 26px 6px 14px; }
.gift img { height: clamp(56px, 11vh, 92px); width: auto; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 560px) {
  .cards { grid-template-columns: repeat(2, 1fr); width: min(100%, 340px); }
  .card { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 12px; border-radius: 22px; font-size: 17px; text-align: left; }
  .card img { width: 50px; height: 50px; }
  .hud { padding: 0 64px; gap: 3px; }
  .slot { border-width: 3px; }
  .track .marker { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
}
@media (max-height: 520px) {
  h2.sticker { font-size: clamp(30px, 8vh, 48px); margin-top: 2px; }
  h1.sticker { font-size: clamp(60px, 26vh, 130px); margin-top: 0; }
  .card { flex-direction: row; gap: 10px; padding: 6px 12px; }
  .card img { width: 46px; height: 46px; }
  .tile { flex-direction: row; gap: 12px; padding: 8px 12px; }
  .tile .art { width: 52px; height: 52px; }
  .btn { min-height: 56px; padding: 12px 36px; }
  .btn.big { min-height: 64px; padding: 14px 48px; }
}
