/* ═══════════════════════════════════════════
   TYPING SPEED TEST PRO — CSS
   All variables injected by JS from WP settings
═══════════════════════════════════════════ */

#tst-wrap {
  --tst-cyan: #00e5ff;
  --tst-purple: #a855f7;
  --tst-correct: #22c55e;
  --tst-wrong: #ef4444;
  --tst-font: 'Syne', sans-serif;
  --tst-mono: 'JetBrains Mono', monospace;
  font-family: var(--tst-font);
  color: var(--tst-text);
  background: var(--tst-bg);
  transition: background 0.4s, color 0.4s;
  min-height: 200px;
  position: relative;
  overflow-x: hidden;
}

/* THEME VARS — set by JS */
#tst-wrap[data-theme="dark"] {
  --tst-text: #fff;
  --tst-muted: rgba(255,255,255,0.55);
  --tst-card: rgba(255,255,255,0.06);
  --tst-border: rgba(255,255,255,0.1);
  --tst-input-bg: rgba(255,255,255,0.05);
  --tst-overlay: rgba(11,15,46,0.94);
  --tst-res-card: linear-gradient(135deg,#101540,#1a1f6e);
}
#tst-wrap[data-theme="light"] {
  --tst-text: #0b0f2e;
  --tst-muted: rgba(11,15,46,0.5);
  --tst-card: rgba(255,255,255,0.9);
  --tst-border: rgba(0,0,80,0.12);
  --tst-input-bg: rgba(255,255,255,0.95);
  --tst-overlay: rgba(220,230,255,0.96);
  --tst-res-card: linear-gradient(135deg,#fff,#e4eaff);
}

/* ── HERO ── */
.tst-hero {
  text-align: center;
  padding: 60px 20px;
  position: relative;
}
.tst-hero-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, rgba(0,229,255,.18), rgba(168,85,247,.18));
  border: 2px solid var(--tst-cyan);
  border-radius: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; margin-bottom: 24px;
  animation: tst-float 3s ease-in-out infinite;
  box-shadow: 0 0 36px rgba(0,229,255,.3);
}
@keyframes tst-float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.tst-hero h1 {
  font-size: clamp(32px,5vw,60px);
  font-weight: 800; line-height: 1.1; margin-bottom: 14px;
}
.tst-hero h1 span {
  color: var(--tst-cyan);
  text-shadow: 0 0 24px rgba(0,229,255,.4);
}
.tst-hero p {
  color: var(--tst-muted); font-size: 16px;
  max-width: 500px; margin: 0 auto 32px; line-height: 1.7;
}

