/* =========
   Base
   ========= */
:root{
  --bg: #0b1020;
  --card: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.72);
  --stroke: rgba(255,255,255,0.18);
  --shadow: 0 14px 40px rgba(0,0,0,0.35);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: #000;
  color: var(--text);
  overflow: hidden; /* the snap container handles scrolling */
}

code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

/* =========
   Layout (full-page scroll snap)
   ========= */
.snap{
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

.page{
  height: 100vh;
  width: 100%;
  scroll-snap-align: start;
  display: grid;
  place-items: center;
  position: relative;
  padding: 24px;
}

/* =========
   Page 1 (hero)
   ========= */
.page--hero{
  background: #000;
  color: var(--text);
}

.hero-bg{
  position:absolute;
  inset:0;
  background-image: url("assets/earth.jpg"); /* Put your LEO Earth image here */
  background-size: cover;
  background-position: center;
  transform: scale(1.05);
  filter: blur(6px) saturate(1.1) contrast(1.05);
  opacity: 0.95;
}

.hero-bg::after{
  content:"";
  position:absolute;
  inset:0;
  background: radial-gradient(80% 80% at 50% 40%, rgba(0,0,0,0.18), rgba(0,0,0,0.72));
}

.glass-card{
  position: relative;
  width: min(720px, 92vw);
  padding: 28px 26px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.06));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.title{
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: 0.2px;
}
.subtitle{
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.4;
}
.subnote{
  display:inline-block;
  margin-left: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 12px;
  color: rgba(255,255,255,0.82);
}

.form{
  display: grid;
  gap: 12px;
}

.file{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.24);
  border: 1px solid var(--stroke);
}

.file input{ display:none; }
.file-btn{
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.20);
  cursor:pointer;
  user-select:none;
}
.file-btn:hover{ background: rgba(255,255,255,0.18); }

.file-name{
  color: var(--muted);
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.check{
  display:flex;
  gap: 10px;
  align-items:flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.82);
  font-size: 14px;
}
.check input{ margin-top: 3px; }
.check-sub{
  color: rgba(255,255,255,0.62);
  font-size: 12.5px;
}

.primary, .secondary{
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  cursor:pointer;
  font-weight: 650;
}

.primary{
  background: rgba(255,255,255,0.92);
  color: #0b1020;
}
.primary:disabled{
  opacity: 0.45;
  cursor: not-allowed;
}
.secondary{
  background: rgba(0,0,0,0.0);
  color: #0b1020;
  border: 1px solid rgba(0,0,0,0.12);
}
.secondary:hover{
  background: rgba(0,0,0,0.04);
}

.status{
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.meter{
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  overflow:hidden;
  border: 1px solid rgba(255,255,255,0.18);
}
.meter-fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: rgba(255,255,255,0.86);
  transition: width 120ms linear;
}

.hint{
  margin-top: 4px;
  color: rgba(255,255,255,0.65);
  font-size: 12.5px;
}

/* =========
   Loading overlay
   ========= */
.overlay{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(6px);
}
.overlay-card{
  display:flex;
  align-items:center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(20, 25, 40, 0.75);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: var(--shadow);
}
.overlay-title{ font-weight: 750; }
.overlay-detail{ color: rgba(255,255,255,0.72); font-size: 13px; margin-top: 2px; }

.spinner{
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.22);
  border-top-color: rgba(255,255,255,0.92);
  animation: spin 0.9s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.hidden{ display:none !important; }

/* =========
   Results page (white)
   ========= */
.page--results{
  background: #ffffff;
  color: #0b1020;
}

.results-wrap{
  width: min(720px, 92vw);
  display: grid;
  gap: 14px;
}

.results-wrap h2{
  margin: 0;
  font-size: 28px;
}

.results-card{
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.9);
}

.kv{
  display:flex;
  gap: 10px;
  padding: 8px 0;
  font-size: 18px;
}
.k{ font-weight: 700; }
.v{ font-variant-numeric: tabular-nums; }

