@font-face {
  font-family: "Shrikhand";
  src: url("/fonts/shrikhand.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("/fonts/fredoka.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
/* Cyrillic only: Shrikhand and Fredoka have no Russian letters, so these fill in for them letter by letter. */
@font-face {
  font-family: "Lobster";
  src: url("/fonts/lobster-cyrillic.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Nunito";
  src: url("/fonts/nunito-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --tangerine: #ff8a1f;
  --pink: #ff4f9a;
  --violet: #7b4bc9;
  --indigo: #2a1666;
  --night: #1a0e45;
  --bud: #9bdb4d;
  --smoke: #fff1d9;
  --ink: #2a1446;
  --panel: rgba(36, 18, 88, 0.88);
  --display: "Shrikhand", "Lobster", "Cooper Black", Georgia, serif;
  --body: "Fredoka", "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--indigo);
  color: var(--smoke);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }

button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 3px solid var(--bud); outline-offset: 3px; }

/* Sticker buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 48px;
  padding: 10px 22px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--smoke);
  color: var(--ink);
  font-weight: 600;
  font-size: 18px;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: 0 5px 0 var(--ink); }
.btn-primary { background: var(--tangerine); }
.btn-big { font-family: var(--display); font-weight: 400; font-size: 30px; padding: 8px 40px 12px; min-height: 64px; }
.btn-quiet {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--smoke);
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 500;
}
.btn-quiet:active { transform: none; box-shadow: none; }
.btn-count {
  min-width: 1.8em;
  padding: 0 0.5em;
  border-radius: 999px;
  background: var(--ink);
  color: var(--smoke);
  font-size: 15px;
  line-height: 1.6;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--smoke);
  border-radius: 50%;
  background: rgba(26, 14, 69, 0.5);
}
.icon-btn svg { width: 22px; height: 22px; fill: var(--smoke); }
.icon-btn svg .wave { stroke: var(--smoke); fill: none; }

.sound-btn {
  position: fixed;
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  z-index: 30;
}
.sound-btn[aria-pressed="true"] .ico-off,
.sound-btn[aria-pressed="false"] .ico-on { display: none; }
body.playing .sound-btn,
body[data-screen="over"] .sound-btn,
body[data-screen="stash"] .sound-btn { display: none; }

/* Language picker: top left, on the age check and the title screen only */
.lang {
  position: fixed;
  top: calc(12px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  z-index: 30;
  display: none;
}
body[data-screen="gate"] .lang,
body[data-screen="title"] .lang { display: block; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px 0 11px;
  border: 2px solid var(--smoke);
  border-radius: 999px;
  background: rgba(26, 14, 69, 0.5);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
}
.lang-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--smoke); stroke-width: 1.8; }
.lang-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: max-content;
  min-width: 210px;
  max-width: calc(100vw - 24px);
  padding: 8px;
  border: 3px solid var(--smoke);
  border-radius: 22px;
  background: rgba(36, 18, 88, 0.97);
  box-shadow: 6px 6px 0 var(--pink);
  animation: pop-in 200ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
  transform-origin: top left;
}
.lang-menu-h { padding: 4px 10px 6px; font-size: 13px; opacity: 0.75; }
.lang-list { display: grid; gap: 2px; }
.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-weight: 600;
  text-align: left;
}
.lang-item:hover { background: rgba(255, 241, 217, 0.08); }
.lang-item[aria-pressed="true"] { background: rgba(155, 219, 77, 0.16); }
.lang-item[aria-pressed="true"]::after { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--bud); }

