/* Start screen on the Play tab (website and store apps): Continue card, level strip, Premium row.
   Filled by app.js renderAppStart(). The website hero and the menu tiles that only repeat the tab bar give way;
   the rest of the home page (Daily Pick, sessions, studio, community, footer) follows below. */
#home > .hero,
#home .tile[data-screen="home"],
#home .tile[data-screen="catalog"],
#home .tile[data-screen="editor"],
#home .tile[data-screen="records"],
#home .tile[data-screen="subscribe"] {
  display: none !important;
}
/* Only the owner's Stats tile is left in the row; without it the row would just add empty margin. */
#home > .menu-tiles:not(:has(.tile-stats:not([hidden]))) {
  display: none;
}
.app-start {
  --as-card: #0e1324;
  --as-hero: #0c1222;
  --as-inset: #080c19;
  --as-border: #1c2338;
  --as-divider: #151b2e;
  --as-track: #1a2238;
  --as-text2: #aeb6cc;
  --as-gold: #ffd27a;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 0 8px;
}
.app-start h2 {
  margin: 0;
}
.app-start [hidden] {
  display: none !important;
}

/* ----- Continue card ----- */
.as-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid #1f3a3d;
  border-radius: 24px;
  background: var(--as-hero);
}
.as-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.as-eyebrow {
  color: var(--mint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
}
.as-of {
  color: var(--muted);
  font-size: 12px;
}
.as-title {
  min-width: 0;
  overflow: hidden;
  font: 700 32px/1.1 "Space Grotesk", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-diff {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  color: var(--as-text2);
  font-size: 12px;
  font-weight: 600;
}
.as-diff i {
  width: 8px;
  height: 8px;
  background: #2a3350;
  transform: rotate(45deg);
}
.as-diff i.on {
  background: var(--course, var(--mint));
}
.as-diff span {
  margin-left: 4px;
}
.as-preview {
  display: block;
  width: 100%;
  height: 84px;
  border-radius: 14px;
  background: var(--as-inset);
}
.as-best-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: -8px;
  color: var(--as-text2);
  font-size: 12px;
}
.as-best-row b {
  margin-left: 4px;
  color: var(--text);
  font: 700 13px "Space Grotesk", system-ui, sans-serif;
}
.as-last {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Slides: one level per slide, swiped (scroll snap), or stepped with the arrows, the dots or ←/→. */
.as-hero-head {
  margin: -4px 0 -6px;
}
.as-hero-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.as-arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--as-border);
  border-radius: 10px;
  background: var(--as-card);
  color: var(--text);
}
.as-arrow:disabled {
  opacity: 0.35;
}
.as-history {
  height: 30px;
  padding: 0 12px;
  border: 1px solid #1f3a3d;
  border-radius: 10px;
  background: transparent;
  color: var(--mint);
  font: 700 13px "Space Grotesk", system-ui, sans-serif;
}
.as-slides {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: 16px;
}
.as-slides::-webkit-scrollbar {
  display: none;
}
.as-slides:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}
.as-slide {
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.as-result {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.as-result.pass {
  background: #10312b;
  color: var(--mint);
}
.as-result.fail {
  background: #2a1a24;
  color: #ff9db2;
}
.as-result.next {
  background: #1a2238;
  color: var(--as-text2);
}
.as-dots {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: -10px 0 -12px;
}
.as-dot {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
}
.as-dot::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  margin: auto;
  border-radius: 50%;
  background: #2a3350;
  transition: width 0.15s;
}
.as-dot[aria-current="true"]::before {
  width: 18px;
  border-radius: 4px;
  background: var(--mint);
}
.as-empty {
  margin: -4px 0 0;
  color: var(--as-text2);
  font-size: 12px;
  text-align: center;
}
/* Touch screens swipe; the arrows stay for mouse and keyboard. */
@media (hover: none) and (pointer: coarse) {
  .as-arrow {
    display: none;
  }
}
.as-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--as-track);
}
.as-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--course, var(--mint));
}
.as-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 64px;
  border-radius: 20px;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(109, 255, 208, 0.14);
  color: #04231b;
  font: 700 24px "Space Grotesk", system-ui, sans-serif;
}
.as-play:active {
  transform: scale(0.98);
}
/* A Premium level the player started before their subscription ended: the card stays, the button unlocks. */
.as-play.locked {
  border: 1px solid var(--as-gold);
  background: #12121c;
  box-shadow: none;
  color: var(--as-gold);
  font-size: 18px;
}
.as-play[aria-busy] {
  opacity: 0.7;
}

