/* Trafik İşareti Eşleştirme — Teal & Green Theme */

.te-game {
  /* Colors */
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #2dd4bf;
  --primary-glow: rgba(13, 148, 136, 0.25);

  --success: #10b981;
  --success-light: #34d399;
  --success-bg: rgba(16, 185, 129, 0.1);

  --danger: #ef4444;
  --danger-light: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.1);

  --warning: #f59e0b;

  --bg: #f8fafc;
  --bg-dark: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.te-game *, .te-game *::before, .te-game *::after { box-sizing: border-box; }

/* ============ SCREENS ============ */
.te-screen { display: none; flex-direction: column; }
.te-screen.te-active { display: flex; animation: teFadeIn 0.4s ease-out; }
@keyframes teFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============ LANDING ============ */
.te-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow);
}

.te-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: var(--primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 16px;
}

.te-title {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 8px;
  line-height: 1.2;
}

.te-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 0 0 32px;
  line-height: 1.6;
}

/* Rules */
.te-rules {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.te-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
}

.te-rule-icon {
  font-size: 13px;
  font-weight: 800;
  min-width: 42px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.te-rule-match { background: rgba(13, 148, 136, 0.1); color: var(--primary); }
.te-rule-pair { background: var(--success-bg); color: var(--success); }
.te-rule-time { background: var(--bg-dark); color: var(--text-muted); }

/* Difficulty Selector */
.te-difficulty-selector {
  margin-bottom: 28px;
}

.te-difficulty-selector h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
  text-align: center;
}

.te-diff-group {
  display: flex;
  gap: 8px;
}

.te-diff-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.te-diff-btn span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.te-diff-btn:hover { border-color: var(--primary-light); }

.te-diff-btn.te-active {
  background: rgba(13, 148, 136, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.te-diff-btn.te-active span { color: var(--primary); }

/* Primary Button */
.te-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.te-btn-primary:hover { background: var(--primary-dark); }
.te-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* SEO */
.te-seo {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.te-seo h3, .te-seo h4 { font-size: 14px; font-weight: 700; margin: 20px 0 10px; color: var(--text); }
.te-seo p, .te-seo li { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
.te-seo ul { padding-left: 20px; margin: 0; }

/* ============ PLAY SCREEN ============ */
.te-play-header {
  margin-bottom: 16px;
}

.te-play-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

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

.te-stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.te-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.te-stat-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
}

/* ============ CARD GRID ============ */
.te-grid {
  display: grid;
  gap: 10px;
  perspective: 1200px;
}

.te-grid-easy { grid-template-columns: repeat(4, 1fr); }
.te-grid-medium { grid-template-columns: repeat(4, 1fr); }
.te-grid-hard { grid-template-columns: repeat(5, 1fr); }

/* Card Item */
.te-card-item {
  aspect-ratio: 1;
  cursor: pointer;
  perspective: 800px;
}

.te-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.te-card-item.te-card-flipped .te-card-inner {
  transform: rotateY(180deg);
}

.te-card-front, .te-card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Card Front (content — hidden by default, visible when flipped) */
.te-card-front {
  transform: rotateY(180deg);
  background: var(--card);
  border: 2px solid var(--border);
  padding: 8px;
}

.te-card-img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.te-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
  padding: 4px;
  word-break: break-word;
}

/* Card Back (hidden) */
.te-card-back {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.te-card-back-icon {
  font-size: 24px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.6);
}

/* Matched State */
.te-card-item.te-card-matched .te-card-front {
  border-color: var(--success);
  background: var(--success-bg);
}

.te-card-item.te-card-matched {
  pointer-events: none;
  animation: teMatchPop 0.3s ease-out;
}

@keyframes teMatchPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Shake (wrong match) */
.te-card-item.te-card-shake {
  animation: teShake 0.4s ease-out;
}

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

/* ============ RESULTS ============ */
.te-results-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.te-results-emoji { font-size: 48px; margin-bottom: 8px; }

.te-results-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.te-results-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 28px;
}

.te-results-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 28px;
}

