/* =========================================================================
   JETPACK RUSH — UI styles. Change the palette here (canvas colors are in
   js/config.js → COLORS).
   ========================================================================= */
:root {
  --night: #050914;
  --navy: #0d1a3d;
  --panel: rgba(8, 14, 34, 0.9);
  --line: rgba(47, 230, 255, 0.28);
  --cyan: #2fe6ff;
  --cyan-deep: #0b8fb3;
  --gold: #ffc93a;
  --hazard: #ff5a1f;
  --red: #ff2e4d;
  --fur: #f28c28;
  --white: #f4f8ff;
  --muted: #9fb0d6;
  --display: 'Bungee', 'Impact', 'Arial Black', sans-serif;
  --body: 'Barlow Semi Condensed', 'Arial Narrow', 'Segoe UI', sans-serif;
  --notch: 10px;
  color-scheme: dark;
}
/* the game is always night-lit; tokens stay the same in both schemes */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --panel: rgba(8, 14, 34, 0.9); } }
:root[data-theme="dark"] { --panel: rgba(8, 14, 34, 0.9); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--night); color: var(--white); overflow: hidden; }
body { font-family: var(--body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }

#jr-root {
  position: relative; width: 100%; height: 100%; min-height: 260px; overflow: hidden;
  background: var(--night); touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#jr-canvas { position: absolute; display: block; touch-action: none; }

#jr-ui { position: absolute; inset: 0; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
#jr-ui > * { pointer-events: auto; }
#toasts, #rotate-hint { pointer-events: none !important; }

/* ---------------------------------------------------------------- screens */
.screen { position: absolute; inset: 0; display: none; padding: inherit; }
.screen.show { display: flex; animation: screenIn 0.22s ease-out; }
.screen.dim { background: rgba(3, 6, 16, 0.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); align-items: center; justify-content: center; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------- wordmark */
.wordmark {
  text-transform: uppercase;
  font-family: var(--display); font-weight: 400; margin: 0; line-height: 0.92; letter-spacing: 0.01em;
  font-size: clamp(36px, min(11vh, 14vw), 88px); color: var(--white);
  text-shadow: 0.05em 0.05em 0 var(--cyan-deep), 0.1em 0.1em 0 rgba(5, 9, 20, 0.7);
}
.wordmark.mid { font-size: clamp(30px, 8vh, 52px); }
.wordmark.small { font-size: 34px; }

/* ---------------------------------------------------------------- buttons: courier tickets */
.btn {
  font-family: var(--display); font-size: 15px; letter-spacing: 0.02em; color: var(--white);
  background: rgba(13, 26, 61, 0.88); border: 0; padding: 12px 18px; cursor: pointer;
  clip-path: polygon(var(--notch) 0, 100% 0, 100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%, 0 100%, 0 var(--notch));
  box-shadow: inset 3px 0 0 var(--cyan), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn em { font-style: normal; font-family: var(--body); font-weight: 700; font-size: 13px; color: var(--muted); }
.btn:hover:not(:disabled) { background: rgba(26, 46, 100, 0.95); }
.btn:active:not(:disabled) { transform: translateY(2px) scale(0.98); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--cyan); color: #04112b; box-shadow: inset 0 -4px 0 var(--cyan-deep); }
.btn.primary:hover:not(:disabled) { background: #7cf5ff; }
.btn.primary em { color: #04335a; }
.btn.ghost { background: rgba(5, 9, 20, 0.55); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { box-shadow: inset 3px 0 0 var(--red); color: #ffb1bd; }
.btn.small { font-size: 13px; padding: 9px 14px; }
.btn.wide { width: 100%; }
.btn img { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- menu */
#scr-menu { align-items: center; }
.menu-col {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  width: min(440px, 46%); margin-left: max(5vw, 24px); max-height: 100%; padding: 16px 0; overflow: auto;
}
.tagline { margin: 2px 0 0; font-size: 19px; font-style: italic; color: var(--fur); font-weight: 500; }
.bests { margin: 0; color: var(--muted); font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bests strong { color: var(--white); font-family: var(--display); font-weight: 400; font-size: 15px; }
.bests .sep { width: 4px; height: 4px; background: var(--line); transform: rotate(45deg); display: inline-block; }
.btn.play { font-size: 26px; padding: 14px 54px; margin-top: 6px; --notch: 14px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.menu-grid .btn { justify-content: space-between; }
.daily {
  width: 100%; margin-top: 4px; padding: 10px 14px 12px; background: rgba(5, 9, 20, 0.72);
  border-top: 2px dashed var(--gold); position: relative;
}
.daily-tag { font-family: var(--display); font-size: 12px; color: var(--gold); }
.daily p { margin: 4px 0 2px; font-size: 17px; font-weight: 700; line-height: 1.2; }
.daily small { color: var(--muted); font-size: 14px; }
.daily.done { border-top-color: var(--cyan); }
.daily.done .daily-tag { color: var(--cyan); }
.wallet {
  position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(18px + env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: rgba(5, 9, 20, 0.7);
  font-family: var(--display); color: var(--gold); font-size: 18px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.coin-ico { width: 20px; height: 20px; }
.hint-keys { position: absolute; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); right: calc(18px + env(safe-area-inset-right, 0px)); margin: 0; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- cards (pause / over) */
.card {
  width: min(380px, 92%); max-height: 94%; overflow: auto; padding: 22px 22px 18px; background: var(--panel);
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  box-shadow: inset 0 3px 0 var(--cyan);
}
.card.center { text-align: center; }
.card .sub { margin: -2px 0 6px; color: var(--muted); font-family: var(--display); font-size: 14px; }
.card .row { display: flex; gap: 8px; }
.card .row .btn { flex: 1; }
.over .wordmark { color: var(--white); }
.newbest { display: none; align-self: center; font-family: var(--display); color: #04112b; background: var(--gold); padding: 4px 12px; font-size: 14px; transform: rotate(-3deg); }
.newbest.show { display: inline-block; animation: stamp 0.45s cubic-bezier(.2, 1.6, .4, 1) 0.6s both; }
@keyframes stamp { from { transform: rotate(-3deg) scale(2.2); opacity: 0; } to { transform: rotate(-3deg) scale(1); opacity: 1; } }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 2px; }
.results div { background: rgba(5, 9, 20, 0.6); padding: 8px 10px; text-align: left; }
.results dt { color: var(--muted); font-size: 14px; }
.results dd { margin: 2px 0 0; font-family: var(--display); font-size: 22px; }
.results dd.big { color: var(--cyan); }
.gold { color: var(--gold); }
.cyan { color: var(--cyan); }
.earned { margin: 0; color: var(--gold); font-weight: 700; font-size: 16px; min-height: 0; }
.earned:empty { display: none; }

/* ---------------------------------------------------------------- panels */
.panel {
  width: min(680px, 94%); max-height: 92%; display: flex; flex-direction: column; background: var(--panel);
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  box-shadow: inset 0 3px 0 var(--cyan);
}
.panel.narrow { width: min(460px, 94%); }
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; gap: 12px; }
.panel h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; }
.panel-sub { margin: 0; padding: 0 18px 8px; color: var(--muted); font-size: 16px; }
.panel-body { overflow: auto; padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }

.mission, .daily-row, .upgrade, .ach { display: flex; align-items: center; gap: 14px; padding: 10px 12px; background: rgba(5, 9, 20, 0.55); }
.mission.done { opacity: 0.7; }
.m-main, .u-main { flex: 1; min-width: 0; }
.m-text { font-weight: 700; font-size: 17px; }
.m-prog { color: var(--muted); font-size: 14px; }
.mission.done .m-prog { color: var(--cyan); }
.bar { height: 6px; background: rgba(255, 255, 255, 0.08); margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: var(--cyan); }
.mission.done .bar i { background: var(--gold); }
.reward { display: inline-flex; align-items: center; gap: 4px; font-family: var(--display); color: var(--gold); font-size: 15px; white-space: nowrap; }
.reward img { width: 16px; height: 16px; }
.daily-row { border-top: 2px dashed var(--gold); }
.daily-row strong { font-family: var(--display); font-weight: 400; color: var(--gold); font-size: 13px; }
.daily-row p { margin: 3px 0 0; font-weight: 700; font-size: 17px; }
.daily-row.done strong { color: var(--cyan); }
.daily-row > div { flex: 1; }

.upgrade strong { font-family: var(--display); font-weight: 400; font-size: 16px; }
.upgrade p { margin: 2px 0 6px; color: var(--muted); font-size: 15px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 22px; height: 7px; background: rgba(255, 255, 255, 0.1); transform: skewX(-20deg); }
.pips i.on { background: var(--cyan); }
.upgrade .btn { min-width: 108px; }

.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: rgba(5, 9, 20, 0.55); border: 0; color: var(--white); cursor: pointer; font-family: var(--body);
}
.toggle span { display: flex; flex-direction: column; }
.toggle strong { font-size: 17px; }
.toggle small { color: var(--muted); font-size: 14px; }
.toggle i { width: 46px; height: 24px; background: rgba(255, 255, 255, 0.12); position: relative; flex: none; transition: background 0.15s; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.toggle.on i { background: var(--cyan-deep); }
.toggle.on i::after { transform: translateX(22px); background: var(--white); }
.toggle:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.fine { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

.prose h3 { font-family: var(--display); font-weight: 400; font-size: 16px; color: var(--cyan); margin: 10px 0 2px; }
.prose p, .prose li { font-size: 16px; line-height: 1.4; color: #dbe4f8; max-width: 70ch; }
.prose p { margin: 0; }
.prose ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prose ul.icons li { display: flex; gap: 10px; align-items: center; }
.prose ul.icons img { width: 32px; height: 32px; background: rgba(5, 9, 20, 0.7); padding: 4px; flex: none; }
.prose strong { color: var(--white); }
kbd { font-family: var(--display); font-size: 12px; padding: 2px 7px; margin-right: 4px; background: rgba(47, 230, 255, 0.14); color: var(--cyan); }

.stats { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 12px; background: rgba(5, 9, 20, 0.55); }
.stat span { color: var(--muted); font-size: 15px; }
.stat strong { font-family: var(--display); font-weight: 400; font-size: 15px; }

.achs { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
.ach { opacity: 0.55; }
.ach.got { opacity: 1; box-shadow: inset 3px 0 0 var(--gold); }
.medal { width: 34px; height: 34px; flex: none; display: grid; place-items: center; font-size: 18px; color: #04112b; background: rgba(255, 255, 255, 0.08); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.ach.got .medal { background: var(--gold); }
.ach strong { font-family: var(--display); font-weight: 400; font-size: 14px; }
.ach p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- HUD bits */
.hud-btn {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px));
  width: 46px; height: 46px; display: none; align-items: center; justify-content: center; gap: 6px;
  background: rgba(5, 9, 20, 0.55); border: 0; cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.hud-btn.show { display: flex; }
.hud-btn span { width: 5px; height: 18px; background: var(--white); }
.hud-btn:focus-visible { outline: 3px solid var(--gold); }

#toasts { position: absolute; top: calc(42px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 5; width: max-content; max-width: 92%; }
.toast {
  display: flex; flex-direction: column; align-items: center; padding: 8px 18px; background: rgba(5, 9, 20, 0.88);
  box-shadow: inset 0 -3px 0 var(--cyan); animation: toastIn 0.3s cubic-bezier(.2, 1.4, .4, 1);
  transition: opacity 0.35s, transform 0.35s;
}
.toast strong { font-family: var(--display); font-weight: 400; font-size: 13px; color: var(--cyan); }
.toast span { font-size: 16px; font-weight: 700; }
.toast.mission { box-shadow: inset 0 -3px 0 var(--gold); }
.toast.mission strong, .toast.daily strong { color: var(--gold); }
.toast.achievement { box-shadow: inset 0 -3px 0 var(--fur); }
.toast.achievement strong { color: var(--fur); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { transform: translateY(-14px) scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }

#rotate-hint {
  display: none; position: absolute; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top, 0px));
  padding: 6px 12px; font-size: 14px; color: var(--muted); background: rgba(5, 9, 20, 0.7); white-space: nowrap;
  top: auto; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.portrait #rotate-hint { display: block; }
.portrait .hint-keys { display: none; }
.portrait #scr-menu.show ~ #rotate-hint, .portrait #rotate-hint:has(~ #scr-menu.show) { display: none; }

/* ---------------------------------------------------------------- loading */
#scr-loading { background: var(--night); align-items: center; justify-content: center; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.load-track { width: 220px; height: 6px; background: rgba(255, 255, 255, 0.08); }
.load-track i { display: block; height: 100%; width: 0; background: var(--cyan); transition: width 0.25s; }

/* ---------------------------------------------------------------- responsive */
@media (max-height: 520px) {
  .wordmark { font-size: clamp(30px, 12vh, 56px); }
  .tagline { font-size: 15px; }
  .bests { font-size: 14px; }
  .btn { font-size: 13px; padding: 9px 14px; }
  .btn.play { font-size: 20px; padding: 10px 40px; }
  .menu-col { gap: 7px; padding: 10px 0; }
  .daily { padding: 6px 12px 8px; }
  .daily p { font-size: 15px; }
  .hint-keys { display: none; }
  .card { padding: 14px 16px 12px; gap: 7px; }
  .results dd { font-size: 18px; }
}
@media (max-height: 380px) {
  .daily, .tagline { display: none; }
}
@media (max-width: 760px) {
  .menu-col { width: calc(100% - 40px); margin: 0 20px; }
  .stats, .achs { grid-template-columns: 1fr; }
}
/* portrait phones: the canvas is letterboxed; keep the menu in the open space */
.portrait #scr-menu { align-items: flex-end; }
.portrait .menu-col { width: calc(100% - 32px); margin: 0 16px 20px; background: rgba(5, 9, 20, 0.55); padding: 14px; }

@media (prefers-reduced-motion: reduce) {
  .screen.show, .toast, .newbest.show { animation: none; }
  .btn, .toggle i::after { transition: none; }
}
