:root {
  --bg: #0b1220;
  --bg-soft: #121a2b;
  --card: #151f34;
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #9aa8c0;
  --accent: #4f8cff;
  --accent-strong: #2f6fff;
  --success: #3ddc97;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(79, 140, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #0b1220 0%, #0a101b 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  width: min(100%, 480px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 14px calc(220px + var(--safe-bottom));
}

.app:has(.topbar.is-home) {
  padding-top: 8px;
}

.topbar.is-home {
  display: none;
}

.topbar,
.result-head,
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.brand-name,
.result-label,
.ad-label,
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--muted);
}

.brand-tag,
.lede,
.hint,
.result-meta,
.footer-note,
.overlay-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7b61ff);
  box-shadow: var(--shadow);
}

.brand-name {
  font-size: 12px;
}

.brand-tag {
  font-size: 13px;
}

.card {
  background: rgba(21, 31, 52, 0.92);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.hero h1,
.steps h2,
.trending h2,
.result h2,
.overlay-card h2,
.section-head h2,
.platform-hero h1,
.fetch-card h1 {
  margin: 8px 0 10px;
  line-height: 1.2;
  font-size: 1.45rem;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.back-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  cursor: pointer;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffd27d;
  background: rgba(255, 210, 125, 0.12);
  border: 1px solid rgba(255, 210, 125, 0.24);
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.home-grid {
  margin-top: 0;
  margin-bottom: 14px;
}

.platform-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.platform-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  min-height: 96px;
}

.platform-tile.icon-only {
  justify-content: center;
  min-height: 88px;
  padding: 12px 8px;
}

.platform-tile:active {
  transform: scale(0.98);
}

.platform-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.platform-icon.large {
  width: 58px;
  height: 58px;
  font-size: 15px;
}

.platform-icon.label-text {
  width: 52px;
  height: 52px;
  padding: 4px;
  font-size: 9px;
  line-height: 1.15;
  font-weight: 700;
  white-space: normal;
  text-align: center;
}

.platform-icon.large.label-text {
  width: 64px;
  height: 64px;
  font-size: 10px;
}

.platform-name {
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  color: var(--muted);
}

.platform-banner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.guide-list,
.fetch-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.sample-chip {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
}

.fetch-card {
  text-align: center;
}

.loader-ring {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: 18px 0;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), #7b61ff);
  transition: width 0.35s ease;
}

.fetch-steps {
  list-style: none;
  padding: 0;
  text-align: left;
}

.fetch-steps li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fetch-steps li.is-done {
  color: var(--success);
}

.result-back {
  width: 100%;
  margin-top: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.input-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
}

.platforms,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.platforms span,
.chip {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.quality-option {
  border: 0;
  cursor: pointer;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  margin-top: 14px;
  border-radius: 14px;
  padding: 15px 16px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-strong), #5a7dff);
  color: #fff;
}

.secondary-btn {
  background: rgba(79, 140, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(79, 140, 255, 0.28);
}

.ghost-btn,
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
}

.icon-btn {
  flex-shrink: 0;
}

.steps ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.quality-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.quality-option {
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--card-border);
}

.quality-option.is-active {
  border-color: rgba(79, 140, 255, 0.65);
  background: rgba(79, 140, 255, 0.14);
}

.thumb {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.35), rgba(123, 97, 255, 0.35)),
    rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.ad-block {
  text-align: center;
}

.ad-label {
  margin-bottom: 10px;
}

.ad-slot {
  margin: 0 auto;
  overflow: hidden;
}

.ad-slot-rectangle,
.ad-slot-banner {
  min-width: 300px;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot-fluid {
  width: 100%;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: rgba(8, 12, 20, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--card-border);
}

.bottom-dock .ad-block {
  width: min(100%, 480px);
  margin: 0 auto 8px;
  padding: 10px 0 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.footer-note {
  width: min(100%, 480px);
  margin: 0 auto;
  font-size: 12px;
  text-align: center;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(4, 8, 16, 0.72);
  z-index: 30;
}

.overlay-card {
  width: min(100%, 420px);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px 22px 18px 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.overlay-close {
  width: 100%;
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 420px);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(18, 26, 43, 0.96);
  border: 1px solid var(--card-border);
  color: var(--text);
  z-index: 40;
  text-align: center;
}

.hidden {
  display: none !important;
}

.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

@media (min-width: 768px) {
  .app {
    padding-top: 28px;
  }

  .hero h1,
  .overlay-card h2 {
    font-size: 1.8rem;
  }
}
