/* Leafy Bugs: base (font, sizes, colors, buttons, plates, banner). Sizes in --u = 1% of the screen's shorter side, taken
   from the designs (941 px = 100u). Clean Fredoka 600 text, no outline: reads thanks to the plate and a short
   shadow. Stretching pieces (pill, plate, banner, panel, row) are 9 slices assembled on a canvas by src/lib/nine.js. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/fredoka-600-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;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/fredoka-600-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;
}
/* Cyrillic (ru): Fredoka does not have it; Nunito (OFL, rounded) is added only for those letters, inside the package, so
   Safari and Chrome show the same letter (before, each engine picked a different system font) */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/nunito-cyrillic-900.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
:root {
  /* 11 px cap: on a huge screen (5120x1440) the interface does not grow without a limit */
  --u: min(1vmin, 11px);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --violet: #13a39b;
  --violet-dk: #0a6b66;
  --pink: #f048a8;
  --sky: #3cc8bf; /* Leafy Bugs: "violet" = aqua turquoise */
  --shadow: 0 0.06em 0 rgba(5, 66, 64, 0.38), 0 0.1em 0.12em rgba(5, 66, 64, 0.18); /* short shadow, no ring */
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Fredoka has no Cyrillic or CJK: system fallback, rounded and bold when available */
  --font:
    'Fredoka', 'Nunito', 'Arial Rounded MT Bold', 'Hiragino Maru Gothic ProN', 'Yu Gothic UI', 'Meiryo',
    'Malgun Gothic', 'Apple SD Gothic Neo', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --cap: -0.03em; /* the ink of Fredoka 600 sits a hair below the middle of the line: moves it up (measured) */
  --corner: max(44px, calc(var(--u) * 9.6)); /* sound, gear, pause, back */
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
}
body {
  font-family: var(--font);
  font-weight: 600;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
img {
  -webkit-user-drag: none;
  user-select: none;
}
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  position: relative;
}
button:focus {
  outline: none;
}
button:focus-visible {
  outline: max(2px, calc(var(--u) * 0.5)) solid #ffffffb0;
  outline-offset: calc(var(--u) * 0.4);
  border-radius: 999px;
}

#bg {
  position: fixed;
  inset: 0;
  background: var(--sky) url(../assets/bg/bg-p.webp) center bottom / cover no-repeat;
  transition: background-image 0.3s ease;
} /* src/ui/bg.js swaps to the world / menu scenery */
body.land #bg {
  background-image: url(../assets/bg/bg-l.webp);
}
@media (min-aspect-ratio: 2/1) {
  body.land #bg {
    background-image: url(../assets/bg/bg-xl.webp);
  }
}
#board {
  position: fixed;
  inset: 0;
  display: none;
  touch-action: none;
}
body[data-screen='game'] #board {
  display: block;
}

/* ---- text ---- */
.face,
.lbl,
.rowtxt,
.badge {
  letter-spacing: 0.005em;
  line-height: 1.15;
  white-space: nowrap;
  text-shadow: var(--shadow);
}
.face {
  display: block;
  min-width: 0;
  max-width: 100%;
  text-align: center;
  pointer-events: none;
  translate: 0 calc(var(--fy, 0px) + var(--cap) + var(--pd, 0px));
}

/* Japanese, Korean and Chinese come from the system font: their ink sits higher (measured) */
:lang(ja),
:lang(ko),
:lang(zh-Hans) {
  --cap: 0.06em;
}

/* ---- press: data-p=dn while the finger is on the button (src/ui/press.js). The art swaps to the "-down" one, the text and icon
   go down with it and, on release, the button springs back (scale, not transform, to avoid clashing with animations). ---- */
button {
  transition: scale 0.26s var(--pop);
}
[data-p='dn'] {
  scale: 0.96;
  --pd: calc(var(--u) * 0.4);
  transition-duration: 0.05s;
}
[data-p='dn'] .ic,
[data-p='dn'] .pi {
  translate: 0 var(--pd);
}
body.reduced button {
  transition: none;
}

/* ---- round button (btn-round art; icon drawn in the middle of the face) ---- */
.rb,
.hb {
  width: var(--s);
  height: var(--s);
  background: url(../assets/ui/btn-round.webp) center / 100% 100% no-repeat;
  flex: none;
}
.rb.pink,
.hb.pink {
  background-image: url(../assets/ui/btn-round-pink.webp);
}
.rb[data-p='dn'],
.hb[data-p='dn'] {
  background-image: url(../assets/ui/btn-round-down.webp);
}
.rb.pink[data-p='dn'],
.hb.pink[data-p='dn'] {
  background-image: url(../assets/ui/btn-round-pink-down.webp);
}
.rb {
  --s: var(--corner);
}
.rb:disabled {
  opacity: 0.45;
  cursor: default;
}
.ic {
  position: absolute;
  left: 24%;
  top: 21%;
  width: 52%;
  height: 52%;
  object-fit: contain;
  pointer-events: none;
}
.rb::before,
.x::before,
.sw::before,
.slider::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
}

/* ---- pill (9 slices: only the middle stretches; the round ends stay whole). Grows with the text up to a cap
   (--wmax) and only then does the letter shrink (fit.js). Never wraps onto two lines. ---- */
