/* ═══════════════════════════════════════════════
   THE FLIP GAME — style.css
   Dark theme, animations, responsive layout
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────── */

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

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --bg-input: #1e1e1e;
  --text: #e8e8e8;
  --text-dim: #888;
  --text-muted: #555;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --correct: #00ff88;
  --wrong: #ff4444;
  --warning: #ffaa00;
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Screens ───────────────────────────────────── */

.screen {
  display: none;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

/* ── Title Screen ──────────────────────────────── */

.title-container {
  text-align: center;
  width: 100%;
}

.game-title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent), #00ccff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.game-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 48px;
  font-style: italic;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.mode-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  box-shadow: var(--shadow);
}

.mode-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(0, 255, 136, 0.1);
}

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

.mode-btn .mode-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 10px;
}

.mode-btn .mode-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.mode-btn .mode-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
  display: block;
}

/* ── Game Screen ───────────────────────────────── */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.game-header .mode-label {
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.75rem;
}

.score-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.score-display .score-value {
  color: var(--accent);
  font-size: 1.2rem;
  font-family: var(--font-mono);
}

/* ── Timer ──────────────────────────────────────── */

.timer-container {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}

.timer-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 100%;
  transition: width 5s linear;
}

.timer-bar.warning {
  background: var(--warning);
}

.timer-text {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Solo timer */
.solo-timer {
  width: 100%;
  margin-bottom: 12px;
  display: none;
}

.solo-timer.visible {
  display: block;
}

.solo-timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.solo-timer-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.solo-timer-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--warning);
  font-family: var(--font-mono);
}

.solo-timer-track {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.solo-timer-bar {
  height: 100%;
  background: var(--warning);
  border-radius: 2px;
  width: 100%;
  transition: width 60s linear;
}

.solo-timer-bar.warning {
  background: var(--wrong);
}

/* ── Game Card ─────────────────────────────────── */

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 24px 32px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.game-card.flash-correct {
  border-color: var(--correct);
  box-shadow: var(--shadow), 0 0 30px rgba(0, 255, 136, 0.2);
}

.game-card.flash-wrong {
  border-color: var(--wrong);
  box-shadow: var(--shadow), 0 0 30px rgba(255, 68, 68, 0.2);
}

.mode-badge {
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.mode-badge.visible {
  display: block;
}

.game-category {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.game-category.visible {
  display: block;
}

.game-word {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 32px;
  line-height: 1.1;
  word-break: break-word;
}

.input-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  margin: 0 auto 16px;
}

.answer-input {
  flex: 1;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 1.1rem;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s ease;
}

.answer-input:focus {
  border-color: var(--accent);
}

.answer-input::placeholder {
  color: var(--text-muted);
}

.answer-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-submit {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-submit:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
}

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

.btn-skip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-skip:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

/* ── Feedback ──────────────────────────────────── */

.feedback {
  font-size: 1rem;
  font-weight: 600;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  opacity: 0;
}

.feedback.correct {
  color: var(--correct);
  opacity: 1;
  animation: popIn 0.3s ease;
}

.feedback.wrong {
  color: var(--wrong);
  opacity: 1;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── End Screen ────────────────────────────────── */

.end-container {
  text-align: center;
  width: 100%;
}

.end-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 32px;
  color: var(--text);
}

.score-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.big-score {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}

.big-score .total {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 20px 0;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.fun-rating {
  font-size: 1rem;
  color: var(--accent);
  font-style: italic;
  margin-top: 16px;
  padding: 12px;
  background: rgba(0, 255, 136, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 255, 136, 0.1);
}

.end-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-end {
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-end:hover {
  transform: translateY(-2px);
}

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

.btn-end.primary {
  background: var(--accent);
  color: #000;
}

.btn-end.primary:hover {
  background: var(--accent-dim);
}

.btn-end.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-end.secondary:hover {
  border-color: var(--accent);
}

/* ── Responsive ────────────────────────────────── */

@media (max-width: 520px) {
  .screen {
    padding: 16px;
  }

  .game-title {
    font-size: 2.2rem;
  }

  .game-subtitle {
    font-size: 0.95rem;
    margin-bottom: 32px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mode-btn {
    padding: 18px 16px;
  }

  .game-word {
    font-size: 2.2rem;
  }

  .game-card {
    padding: 28px 16px 24px;
  }

  .input-row {
    flex-direction: column;
  }

  .big-score {
    font-size: 2.5rem;
  }

  .stats-row {
    gap: 20px;
  }

  .end-buttons {
    flex-direction: column;
  }

  .btn-end {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .game-title {
    font-size: 1.8rem;
  }

  .game-word {
    font-size: 1.8rem;
  }
}

/* ── Utilities ─────────────────────────────────── */

::selection {
  background: var(--accent);
  color: #000;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
