/* One type family (Noto Sans and its sister fonts for non-Latin scripts), flat colors only — no gradients. */

/* Country flag emoji drawn the same on every device (Windows has no flag emoji).
   Artwork: Twemoji by Twitter, CC-BY 4.0 — see /fonts/LICENSE-TwemojiCountryFlags.md */
@font-face {
  font-family: "Twemoji Country Flags";
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("/fonts/TwemojiCountryFlags.woff2") format("woff2");
  font-display: swap;
}

/* Noto Sans, self-hosted (SIL Open Font License); variable weight 400–700, split by script. */
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-devanagari.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF4, U+1CF7-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B0A;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-greek-ext.woff2") format("woff2");
  unicode-range: U+1F00-1FFF;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Noto Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/noto-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F4F4F5;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --text: #18181B;
  --muted: #71717A;
  --primary: #18181B;
  --on-primary: #FFFFFF;
  --error: #B91C1C;
  --error-bg: #FEF2F2;
  --pattern: #E4E4E7;

  --radius: 14px;
  --radius-sm: 10px;
  --font-script: "Noto Sans";
  --font: "Twemoji Country Flags", "Noto Sans", var(--font-script), system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --header-h: calc(65px + env(safe-area-inset-top));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0A0A;
    --surface: #141414;
    --surface-2: #1C1C1E;
    --border: #27272A;
    --border-strong: #3F3F46;
    --text: #FAFAFA;
    --muted: #A1A1AA;
    --primary: #FAFAFA;
    --on-primary: #0A0A0A;
    --error: #F87171;
    --error-bg: #1F1212;
    --pattern: #222225;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}


body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* Form controls don't inherit the page font by default on Android/iOS/Windows. */
button, input, select, textarea, summary { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, p, ol, ul { margin: 0; }
img, svg { display: block; }
a { color: inherit; }
strong { font-weight: 600; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; inset-inline-start: 12px; top: -48px; z-index: 20;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary); text-decoration: none; font-weight: 600;
}
.skip:focus { top: 12px; }

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.container.narrow { max-width: 880px; }

/* ---------- header ---------- */
.header {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
/* Three columns with equal sides, so the nav sits exactly in the middle of the bar. */
.header-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; height: 64px; }
.brand { justify-self: start; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 9px; background: var(--primary); color: var(--on-primary);
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }

/* ---------- language picker ---------- */
.lang-button {
  justify-self: end;
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 40px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.lang-button:hover { border-color: var(--text); }
.lang-flag { font-size: 20px; line-height: 1; }

.lang-dialog {
  width: min(440px, calc(100% - 32px)); max-height: min(640px, calc(100dvh - 48px));
  padding: 0; margin: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  overflow: hidden; flex-direction: column;
}
.lang-dialog[open] { display: flex; }
.lang-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.lang-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 16px 8px 20px; padding-inline: 20px 12px;
}
.lang-head h2 { font-size: 18px; font-weight: 700; }
.icon-button {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.lang-search-wrap { padding: 4px 16px 12px; }
.lang-search {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); font-size: 16px; outline: 0;
  -webkit-appearance: none; appearance: none;
}
.lang-search:focus { border-color: var(--text); }
.lang-list {
  position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 8px 12px; list-style: none;
  border-top: 1px solid var(--border);
}
.lang-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 6px 12px; margin-top: 4px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  text-align: start; cursor: pointer;
}
.lang-item:hover { background: var(--surface-2); }
.lang-item[aria-current] { background: var(--primary); color: var(--on-primary); }
.lang-item[aria-current] .lang-english { color: inherit; opacity: .75; }
.lang-item .lang-flag { font-size: 24px; flex: none; }
.lang-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.lang-native { font-weight: 600; font-size: 15px; }
.lang-english { color: var(--muted); font-size: 13px; }
.lang-empty { padding: 16px 20px 24px; color: var(--muted); text-align: center; }
.lang-empty[hidden] { display: none; }

