/* Mingli Games — shared shell.
 *
 * Design target: a five-year-old on an iPad. Everything tappable is at least
 * 56px, nothing depends on reading a sentence, and no interaction needs
 * precision dragging. Colour does the talking; text is a label at most.
 */

:root {
  --sunny: #ffb703;
  --orange: #fb8500;
  --sky: #219ebc;
  --sky-soft: #8ecae6;
  --mint: #06d6a0;
  --pink: #ef476f;
  --purple: #9b5de5;
  --cream: #fff8ec;
  --ink: #2b2118;
  --ink-soft: #6b5a49;
  --card: #ffffff;
  --shadow: 0 6px 0 rgba(43, 33, 24, 0.18);
  --shadow-lift: 0 10px 0 rgba(43, 33, 24, 0.18);
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito",
    "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #bfe8ff 0%, #ffe6bd 100%);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body.scrollable {
  overflow: auto;
  height: auto;
  min-height: 100%;
}

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

/* ---------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: none;
  font-family: var(--font);
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  background: var(--card);
  border-radius: 18px;
  min-height: 56px;
  min-width: 56px;
  padding: 0 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 rgba(43, 33, 24, 0.18);
}

.btn[disabled] {
  filter: grayscale(0.7) opacity(0.5);
  pointer-events: none;
}

.btn.round {
  border-radius: 50%;
  padding: 0;
  width: 60px;
  height: 60px;
  font-size: 26px;
}

.btn.big {
  font-size: 28px;
  min-height: 68px;
  padding: 0 28px;
}

.btn.go {
  background: var(--mint);
  color: #04352a;
}
.btn.stop {
  background: var(--pink);
  color: #fff;
}
.btn.sun {
  background: var(--sunny);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.75);
}

/* ------------------------------------------------------------------- hud */

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
}

.hud > * {
  pointer-events: auto;
}

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

.topbar .spacer {
  flex: 1;
  pointer-events: none;
}

.level-pill {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 900;
  font-size: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
}

.goal-chip {
  align-self: center;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 22px;
  font-weight: 800;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 620px);
  text-align: center;
}

.bottombar {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

/* A horizontal tray of controls. Every game has one. */
.run-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- panels */

.veil {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 15, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.panel {
  background: var(--cream);
  border-radius: 32px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 18px 0 rgba(43, 33, 24, 0.25);
  max-width: 460px;
  width: 100%;
  animation: pop 0.32s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 34px;
}

.panel p {
  margin: 0 0 16px;
  font-size: 20px;
  color: var(--ink-soft);
  font-weight: 700;
}

.stars,
.big-icon {
  font-size: 46px;
  letter-spacing: 6px;
  margin: 6px 0 18px;
  min-height: 56px;
}

.big-icon {
  letter-spacing: 0;
}

.star-pop {
  display: inline-block;
  animation: starIn 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes starIn {
  from {
    transform: scale(0) rotate(-40deg);
    opacity: 0;
  }
}

.panel-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 22px;
  padding: 16px 26px;
  font-size: 24px;
  font-weight: 900;
  box-shadow: var(--shadow);
  z-index: 60;
  animation: pop 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-width: 88vw;
  text-align: center;
}

.toast.leaving {
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: translateX(-50%) translateY(-14px);
}

/* ------------------------------------------------------------ level select */

.sheet {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #bfe8ff, #ffe6bd);
  z-index: 40;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(14px, env(safe-area-inset-top)) 14px
    max(24px, env(safe-area-inset-bottom));
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.sheet-head h1 {
  font-size: 28px;
  margin: 0;
}

.world {
  margin: 0 auto 22px;
  max-width: 620px;
}

.world h3 {
  font-size: 21px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.world .blurb {
  font-size: 16px;
  color: var(--ink-soft);
  font-weight: 700;
  margin: 0 0 10px;
}

.lvl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 12px;
}

.lvl {
  aspect-ratio: 1;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  border: none;
  font-family: var(--font);
  font-weight: 900;
  font-size: 30px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.lvl:active {
  transform: translateY(5px);
}

.lvl .mini-stars {
  font-size: 13px;
  letter-spacing: 1px;
  height: 15px;
}

.lvl.locked {
  background: rgba(255, 255, 255, 0.45);
  color: rgba(43, 33, 24, 0.3);
  box-shadow: none;
  pointer-events: none;
}

.lvl.done {
  background: var(--sunny);
}

/* ------------------------------------------------------------------- misc */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .btn {
    font-size: 19px;
    min-height: 52px;
    padding: 0 14px;
  }
  .btn.round {
    width: 54px;
    height: 54px;
    font-size: 23px;
  }
  .goal-chip {
    font-size: 18px;
    padding: 8px 16px;
  }
  .panel h2 {
    font-size: 28px;
  }
}
