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

:root {
  --black: #010101;
  --white: #ffffff;
  --tiktok-red: #fe2c55;
  --tiktok-cyan: #25f4ee;
  --gray-400: #999;
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 20px;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -120px;
  right: -120px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(254,44,85,.18) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -100px;
  left: -100px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(37,244,238,.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: #111;
  border: 1px solid #222;
  border-radius: 24px;
  padding: 40px 28px 36px;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,.6);
}

.logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
}

.logo-inner {
  width: 100%;
  height: 100%;
  background: #1a1a1a;
  border-radius: 18px;
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
}

/* ── Loading ── */
#loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner-wrap {
  position: relative;
  width: 56px;
  height: 56px;
}

.spinner-track {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid #222;
}

.spinner-arc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--tiktok-red);
  border-right-color: var(--tiktok-cyan);
  animation: spin .9s linear infinite;
}

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

.loading-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.3px;
}

.loading-sub {
  font-size: 13px;
  color: var(--gray-400);
  line-height: 1.5;
}

.dots span {
  animation: blink 1.4s infinite;
}
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* ── Fallback ── */
#fallback-section {
  display: none;
  flex-direction: column;
  align-items: center;
}

.fallback-icon {
  font-size: 44px;
  margin-bottom: 16px;
}

.fallback-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -.3px;
}

.fallback-desc {
  font-size: 14px;
  color: var(--gray-400);
  line-height: 1.6;
  margin-bottom: 24px;
}

.hint-block {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-bottom: 24px;
}

.hint-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
}

.hint-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #2a2a2a;
  color: var(--gray-400);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hint-step p {
  font-size: 13px;
  line-height: 1.5;
  color: #ccc;
}

.hint-step strong {
  color: var(--white);
}

.url-box {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.url-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gray-400);
  margin-bottom: 6px;
}

.url-text {
  font-size: 13px;
  color: var(--tiktok-cyan);
  word-break: break-all;
  line-height: 1.4;
  font-family: 'SF Mono', 'Menlo', monospace;
}

/* ── Buttons ── */
.btn {
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  letter-spacing: -.1px;
}

.btn:active {
  transform: scale(.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--tiktok-red), #c0002a);
  color: var(--white);
  margin-bottom: 10px;
}

.btn-primary:hover { opacity: .9; }

.btn-secondary {
  background: #1e1e1e;
  color: var(--white);
  border: 1px solid #333;
}

.btn-secondary:hover { background: #252525; }

.btn-secondary.copied {
  background: #0d2e1a;
  border-color: #1a5c34;
  color: #4ade80;
}

/* ── Error ── */
#error-section {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.error-icon { font-size: 40px; }
.error-title { font-size: 18px; font-weight: 700; }
.error-desc { font-size: 14px; color: var(--gray-400); line-height: 1.5; }

/* ── Footer ── */
.page-footer {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  font-size: 12px;
  color: #444;
}

@media (max-width: 380px) {
  .card {
    padding: 32px 20px 28px;
    border-radius: 20px;
  }
}

/* ── RTL (Arabic, Hebrew, etc.) ── */
[dir="rtl"] .hint-step {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .url-label,
[dir="rtl"] .url-text {
  text-align: right;
  direction: ltr; /* keep URLs visually LTR */
}

[dir="rtl"] .fallback-desc,
[dir="rtl"] .loading-sub,
[dir="rtl"] .error-desc {
  direction: rtl;
}
