:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #fff;
  --ink: #202434;
  --ink-soft: #697084;
  --muted: #747d90;
  --line: #e4e7ef;
  --blue: #2763df;
  --blue-soft: #e9f0ff;
  --mint: #0f9f6e;
  --violet: #7556d9;
  --amber: #d06b1d;
  --rose: #e14573;
  --font-game: "Nunito", "Segoe UI Rounded", "Aptos", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  font-family: var(--font-game);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --surface: #182133;
  --ink: #f4f7fb;
  --ink-soft: #b9c2d0;
  --muted: #8c96a8;
  --line: #2d384b;
  --blue: #75a8ff;
  --blue-soft: rgba(117, 168, 255, .16);
  --mint: #4ed19d;
  --violet: #b9a4ff;
  --amber: #ffae69;
  --rose: #ff6f9d;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: 0;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden],
.nav-brand {
  display: none !important;
}

.ws-game {
  min-height: 100svh;
  background: linear-gradient(180deg, #f8f9fd 0%, #eef2f8 100%);
}

html[data-theme="dark"] .ws-game {
  background: linear-gradient(180deg, #121b2b 0%, #0f1726 100%);
}

.ws-shell {
  min-height: 100svh;
  display: grid;
  place-items: stretch center;
}

.ws-surface {
  width: 100%;
  max-width: 430px;
  min-height: 100svh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.ws-topbar,
.home-lite-topbar {
  min-height: 58px;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(246, 247, 251, .96);
  border-bottom: 1px solid rgba(209, 216, 229, .72);
  backdrop-filter: blur(12px);
  z-index: 3;
}

html[data-theme="dark"] .ws-topbar,
html[data-theme="dark"] .home-lite-topbar {
  background: rgba(17, 24, 39, .94);
  border-bottom-color: rgba(255, 255, 255, .08);
}

.home-lite-brand,
.app-topbar-brand {
  min-width: 0;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 900;
  line-height: 1.08;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.theme-toggle-cta,
.round-action,
.create-facts-trigger {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(39, 99, 223, .16);
  border-radius: 999px;
  background: var(--surface);
  color: var(--blue);
  display: inline-grid;
  place-items: center;
  box-shadow: 0 7px 18px rgba(34, 40, 59, .08);
}

.install-app-cta {
  min-height: 34px;
  border: 1px solid rgba(39, 99, 223, .16);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .8125rem;
  font-weight: 900;
}

.ws-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.screen {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 96px;
}

.screen-route,
.create-studio,
.explore-step-page,
.category-step-page {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px 16px 96px;
}

.route-kicker,
.daily-tag,
.screen-title p {
  margin: 0;
  color: var(--blue);
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.screen-title h1,
.explore-hero-panel h1,
.category-detail-hero h1,
.detail-hero h1,
.create-hero-panel h1 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1.08;
  font-weight: 900;
}

.explore-hero-panel,
.category-detail-hero,
.detail-hero,
.create-hero-panel,
.route-panel,
.category-search-panel,
.home-panel-card {
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(209, 216, 229, .9);
  box-shadow: 0 12px 30px rgba(34, 40, 59, .08);
  padding: 16px;
}

html[data-theme="dark"] .explore-hero-panel,
html[data-theme="dark"] .category-detail-hero,
html[data-theme="dark"] .detail-hero,
html[data-theme="dark"] .create-hero-panel,
html[data-theme="dark"] .route-panel,
html[data-theme="dark"] .category-search-panel,
html[data-theme="dark"] .home-panel-card {
  background: rgba(24, 33, 51, .96);
  border-color: rgba(255, 255, 255, .09);
  box-shadow: 0 14px 30px rgba(3, 8, 18, .22);
}

.explore-hero-panel p,
.category-detail-hero p,
.detail-hero p,
.create-hero-panel p,
.route-panel p {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.primary-cta,
.ghost-cta,
.daily-play-cta {
  min-height: 48px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 1.0625rem;
  font-weight: 900;
  text-align: center;
}

.primary-cta,
.daily-play-cta {
  border: 0;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 13px 24px rgba(39, 99, 223, .22);
}

.ghost-cta {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--blue);
}

.difficulty-list,
.mode-grid,
.explore-topic-grid,
.category-puzzle-grid {
  display: grid;
  gap: 12px;
}

.difficulty-option,
.explore-topic-card,
.puzzle-card,
.profile-created-card {
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(34, 40, 59, .08);
  padding: 14px;
}

.difficulty-option {
  display: grid;
  gap: 8px;
}

.difficulty-option strong,
.explore-topic-card h3,
.route-panel h2,
.profile-section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.3125rem;
  line-height: 1.08;
  font-weight: 900;
}

.difficulty-meta,
.explore-topic-meta,
.explore-topic-puzzles small,
.puzzle-card-meta {
  color: var(--ink-soft);
  font-size: .8125rem;
}

.creator-prompt-area,
.create-ai-primary,
.create-layout {
  display: grid;
  gap: 14px;
}

.creator-prompt {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
}

.creator-prompt input,
.creator-prompt textarea,
.category-search-box input {
  width: 100%;
  border: 1px solid rgba(39, 99, 223, .28);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 14px 16px;
  font-weight: 800;
}

.bottom-nav {
  height: calc(68px + env(safe-area-inset-bottom));
  padding: 6px 12px max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  z-index: 4;
}

html[data-theme="dark"] .bottom-nav {
  background: rgba(17, 24, 39, .94);
}

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 6px 3px;
  font-size: .75rem;
  font-weight: 900;
}

.nav-item.is-active {
  background: var(--blue-soft);
  color: var(--blue);
}

@media (min-width: 768px) {
  .ws-surface {
    max-width: min(100%, 920px);
  }

  .explore-topic-grid,
  .category-puzzle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .ws-shell {
    width: min(100%, 1480px);
    min-height: 100svh;
    margin: 0 auto;
    padding: 24px;
  }

  .ws-surface {
    max-width: none;
    min-height: calc(100svh - 48px);
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(25, 33, 52, .16);
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .ws-topbar,
  .home-lite-topbar {
    grid-column: 2;
    grid-row: 1;
    min-height: 78px;
    padding: 18px 28px 14px;
  }

  .ws-main {
    grid-column: 2;
    grid-row: 2;
  }

  .bottom-nav {
    grid-column: 1;
    grid-row: 1 / span 2;
    height: 100%;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .nav-brand {
    min-height: 84px;
    display: grid !important;
    place-items: center;
    align-content: center;
    gap: 6px;
    border-radius: 8px;
  }

  .nav-brand img {
    width: 54px;
    height: 54px;
    object-fit: contain;
  }

  .screen-route,
  .create-studio,
  .explore-step-page,
  .category-step-page {
    padding: 30px clamp(28px, 4vw, 56px) 40px;
  }
}