/* ----- Levels strip ----- */
.as-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: -8px;
}
.as-head h2 {
  font: 700 18px "Space Grotesk", system-ui, sans-serif;
}
.as-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.as-levels {
  display: flex;
  gap: 10px;
  margin: 0 -16px;
  padding: 0 16px;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
}
.as-level {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 128px;
  height: 104px;
  padding: 12px;
  border: 1px solid var(--as-border);
  border-top: 2px solid var(--course, var(--mint));
  border-radius: 16px;
  background: var(--as-card);
  color: inherit;
  text-align: left;
  scroll-snap-align: start;
}
.as-level.current {
  border: 1px solid var(--course, var(--mint));
}
.as-num {
  overflow: hidden;
  color: var(--course, var(--mint));
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-level strong {
  overflow: hidden;
  font: 700 16px/1.2 "Space Grotesk", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-level .as-track {
  height: 4px;
  margin-top: auto;
  border-radius: 2px;
}
.as-status {
  color: var(--as-text2);
  font-size: 12px;
  font-weight: 600;
}
.as-level.current .as-status,
.as-level.done .as-status {
  color: var(--mint);
}

/* ----- Popular Levels (same cards as the Daily Pick; Premium ones locked for free players) ----- */
.as-popular {
  position: relative;
  width: 144px;
}
.as-popular .as-status {
  margin-top: auto;
  white-space: nowrap;
}
.as-popular.locked {
  border-top-color: var(--as-gold);
}
.as-popular.locked .as-num {
  padding-right: 18px;
}
.as-popular.locked strong {
  color: var(--as-text2);
}
.as-lock {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--as-gold);
}
.as-lock svg {
  display: block;
  width: 14px;
  height: 14px;
}

/* ----- Free Levels · Levels (primary) · Leaderboard ----- */
.as-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.as-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 4px;
  white-space: nowrap;
  border: 1px solid #4a3f24;
  border-radius: 18px;
  background: #12121c;
  color: var(--as-gold);
  font: 700 14px "Space Grotesk", system-ui, sans-serif;
}
.as-mode svg {
  flex: none;
}
.as-mode.primary {
  border-color: var(--as-gold);
  background: linear-gradient(160deg, #3a2f12, #1d1a12);
  box-shadow: 0 0 0 1px #6a5420 inset, 0 8px 24px #f5c54222;
}
.as-mode small {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--as-text2);
  font: 600 11px system-ui, sans-serif;
}
.as-mode small svg {
  width: 11px;
  height: 11px;
}
.as-head h2 small {
  margin-left: 6px;
  color: var(--mint);
  font: 600 12px system-ui, sans-serif;
}
.as-note {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 12px 16px;
  border: 1px dashed #34344a;
  border-radius: 18px;
  color: var(--as-text2);
  font-size: 13px;
}
.as-note p {
  margin: 0;
}
.as-note button {
  flex: none;
  height: 40px;
  padding: 0 16px;
}

/* ----- Play history screen (#history) ----- */
#history [hidden] {
  display: none !important;
}
.history-link {
  float: right;
  margin-top: 2px;
  padding: 0;
  color: var(--mint);
  font: 600 13px system-ui, sans-serif;
}
.history-panel {
  --as-track: #1a2238;
}
.history-panel .records-filters {
  margin-bottom: 8px;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 128px 96px 112px;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid #1c2338;
  border-left: 3px solid var(--course, var(--mint));
  border-radius: 14px;
  background: #0e1324;
}
.hr-main,
.hr-when {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.hr-main strong {
  overflow: hidden;
  font: 700 16px/1.2 "Space Grotesk", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hr-meta,
.hr-when small {
  overflow: hidden;
  color: #aeb6cc;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hr-when span {
  font-size: 13px;
  font-weight: 600;
}
.hr-best {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.hr-best .as-track {
  height: 4px;
}
.history-row .as-result {
  justify-self: start;
}
.hr-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--mint);
  color: #04231b;
  font: 700 14px "Space Grotesk", system-ui, sans-serif;
  white-space: nowrap;
}
.hr-play.locked {
  border: 1px solid #ffd27a;
  background: #12121c;
  color: #ffd27a;
}
.hr-play.locked svg {
  width: 14px;
  height: 14px;
}
.hr-play:disabled {
  background: #1a2238;
  color: #7c86a3;
  font-size: 12px;
}
.hr-play[aria-busy] {
  opacity: 0.7;
}
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border: 1px dashed #34344a;
  border-radius: 16px;
  color: #aeb6cc;
}
.history-empty p {
  margin: 0;
}
.history-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  color: #aeb6cc;
  font-size: 13px;
}
@media (max-width: 720px) {
  .history-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main play" "when result" "best best";
    gap: 8px 12px;
  }
  .hr-main {
    grid-area: main;
  }
  .hr-when {
    grid-area: when;
  }
  .hr-best {
    grid-area: best;
    flex-direction: row;
    align-items: center;
  }
  .hr-best b {
    flex: none;
    font-size: 12px;
  }
  .hr-best .as-track {
    flex: 1;
  }
  .history-row .as-result {
    grid-area: result;
    justify-self: end;
  }
  .hr-play {
    grid-area: play;
    height: 36px;
  }
}

/* Phones on their side: Continue card on the left, levels and Premium on the right. */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 560px) {
  .app-start {
    display: grid;
    grid-template-columns: minmax(240px, 42%) minmax(0, 1fr);
    grid-auto-rows: min-content;
    gap: 12px 16px;
  }
  .as-hero {
    grid-row: 1 / span 3;
    align-self: start;
    position: sticky;
    top: 8px;
    gap: 10px;
    padding: 14px;
  }
  .as-preview {
    display: none;
  }
  .as-title {
    font-size: 24px;
  }
  .as-head,
  .as-levels,
  .as-modes {
    grid-column: 2;
  }
  .as-head {
    margin-bottom: 0;
  }
  .as-levels {
    margin: 0;
    padding: 0;
  }
}
