@font-face {
  font-family: 'Rubik';
  src: url('../assets/fonts/rubik.woff2') format('woff2');
  font-weight: 500 900;
  font-display: swap;
}

:root {
  --ink: #1f2d4d;
  --ink-soft: #4a5b80;
  --sky: #5db4f5;
  --sky-2: #bfe6ff;
  --card: #ffffff;
  --green: #22a356;
  --green-2: #3fd47a;
  --red: #e23b3b;
  --gold: #ffc531;
  --violet: #5b3a9e;
  font-family: 'Rubik', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(#3d9cf2, #bfe6ff);
  z-index: 50;
}
.boot-balloon {
  width: 46px;
  height: 56px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 35% 30%, #ffb0b0, #ff4b4b 55%, #c92a2a);
  animation: bob 1.2s ease-in-out infinite;
  position: relative;
}
.boot-balloon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 30px;
  background: #fff;
}
@keyframes bob { 50% { transform: translateY(-10px); } }

#app, .game { position: fixed; inset: 0; }
.game { overflow: hidden; }
canvas.world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ------------------------------------------------------------------ top bar */
.top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 0;
  pointer-events: none;
  z-index: 10;
}
.top > * { pointer-events: auto; }
.rbtn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(20, 50, 100, 0.25);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.rbtn svg { width: 26px; height: 26px; }
.goal {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  box-shadow: 0 3px 0 rgba(20, 50, 100, 0.25);
  padding: 5px 12px 6px;
  text-align: center;
}
.goal-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.goal-row img { width: 30px; height: 30px; object-fit: contain; vertical-align: middle; }
.g-me, .g-boss { display: inline-flex; align-items: center; gap: 4px; font-size: 26px; font-weight: 900; line-height: 1; }
.g-me b { color: var(--red); transition: color 0.2s; }
.g-me.ok b { color: var(--green); }
.g-boss b { color: var(--violet); }
.g-boss img { width: 38px; }
.g-vs { font-size: 22px; font-weight: 900; color: var(--ink-soft); }
.goal-t {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.lvl {
  flex: none;
  min-width: 46px;
  height: 46px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 0 rgba(20, 50, 100, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 6px;
}
.lvl small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.lvl b { font-size: 21px; font-weight: 900; }

/* the tip lives under the top bar, above the road: it never covers the flight */
.tip {
  position: absolute;
  left: 50%;
  top: calc(max(8px, env(safe-area-inset-top)) + 62px);
  transform: translate(-50%, -6px);
  max-width: calc(100% - 24px);
  width: max-content;
  padding: 8px 16px;
  border-radius: 16px;
  background: rgba(31, 45, 77, 0.86);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 9;
}
.tip.show { opacity: 1; transform: translate(-50%, 0); }
.tip.bad { background: rgba(205, 32, 32, 0.92); }

.go {
  position: absolute;
  left: 50%;
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 4%);
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(20, 50, 100, 0.25);
  white-space: nowrap;
  pointer-events: none;
  display: none;
  z-index: 9;
}
.go.show:not(:empty) { display: block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.05); } }

.hand {
  position: absolute;
  left: -28px;
  top: -10px;
  width: 58px;
  height: 58px;
  z-index: 40;
  display: none;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.3));
}
.hand svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------------ windows */
.modal {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 40, 80, 0.45);
  padding: 16px;
}
.modal.open { display: flex; }
.card {
  position: relative;
  width: min(380px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--card);
  border-radius: 26px;
  padding: 18px 18px 16px;
  text-align: center;
  box-shadow: 0 8px 0 rgba(20, 50, 100, 0.25), 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: pop-in 0.25s ease-out;
}
.card.menu, .card.how { width: min(460px, 100%); }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } }
.m-hero { width: 110px; height: 110px; object-fit: contain; margin: -6px auto 0; display: block; animation: bob 1.6s ease-in-out infinite; }
.m-title { font-size: 26px; font-weight: 900; margin: 4px 0 6px; }
.m-sub { font-size: 16px; font-weight: 600; color: var(--ink-soft); margin: 4px 0 8px; }
.m-stars { display: flex; justify-content: center; gap: 8px; margin: 6px 0; }
.m-stars i { width: 54px; height: 54px; color: #d9dfea; }
.m-stars i.on { color: var(--gold); animation: star-in 0.45s backwards cubic-bezier(.3, 1.6, .5, 1); }
.m-stars i:nth-child(2) { transform: translateY(-10px); }
.m-stars i svg { width: 100%; height: 100%; }
@keyframes star-in { from { transform: scale(0) rotate(-30deg); } }
.m-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.m-btns.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.m-btns.row .btn { flex: 1 1 auto; }
.btn {
  min-height: 52px;
  border: 0;
  border-radius: 18px;
  padding: 8px 18px;
  background: #e8eef8;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 0 #b9c6dc;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b9c6dc; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn small { display: block; font-size: 12px; font-weight: 600; opacity: 0.75; }
.btn span { display: flex; flex-direction: column; }
.btn.primary { background: var(--green-2); color: #fff; box-shadow: 0 4px 0 var(--green); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.btn.icon { flex: 0 0 52px !important; padding: 0; }

.lvgrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  padding: 4px;
}
.lv {
  border: 0;
  border-radius: 14px;
  background: #e8f4ff;
  box-shadow: 0 3px 0 #b6d4f0;
  padding: 6px 2px 4px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.lv b { font-size: 18px; font-weight: 900; height: 22px; display: grid; place-items: center; }
.lv b svg { width: 16px; height: 16px; color: #9aa7bd; }
.lv span { display: flex; }
.lv span i { width: 13px; height: 13px; color: #c9d3e3; }
.lv span i.on { color: var(--gold); }
.lv span i svg { width: 100%; height: 100%; }
.lv.cur { background: #fff2c2; box-shadow: 0 3px 0 #e8c55a; }
.lv.locked { opacity: 0.55; cursor: default; }

.rules { text-align: left; display: flex; flex-direction: column; gap: 10px; }
.rule { display: flex; align-items: center; gap: 10px; }
.rule p { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; }
.rule-pics { flex: 0 0 92px; display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; align-items: center; }
.rule-pics img { width: 30px; height: 30px; object-fit: contain; }
.chip { font-size: 14px; font-weight: 900; color: #fff; border-radius: 10px; padding: 2px 6px; }
.chip.good { background: var(--green); }
.chip.bad { background: var(--red); }
.meter { position: relative; width: 18px; height: 52px; border-radius: 9px; background: #fff; border: 2px solid #8a97b3; overflow: hidden; }
.meter i { position: absolute; left: 0; right: 0; top: 10px; height: 14px; background: #e23b3b; }
.meter b { position: absolute; left: 0; right: 0; top: 34px; height: 3px; background: #1f2d4d; }

@media (max-height: 520px) and (orientation: landscape) {
  .card { padding: 12px 16px; }
  .m-hero { width: 70px; height: 70px; }
  .m-btns { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .m-btns .btn { flex: 1 1 40%; }
  .lvgrid { grid-template-columns: repeat(8, minmax(0, 1fr)); max-height: 40vh; }
}
@media (max-width: 370px) {
  .g-me, .g-boss { font-size: 22px; }
  .goal-row img { width: 24px; height: 24px; }
  .g-boss img { width: 32px; }
}
