/* ============================================================
   YearGuess — Game Stylesheet
   ============================================================ */

/* ----------------------------------------------------------
   1. CSS Custom Properties
   ---------------------------------------------------------- */
:root {
  --g-bg:            #0f1117;
  --g-surface:       #181c27;
  --g-surface-2:     #222840;
  --g-primary:       #f59e0b;
  --g-primary-hover: #d97706;
  --g-accent:        #6366f1;
  --g-success:       #22c55e;
  --g-error:         #ef4444;
  --g-text:          #f1f5f9;
  --g-text-muted:    #94a3b8;
  --g-border:        rgba(255, 255, 255, 0.08);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  /* Slider thumb size */
  --thumb-size: 24px;
}

/* ----------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  background-color: var(--g-bg);
  color: var(--g-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

ul { list-style: none; }
a  { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ----------------------------------------------------------
   3. Screens
   ---------------------------------------------------------- */
.screen { display: none; min-height: 100dvh; }
.screen--active { display: block; }

/* ----------------------------------------------------------
   4. Menu Screen
   ---------------------------------------------------------- */
.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
}

.menu__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  width: 100%;
  max-width: 400px;
  gap: var(--space-4);
}

.menu__icon { font-size: 4rem; line-height: 1; }

.menu__title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu__subtitle {
  font-size: 1rem;
  color: var(--g-text-muted);
  max-width: 280px;
}

.menu__meta {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--g-primary);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xl);
}

.menu__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-2);
}

.menu__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-6) var(--space-8);
  margin-top: auto;
}

.menu__footer-links {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.menu__footer-link {
  font-size: 0.8125rem;
  color: var(--g-text-muted);
  transition: color var(--transition-fast);
}
.menu__footer-link:hover { color: var(--g-text); }

.menu__footer-sep { color: var(--g-border); font-size: 0.8125rem; }

.menu__footer-brand {
  font-size: 0.8125rem;
  color: var(--g-text-muted);
  transition: color var(--transition-fast);
}
.menu__footer-brand:hover { color: var(--g-text); }
.menu__footer-brand strong {
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* ----------------------------------------------------------
   5. Buttons
   ---------------------------------------------------------- */
.game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding-block: var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
  user-select: none;
}

.game-btn:focus-visible {
  outline: 2px solid var(--g-accent);
  outline-offset: 2px;
}

.game-btn--primary {
  background-color: var(--g-primary);
  color: #000;
  font-weight: 800;
}
.game-btn--primary:hover {
  background-color: var(--g-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}
.game-btn--primary:active { transform: translateY(0); }

.game-btn--secondary {
  background-color: var(--g-surface-2);
  color: var(--g-text);
  border: 1px solid var(--g-border);
}
.game-btn--secondary:hover {
  background-color: var(--g-surface);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.game-btn[hidden] { display: none; }

/* ----------------------------------------------------------
   6. Back Button
   ---------------------------------------------------------- */
.back-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--g-text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.back-btn:hover { color: var(--g-text); background-color: var(--g-surface-2); }

/* ----------------------------------------------------------
   7. Game Screen
   ---------------------------------------------------------- */
.game {
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin-inline: auto;
  padding-bottom: var(--space-8);
}

/* Header */
.game__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
}

.game__round-label {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--g-text-muted);
}

.game__score-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--g-text-muted);
}

.game__score-label strong {
  color: var(--g-primary);
  font-weight: 800;
  font-size: 1.0625rem;
}

/* Progress bar */
.game__progress-bar {
  height: 4px;
  background-color: var(--g-surface-2);
  overflow: hidden;
}

.game__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--g-primary), var(--g-accent));
  width: 0%;
  transition: width 400ms ease;
}

/* Photo */
.game__photo-wrap {
  position: relative;
  margin: var(--space-4) var(--space-4) var(--space-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3 / 2;
  background-color: var(--g-surface);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.5);
}

.game__photo-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--g-surface) 25%,
    var(--g-surface-2) 50%,
    var(--g-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

.game__photo-skeleton.hidden { display: none; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.game__photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 300ms ease;
}
.game__photo.loaded { opacity: 1; }

/* ----------------------------------------------------------
   Result card (shown after guess)
   ---------------------------------------------------------- */
.game__result {
  margin: 0 var(--space-4) 0;
  border-radius: var(--radius-lg);
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-left: 4px solid var(--result-accent, var(--g-border));
  overflow: hidden;
}

.game__result[hidden] { display: none; }

.game__result--great { --result-accent: var(--g-success); }
.game__result--miss  { --result-accent: var(--g-error); }

.game__result-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.game__result-year-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game__result-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--g-text-muted);
}

.game__result-year {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--result-accent, var(--g-text));
}

.game__result-pts {
  flex-shrink: 0;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--g-primary);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  white-space: nowrap;
}

.game__result-sub {
  padding: 0 var(--space-4) var(--space-3);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--g-text-muted);
  border-bottom: 1px solid var(--g-border);
}

.game__event-info {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.game__event-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--g-text);
}

.game__event-desc {
  font-size: 0.875rem;
  color: var(--g-text-muted);
  line-height: 1.65;
}

/* ----------------------------------------------------------
   Slider section
   ---------------------------------------------------------- */
.game__slider-section {
  padding: var(--space-2) var(--space-4) 0;
}

.game__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-2);
}

