/* ==========================================================================
   Star Hunter Crew — app styles. Full-viewport PWA, fixed bottom nav,
   safe-area aware. Design matches the app export.
   ========================================================================== */
@import url("../fonts/fonts.css");

:root {
  --navy-900: #050f20;
  --navy-800: #0a1729;
  --navy-700: #0c1d3c;
  --card: #10213f;
  --card-2: #142a4d;
  --border: rgba(143, 168, 204, 0.18);
  --border-strong: rgba(143, 168, 204, 0.32);
  --ink-100: #eaf3ff;
  --ink-200: #bcd2ee;
  --ink-300: #8fa8cc;
  --green: #8fe36b;
  --orange: #ff8a3c;
  --orange-deep: #f26419;
  --font-head: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  color: var(--ink-200);
  background:
    radial-gradient(900px 500px at 70% -8%, rgba(90, 200, 160, 0.14), transparent 60%),
    linear-gradient(180deg, var(--navy-800), var(--navy-900));
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* The "device" column — full width on phones, centred card on larger screens */
.device {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin-inline: auto;
  position: relative;
  overflow: hidden;
}

#app {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 18px;
}

h1, h2 { font-family: var(--font-head); color: var(--ink-100); margin: 0; font-weight: 600; }

.btn-primary {
  border: none;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  color: #2a1400;
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
  border-radius: 16px;
  padding: 14px;
  font-size: 1rem;
  box-shadow: 0 12px 26px -12px rgba(242, 100, 25, 0.85);
}
.btn-primary.big { width: 100%; font-size: 1.05rem; }
.btn-primary.done { background: rgba(143, 227, 107, 0.16); color: var(--green); box-shadow: none; border: 1px solid rgba(143, 227, 107, 0.4); }

/* --- Shared header ------------------------------------------------------- */
.app-head { display: flex; align-items: center; justify-content: space-between; }
.app-head h2 { font-size: 1.5rem; }
.tag-live {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 0.68rem;
  letter-spacing: 0.08em; color: #0b2a12; background: var(--green); padding: 4px 10px; border-radius: 999px;
}
.tag-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #0b2a12; }
.app-sub { font-size: 0.85rem; color: var(--ink-300); margin-top: 4px; }