.results-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.save-hint{
  margin: 0;
  color: rgba(0,0,0,0.60);
  font-size: 13px;
}

/* =========
   Equations page
   ========= */
.page--equations{
  background: #f6f7fb;
  color: #0b1020;
}

.eq-wrap{
  width: min(880px, 92vw);
  display: grid;
  gap: 12px;
}

.eq-wrap h2{
  margin: 0;
  font-size: 28px;
}

.eq-sub{
  margin: 0;
  color: rgba(0,0,0,0.65);
}

.eq-card{
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 18px 16px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
}

.eq-card .eq-item{
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.eq-card .eq-item:last-child{ border-bottom: 0; }

.eq-title{
  font-weight: 800;
  margin: 0 0 6px;
}

.eq-notes{
  border: 1px dashed rgba(0,0,0,0.2);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.6);
}
.eq-notes h3{ margin: 0 0 8px; font-size: 16px; }
.eq-notes ul{ margin: 0; padding-left: 18px; color: rgba(0,0,0,0.72); }

/* --- Make MathJax equations behave on small screens --- */
.eq-card {
  width: 100%;
}

.eq-latex {
  display: block;
}

/* Let long equations scroll horizontally instead of breaking layout */
.eq-latex mjx-container[jax="SVG"][display="true"] {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px; /* space for scrollbar on iOS */
}

/* Make the SVG itself scale down to fit the container when possible */
.eq-latex mjx-container[jax="SVG"] > svg {
  max-width: 100%;
  height: auto;
}

/* --- Mobile-specific spacing / typography --- */
@media (max-width: 600px) {
  .page { padding: 14px; }

  .eq-wrap {
    width: 100%;
    gap: 10px;
  }

  .eq-wrap h2 { font-size: 22px; }
  .eq-sub { font-size: 14px; }

  .eq-card { padding: 14px 12px; border-radius: 14px; }
  .eq-title { font-size: 15px; }

  /* Slightly reduce equation scale on mobile */
  .eq-latex mjx-container { font-size: 0.92em; }
}

.page--equations { overflow: hidden; place-items: start center; }

.eq-card {
  max-height: 70svh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
@supports (height: 100dvh) {
  .eq-card { max-height: 70dvh; }
}


/* =========
   Leaderboard
   ========= */
.leaderboard{
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.leaderboard-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.leaderboard-head h3{
  margin: 0;
  font-size: 16px;
  font-weight: 850;
}
.leaderboard-card{
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 12px 12px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
}
.leaderboard-scroll{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.leaderboard-table{
  width: 100%;
  border-collapse: collapse;
  min-width: 360px;
}
.leaderboard-table th, .leaderboard-table td{
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  font-size: 14px;
}
.leaderboard-table th{
  font-weight: 800;
  color: rgba(0,0,0,0.72);
}
.leaderboard-table td.score{
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.leaderboard-note{
  margin: 10px 0 0;
  font-size: 12.5px;
  color: rgba(0,0,0,0.60);
}

/* =========
   Modal
   ========= */
.modal{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  z-index: 50;
  padding: 18px;
}
.modal-card{
  width: min(520px, 95vw);
  border-radius: 18px;
  background: #ffffff;
  color: #0b1020;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 18px 55px rgba(0,0,0,0.22);
  padding: 16px 16px;
}
.modal-title{
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 900;
}
.modal-sub{
  margin: 0 0 12px;
  color: rgba(0,0,0,0.62);
  font-size: 13.5px;
  line-height: 1.35;
}
.modal-field{
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}
.modal-field span{
  font-size: 13px;
  color: rgba(0,0,0,0.72);
  font-weight: 700;
}
.modal-field input{
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.modal-field input:focus{
  border-color: rgba(0,0,0,0.35);
}
.modal-error{
  min-height: 18px;
  color: #b00020;
  font-size: 13px;
}
.modal-actions{
  display:flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 600px){
  .leaderboard-head{ align-items: flex-start; }
  .leaderboard-head .primary{ width: 100%; }
}

.score-big{
  font-size: clamp(1.6rem, 4.2vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}