/* Fredoka (SIL Open Font License), served from this site so the game needs no third-party requests.
   One variable file covers every weight. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/fredoka-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;
}

:root {
  --ink: #1d2a44;
  --ink-soft: #4a5a78;
  --muted: #6b7a94;
  --card: rgba(255, 255, 255, 0.94);
  --glass: rgba(14, 26, 52, 0.42);
  --line: rgba(29, 42, 68, 0.1);
  --accent: #ff7a1a;
  --blue: #2f7de1;
  --good: #2fb36a;
  --bad: #e5484d;
  --cyan: #5fe0ff;
  --shadow: 0 10px 30px rgba(10, 30, 70, 0.25);
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #4ea6ee;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
.layer { position: fixed; inset: 0; pointer-events: none; }
.layer > * { pointer-events: auto; }

.coin-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3a8 0 18%, #ffd23f 20% 62%, #e59a12 64%);
  box-shadow: inset 0 0 0 1.5px #c27c0e;
  vertical-align: -0.12em;
  flex: none;
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  box-shadow: var(--shadow);
  font-size: 22px;
}
.pill b { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill.bump b { animation: bump 0.35s ease; }

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  flex: none;
  transition: transform 0.12s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 24px; height: 24px; stroke: var(--ink-soft); stroke-width: 2.6; stroke-linecap: round; fill: none; }
.glass { background: var(--glass); color: #fff; border-radius: 16px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* Launch screen -------------------------------------------------------------- */
.topbar {
  position: absolute;
  top: calc(12px + var(--safe-t));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.level-pill {
  margin: 0 auto;
  flex-direction: column;
  gap: 0;
  padding: 6px 22px;
  line-height: 1.1;
  min-width: 0;
}
.level-pill small { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; color: var(--accent); }
.level-pill b { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }

.course {
  position: absolute;
  top: calc(76px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 28px));
  padding: 10px 14px 12px;
}
.course-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.course-row b { font-size: 16px; }
.course-bar { position: relative; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); }
.course-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffd23f, #ffb02e); transition: width 0.6s ease; }
.flag {
  position: absolute;
  right: -4px;
  top: -9px;
  width: 18px;
  height: 14px;
  border-radius: 2px;
  background: conic-gradient(#fff 0 25%, #1d2433 0 50%, #fff 0 75%, #1d2433 0) 0 0 / 9px 7px;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.35);
}
.flag::after { content: ''; position: absolute; left: -2px; top: 0; width: 2px; height: 26px; background: #1d2433; }

.pull-hint {
  position: absolute;
  left: 50%;
  bottom: calc(196px + var(--safe-b));
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 2px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(10, 30, 70, 0.5);
  pointer-events: none !important;
  text-align: center;
  width: max-content;
  max-width: 92vw;
}
.pull-hint b { font-size: 26px; font-weight: 700; }
.pull-hint small { font-size: 14px; opacity: 0.95; }
.kbd-only { display: none !important; }
@media (hover: hover) and (pointer: fine) {
  .kbd-only { display: block !important; }
}
.finger {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25);
  margin-bottom: 8px;
  animation: pull 1.6s ease-in-out infinite;
}

.upgrade-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px calc(14px + var(--safe-b));
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}
.upgrade-bar::-webkit-scrollbar { display: none; }
.up-card {
  position: relative;
  flex: none;
  width: 132px;
  padding: 10px 10px 10px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  justify-items: center;
  gap: 2px;
  text-align: center;
  transition: transform 0.1s ease;
}
.up-card:active:not(:disabled) { transform: scale(0.95); }
.up-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; margin-bottom: 2px; }
.up-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.up-name { font-weight: 700; font-size: 16px; line-height: 1.1; }
.up-lvl { font-size: 12px; font-weight: 600; color: var(--muted); }
.up-part { font-size: 12px; color: var(--ink-soft); min-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.up-evo { width: 100%; height: 5px; border-radius: 3px; background: rgba(29, 42, 68, 0.1); overflow: hidden; margin: 3px 0 4px; }
.up-evo i { display: block; height: 100%; background: linear-gradient(90deg, #7c5cff, #ff7ad9); border-radius: inherit; }
.up-cost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  border-radius: 12px;
  padding: 6px 8px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(180deg, #4fd38a, var(--good));
  box-shadow: 0 3px 0 #1f8a4f;
}
.up-card:disabled .up-cost { background: #b9c3d3; box-shadow: 0 3px 0 #8f9bb0; }
.up-card.maxed .up-cost { background: linear-gradient(180deg, #ffd23f, #f0a81a); box-shadow: 0 3px 0 #b07a10; }
.up-card.flash { animation: flash 0.5s ease; }
.up-card .new-dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.25); }

/* Flight HUD ---------------------------------------------------------------- */
.hud-top {
  position: absolute;
  top: calc(10px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 4px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(10, 30, 70, 0.55);
  pointer-events: none !important;
  width: min(420px, 60vw);
}
.hud-top b { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.hud-top small { font-size: 13px; font-weight: 600; opacity: 0.9; }
.hud-progress { position: relative; width: 100%; height: 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.28); }
.hud-progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #5fe0ff, #7c5cff); }
.best-tick { position: absolute; top: -5px; width: 3px; height: 19px; background: #ffd23f; border-radius: 2px; box-shadow: 0 0 6px #ffd23f; }
.hud-coins { position: absolute; top: calc(12px + var(--safe-t)); left: 14px; font-size: 20px; padding: 6px 14px 6px 10px; pointer-events: none !important; }
.pause-btn { position: absolute; top: calc(12px + var(--safe-t)); right: 14px; background: var(--glass); box-shadow: none; }
.pause-btn svg { fill: #fff; stroke: none; }
.hud-bars { position: absolute; left: 14px; bottom: calc(16px + var(--safe-b)); display: grid; gap: 8px; pointer-events: none !important; }
.bar-row { display: grid; grid-template-columns: 58px 160px; align-items: center; gap: 8px; color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.hbar { height: 12px; border-radius: 999px; background: rgba(14, 26, 52, 0.45); overflow: hidden; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35); }
.hbar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffb02e, #ffd23f); }
.hbar.rocket i { background: linear-gradient(90deg, #ff4d2e, #ffb02e); }
.boost-btn {
  position: absolute;
  right: 18px;
  bottom: calc(20px + var(--safe-b));
  width: 104px;
  height: 104px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  background: radial-gradient(circle at 50% 35%, #ff9a4d, #ff4d2e 70%);
  box-shadow: 0 6px 0 #b8321a, 0 12px 26px rgba(255, 77, 46, 0.45);
  touch-action: none;
}
.boost-btn.on { transform: translateY(4px) scale(0.97); box-shadow: 0 2px 0 #b8321a, 0 0 30px rgba(255, 160, 60, 0.9); }
.boost-btn:disabled { background: #8f9bb0; box-shadow: 0 6px 0 #5f6a7e; opacity: 0.7; }
.warp { position: absolute; top: calc(70px + var(--safe-t)); right: 18px; color: #fff; font-weight: 700; font-size: 14px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); pointer-events: none !important; }
.hud-tip {
  position: absolute;
  left: 50%;
  bottom: calc(150px + var(--safe-b));
  transform: translateX(-50%);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 2px 6px rgba(10, 30, 70, 0.6);
  pointer-events: none !important;
  width: max-content;
  max-width: 90vw;
  transition: opacity 0.4s;
}
.joy {
  position: fixed;
  width: 130px;
  height: 130px;
  margin: -65px 0 0 -65px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none !important;
}
.joy i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, 0.75); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }

/* Launch timing ring */
.aim { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 5; }
.aim i {
  position: absolute;
  left: -60px;
  top: -60px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 5px solid #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}
.aim::before {
  content: '';
  position: absolute;
  left: -60px;
  top: -60px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.7);
}
.aim.perfect i { border-color: #7dff8a; box-shadow: 0 0 22px #7dff8a; }
.aim b { position: absolute; left: 0; top: 74px; transform: translateX(-50%); color: #fff; font-size: 20px; font-weight: 700; white-space: nowrap; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }

/* Banner + floaters */
.banner {
  position: fixed;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 6;
  color: #fff;
  opacity: 0;
  width: max-content;
  max-width: 94vw;
}
.banner.show { animation: banner 2.2s ease forwards; }
.banner b { display: block; font-size: clamp(30px, 6vw, 52px); font-weight: 700; line-height: 1.05; -webkit-text-stroke: 2px rgba(10, 20, 40, 0.35); text-shadow: 0 4px 0 rgba(10, 20, 40, 0.35), 0 8px 24px rgba(10, 20, 40, 0.35); }
.banner small { display: block; font-size: 18px; font-weight: 600; margin-top: 4px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.floater { position: absolute; transform: translate(-50%, -50%); font-weight: 700; font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(10, 20, 40, 0.45), 0 4px 10px rgba(10, 20, 40, 0.35); animation: floatup 1s ease-out forwards; white-space: nowrap; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 22, 48, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.2s ease;
}
.modal-card {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #fff;
  border-radius: 24px;
  padding: 24px 22px 20px;
  box-shadow: 0 24px 60px rgba(10, 22, 48, 0.4);
  text-align: center;
  animation: card-in 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.modal-card h2 { margin: 0 0 6px; font-size: 28px; line-height: 1.1; }
.modal-card p { margin: 6px 0; color: var(--ink-soft); line-height: 1.4; }
.modal-card .actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { flex: 1; border-radius: 14px; padding: 13px 16px; font-size: 18px; font-weight: 700; background: rgba(29, 42, 68, 0.08); transition: transform 0.08s ease; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #ffa53d, var(--accent)); color: #fff; box-shadow: 0 4px 0 #c4560a; }
.btn.danger { background: var(--bad); color: #fff; box-shadow: 0 4px 0 #a32a2e; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
.res-dist { font-size: 46px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #ffd23f; color: #5a3d00; animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.res-bar { position: relative; height: 12px; border-radius: 999px; background: rgba(29, 42, 68, 0.1); margin: 10px 4px 16px; }
.res-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5fe0ff, #7c5cff); }
.res-bar .flag { top: -8px; }
.res-meta { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.res-rows { text-align: left; border-top: 1px solid var(--line); margin-top: 8px; }
.res-rows div { display: flex; justify-content: space-between; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 16px; }
.res-rows b { font-variant-numeric: tabular-nums; }
.res-total { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 40px; font-weight: 700; margin-top: 14px; font-variant-numeric: tabular-nums; }
.level-list { display: grid; gap: 8px; margin-top: 12px; text-align: left; }
.level-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(29, 42, 68, 0.05); font-size: 16px; }
.level-item.current { box-shadow: inset 0 0 0 2px var(--accent); }
.level-item:disabled { opacity: 0.45; }
.level-item small { color: var(--muted); font-weight: 600; }
.level-item .swatch { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.level-item span.name { flex: 1; font-weight: 700; }
.settings-list { text-align: left; margin-top: 14px; display: grid; gap: 10px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(29, 42, 68, 0.05); font-size: 16px; }
.toggle { width: 54px; height: 32px; border-radius: 999px; background: #c3cad6; position: relative; transition: background 0.2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); }
.toggle.on { background: var(--good); }
.toggle.on::after { transform: translateX(22px); }
.howto { text-align: left; font-size: 14px; color: var(--ink-soft); line-height: 1.5; padding-left: 18px; margin: 10px 0 0; }

#toasts { position: fixed; left: 50%; bottom: calc(190px + var(--safe-b)); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 14px; font-size: 15px; box-shadow: 0 10px 24px rgba(10, 22, 48, 0.35); animation: toast 2.6s ease forwards; max-width: 100%; text-align: center; }

.loading { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; text-align: center; background: linear-gradient(#4ea6ee, #cdeeff); color: #fff; transition: opacity 0.5s; }
.loading b { font-size: 44px; text-shadow: 0 4px 0 rgba(20, 60, 120, 0.35); }
.loading.done { opacity: 0; pointer-events: none; }

@keyframes bump { 40% { transform: scale(1.18); } }
@keyframes pop { 0% { transform: scale(0.3); } 100% { transform: scale(1); } }
@keyframes flash { 0% { box-shadow: 0 0 0 6px rgba(255, 210, 63, 0.9), var(--shadow); } 100% { box-shadow: var(--shadow); } }
@keyframes fade { from { opacity: 0; } }
@keyframes card-in { from { transform: translateY(24px) scale(0.92); opacity: 0; } }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes pull { 0%, 15% { transform: translateY(-10px); opacity: 0; } 30% { opacity: 1; } 75% { transform: translateY(40px); opacity: 1; } 100% { transform: translateY(40px); opacity: 0; } }
@keyframes banner { 0% { opacity: 0; transform: translateX(-50%) scale(1.4); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-14px); } }
@keyframes floatup { 0% { opacity: 0; margin-top: 10px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -50px; } }

@media (max-width: 600px) {
  .up-card { width: 112px; padding: 8px; }
  .up-name { font-size: 14px; }
  .hud-top b { font-size: 32px; }
  .boost-btn { width: 88px; height: 88px; font-size: 16px; }
  .bar-row { grid-template-columns: 50px 110px; }
  .pull-hint b { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
