/* ============================= The iOS app's own look =============================
   "B's layout with C's colours" (owner, 2026-09-27): Apple's layout — large titles, grouped white
   cards, a nav bar, a translucent tab bar, sheets that rise from the bottom — in the brand's
   purple-to-pink gradient. EVERY rule is scoped to html.in-app, which app.js sets only inside the
   iOS app, so the website is untouched. The behaviour is the page's own; see public/app-shell.js. */

html.in-app {
  /* green (owner, 2026-09-27), the same values as ios/WordBlitz/App/Theme.swift */
  --g1: #12b076; --g2: #33c78a; --g3: #a3de5e;
  --app-accent: #0e9660; --app-ink: #1e2b25; --app-muted: #7c8c84; --app-line: #e3efe8;
  /* one light look everywhere in the app (the gradient carries it; dark cards on it read badly) */
  --bg: #f2fbf6; --card: #ffffff; --ink: #1e2b25; --muted: #7c8c84; --accent: #0e9660; --accent-soft: #e4f6ec;
  --ring-track: #ddf3e7;
  color-scheme: light;
  background: var(--g1) !important;
  -webkit-tap-highlight-color: transparent;
}
html.in-app body {
  background: linear-gradient(170deg, var(--g1) 0%, var(--g2) 48%, var(--g3) 100%) fixed;
  min-height: 100vh;
  font-family: "Fredoka", -apple-system, "PingFang SC", "Hiragino Sans", sans-serif;
  color: var(--app-ink);
  -webkit-user-select: none;
}
/* The website's chrome, gone in the app: the splash, the header, the edge tabs, the sky backdrop. */
html.in-app #splash, html.in-app .topbar, html.in-app #backdrop, html.in-app #bdEdge,
html.in-app #bookBtn, html.in-app #artBtn, html.in-app footer.hint, html.in-app #timerWrap,
html.in-app #pauseBtn { display: none !important; }