.pb,
.plate,
.ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--h) * 0.16);
  height: var(--h);
  border-style: solid;
  border-color: transparent;
}
.pb {
  --h: calc(var(--u) * 12.5);
  --cw: calc(var(--h) * 0.44);
  min-width: var(--w, calc(var(--u) * 44));
  max-width: var(--wmax, calc(var(--u) * 70));
  border-width: 0 var(--cw);
  border-image: url(../assets/ui/pill-violet.webp) 0 76 fill / 0 var(--cw);
}
.pb.pink {
  border-image-source: url(../assets/ui/pill-pink.webp);
}
.pb .face {
  flex: 0 1 auto;
  font-size: calc(var(--h) * 0.46);
  --fy: calc(var(--h) * -0.006);
} /* pill face (measured: the whole silhouette) */
.pb[data-p='dn'][data-nd] {
  background-image: var(--nine-down) !important;
}
.pb::after {
  content: '';
  position: absolute;
  left: calc(var(--cw) * -1);
  right: calc(var(--cw) * -1);
  top: 50%;
  height: max(100%, 44px);
  translate: 0 -50%;
}

/* plate (value, world title, stars): plate art, darker */
.plate {
  --h: calc(var(--u) * 7);
  --cw: calc(var(--h) * 0.46);
  border-width: 0 var(--cw);
  border-image: url(../assets/ui/plate.webp) 0 60 fill / 0 var(--cw);
}
.plate .face {
  flex: 0 1 auto;
  font-size: calc(var(--h) * 0.52);
  --fy: calc(var(--h) * 0.004);
}
.plate .pi {
  height: calc(var(--h) * 0.78);
  width: auto;
  flex: none;
  margin-left: calc(var(--cw) * -0.35);
  translate: 0 calc(var(--h) * -0.03);
}

/* title banner: straight, one size in the whole game, mounted on the top edge of the panel */
.ribbon {
  --h: calc(var(--u) * 10.5);
  --cw: calc(var(--h) * 0.36);
  width: calc(var(--u) * 56);
  border-width: 0 var(--cw);
  border-image: url(../assets/ui/band.webp) 0 38 fill / 0 var(--cw);
  pointer-events: none;
}
.ribbon .face {
  font-size: calc(var(--h) * 0.56);
  --fy: calc(var(--h) * -0.04);
}

/* ---- helps: big round with a counter badge ---- */
.hb {
  --s: clamp(56px, calc(var(--u) * 15.5), 110px);
}
.hb .ic {
  left: 22%;
  top: 19%;
  width: 56%;
  height: 56%;
}
.badge {
  position: absolute;
  right: -6%;
  top: -8%;
  width: 38%;
  height: 38%;
  display: grid;
  place-items: center;
  background: url(../assets/ui/badge.webp) center / 100% 100%;
  font-size: calc(var(--s) * 0.2);
  line-height: 1;
  padding-bottom: 0.1em;
}
.hb.off {
  filter: saturate(0.35) brightness(0.88);
}
.hb.off .badge {
  visibility: hidden;
}

/* 9 slices assembled on a canvas: the .nine class turns off the browser's border-image and uses the pasted image as background */
.nine {
  border-image: none !important;
  background-size: 100% 100% !important;
  background-origin: border-box !important;
  background-clip: border-box !important;
  background-repeat: no-repeat !important;
}

/* ---- top right corner: sound and gear in the same place on every screen; pause beside them, only in the game ---- */
#corner {
  position: fixed;
  z-index: 5;
  top: calc(var(--sat) + var(--u) * 1.6);
  right: calc(var(--sar) + var(--u) * 2.4);
  display: flex;
  gap: calc(var(--u) * 1.6);
}
#b-pause {
  display: none;
}
body[data-screen='game'] #b-pause {
  display: block;
}
body[data-screen='none'] #corner {
  visibility: hidden;
}

/* ---- loading (index.html #boot): game logo and a discreet bar; disappears with a fade, no blinking ---- */
#boot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 6);
  opacity: 0;
  transition: opacity 0.45s ease;
}
#boot.show {
  opacity: 1;
} /* only shows if loading goes over 0.4 s: a fast launch shows nothing (no blinking) */
#boot.done {
  opacity: 0;
  pointer-events: none;
}
.boot-logo {
  width: min(calc(var(--u) * 60), 420px);
  aspect-ratio: 879 / 644;
}
.boot-bar {
  width: min(calc(var(--u) * 44), 300px);
  height: max(8px, calc(var(--u) * 1.6));
  border-radius: 999px;
  background: rgba(5, 66, 64, 0.28);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #13a39b, #3fd0c4);
  border-radius: inherit;
  transform: scaleX(0.04);
  transform-origin: left;
  transition: transform 0.25s ease-out;
}

/* ---- screens ---- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  padding: calc(var(--sat)) calc(var(--sar)) calc(var(--sab)) calc(var(--sal));
}
body[data-screen='start'] #s-start,
body[data-screen='menu'] #s-menu,
body[data-screen='map'] #s-map,
body[data-screen='game'] #s-game {
  display: flex;
}
#s-game {
  pointer-events: none;
}
#s-game button {
  pointer-events: auto;
}
.screen.enter {
  animation: scr-in 0.32s ease-out both;
}
@keyframes scr-in {
  from {
    opacity: 0;
    translate: 0 calc(var(--u) * 2);
  }
}
body.reduced .screen.enter {
  animation-duration: 1ms;
} /* 1ms, not none: with none the entrance plays again when the option is turned off (blink) */
/* End of css/base.css (complete file). */
