/* ============================================
   BANGLA TYPING APP - PREMIUM DESIGN SYSTEM
   ============================================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1628;
  --bg-card: #141c30;
  --bg-card-hover: #1a2440;
  --accent-primary: #6c63ff;
  --accent-secondary: #00d4aa;
  --accent-warning: #ff6b6b;
  --accent-success: #2dce89;
  --accent-gold: #ffd700;
  --text-primary: #e8eaf6;
  --text-secondary: #a0aec0;
  --text-muted: #6b7fa3;
  --border-color: rgba(108, 99, 255, 0.2);
  --border-glow: rgba(108, 99, 255, 0.5);
  --glass: rgba(20, 28, 48, 0.8);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-glow: 0 0 40px rgba(108, 99, 255, 0.15);
  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.4);
  --font-bangla: 'Hind Siliguri', sans-serif;
  --font-ui: 'Inter', sans-serif;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── BACKGROUND PARTICLES ── */
.bg-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  animation: floatParticle linear infinite;
  opacity: 0;
}

@keyframes floatParticle {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* ── APP CONTAINER ── */
.app-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 24px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-family: var(--font-bangla);
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
}

.logo-text h1 {
  font-family: var(--font-bangla);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-text span {
  font-size: 11px;
  color: var(--accent-secondary);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.header-stats {
  display: flex;
  gap: 12px;
  opacity: 0;
  transition: var(--transition);
}

.header-stats.visible {
  opacity: 1;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 6px 16px;
}

.stat-label {
  font-family: var(--font-bangla);
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-secondary);
  min-width: 36px;
  text-align: right;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ── SETUP SCREEN ── */
.setup-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .setup-screen {
    grid-template-columns: 1fr;
  }
}

.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 48px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.setup-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 30%;
  right: 30%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
  border-radius: 50%;
}

.setup-title {
  text-align: center;
  margin-bottom: 40px;
}

.title-icon {
  font-size: 52px;
  margin-bottom: 16px;
  display: block;
  filter: drop-shadow(0 0 20px rgba(108, 99, 255, 0.5));
}

.setup-title h2 {
  font-family: var(--font-bangla);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.setup-title p {
  font-family: var(--font-bangla);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ── DURATION SELECTOR ── */
.selector-label {
  font-family: var(--font-bangla);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 16px;
}

.duration-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.duration-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px 10px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  position: relative;
  overflow: hidden;
}

.duration-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  opacity: 0;
  transition: var(--transition);
}

.duration-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(108, 99, 255, 0.3);
}

.duration-btn:hover::before {
  opacity: 0.08;
}

.duration-btn.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.15), rgba(0, 212, 170, 0.1));
  color: var(--text-primary);
  box-shadow: 0 0 0 1px rgba(108, 99, 255, 0.3), 0 8px 25px rgba(108, 99, 255, 0.2);
}

.dur-num {
  font-family: var(--font-bangla);
  font-size: 28px;
  font-weight: 700;
  color: inherit;
  position: relative;
  z-index: 1;
  line-height: 1;
}

.duration-btn.active .dur-num {
  color: var(--accent-primary);
}

.dur-unit {
  font-family: var(--font-bangla);
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.duration-btn.active .dur-unit {
  color: var(--text-secondary);
}

/* ── START BUTTON ── */
.start-btn {
  width: 100%;
  padding: 18px 32px;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 16px;
  font-family: var(--font-bangla);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(108, 99, 255, 0.4);
  margin-bottom: 24px;
}

.start-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s, opacity 0.6s;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 40px rgba(108, 99, 255, 0.5);
}

.start-btn:hover::after {
  width: 300px;
  height: 300px;
  opacity: 0;
}

.start-btn:active {
  transform: translateY(0);
}

.btn-text {
  font-size: 17px;
}

.btn-arrow {
  font-size: 20px;
  transition: transform 0.3s;
}

.start-btn:hover .btn-arrow {
  transform: translateX(4px);
}

/* ── KEYBOARD HINT ── */
.keyboard-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(0, 212, 170, 0.06);
  border: 1px solid rgba(0, 212, 170, 0.2);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.hint-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.keyboard-hint p {
  font-family: var(--font-bangla);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.keyboard-hint strong {
  color: var(--accent-secondary);
}

/* ── KEYBOARD PREVIEW ── */
.keyboard-preview {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-card);
}