/* ---------- screens ---------- */
html.in-app body:not([data-app-screen="home"]) #appHome { display: none; }
html.in-app body[data-app-screen="home"] .app { display: none; }
html.in-app body[data-app-screen="rank"] #appNav,
html.in-app body[data-app-screen="rank"] .stage { display: none !important; }
html.in-app body[data-app-screen="practice"] #leaderboard { display: none !important; }
html.in-app body[data-app-screen="practice"] #appTabs,
html.in-app body.app-panel #appTabs { display: none; }
html.in-app .app { display: block; padding: 0 0 calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

/* ---------- large titles (home, ranking) ---------- */
html.in-app .ah-cap { color: rgba(255,255,255,.8); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
html.in-app .ah-title { margin: 0; color: #fff; font-size: 2.3rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }

/* ---------- home ---------- */
html.in-app .ah { min-height: 100vh; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
html.in-app .ah-hero { padding: 6px 4px 14px; }
html.in-app .ah-seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(255,255,255,.28); margin-top: 14px; }
html.in-app .ah-seg button { flex: 1; border: 0; background: transparent; color: #fff; font: 600 .95rem/1.2 inherit; padding: 9px 4px; border-radius: 10px; }
html.in-app .ah-seg button small { display: block; font-size: .7rem; opacity: .8; font-weight: 500; }
html.in-app .ah-seg button.on { background: #fff; color: var(--app-accent); box-shadow: 0 2px 8px rgba(11, 74, 48, .15); }
html.in-app .ah-seg button.locked { opacity: .5; }
html.in-app .ah-body .ah-seg { background: rgba(255,255,255,.22); }
html.in-app .ah-card { background: #fff; border-radius: 18px; padding: 14px 16px; box-shadow: 0 8px 24px rgba(11, 74, 48, .18); }
html.in-app .ah-goal { display: flex; align-items: center; gap: 14px; }
html.in-app .ah-ring { width: 58px; height: 58px; flex: none; transform: rotate(-90deg); }
html.in-app .ah-ring-bg { fill: none; stroke: #e4f6ec; stroke-width: 7; }
html.in-app .ah-ring-fg { fill: none; stroke: var(--app-accent); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .4s; }
html.in-app .ah-goal-text b { font-size: 1.12rem; }
html.in-app .ah-goal-text p { margin: 2px 0 0; color: var(--app-muted); font-size: .88rem; }
html.in-app .ah-start { display: block; width: 100%; margin: 14px 0 4px; border: 0; border-radius: 999px; padding: 15px; background: #fff; color: var(--app-accent);
  font: 700 1.15rem/1.2 inherit; box-shadow: 0 10px 24px rgba(11, 74, 48, .28); }
html.in-app .ah-start span { display: block; font-size: .8rem; font-weight: 500; opacity: .75; }
html.in-app .ah-start:active, html.in-app .ah-row:active { transform: scale(.98); }
html.in-app .ah-h { margin: 22px 6px 8px; color: rgba(255,255,255,.92); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
html.in-app .ah-h span { text-transform: none; letter-spacing: 0; opacity: .85; margin-left: 4px; }
html.in-app .ah-group { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 24px rgba(11, 74, 48, .14); }
html.in-app .ah-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: #fff; padding: 11px 14px; text-align: left;
  font: 500 1rem/1.25 inherit; color: var(--app-ink); border-bottom: 1px solid var(--app-line); }
html.in-app .ah-row:last-child { border-bottom: 0; }
html.in-app .ah-row.on { background: #f4fbf7; }
html.in-app .ah-ic { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; font-size: 17px; background: #e4f6ec; }
html.in-app .ah-name { flex: 1; min-width: 0; }
html.in-app .ah-name small { display: block; color: var(--app-muted); font-size: .78rem; }
html.in-app .ah-row em { font-style: normal; color: var(--app-accent); font-weight: 600; }
html.in-app .ah-row i { font-style: normal; color: #b9c8c0; font-size: 1.3rem; }
html.in-app .ah-foot { text-align: center; color: rgba(255,255,255,.75); font-size: .78rem; margin-top: 22px; }
html.in-app .ah-foot a { color: #fff; }

/* ---------- the tab bar ---------- */
html.in-app .at { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  padding: 7px 4px calc(6px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); border-top: .5px solid rgba(60, 40, 110, .15); }
html.in-app .at button { flex: 1; border: 0; background: none; display: grid; justify-items: center; gap: 1px; color: #9a93ad; font: 500 .66rem/1.1 inherit; padding: 2px 0; }
html.in-app .at i { font-style: normal; font-size: 1.35rem; filter: grayscale(1) opacity(.55); }
html.in-app .at button.on { color: var(--app-accent); }
html.in-app .at button.on i { filter: none; }

/* ---------- practice: the nav bar (focus mode) ---------- */
html.in-app .an { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 4px) 8px 8px; color: #fff; }
html.in-app .an button { border: 0; background: rgba(255,255,255,.22); color: #fff; width: 38px; height: 38px; border-radius: 50%; font: 600 1.05rem/1 inherit; }
html.in-app .an-title { text-align: center; line-height: 1.2; }
html.in-app .an-title b { display: block; font-size: 1.05rem; }
html.in-app .an-title span { font-size: .76rem; opacity: .85; }
html.in-app .an-prog { grid-column: 1 / -1; height: 5px; margin: 10px 6px 0; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; }
html.in-app .an-prog i { display: block; height: 100%; background: #fff; transform-origin: left; transition: transform .2s linear; }
html.in-app .an-prog i.low { background: #ffe066; }

/* ---------- practice: the big card ---------- */
html.in-app .stage { display: block; padding: 6px 14px 0; min-height: 0 !important; }
html.in-app .card-col { display: block; }
html.in-app .card { background: #fff !important; border: 0 !important; border-radius: 28px; padding: 18px 18px 16px; margin: 6px 0 0;
  box-shadow: 0 20px 44px rgba(11, 74, 48, .28) !important; }
html.in-app .card-meta { gap: 6px; margin-bottom: 4px; }
html.in-app .card-meta .realm-label, html.in-app .card-meta .progress-label { background: #f1ebff; color: var(--app-accent); border-radius: 99px; padding: 2px 10px; font-size: .78rem; font-weight: 600; }
html.in-app .sentence { font-size: clamp(1.4rem, 6.2vw, 1.9rem); line-height: 1.85; margin: 10px 0 4px; font-weight: 500; }
html.in-app .sentence .blank { border-bottom-color: var(--app-accent); background: #f6f2ff; border-radius: 8px 8px 0 0; }
html.in-app .romaji { font-size: .92rem; color: var(--app-muted); margin: 0 0 6px; }
html.in-app .translation { font-size: .98rem; color: #5d5670; border-top: 1px solid var(--app-line); padding-top: 10px; margin-top: 8px; }
html.in-app .app-tools { display: flex; gap: 2px; padding: 3px; margin: 14px 0 4px; border-radius: 14px; background: #eef8f2; }
html.in-app .app-tools > button { flex: 1; min-width: 0; margin: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important;
  border-radius: 11px !important; padding: 9px 2px !important; font: 600 .82rem/1.15 inherit !important; color: #5d5670 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.in-app .app-tools > button.hidden { display: none !important; }
html.in-app .app-tools > #pauseBtn { display: block !important; flex: 0 0 52px; }   /* under the question box (owner, 2026-09-27) */
html.in-app .app-tools > button.on, html.in-app .app-tools > button.used, html.in-app .app-tools > button[aria-pressed="true"] { background: #fff !important; color: var(--app-accent) !important; box-shadow: 0 1px 4px rgba(11, 74, 48, .12) !important; }
html.in-app .app-tools .speak-icon { width: 20px; height: 16px; vertical-align: -3px; }
html.in-app .card-actions { margin-top: 12px; }
html.in-app .check-btn { display: block; width: 100%; border: 0; border-radius: 999px; padding: 15px; font: 700 1.15rem/1 inherit;
  background: linear-gradient(135deg, var(--g1), var(--g3)); color: #fff; box-shadow: 0 10px 22px rgba(120, 50, 200, .35); }
html.in-app .check-btn:active { transform: scale(.98); }
html.in-app .feedback { text-align: center; }
html.in-app .vote-row { justify-content: center; }

/* ---------- ranking as its own page ---------- */
html.in-app body[data-app-screen="home"] #leaderboard { display: none !important; }
html.in-app body[data-app-screen="rank"] #leaderboard { display: block !important; }
html.in-app #leaderboard { margin: 0 auto; max-width: 640px; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(96px + env(safe-area-inset-bottom));
  background: transparent !important; border: 0 !important; box-shadow: none !important; }
html.in-app .ar-head { padding: 6px 4px 14px; }
html.in-app #leaderboard .lb-head { background: #fff; border-radius: 16px 16px 0 0; padding: 12px 14px; margin: 0; }
html.in-app #leaderboard .lb-civet { display: none; }
html.in-app #leaderboard .lb-period { background: #fff; padding: 0 14px 10px; margin: 0; }
html.in-app #leaderboard .lb-view { background: #fff; border-radius: 0 0 16px 16px; max-height: none !important; height: auto !important; overflow: visible !important; }
html.in-app #leaderboard .lb-foot { color: rgba(255,255,255,.9); margin-top: 10px; text-align: center; }
html.in-app #leaderboard .lb-row { border-bottom: 1px solid var(--app-line); background: transparent; }

/* ---------- dialogs become bottom sheets ---------- */
html.in-app .overlay { align-items: flex-end !important; padding: 0 !important; background: rgba(35, 15, 70, .35); }
html.in-app .overlay-box { width: 100% !important; max-width: 640px !important; margin: 0 auto !important; border-radius: 26px 26px 0 0 !important;
  padding: 26px 18px calc(18px + env(safe-area-inset-bottom)) !important; max-height: calc(100dvh - env(safe-area-inset-top) - 16px) !important;
  background: #fff !important; box-shadow: 0 -12px 40px rgba(11, 74, 48, .25) !important; }
html.in-app .overlay-box::before { content: ""; position: absolute; top: 9px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: #ddd6ee; }
html.in-app #overlay.show { align-items: center !important; background: transparent; }       /* the loading card stays a card */
html.in-app #overlay .overlay-box { border-radius: 24px !important; width: auto !important; max-width: 86vw !important; padding-bottom: 20px !important; }
html.in-app #overlay .overlay-box::before { display: none; }
html.in-app .retry-btn:not(.ghost-btn) { background: linear-gradient(135deg, var(--g1), var(--g3)); border: 0; color: #fff; }
html.in-app .am h2 { margin-top: 0; }
html.in-app .am .ah-group { box-shadow: none; border: 1px solid var(--app-line); margin: 8px 0 12px; }

/* ---------- the books and 文章赏析: a nav bar in the brand colours ---------- */
html.in-app .book-head { background: linear-gradient(135deg, var(--g1), var(--g3)) !important; color: #fff; padding-top: calc(env(safe-area-inset-top) + 8px) !important; }
html.in-app .book-head * { color: inherit; }
html.in-app .book-overlay { background: #f6f3ff !important; }

/* ---------- toasts drop from the top, like iOS notifications ---------- */
html.in-app .badge-toast { top: calc(env(safe-area-inset-top) + 10px); bottom: auto; border-radius: 20px; max-width: calc(100vw - 24px);
  box-shadow: 0 12px 30px rgba(11, 74, 48, .28); }

/* ---------- app, not web page: no drag past the edges, no zoom, no long-press menus ---------- */
html.in-app, html.in-app body { overscroll-behavior: none; touch-action: manipulation; }
html.in-app * { -webkit-touch-callout: none; }
html.in-app input, html.in-app textarea, html.in-app [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }


/* ---------- native tabs: the SwiftUI app draws home, ranking and the tab bar ---------- */
html.in-app.native-tabs #appHome, html.in-app.native-tabs #appTabs { display: none !important; }
html.in-app.native-tabs body[data-app-screen="home"] { background: transparent; }