/* ----------------------------------------------------------
   8. Slider
   ---------------------------------------------------------- */
.game__slider-wrap {
  position: relative;
  padding: 3rem 0 var(--space-4);
}

/* Year bubble above thumb */
.game__year-bubble {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  background-color: var(--g-text);
  color: var(--g-bg);
  font-size: 0.9375rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  transition: left 0ms; /* updated instantly by JS */
}

/* Bubble tail */
.game__year-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--g-text);
}

/* Correct year marker (added by JS after guess) */
.game__correct-marker {
  position: absolute;
  transform: translateX(-50%);
  top: calc(var(--space-8) - 7px); /* align with slider track centre */
  width: 3px;
  height: 20px;
  background-color: var(--g-success);
  border-radius: 2px;
  pointer-events: none;
}

/* Dual markers (YOU + CORRECT) shown after guess */
.game__marker {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  top: 0;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
  gap: 1px;
}

.game__marker-tag {
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.game__marker-year {
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1.1;
}

.game__marker-line {
  width: 2px;
  height: 22px;
  border-radius: 1px;
  margin-top: 3px;
}

.game__marker--guess .game__marker-tag,
.game__marker--guess .game__marker-year { color: var(--g-primary); }
.game__marker--guess .game__marker-line  { background: var(--g-primary); }

.game__marker--correct .game__marker-tag,
.game__marker--correct .game__marker-year { color: var(--g-success); }
.game__marker--correct .game__marker-line  { background: var(--g-success); }

/* Combined marker (when too close) */
.game__marker--combined {
  gap: 3px;
}

.game__marker-combined-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--g-surface-2);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-md);
  padding: 4px 8px;
}

.game__marker-combined-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.game__marker-combined-row--guess   { color: var(--g-primary); }
.game__marker-combined-row--correct { color: var(--g-success); }

.game__marker-line--neutral { background: var(--g-text-muted); }

/* Range input — cross-browser */
.game__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--g-surface-2);
  outline: none;
  cursor: pointer;
}

/* Track fill effect via inline CSS variable set by JS */
.game__slider {
  background: linear-gradient(
    to right,
    var(--g-primary) 0%,
    var(--g-primary) var(--fill-pct, 0%),
    var(--g-surface-2) var(--fill-pct, 0%),
    var(--g-surface-2) 100%
  );
}

/* Thumb — Webkit */
.game__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: 50%;
  background: var(--g-primary);
  border: 3px solid var(--g-bg);
  box-shadow: 0 0 0 2px var(--g-primary);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.game__slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.3);
}

/* Thumb — Firefox */
.game__slider::-moz-range-thumb {
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: 50%;
  background: var(--g-primary);
  border: 3px solid var(--g-bg);
  box-shadow: 0 0 0 2px var(--g-primary);
  cursor: pointer;
}

.game__slider:disabled {
  cursor: default;
  opacity: 0.7;
}

.game__slider:focus-visible {
  outline: 2px solid var(--g-accent);
  outline-offset: 4px;
}

/* Min/Max year labels */
.game__slider-labels {
  display: flex;
  justify-content: space-between;
  padding-top: var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--g-text-muted);
}

/* Year bubble hidden state */
.game__year-bubble.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ----------------------------------------------------------
   10. Result Screen
   ---------------------------------------------------------- */
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 380px;
  margin-inline: auto;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-4);
}

.result__emoji { font-size: 4rem; line-height: 1; }

.result__title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.result__score-wrap {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  margin-block: var(--space-2);
}

.result__score-value {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result__score-sep,
.result__score-total {
  font-size: 2rem;
  font-weight: 700;
  color: var(--g-text-muted);
}

.result__message {
  font-size: 1rem;
  color: var(--g-text-muted);
  max-width: 260px;
}

.result__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-4);
}

/* ----------------------------------------------------------
   11. Info Sections (How to Play)
   ---------------------------------------------------------- */
.info-section {
  width: 100%;
  padding: var(--space-8) var(--space-6);
  border-top: 1px solid var(--g-border);
}

.info-section__inner {
  max-width: 480px;
  margin-inline: auto;
}

.info-section__title {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-6);
  text-align: center;
}

.htp-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  list-style: none;
}

.htp-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.htp-step__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  font-size: 0.875rem;
  font-weight: 800;
  color: #000;
  flex-shrink: 0;
}

.htp-step__text {
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  line-height: 1.6;
  padding-top: 5px;
}

/* FAQ accordion */
.faq {
  display: flex;
  flex-direction: column;
}

.faq__item {
  border-bottom: 1px solid var(--g-border);
}

.faq__item:first-child {
  border-top: 1px solid var(--g-border);
}

.faq__details {
  width: 100%;
}

.faq__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4) 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--g-text);
  cursor: pointer;
  list-style: none;
  gap: var(--space-4);
  transition: color var(--transition-fast);
}

.faq__question::-webkit-details-marker { display: none; }

.faq__question::after {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.faq__details[open] .faq__question::after {
  transform: rotate(180deg);
}

.faq__question:hover {
  color: var(--g-accent);
}

.faq__answer {
  padding-bottom: var(--space-4);
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  line-height: 1.6;
}

/* ----------------------------------------------------------
   12. Responsive
   ---------------------------------------------------------- */
@media (max-width: 480px) {
  .menu__title { font-size: 2rem; }
  .game__feedback-pts { font-size: 1.125rem; }
}