.donut {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: radial-gradient(circle, var(--indigo) 0 20%, var(--ink) 21% 27%, #ff6fb0 28% 60%, #e9a75b 61% 100%);
  vertical-align: -0.12em;
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  height: 100dvh;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#screen-over, #screen-stash, #screen-pause, #screen-gate { background: rgba(26, 14, 69, 0.35); }

.panel {
  width: 100%;
  max-width: 430px;
  margin: auto;
  padding: 26px 22px 22px;
  border: 3px solid var(--smoke);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--pink);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
  animation: pop-in 260ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.panel h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 36px;
  line-height: 1.05;
  margin-bottom: 8px;
}
.panel h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 22px;
  margin: 18px 0 8px;
  text-align: left;
}
.panel p { margin-bottom: 10px; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.row-small { margin-top: 12px; }
.row-small .btn { font-size: 16px; min-height: 44px; padding: 8px 18px; }

@keyframes pop-in {
  from { transform: scale(0.85) rotate(-2deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Title */
.screen-title {
  justify-content: space-between;
  text-align: center;
  pointer-events: none;
}
.screen-title > * { pointer-events: auto; }
.logo {
  margin-top: calc(2vh + 36px);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(72px, min(21vw, 15vh), 150px);
  line-height: 0.86;
  color: var(--smoke);
  text-shadow:
    0.035em 0.035em 0 var(--pink),
    0.07em 0.07em 0 var(--tangerine),
    0.105em 0.105em 0 var(--violet),
    0.14em 0.14em 0 var(--night);
  transform: rotate(-6deg);
  pointer-events: none;
}
.logo-line { display: block; white-space: nowrap; }
.logo-line + .logo-line { margin-left: 0.5em; }
.logo-line span {
  display: inline-block;
  animation: wave 2.6s ease-in-out infinite;
}
.logo-line:first-child span:nth-child(2) { animation-delay: -0.2s; }
.logo-line:first-child span:nth-child(3) { animation-delay: -0.4s; }
.logo-line + .logo-line span:nth-child(1) { animation-delay: -0.6s; }
.logo-line + .logo-line span:nth-child(2) { animation-delay: -0.8s; }
.logo-line + .logo-line span:nth-child(3) { animation-delay: -1s; }
.logo-line + .logo-line span:nth-child(4) { animation-delay: -1.2s; }
.logo-line + .logo-line span:nth-child(5) { animation-delay: -1.4s; }
@keyframes wave {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-0.09em) rotate(4deg); }
}

.how {
  max-width: 22em;
  margin: 0 auto 14px;
  font-weight: 500;
  text-shadow: 0 2px 0 rgba(26, 14, 69, 0.6);
}
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title-best {
  margin-top: 12px;
  font-weight: 600;
  text-shadow: 0 2px 0 rgba(26, 14, 69, 0.6);
}
.fine {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.75;
}
.title-bottom { display: flex; flex-direction: column; align-items: center; }

/* Missions */
.missions {
  display: grid;
  gap: 6px;
  margin: 14px auto 0;
  width: 100%;
  max-width: 380px;
  text-align: left;
  font-size: 14px;
}
.missions:empty { display: none; }
.missions-title {
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(26, 14, 69, 0.55);
}
.mission { display: grid; grid-template-columns: 20px 1fr auto; gap: 3px 8px; align-items: center; line-height: 1.25; }
.mission .check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--smoke);
  border-radius: 50%;
}
.mission.done .check { background: var(--bud); border-color: var(--bud); }
.mission.done .m-text { text-decoration: line-through; opacity: 0.7; }
.mission .m-reward { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; font-size: 13px; }
.mission .m-prog { grid-column: 2 / 4; height: 4px; border-radius: 4px; background: rgba(255, 241, 217, 0.18); overflow: hidden; }
.mission .m-prog i { display: block; height: 100%; background: var(--bud); transform-origin: left; }
.missions-label { font-size: 13px; opacity: 0.75; margin-bottom: 2px; }