.te-rs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.te-rs-val { font-size: 20px; font-weight: 800; color: var(--text); }
.te-rs-lbl { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

/* Name Form */
.te-results-name-form {
  margin: 24px 0;
  text-align: left;
}

.te-results-name-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.te-name-input-row {
  display: flex;
  gap: 12px;
}

.te-name-input-row input {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
}

.te-name-input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); }
.te-name-input-row input::placeholder { color: var(--text-muted); }
.te-name-input-row .te-btn-primary { width: auto; padding: 14px 24px; font-size: 14px; white-space: nowrap; }

.te-submit-success {
  color: var(--success);
  font-size: 14px;
  font-weight: 600;
  padding: 16px;
  margin: 12px 0;
  background: var(--success-bg);
  border-radius: var(--radius-sm);
}

.te-submit-error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  padding: 16px;
  margin: 12px 0;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
}

/* Results Actions */
.te-results-actions { display: flex; gap: 12px; margin-bottom: 32px; }
.te-results-actions .te-btn-primary { flex: 1; }

.te-btn-share {
  flex: 1;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.te-btn-share:hover { background: var(--bg-dark); }

/* Leaderboard */
.te-leaderboard-section {
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.te-leaderboard-section h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.te-lb-tabs { display: flex; gap: 8px; margin-bottom: 20px; }

.te-lb-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg);
  border: none;
  color: var(--text-secondary);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.te-lb-tab:hover { color: var(--text); background: var(--bg-dark); }
.te-lb-tab.te-active { background: var(--primary); color: #fff; }

.te-lb-list { list-style: none; margin: 0; padding: 0; }

.te-lb-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
}

.te-lb-item .te-lb-rank { font-size: 18px; min-width: 32px; text-align: center; }
.te-lb-item .te-lb-name { flex: 1; font-weight: 600; }
.te-lb-item .te-lb-details { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.te-lb-item .te-lb-score { font-weight: 800; color: var(--primary); min-width: 50px; text-align: right; }
.te-lb-item.te-lb-top { background: var(--bg-dark); }
.te-lb-item.te-lb-top .te-lb-name { color: var(--primary); }

.te-lb-empty, .te-lb-error {
  font-size: 14px;
  color: var(--text-muted);
  padding: 32px;
  text-align: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* Loading / Error */
.te-loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
}

.te-loading::before {
  content: '';
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: teSpinner 0.8s linear infinite;
}

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

.te-error {
  text-align: center;
  padding: 24px;
  color: var(--danger);
  font-weight: 600;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
}

/* ============ MOBILE ============ */
@media (max-width: 600px) {
  .te-game { padding: 12px; }
  .te-card, .te-results-card { padding: 28px 20px; border-radius: 16px; }
  .te-title { font-size: 24px; }
  .te-rules { gap: 8px; }
  .te-rule { padding: 10px 14px; font-size: 13px; }

  .te-grid-easy { grid-template-columns: repeat(4, 1fr); }
  .te-grid-medium { grid-template-columns: repeat(3, 1fr); }
  .te-grid-hard { grid-template-columns: repeat(4, 1fr); }

  .te-card-name { font-size: 11px; }
  .te-card-back-icon { font-size: 20px; }

  .te-play-stats { padding: 12px 14px; gap: 10px; }
  .te-stat-value { font-size: 18px; }

  .te-results-stats { grid-template-columns: repeat(2, 1fr); }
  .te-results-actions { flex-direction: column; }
  .te-name-input-row { flex-direction: column; }
  .te-name-input-row .te-btn-primary { width: 100%; }

  .te-lb-tabs { flex-wrap: wrap; }
  .te-lb-tab { padding: 8px 14px; font-size: 12px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .te-game *, .te-game *::before, .te-game *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
