:root {
  --bg-color: var(--tg-theme-bg-color, #0b0f17);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #151d2c);
  --card-bg: rgba(21, 29, 44, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: var(--tg-theme-text-color, #f8fafc);
  --text-muted: var(--tg-theme-hint-color, #94a3b8);
  --accent-cyan: #38bdf8;
  --accent-blue: #2563eb;
  --correct-green: #22c55e;
  --wrong-red: #ef4444;
  --gold-star: #f59e0b;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 460px;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 50% 15%, rgba(56, 189, 248, 0.08), transparent 70%);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  z-index: 50;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(56, 189, 248, 0.3);
}

.user-titles {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.user-score {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.header-status-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.streak-pill {
  color: #f97316;
  border-color: rgba(249, 115, 22, 0.3);
  background: rgba(249, 115, 22, 0.1);
}

.streak-pill.lit {
  animation: fire-pulse 1s infinite alternate;
}

@keyframes fire-pulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px #f97316); }
  100% { transform: scale(1.08); filter: drop-shadow(0 0 8px #ea580c); }
}

.coins-pill {
  color: #fbbf24;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding-bottom: 74px;
}

.tab-pane {
  display: none;
  min-height: 100%;
  height: auto;
  flex-direction: column;
  padding: 14px 16px;
}

.tab-pane.active {
  display: flex;
}

/* Quiz Info Row */
.quiz-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.difficulty-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.difficulty-badge.medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.difficulty-badge.hard {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.part-type-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

/* Image Viewport */
.image-viewport-wrapper {
  position: relative;
  width: 100%;
  height: 230px;
  min-height: 230px;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  margin-bottom: 12px;
  background: radial-gradient(circle at center, #1b263b 0%, #0a0e17 100%);
}

.image-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.car-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
  will-change: transform;
}

.car-img.revealed {
  object-fit: contain;
  background: radial-gradient(circle at center, #1e293b 0%, #0b0f17 100%);
  transform: scale(1);
}

/* Timer Bar */
.timer-bar-bg {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.6);
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #38bdf8);
  transition: width 0.1s linear, background-color 0.3s;
}

/* Hints Row */
.hints-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.hint-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.hint-btn:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.12);
}

.hint-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint-count-badge {
  background: #38bdf8;
  color: #0b0f17;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 8px;
}

/* Clue Banner */
.clue-banner {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #e0f2fe;
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}

.clue-banner.hidden {
  display: none;
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.option-btn:active {
  transform: scale(0.98);
}

.opt-label {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-cyan);
}

.opt-text {
  flex: 1;
}

/* Option States */
.option-btn.correct {
  background: rgba(34, 197, 94, 0.25) !important;
  border-color: #22c55e !important;
  color: #4ade80 !important;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.option-btn.wrong {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
  animation: shake 0.4s ease;
}

.option-btn.eliminated {
  opacity: 0.25;
  text-decoration: line-through;
  pointer-events: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Reveal Bottom Card */
.reveal-card {
  background: var(--card-bg);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(16px);
  margin-top: 6px;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-card.hidden {
  display: none;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.reveal-icon {
  font-size: 32px;
}

.reveal-verdict {
  font-size: 18px;
  font-weight: 800;
  color: #4ade80;
}

.reveal-verdict.wrong-title {
  color: #f87171;
}

.reveal-sub {
  font-size: 13px;
  font-weight: 600;
  color: #fbbf24;
}

.car-meta-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.car-full-name {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
  color: #fff;
}

.car-country-specs {
  font-size: 13px;
  color: var(--accent-cyan);
  margin-bottom: 8px;
  font-weight: 600;
}

.car-fun-fact {
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.45;
}

.action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
  transition: transform 0.1s;
}

.action-btn:active {
  transform: scale(0.98);
}

/* No Lives / Game Over Card */
.no-lives-card {
  background: var(--card-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-lg);
  padding: 24px 18px;
  backdrop-filter: blur(16px);
  margin-top: 10px;
  text-align: center;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.no-lives-card.hidden {
  display: none !important;
}

.no-lives-icon {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.4));
}

.no-lives-title {
  font-size: 20px;
  font-weight: 800;
  color: #f87171;
  margin-bottom: 8px;
}

.no-lives-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 18px;
}

.no-lives-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.buy-lives-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.secondary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 13px 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.12);
}

/* Leaderboard */
.section-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leader-item {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: 14px;
  gap: 12px;
}

.leader-rank {
  font-size: 16px;
  font-weight: 800;
  width: 28px;
  text-align: center;
}

.leader-rank.top-1 { font-size: 22px; }
.leader-rank.top-2 { font-size: 20px; }
.leader-rank.top-3 { font-size: 20px; }

.leader-info {
  flex: 1;
}

.leader-name {
  font-size: 15px;
  font-weight: 700;
}

.leader-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.leader-score {
  font-size: 16px;
  font-weight: 800;
  color: #38bdf8;
}

/* Garage & Stats */
.stats-summary-card {
  display: flex;
  justify-content: space-around;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 8px;
  margin-bottom: 24px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-number {
  font-size: 22px;
  font-weight: 800;
  color: #38bdf8;
}

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

.shop-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shop-item {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: 16px;
  gap: 14px;
}

.shop-item-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shop-item-info {
  flex: 1;
}

.shop-item-name {
  font-size: 15px;
  font-weight: 700;
}

.shop-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.shop-buy-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

/* Nav Bar */
.nav-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(11, 15, 23, 0.95);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.nav-btn.active {
  color: var(--accent-cyan);
}

.nav-icon {
  font-size: 20px;
}

.nav-text {
  font-size: 11px;
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease-out;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