/* HUD */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(14px + var(--safe-l));
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(26, 14, 69, 0.55);
}
.hud-alt { display: flex; flex-direction: column; min-width: 0; }
.hud-ft { font-family: var(--display); font-size: 30px; line-height: 1; white-space: nowrap; }
.hud-zone { font-size: 13px; font-weight: 600; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-buzz { display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 6px; }
.hud-buzz-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; opacity: 0.9; }
.hud-buzz-track {
  display: block;
  width: clamp(96px, 30vw, 200px);
  height: 14px;
  border: 2px solid var(--smoke);
  border-radius: 999px;
  background: rgba(26, 14, 69, 0.55);
  overflow: hidden;
}
.hud-buzz-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bud), var(--tangerine) 65%, var(--pink));
  transform-origin: left;
  transform: scaleX(0.7);
}
.hud.low .hud-buzz-track { animation: low-pulse 0.5s ease-in-out infinite alternate; }
.hud.brownie .hud-buzz-fill { background: linear-gradient(90deg, #ff4f9a, #ff8a1f, #ffd15c, #9bdb4d, #6fd3ff, #b98cff); }
@keyframes low-pulse { to { border-color: var(--pink); box-shadow: 0 0 12px var(--pink); } }
.hud-right { display: flex; justify-content: flex-end; align-items: center; gap: 10px; pointer-events: auto; }
.munch { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 18px; }
.munch-big { font-size: 22px; }

/* Banners */
.banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 19%;
  z-index: 12;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}
.banner.on { animation: banner 2.6s ease both; }
.banner b {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 9vw, 52px);
  line-height: 1;
  text-shadow: 0.05em 0.05em 0 var(--pink), 0.1em 0.1em 0 var(--night);
}
.banner small { display: block; margin-top: 8px; font-weight: 600; font-size: 15px; text-shadow: 0 2px 0 var(--night); }
@keyframes banner {
  0% { opacity: 0; transform: scale(0.6) rotate(-6deg); }
  12% { opacity: 1; transform: scale(1.08) rotate(2deg); }
  20% { transform: scale(1) rotate(0); }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-30px); }
}

.warn {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 22%;
  z-index: 12;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(26px, 8vw, 40px);
  line-height: 1;
  color: var(--pink);
  text-shadow: 0.06em 0.06em 0 var(--night);
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms;
}
.warn small { display: block; margin-top: 6px; font-family: var(--body); font-weight: 600; font-size: 16px; color: var(--smoke); }
.warn.on { opacity: 1; animation: wobble 0.35s ease-in-out infinite alternate; }
@keyframes wobble { from { transform: rotate(-3deg) scale(1); } to { transform: rotate(3deg) scale(1.05); } }

/* Game over: the buttons stay put, the middle scrolls when the screen is too short */
.panel-over { display: flex; flex-direction: column; max-height: 100%; padding: 20px 18px 18px; }
.over-scroll {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 -8px;
  padding: 0 8px 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.over-actions { flex: none; }
.panel-over h2 { font-size: 30px; margin-bottom: 2px; }
.panel-over p { margin-bottom: 6px; }
.panel-over .row { margin-top: 12px; }
.panel-over .row-small { margin-top: 10px; }
.over-ft { font-family: var(--display); font-size: 62px; line-height: 1; margin: 2px 0 4px; text-shadow: 0.05em 0.05em 0 var(--pink); }
.over-ft .unit { font-size: 26px; margin-left: 6px; }
.over-zone { font-weight: 600; font-size: 17px; }
.over-cause { opacity: 0.9; font-size: 15px; line-height: 1.35; }
.next { display: grid; gap: 5px; margin: 4px 0 10px; font-size: 14px; }
.bar { display: block; height: 8px; border-radius: 8px; background: rgba(255, 241, 217, 0.18); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--bud), var(--tangerine)); transform-origin: left; }
.over-earn { display: grid; justify-items: center; gap: 2px; }
.over-earn b { display: inline-flex; gap: 8px; align-items: center; font-size: 20px; font-weight: 700; }
.over-earn small { font-size: 14px; opacity: 0.85; }
.over-tip { margin-top: 10px; font-size: 13px; opacity: 0.8; }
.panel-over .missions { margin-top: 10px; gap: 5px; }
.mission.done-now .check { background: var(--bud); border-color: var(--bud); }
.mission.done-now .m-text { font-weight: 600; }