/* --- Sky map ------------------------------------------------------------- */
.starmap {
  position: relative; margin-top: 14px; border-radius: 20px; overflow: hidden;
  height: min(58vh, 470px);
  background:
    radial-gradient(120% 72% at 50% 6%, #3b4088 0%, transparent 62%),
    linear-gradient(180deg, #23275e 0%, #171a45 52%, #0d0f2c 100%);
  border: 1px solid var(--border);
}
.skymap { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Faint hunter figure behind the stars */
.figure { opacity: 0.3; }
.figure .fig-body { fill: #5a67b5; }
.figure .fig-limbs { fill: none; stroke: #5a67b5; stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }

/* Constellation lines + fainter figure stars */
.cline { stroke: #aecbff; stroke-width: 0.5; opacity: 0.5; }
.cdot { fill: #cdd9f5; opacity: 0.85; }

/* Bright, named stars — tappable */
.fstar { cursor: pointer; animation: twinkle 4.5s ease-in-out infinite; }
.fstar:nth-of-type(2n) { animation-duration: 3.4s; animation-delay: .5s; }
.fstar:nth-of-type(3n) { animation-duration: 5.2s; animation-delay: .9s; }
.fstar .halo { fill: var(--c); opacity: 0.25; }
.fstar .core { fill: #f4f8ff; }
.fstar .ring { fill: none; stroke: var(--green); stroke-width: 0.7; opacity: 0.9; }
.fstar:focus-visible { outline: none; }
.fstar:focus-visible .core { stroke: var(--green); stroke-width: 1; }

.point-chip {
  position: absolute; top: 12px; right: 12px; z-index: 3; font-size: 0.72rem; font-weight: 700;
  color: var(--ink-100); background: rgba(8, 18, 34, 0.82); border: 1px solid var(--border-strong);
  padding: 5px 10px; border-radius: 999px;
}
@keyframes twinkle { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.orion-label { position: absolute; left: 14px; bottom: 12px; z-index: 2; }
.orion-label strong { display: block; font-family: var(--font-head); font-weight: 600; color: var(--green); font-size: 1rem; }
.orion-label span { font-size: 0.72rem; color: var(--ink-300); }

.mission-strip {
  width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 13px 14px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 138, 60, 0.18), rgba(242, 100, 25, 0.10));
  border: 1px solid rgba(255, 138, 60, 0.4); color: var(--ink-100);
}
.mission-strip .ic {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  background: linear-gradient(180deg, var(--orange), var(--orange-deep)); font-size: 1rem;
}
.mission-strip strong { display: block; font-family: var(--font-head); font-weight: 600; font-size: 0.92rem; }
.mission-strip span { font-size: 0.75rem; color: var(--ink-200); }
.mission-strip .chev { margin-left: auto; color: var(--ink-300); font-size: 1.3rem; }

/* --- Star detail --------------------------------------------------------- */
.back-row { background: none; border: none; cursor: pointer; color: var(--ink-200); font-weight: 700; font-size: 0.9rem; padding: 0; }
.star-hero { display: grid; place-items: center; margin: 10px 0 4px; }
.star-name { text-align: center; font-family: var(--font-head); color: var(--ink-100); font-size: 1.7rem; }
.star-tagline { text-align: center; font-size: 0.85rem; color: var(--ink-300); margin: 4px 0 14px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border-radius: 14px; padding: 12px 4px; text-align: center; border: 1px solid; }
.stat b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; }
.stat small { font-size: 0.55rem; letter-spacing: 0.05em; color: var(--ink-300); }
.stat.green { background: rgba(143, 227, 107, 0.10); border-color: rgba(143, 227, 107, 0.3); }
.stat.green b { color: var(--green); }
.stat.orange { background: rgba(255, 138, 60, 0.12); border-color: rgba(255, 138, 60, 0.35); }
.stat.orange b { color: var(--orange); font-size: 0.82rem; }
.stat.blue { background: rgba(59, 111, 212, 0.14); border-color: rgba(90, 130, 220, 0.4); }
.stat.blue b { color: #9fc0ff; }

.story-card { margin-top: 14px; border-radius: 16px; padding: 14px; background: rgba(143, 227, 107, 0.07); border: 1px solid rgba(143, 227, 107, 0.22); }
.sc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sc-head strong { font-family: var(--font-head); font-weight: 600; color: var(--green); font-size: 0.95rem; }
.listen { cursor: pointer; font-weight: 700; font-size: 0.8rem; color: #0b2a12; background: var(--green); border: none; padding: 6px 12px; border-radius: 999px; }
.listen.off, .listen[disabled] { background: rgba(143, 227, 107, 0.25); color: rgba(11, 42, 18, 0.6); cursor: not-allowed; }
.listen.na { background: none; color: var(--ink-300); font-weight: 600; font-size: 0.72rem; }
.story-text { font-size: 0.98rem; line-height: 1.6; color: var(--ink-100); margin: 0; }
.story-text .spoken { background: rgba(143, 227, 107, 0.28); border-radius: 4px; box-shadow: 0 0 0 2px rgba(143, 227, 107, 0.28); }
.spot { width: 100%; margin-top: 16px; }

/* --- Missions ------------------------------------------------------------ */
.ring { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) var(--deg), rgba(143, 168, 204, 0.22) 0); }
.ring span { width: 35px; height: 35px; border-radius: 50%; background: var(--navy-700); display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; font-size: 0.72rem; color: var(--green); }
.miss-list { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.miss-row { width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 15px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); color: var(--ink-100); }
.miss-row[disabled] { cursor: default; }
.miss-row .mi { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; background: rgba(143, 168, 204, 0.12); }
.miss-row div { flex: 1; }
.miss-row strong { display: block; font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; }
.miss-row small { font-size: 0.75rem; color: var(--ink-300); }
.miss-row .chk { color: var(--green); font-size: 1.1rem; }
.miss-row .chev { color: var(--ink-300); font-size: 1.3rem; }
.miss-row.done { background: rgba(143, 227, 107, 0.10); border-color: rgba(143, 227, 107, 0.3); }
.miss-row.done .mi { background: rgba(143, 227, 107, 0.2); }
.miss-row.streak { background: linear-gradient(180deg, rgba(143, 227, 107, 0.14), rgba(143, 227, 107, 0.04)); border-color: rgba(143, 227, 107, 0.35); cursor: default; }

/* --- Stories ------------------------------------------------------------- */
.story-list { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.story-row { width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 15px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); color: var(--ink-100); }
.story-row .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.story-row div { flex: 1; }
.story-row strong { display: block; font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; }
.story-row small { font-size: 0.72rem; color: var(--ink-300); }
.story-row .chev { color: var(--ink-300); font-size: 1.2rem; }

/* --- Crew ---------------------------------------------------------------- */
.crew-top { text-align: center; }
.app-icon { width: 66px; height: 66px; border-radius: 18px; margin: 4px auto 10px; display: grid; place-items: center; font-size: 1.9rem; background: linear-gradient(180deg, var(--orange), var(--orange-deep)); box-shadow: 0 10px 22px -10px rgba(242, 100, 25, 0.8); }
.crew-name { font-family: var(--font-head); font-weight: 600; color: var(--ink-100); font-size: 1.4rem; }
.level-pill { display: inline-block; margin-top: 7px; font-size: 0.72rem; font-weight: 700; color: var(--green); background: rgba(143, 227, 107, 0.12); border: 1px solid rgba(143, 227, 107, 0.3); padding: 4px 13px; border-radius: 999px; }
.xp-card { margin-top: 16px; padding: 13px 15px; border-radius: 15px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); }
.xp-top { display: flex; justify-content: space-between; font-size: 0.8rem; }
.xp-top b { font-family: var(--font-head); color: var(--ink-100); }
.xp-top span { color: var(--ink-300); }
.xp-bar { height: 9px; border-radius: 999px; background: rgba(143, 168, 204, 0.2); margin-top: 8px; overflow: hidden; }
.xp-bar i { display: block; height: 100%; background: linear-gradient(90deg, #8fe36b, #b6f097); }
.crew-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.crew-stats .cs { border-radius: 14px; padding: 12px 4px; text-align: center; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); }
.crew-stats .cs b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; color: var(--ink-100); }
.crew-stats .cs.g b { color: var(--green); }
.crew-stats .cs.o b { color: var(--orange); }
.crew-stats .cs small { font-size: 0.5rem; letter-spacing: 0.03em; color: var(--ink-300); }
.badge-head { font-family: var(--font-head); font-weight: 600; color: var(--ink-100); font-size: 0.92rem; margin: 16px 0 8px; }
.badge-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.badge-grid .bg { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; background: rgba(143, 168, 204, 0.1); border: 1px solid rgba(143, 168, 204, 0.18); }
.badge-grid .bg.green { background: rgba(143, 227, 107, 0.16); border-color: rgba(143, 227, 107, 0.45); }
.badge-grid .bg.orange { background: rgba(255, 138, 60, 0.16); border-color: rgba(255, 138, 60, 0.45); }
.badge-grid .bg.dim { opacity: 0.32; filter: grayscale(0.6); }

/* Settings */
.settings { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row strong { display: block; font-family: var(--font-head); font-weight: 600; color: var(--ink-100); font-size: 0.95rem; }
.set-row small { font-size: 0.72rem; color: var(--ink-300); }
.switch { flex: none; width: 46px; height: 27px; border-radius: 999px; border: none; cursor: pointer; background: rgba(143, 168, 204, 0.25); position: relative; }
.switch i { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: left 0.15s ease; }
.switch.on { background: var(--green); }
.switch.on i { left: 22px; }
.switch[disabled] { opacity: 0.5; cursor: not-allowed; }
.set-reset { margin-top: 16px; width: 100%; background: none; border: 1px solid rgba(255, 120, 100, 0.4); color: #ff9c8a; border-radius: 12px; padding: 11px; font-weight: 700; cursor: pointer; font-family: var(--font-body); }

/* --- Welcome ------------------------------------------------------------- */
.welcome { text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 100%; }
.wlogo { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto 12px; }
.eyebrow-sm { font-family: var(--font-head); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green); font-size: 0.72rem; }
.wtitle { font-size: 1.9rem; margin: 6px 0 10px; line-height: 1.1; }
.wsub { font-size: 0.95rem; color: var(--ink-300); line-height: 1.5; margin: 0 auto; max-width: 300px; }
.name-label { display: block; text-align: left; font-size: 0.62rem; letter-spacing: 0.08em; color: var(--ink-300); font-weight: 700; margin: 22px 0 6px; }
.name-input { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; background: rgba(6, 14, 28, 0.6); border: 1px solid var(--green); }
.name-input input { flex: 1; border: none; background: none; outline: none; color: var(--ink-100); font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.name-input input::placeholder { color: var(--ink-300); }
.welcome .btn-primary { margin-top: 16px; }
.grownup-link { margin-top: 14px; font-size: 0.78rem; color: var(--ink-300); }

/* --- Bottom tab bar ------------------------------------------------------ */
#nav {
  flex: none; display: flex; border-top: 1px solid var(--border);
  background: rgba(8, 18, 34, 0.9); backdrop-filter: blur(8px);
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
}
#nav[hidden] { display: none; }
.tab { flex: 1; background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.62rem; font-weight: 700; color: var(--ink-300); font-family: var(--font-body); padding: 4px; }
.tab .ti { font-size: 1.25rem; opacity: 0.75; }
.tab.active { color: var(--green); }
.tab.active .ti { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .fstar { animation: none !important; }
}
