:root {
  --green: #01875f;
  --green-dark: #016b4c;
  --green-ghost: #f1f8f5;
  --text: #1f1f1f;
  --muted: #5f6368;
  --divider: #e8eaed;
  --star: #fbbc04;
  --radius: 8px;
  --bg: #ffffff;
  --card-bg: #ffffff;
  --track: #f1f3f4;
  --desc-text: #333333;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --green-ghost: rgba(1, 135, 95, .18);
    --text: #e8eaed;
    --muted: #9aa0a6;
    --divider: #3c4043;
    --bg: #1f1f1f;
    --card-bg: #2b2c2e;
    --track: #3c4043;
    --desc-text: #c9cdd1;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* the hidden attribute must always win over display rules below */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

/* launched as an installed PWA: keep clear of the status bar / notch */
@media (display-mode: standalone) {
  .page { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
}
body.is-standalone .page { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }

/* ---------- header ---------- */
.app-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-top: 8px;
}

.app-icon {
  border-radius: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.app-name {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.25;
}

.app-dev {
  color: var(--green);
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
  margin-top: 4px;
}

.app-badges {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.app-badges span + span::before { content: " · "; }

/* ---------- stats ---------- */
.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 20px 0 4px;
  text-align: center;
}

.stat { display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.stat-value { font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; justify-content: center; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-divider { width: 1px; height: 28px; background: var(--divider); }

.stat-esrb {
  border: 1px solid var(--muted);
  border-radius: 3px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 18px;
  align-self: center;
}

.star-icon { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; }

/* ---------- install button ---------- */
.install-section { margin: 16px 0 8px; }

.btn-install {
  display: block;
  width: 100%;
  border: none;
  border-radius: 20px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 24px;
  cursor: pointer;
  transition: background .2s;
  position: relative;
}

.btn-install:hover { background: var(--green-dark); }
.btn-install.small { width: auto; padding: 8px 20px; border-radius: 16px; font-size: 14px; }

.btn-install.is-open {
  background: var(--bg);
  color: var(--green);
  border: 1px solid var(--green);
}
.btn-install.is-open:hover { background: var(--green-ghost); }

.btn-install:disabled { opacity: .75; cursor: default; }

.btn-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}

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

/* ---------- screenshots ---------- */
.shots-wrap { position: relative; }

.shots {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px 0 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.shots::-webkit-scrollbar { display: none; }

.shots img {
  height: 200px;
  border-radius: var(--radius);
  scroll-snap-align: start;
  flex-shrink: 0;
  background: var(--track);
}

.shot-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--card-bg);
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.shot-nav svg { width: 22px; height: 22px; fill: var(--muted); }
.shot-nav:hover svg { fill: var(--text); }
.shot-nav.prev { left: 8px; }
.shot-nav.next { right: 8px; }

@media (min-width: 720px) {
  .shots img { height: 300px; }
  .shot-nav { display: flex; }
}

/* ---------- tags ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
}

.tag {
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 4px 12px;
  background: var(--bg);
}

/* ---------- sections ---------- */
.section {
  border-top: 1px solid var(--divider);
  padding: 20px 0;
}

.section-title { font-size: 18px; font-weight: 500; margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; margin-top: 6px; }

/* description */
.description { font-size: 14px; color: var(--desc-text); position: relative; overflow: hidden; }
.description.collapsed { max-height: 180px; }
.description.collapsed::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 48px;
  background: linear-gradient(transparent, var(--bg));
}
.description h3 { font-size: 15px; margin: 14px 0 6px; }
.description p { margin: 8px 0; }
.description ul { margin: 8px 0 8px 20px; }
.description li { margin: 4px 0; }

.desc-toggle {
  display: block;
  margin: 4px auto 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  transition: transform .2s;
}
.desc-toggle.open { transform: rotate(90deg); }

/* ---------- ratings ---------- */
.ratings-summary { display: flex; gap: 32px; align-items: center; margin-bottom: 20px; }

.score-number { font-size: 56px; font-weight: 400; line-height: 1; }

.stars { display: inline-flex; gap: 1px; margin: 6px 0 2px; }
.stars svg { width: 14px; height: 14px; }
.stars .full { fill: var(--star); }
.stars .empty { fill: #dadce0; }

.ratings-bars { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar-track { flex: 1; height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 4px; }

/* reviews */
.review {
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.review-author { font-size: 13px; font-weight: 600; }
.review-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.review-text { font-size: 13px; color: var(--desc-text); margin: 8px 0; }
.review-helpful { font-size: 12px; color: var(--muted); }

/* ---------- app info ---------- */
.info-table { font-size: 14px; }
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.info-row dt { color: var(--muted); }
.info-row dd { text-align: right; }

.page-footer { height: 24px; }

/* ---------- sticky bar ---------- */
.sticky-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--divider);
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  z-index: 40;
}

.sticky-icon { border-radius: 10px; }
.sticky-info { flex: 1; min-width: 0; }
.sticky-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-sub { font-size: 12px; color: var(--muted); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.overlay-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px 24px;
  width: min(320px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  overflow-y: auto;
  text-align: center;
  animation: popIn .25s ease;
}

@keyframes popIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.overlay-icon-wrap { position: relative; width: 88px; height: 88px; margin: 0 auto 16px; }
.overlay-icon { position: absolute; inset: 12px; width: 64px; height: 64px; border-radius: 14px; }

.progress-ring { position: absolute; inset: 0; width: 88px; height: 88px; transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: var(--divider); }
.ring-fg {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 188;
  animation: ringSpin 1.2s linear infinite;
  transform-origin: center;
}

@keyframes ringSpin {
  0%   { stroke-dashoffset: 220; transform: rotate(0deg); }
  50%  { stroke-dashoffset: 80; }
  100% { stroke-dashoffset: 220; transform: rotate(360deg); }
}

.check-mark { position: absolute; inset: 0; width: 88px; height: 88px; display: none; }
.check-mark .check-circle {
  fill: none; stroke: var(--green); stroke-width: 3;
  stroke-dasharray: 151; stroke-dashoffset: 151;
}
.check-mark .check-path {
  fill: none; stroke: var(--green); stroke-width: 4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
}
.check-mark.show { display: block; }
.check-mark.show .check-circle { animation: draw .4s ease forwards; }
.check-mark.show .check-path { animation: draw .3s ease .35s forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }

.overlay-text { font-size: 15px; color: var(--text); }

/* guide modal */
.guide-card { text-align: left; }
.guide-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; text-align: center; }
.guide-steps { margin: 0 0 16px 20px; font-size: 14px; color: var(--desc-text); }
.guide-steps li { margin: 8px 0; }
.guide-card .btn-install { display: block; margin: 0 auto; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: #202124;
  color: #fff;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 120;
  animation: toastIn .25s ease;
  white-space: nowrap;
}

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 720px) {
  .sticky-bar { display: none; }
  .app-name { font-size: 28px; }
}