/* ---------- section background: flat dot pattern (SVG mask tinted with --pattern). Each tile has its dot in the
   middle and tiles are rounded to fit the section, so dots sit 12px either side of every divider. ---------- */
.pattern-dots { position: relative; isolation: isolate; }
.pattern-dots::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-color: var(--pattern);
  -webkit-mask-repeat: round; mask-repeat: round; /* whole tiles only: dots sit 12px from every edge */
}
.pattern-dots::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1.5'/%3E%3C/svg%3E"); }

/* ---------- full-screen sections (desktop and tablet) ---------- */
.screen {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  display: flex; flex-direction: column; justify-content: center;
}

/* ---------- hero ---------- */
.hero { padding: 48px 0; text-align: center; }
h1 {
  font-size: clamp(28px, 6vw, 48px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.lead {
  max-width: 560px; margin: 16px auto 0;
  color: var(--muted); font-size: clamp(16px, 2.2vw, 18px);
  text-wrap: pretty;
}

.search { display: flex; gap: 10px; margin-top: 32px; }
.field {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center;
  height: 56px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.field:focus-within { border-color: var(--text); }
.field-icon { flex: none; margin-inline-start: 16px; color: var(--muted); }
.field input {
  flex: 1; min-width: 0; height: 100%;
  padding: 0; padding-inline: 12px 8px;
  border: 0; outline: 0; background: transparent;
  font-size: 16px; /* >=16px stops iOS Safari from zooming on focus */
  -webkit-appearance: none; appearance: none;
  border-radius: 0;
}
.field input::placeholder { color: var(--muted); opacity: 1; }
.field-action {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  height: 40px; min-width: 40px; margin-inline-end: 8px; padding: 0 12px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.field-action:hover { background: var(--border); }
.field-action[hidden] { display: none; }
#clear { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  touch-action: manipulation;
  transition: opacity .15s, background-color .15s, border-color .15s;
}
.btn-primary { height: 56px; padding: 0 28px; background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { cursor: wait; opacity: .7; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--text); }

.spinner {
  display: none; width: 18px; height: 18px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.is-loading .spinner { display: block; }
.is-loading .btn-label { display: none; }
.btn.is-busy { cursor: progress; }
.btn.is-busy .spinner { display: block; width: 16px; height: 16px; }
.btn.is-busy > svg { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin-top: 24px; padding: 0; list-style: none;
}
.chips li {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500;
}

/* ---------- results ---------- */
.results { display: grid; gap: 16px; margin-top: 32px; text-align: start; }
.results[hidden] { display: none; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { font-size: 18px; }
.results-head span { color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.result { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; padding: 20px; }
.result-media { min-width: 0; }
.thumb {
  position: relative; overflow: hidden;
  aspect-ratio: var(--ratio, 1); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .thumb-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
}
.badge {
  position: absolute; inset-inline-start: 8px; bottom: 8px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--primary); color: var(--on-primary);
  font-size: 12px; font-weight: 600;
}
.result-body { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.result-title {
  font-size: 17px; font-weight: 600; line-height: 1.4;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.result-meta { margin-top: 4px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.group-title {
  margin-bottom: 8px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
}
.options { display: grid; gap: 8px; padding: 0; list-style: none; }
.option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 8px; padding-inline: 16px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.option-info { min-width: 0; }
.option-quality { font-weight: 600; font-size: 15px; }
.option-detail { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.option .btn { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: var(--radius-sm); flex: none; }

.more {
  justify-self: start; margin-top: -4px; padding: 6px 0;
  border: 0; background: none; color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.more:hover { color: var(--text); }

.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--error); background: var(--error-bg); color: var(--error);
  font-size: 15px; font-weight: 500;
}
.alert svg { flex: none; margin-top: 2px; }

/* skeleton */
.skeleton .thumb, .sk { animation: pulse 1.4s ease-in-out infinite; }
.sk { height: 14px; border-radius: 6px; background: var(--surface-2); }
.sk-title { height: 20px; width: 80%; }
.sk-line { width: 40%; }
.sk-row { height: 60px; border-radius: var(--radius-sm); }
.loading-text { color: var(--muted); font-size: 14px; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- sections ---------- */
.section { padding: 64px 0; border-top: 1px solid var(--border); }
.section h2 { font-size: clamp(22px, 4vw, 28px); font-weight: 700; letter-spacing: -0.02em; text-align: center; }
.section-lead { max-width: 560px; margin: 8px auto 0; color: var(--muted); text-align: center; }

.steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
  margin-top: 32px; padding: 0; list-style: none;
}
.step { padding: 24px; }
.step-num {
  display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 16px;
  border-radius: 10px; background: var(--primary); color: var(--on-primary);
  font-weight: 700;
}
.step h3 { font-size: 17px; font-weight: 600; }
.step p { margin-top: 6px; color: var(--muted); font-size: 15px; }

.platforms {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px;
  margin-top: 32px; padding: 0; list-style: none;
}
.platforms li {
  display: grid; place-items: center; min-height: 52px; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 15px; font-weight: 500; text-align: center;
}

.faq { display: grid; gap: 10px; margin-top: 32px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 56px; padding: 12px 16px;
  font-weight: 600; cursor: pointer; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; flex: none; width: 10px; height: 10px; margin-inline-end: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-3px); transition: transform .2s;
}
.faq details[open] summary::after { transform: rotate(-135deg) translateY(-3px); }
.faq details p { padding: 0 16px 16px; color: var(--muted); }

/* ---------- footer ---------- */
.footer {
  margin-top: auto;
  padding: 24px 0 calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.footer p { color: var(--muted); font-size: 14px; text-align: center; }
.footer a { color: var(--text); font-weight: 700; text-decoration: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 30;
  left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary);
  font-size: 14px; font-weight: 500; text-align: center;
}
.toast[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .platforms { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  /* Phones: sections take the height of their content again. */
  .screen { min-height: 0; display: block; }
  .hero { padding: 40px 0 28px; }
  .section { padding: 44px 0; }
  .search { flex-direction: column; }
  .btn-primary { width: 100%; }
  .result { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .result-media .thumb { aspect-ratio: 16 / 9; }
  .result-media .thumb img { object-fit: contain; }
  .steps { grid-template-columns: 1fr; }
  .step { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; padding: 20px; }
  .step-num { grid-row: span 2; margin-bottom: 0; }
  .platforms { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .nav { display: none; }
  .header-inner { grid-template-columns: 1fr auto; }
}

@media (max-width: 520px) {
  .platforms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chips li { font-size: 12px; padding: 5px 10px; }
}

/* Very narrow screens, e.g. Galaxy Z Fold cover display (~280px). */
@media (max-width: 340px) {
  :root { --gutter: max(12px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .field-icon { display: none; }
  .field input { padding-inline-start: 14px; }
  .option { flex-wrap: wrap; padding: 12px; }
  .option .btn { width: 100%; }
  .step { grid-template-columns: 1fr; }
  .step-num { grid-row: auto; margin-bottom: 12px; }
  .platforms li { font-size: 14px; }
}

/* Scripts that need more room above and below the line. */
:lang(th) h1, :lang(lo) h1, :lang(km) h1, :lang(my) h1, :lang(si) h1, :lang(ta) h1, :lang(ml) h1,
:lang(te) h1, :lang(kn) h1, :lang(bn) h1, :lang(hi) h1, :lang(mr) h1, :lang(ne) h1, :lang(ur) h1 { line-height: 1.45; }
/* Letter spacing breaks joined scripts like Arabic. */
[dir="rtl"] *, :lang(th) *, :lang(lo) *, :lang(km) *, :lang(my) * { letter-spacing: normal !important; }

@media (hover: none) {
  .nav a:hover, .field-action:hover { background: transparent; }
  .field-action:hover { background: var(--surface-2); }
  .btn-primary:hover { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* The skip link focuses <main>; it needs no visible ring. */
main:focus { outline: none; }