/* Stash */
.panel-stash {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  padding: 18px 16px 16px;
  text-align: left;
}
.stash-scroll {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 -6px;
  padding: 0 6px 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel-stash .row { margin-top: 12px; }
.panel-stash h3 { margin: 12px 0 8px; }
.stash-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stash-head h2 { margin: 0; }
.stash-sub { font-size: 14px; opacity: 0.85; }
.upgrades, .skins { list-style: none; margin: 0; padding: 0; }
.upgrades { display: grid; gap: 7px; }
.upgrade {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(26, 14, 69, 0.6);
}
.upgrade b { font-weight: 600; font-size: 16px; }
.upgrade .u-desc { grid-column: 1; margin: 0; font-size: 12.5px; opacity: 0.85; line-height: 1.25; }
.upgrade .pips { display: flex; gap: 4px; margin-top: 2px; }
.upgrade .pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255, 241, 217, 0.22); }
.upgrade .pips i.on { background: var(--bud); }
.upgrade .btn { grid-column: 2; grid-row: 1 / 4; font-size: 15px; min-height: 40px; padding: 6px 14px; box-shadow: 0 4px 0 var(--ink); }
.skins { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.skin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  height: 100%;
  padding: 6px 2px 8px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: rgba(26, 14, 69, 0.6);
  font-size: 11.5px;
  line-height: 1.15;
  text-align: center;
}
.skin canvas { width: 44px; height: 44px; }
.skin.on { border-color: var(--bud); }
.skin .s-price { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; opacity: 0.9; }
.skin.locked canvas { filter: grayscale(0.6) brightness(0.8); }

.gate-no { margin-top: 14px; font-weight: 600; color: var(--bud); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  z-index: 40;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border: 2px solid var(--smoke);
  border-radius: 999px;
  background: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  box-shadow: 4px 4px 0 var(--pink);
  transform: translate(-50%, calc(100% + 60px));
  visibility: hidden;
  transition: transform 260ms cubic-bezier(0.2, 1.4, 0.4, 1), visibility 0s 260ms;
  pointer-events: none;
}
.toast.on { transform: translate(-50%, 0); visibility: visible; transition: transform 260ms cubic-bezier(0.2, 1.4, 0.4, 1); }

body.og .title-bottom, body.og .sound-btn, body.og .lang { display: none; }
body.og .logo { font-size: 140px; margin-top: 0; }

@media (max-height: 760px) {
  .over-tip { display: none; }
  .over-ft { font-size: 54px; }
  .panel-over h2 { font-size: 27px; }
  .stash-sub { display: none; }
}

@media (max-height: 700px) {
  .missions-title { display: none; }
  .logo { font-size: clamp(60px, min(19vw, 14vh), 120px); }
  .how { margin-bottom: 10px; }
}

/* Phone held sideways: title beside the couch, game-over result beside its buttons */
@media (orientation: landscape) and (max-height: 520px) {
  .screen-title { flex-direction: row; align-items: center; }
  .logo { margin: 0 0 0 2vw; font-size: clamp(44px, min(8vw, 18vh), 96px); }
  .title-bottom { width: min(320px, 38vw); }
  .how { font-size: 15px; margin-bottom: 10px; }
  .title-actions { gap: 10px; }
  .btn-big { font-size: 26px; min-height: 56px; }
  .panel-over { flex-direction: row; align-items: center; gap: 18px; max-width: 760px; }
  .over-scroll { align-self: stretch; }
  .over-actions .row:first-child { margin-top: 0; }
}

@media (min-width: 720px) {
  .hud-ft { font-size: 38px; }
  .hud-zone { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-line span, .warn.on, .hud.low .hud-buzz-track { animation: none; }
  .panel { animation: none; }
  .banner.on { animation: banner-plain 2.6s linear both; }
  @keyframes banner-plain { 0%, 100% { opacity: 0; } 10%, 85% { opacity: 1; } }
}