.keyboard-preview h3 {
  font-family: var(--font-bangla);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

.kb-layout {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.kb-key {
  min-width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: var(--transition);
  position: relative;
  padding: 3px;
}

.kb-key:hover {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.kb-key .bn-char {
  font-family: var(--font-bangla);
  font-size: 13px;
  color: var(--accent-secondary);
  line-height: 1;
}

.kb-key .en-char {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1;
}

.kb-key.wide {
  min-width: 70px;
}

.kb-key.space-key {
  min-width: 200px;
}

/* ── TYPING SCREEN ── */
.typing-screen {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── TIMER SECTION ── */
.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.timer-display {
  display: flex;
  justify-content: center;
}

.timer-ring {
  position: relative;
  width: 110px;
  height: 110px;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-track {
  fill: none;
  stroke: var(--bg-secondary);
  stroke-width: 6;
}

.timer-progress {
  fill: none;
  stroke: url(#timerGrad);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
  filter: drop-shadow(0 0 6px var(--accent-primary));
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-ui);
  letter-spacing: 1px;
}

.progress-bar-wrap {
  width: 100%;
  max-width: 600px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 99px;
  width: 100%;
  transition: width 1s linear;
}

/* ── TEXT DISPLAY CARD ── */
.text-display-card,
.input-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-card);
}

.text-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.label-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-primary);
}

.input-dot {
  background: var(--accent-secondary);
  box-shadow: 0 0 8px var(--accent-secondary);
}

/* ── REFERENCE TEXT ── */
.reference-text {
  font-family: var(--font-bangla);
  font-size: 20px;
  line-height: 2;            /* 40px per line */
  height: 160px;             /* exactly 4 lines: 4 × 40px */
  overflow: hidden;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  user-select: none;
  transition: opacity 0.25s ease;
}

.word-span {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all 0.2s;
  cursor: default;
}

.word-span.word-current {
  background: rgba(108, 99, 255, 0.15);
  border-bottom: 2px solid var(--accent-primary);
  color: var(--text-primary);
}

.word-span.word-correct {
  color: var(--accent-success);
  background: rgba(45, 206, 137, 0.08);
}

.word-span.word-incorrect {
  color: var(--accent-warning);
  background: rgba(255, 107, 107, 0.12);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 107, 107, 0.5);
}

.word-span.word-pending {
  color: var(--text-muted);
}

/* ── TYPING INPUT ── */
.typing-input {
  width: 100%;
  min-height: 140px;
  background: var(--bg-secondary);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-bangla);
  font-size: 18px;
  line-height: 1.8;
  padding: 16px 20px;
  resize: none;
  outline: none;
  transition: var(--transition);
  letter-spacing: 0.3px;
}

.typing-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.12), 0 0 20px rgba(108, 99, 255, 0.1);
}

.typing-input::placeholder {
  color: var(--text-muted);
  font-size: 15px;
}

/* ── LIVE STATS ── */
.live-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 700px) {
  .live-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.live-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}

.live-stat-card:hover {
  border-color: var(--border-color);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 26px;
}

.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-family: var(--font-ui);
}

.stat-desc {
  font-family: var(--font-bangla);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── STOP BUTTON ── */
.stop-btn {
  align-self: center;
  padding: 12px 32px;
  background: transparent;
  border: 2px solid rgba(255, 107, 107, 0.4);
  border-radius: 50px;
  color: var(--accent-warning);
  font-size: 14px;
  font-family: var(--font-bangla);
  cursor: pointer;
  transition: var(--transition);
}

.stop-btn:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--accent-warning);
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.2);
}

/* ── RESULTS SCREEN ── */
.results-screen {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.results-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 52px 48px;
  max-width: 720px;
  width: 100%;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.results-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

.results-header {
  text-align: center;
  margin-bottom: 40px;
}

.trophy-anim {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
  animation: trophyBounce 1s ease-out;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

@keyframes trophyBounce {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(5deg); }
  80% { transform: scale(0.95) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.results-header h2 {
  font-family: var(--font-bangla);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.results-header p {
  font-family: var(--font-bangla);
  font-size: 15px;
  color: var(--text-secondary);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 36px;
}

@media (max-width: 600px) {
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.result-item {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  transition: var(--transition);
}

.result-item:hover {
  transform: translateY(-3px);
  border-color: var(--border-color);
}

.result-item.primary {
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.12), rgba(0, 212, 170, 0.08));
  border-color: rgba(108, 99, 255, 0.3);
}

.result-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

.result-val {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1;
  margin-bottom: 6px;
}

.result-item.primary .result-val {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 42px;
}

.result-label {
  font-family: var(--font-bangla);
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.result-sublabel {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── PERFORMANCE BAR ── */
.perf-section {
  margin-bottom: 36px;
}

.perf-label {
  font-family: var(--font-bangla);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.perf-bar-wrap {
  position: relative;
  height: 10px;
  background: var(--bg-secondary);
  border-radius: 99px;
  overflow: visible;
  margin-bottom: 10px;
}

.perf-bar {
  height: 100%;
  background: linear-gradient(90deg, #6c63ff, #00d4aa, #ffd700);
  border-radius: 99px;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.perf-bar::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.perf-score {
  position: absolute;
  right: 0;
  top: -30px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
  font-family: var(--font-ui);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 50px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.perf-marks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-bangla);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── ACTION BUTTONS ── */
.results-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.action-btn {
  padding: 14px 32px;
  border-radius: 50px;
  font-size: 15px;
  font-family: var(--font-bangla);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.primary-action {
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  color: white;
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.4);
}

.primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(108, 99, 255, 0.5);
}

.secondary-action {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}

.secondary-action:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
  transform: translateY(-2px);
}

/* ── HIDDEN ── */
.hidden {
  display: none !important;
}

/* ── FOOTER ── */
.footer {
  text-align: center;
  padding: 20px 24px;
  border-top: 1px solid var(--glass-border);
}

.footer p {
  font-family: var(--font-bangla);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── TIMER WARNING ── */
.timer-text.warning {
  color: var(--accent-warning);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── SCROLL INTO VIEW ── */
.scroll-hint {
  text-align: center;
  font-family: var(--font-bangla);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── KEYBOARD ACTIVE HIGHLIGHT ── */
.kb-key.active-key {
  background: rgba(108, 99, 255, 0.3);
  border-color: var(--accent-primary);
  transform: translateY(1px);
}

/* ── SVG GRADIENT ── */
svg defs {
  display: none;
}