/* ── BUTTONS ── */
.tst-btn-hero {
  background: linear-gradient(135deg, var(--tst-cyan), #0099cc);
  color: #0b0f2e; padding: 14px 34px; border-radius: 12px;
  font-weight: 800; font-size: 16px; border: none; cursor: pointer;
  font-family: var(--tst-font); transition: all 0.3s;
  box-shadow: 0 0 24px rgba(0,229,255,.3);
}
.tst-btn-hero:hover { transform: translateY(-2px); box-shadow: 0 0 40px rgba(0,229,255,.4); }

.tst-btn-ctrl {
  background: var(--tst-card); border: 1px solid var(--tst-border);
  color: var(--tst-text); padding: 10px 22px; border-radius: 10px;
  font-weight: 700; font-size: 14px; cursor: pointer;
  font-family: var(--tst-font); transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.tst-btn-ctrl:hover { background: rgba(255,255,255,.1); transform: translateY(-2px); }
.tst-btn-accent { border-color: var(--tst-cyan); color: var(--tst-cyan); }

/* ── SECTION ── */
.tst-section {
  padding: 40px 20px 60px;
  max-width: 900px; margin: 0 auto;
}
.tst-section-title {
  text-align: center; font-size: 36px; font-weight: 800; margin-bottom: 8px;
}
.tst-section-sub {
  text-align: center; color: var(--tst-muted); font-size: 14px;
  margin-bottom: 36px;
}

/* ── TIME SELECTOR ── */
.tst-time-row {
  display: flex; justify-content: center; gap: 8px; margin-bottom: 28px;
}
.tst-time-btn {
  padding: 7px 18px; background: var(--tst-card);
  border: 1px solid var(--tst-border); border-radius: 24px;
  color: var(--tst-muted); font-family: var(--tst-font);
  font-weight: 700; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.tst-time-btn:hover { color: var(--tst-text); border-color: var(--tst-cyan); }
.tst-time-btn.active { background: rgba(0,229,255,.12); border-color: var(--tst-cyan); color: var(--tst-cyan); }

/* ── DIFFICULTY ── */
.tst-diff-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 12px; margin-bottom: 36px;
}
.tst-diff-card {
  background: var(--tst-card); border: 2px solid var(--tst-border);
  border-radius: 16px; padding: 20px; cursor: pointer; transition: all 0.3s;
}
.tst-diff-card:hover { transform: translateY(-3px); }
.tst-diff-card.selected {
  border-color: var(--tst-cyan);
  background: rgba(0,229,255,.08);
  box-shadow: 0 0 24px rgba(0,229,255,.18);
}
.tst-diff-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}
.tst-diff-icon.easy   { background: linear-gradient(135deg,#22c55e,#16a34a); }
.tst-diff-icon.medium { background: linear-gradient(135deg,#00e5ff,#0099cc); }
.tst-diff-icon.hard   { background: linear-gradient(135deg,#f97316,#ea580c); }
.tst-diff-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.tst-diff-card p  { color: var(--tst-muted); font-size: 12px; line-height: 1.5; }
.tst-diff-badge   { display: none; margin-top: 8px; color: var(--tst-cyan); font-size: 12px; font-weight: 700; }
.tst-diff-card.selected .tst-diff-badge { display: block; }

/* ── STATS ── */
.tst-stats {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 12px; margin-bottom: 16px;
}
.tst-stat {
  background: var(--tst-card); border: 1px solid var(--tst-border);
  border-radius: 14px; padding: 18px 12px; text-align: center; transition: all 0.3s;
}
.tst-stat:hover { border-color: rgba(0,229,255,.3); transform: translateY(-2px); }
.tst-stat-icon { font-size: 18px; margin-bottom: 4px; }
.tst-stat-val  { font-size: 30px; font-weight: 800; font-family: var(--tst-mono); line-height: 1; }
.tst-stat-label{ font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--tst-muted); margin-top: 4px; }

.tst-time { color: var(--tst-cyan); }
.tst-wpm  { color: #facc15; }
.tst-acc  { color: var(--tst-correct); }
.tst-err  { color: var(--tst-wrong); }

#tst-stat-time.warning .tst-time { color: var(--tst-wrong); animation: tst-pulse 0.5s infinite; }
@keyframes tst-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── PROGRESS ── */
.tst-progress-wrap {
  height: 4px; background: rgba(128,128,255,.1);
  border-radius: 4px; margin-bottom: 16px; overflow: hidden;
}
#tst-progress {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--tst-cyan), var(--tst-purple));
  border-radius: 4px; transition: width 1s linear;
}

/* ── TYPING BOX ── */
.tst-box {
  background: var(--tst-card); border: 1px solid var(--tst-border);
  border-radius: 16px; padding: 22px; margin-bottom: 16px;
}
#tst-words {
  font-family: var(--tst-mono); font-size: 18px;
  line-height: 1.9; word-spacing: 6px; user-select: none; margin-bottom: 16px;
}
.tst-word { display: inline-block; margin-right: 8px; }
.tst-char { position: relative; }
.tst-char.correct { color: var(--tst-correct); }
.tst-char.wrong   { color: var(--tst-wrong); text-decoration: underline; }
.tst-char.current { color: var(--tst-cyan); }
.tst-char.current::before {
  content: ''; position: absolute; left: 0; bottom: -2px;
  width: 100%; height: 2px; background: var(--tst-cyan);
  animation: tst-blink 0.8s infinite;
}
@keyframes tst-blink { 0%,100%{opacity:1} 50%{opacity:0} }

#tst-input {
  width: 100%; background: var(--tst-input-bg);
  border: 2px solid var(--tst-border); border-radius: 10px;
  padding: 12px 14px; font-family: var(--tst-mono);
  font-size: 15px; color: var(--tst-text); outline: none;
  transition: border-color 0.2s; caret-color: var(--tst-cyan);
}
#tst-input:focus { border-color: var(--tst-cyan); }
#tst-input::placeholder { color: var(--tst-muted); }

/* ── CONTROLS ── */
.tst-controls {
  display: flex; gap: 8px; justify-content: center;
  margin-top: 12px; flex-wrap: wrap;
}

/* ── LEADERBOARD ── */
.tst-lb-table {
  background: var(--tst-card); border: 1px solid var(--tst-border);
  border-radius: 16px; overflow: hidden;
}
.tst-lb-head {
  display: grid; grid-template-columns: 44px 1fr 70px 70px 70px;
  padding: 12px 18px;
  background: rgba(0,229,255,.07);
  border-bottom: 1px solid var(--tst-border);
  font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--tst-muted);
}
.tst-lb-row {
  display: grid; grid-template-columns: 44px 1fr 70px 70px 70px;
  padding: 14px 18px; border-bottom: 1px solid var(--tst-border);
  align-items: center; transition: background 0.2s;
}
.tst-lb-row:last-child { border-bottom: none; }
.tst-lb-row:hover { background: rgba(255,255,255,.03); }
.tst-lb-row.top1 { background: rgba(255,215,0,.05); }
.tst-lb-row.top2 { background: rgba(192,192,192,.04); }
.tst-lb-row.top3 { background: rgba(205,127,50,.04); }

.tst-rank {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
}
.tst-r1 { background: linear-gradient(135deg,#ffd700,#ff8c00); color:#000; }
.tst-r2 { background: linear-gradient(135deg,#c0c0c0,#909090); color:#000; }
.tst-r3 { background: linear-gradient(135deg,#cd7f32,#8b4513); color:#fff; }
.tst-rn { background: var(--tst-card); color: var(--tst-muted); }

.tst-lb-name { font-weight: 700; font-size: 14px; }
.tst-lb-wpm  { font-family: var(--tst-mono); font-weight: 800; font-size: 16px; color: #facc15; }
.tst-lb-acc  { font-family: var(--tst-mono); font-size: 13px; color: var(--tst-correct); font-weight: 700; }
.tst-lb-diff { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.tst-lb-diff.easy   { background: rgba(34,197,94,.15);  color: #22c55e; }
.tst-lb-diff.medium { background: rgba(0,229,255,.15);  color: #00e5ff; }
.tst-lb-diff.hard   { background: rgba(249,115,22,.15); color: #f97316; }
.tst-lb-empty { text-align: center; padding: 40px; color: var(--tst-muted); font-size: 14px; }

/* ── RESULTS OVERLAY ── */
#tst-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--tst-overlay); backdrop-filter: blur(18px);
  z-index: 9999; align-items: center; justify-content: center;
  flex-direction: column;
}
#tst-overlay.show { display: flex; animation: tst-fade .3s ease; }
@keyframes tst-fade { from{opacity:0;transform:scale(.95)} to{opacity:1;transform:scale(1)} }

.tst-results-card {
  background: var(--tst-res-card);
  border: 1px solid var(--tst-border);
  border-radius: 22px; padding: 40px;
  text-align: center; max-width: 500px; width: 92%;
  box-shadow: 0 30px 60px rgba(0,0,0,.3);
}
.tst-res-emoji { font-size: 48px; margin-bottom: 12px; }
.tst-res-title { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.tst-res-sub   { color: var(--tst-muted); margin-bottom: 24px; }
.tst-res-grid  { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; margin-bottom: 20px; }
.tst-res-item  { background: rgba(255,255,255,.06); border-radius: 12px; padding: 16px; }
.tst-res-val   { font-size: 34px; font-weight: 800; font-family: var(--tst-mono); }
.tst-res-label { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--tst-muted); margin-top: 3px; }

.tst-save-row {
  display: flex; gap: 7px; margin-bottom: 10px;
}
.tst-name-input {
  flex: 1; background: var(--tst-input-bg);
  border: 1px solid var(--tst-border); border-radius: 8px;
  padding: 10px 12px; color: var(--tst-text);
  font-family: var(--tst-font); font-size: 13px; outline: none;
  caret-color: var(--tst-cyan);
}
.tst-name-input:focus { border-color: var(--tst-cyan); }
.tst-name-input::placeholder { color: var(--tst-muted); }
.tst-btn-save {
  background: var(--tst-cyan); color: #0b0f2e;
  padding: 10px 16px; border-radius: 8px;
  font-weight: 800; font-size: 13px; border: none; cursor: pointer;
  font-family: var(--tst-font);
}
.tst-save-msg { font-size: 12px; color: var(--tst-correct); min-height: 16px; margin-bottom: 14px; }
.tst-res-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ── TOAST ── */
.tst-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: linear-gradient(135deg,#22c55e,#16a34a);
  color: #fff; padding: 10px 22px; border-radius: 10px;
  font-weight: 700; font-size: 13px; z-index: 99999;
  transition: transform 0.4s ease; white-space: nowrap;
  box-shadow: 0 6px 24px rgba(34,197,94,.3);
}
.tst-toast.show { transform: translateX(-50%) translateY(0); }

/* ── BLOG CTA ── */
.tst-blog-cta {
  display: flex; align-items: center; gap: 20px;
  background: linear-gradient(135deg,rgba(0,229,255,.08),rgba(168,85,247,.08));
  border: 1px solid rgba(0,229,255,.25);
  border-radius: 16px; padding: 24px 28px; margin: 32px 0;
  flex-wrap: wrap;
}
.tst-blog-cta-icon { font-size: 40px; }
.tst-blog-cta-text { flex: 1; }
.tst-blog-cta-text h3 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.tst-blog-cta-text p  { color: var(--tst-muted); font-size: 14px; }
.tst-blog-cta-btn {
  background: linear-gradient(135deg,#00e5ff,#0099cc);
  color: #0b0f2e; padding: 12px 24px; border-radius: 10px;
  font-weight: 800; font-size: 14px; text-decoration: none;
  white-space: nowrap; transition: all 0.2s;
}
.tst-blog-cta-btn:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(0,229,255,.3); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .tst-stats     { grid-template-columns: repeat(2,1fr); }
  .tst-diff-grid { grid-template-columns: 1fr; }
  .tst-lb-head, .tst-lb-row { grid-template-columns: 38px 1fr 58px 58px; }
  .tst-lb-head span:last-child, .tst-lb-row .tst-lb-diff { display: none; }
}
