/* ═══════════════════════════════════════════════
   TIMEHUNTER — style.css
   Primärt för liggande mobil (landscape)
═══════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:      #0e0e1c;
  --bg-panel:     #16213e;
  --bg-question:  #0f3460;
  --bg-card:      #1a1a2e;

  --green:        #6ec995;
  --green-border: #4aaa75;
  --green-glow:   rgba(110, 201, 149, 0.35);

  --red:          #e05c5c;
  --red-border:   #c03030;
  --red-glow:     rgba(220, 80, 80, 0.55);

  --orange:       #f0913a;
  --orange-border:#c96d1e;
  --orange-glow:  rgba(240, 145, 58, 0.45);

  --blue-accent:  #a8c5e8;
  --muted:        #a0a0b0;
  --faint:        #505070;

  --font-game:    'Rajdhani', sans-serif;
  --font-body:    'Barlow', sans-serif;

  --radius-sm:    6px;
  --radius-md:    8px;
  --radius-lg:    12px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: #fff;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Screens ───────────────────────────────────── */
.screen { display: none; width: 100%; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* ── Overlays ──────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 20, 0.82);
  display: flex; align-items: center; justify-content: center;
}
.overlay.hidden { display: none; }

/* ═══════════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════════ */
#top-bar {
  background: var(--bg-panel);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  gap: 8px;
  flex-shrink: 0;
  min-height: 38px;
}

/* Logo */
#logo { flex-shrink: 0; }
.logo-time   { font-family: var(--font-game); font-weight: 300; font-size: 17px; color: #fff; letter-spacing: 1.5px; }
.logo-hunter { font-family: var(--font-game); font-weight: 300; font-size: 17px; color: var(--red); letter-spacing: 1.5px; }

/* Players row */
#players-row {
  display: flex; gap: 5px; flex-wrap: nowrap;
  overflow: hidden; flex: 1;
  justify-content: center;
}

.player-chip {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  transition: border-color 0.2s;
}
.player-chip.active-player {
  background: rgba(110,201,149,0.12);
  border-color: rgba(100,200,150,0.3);
}
.player-chip.done-player {
  border-color: rgba(110,201,149,0.2);
}
.chip-name  { font-size: 11px; font-family: var(--font-game); font-weight: 400; color: var(--muted); }
.chip-score { font-size: 12px; font-family: var(--font-game); font-weight: 600; color: #fff; }
.player-chip.active-player .chip-name { color: var(--green); }

/* Round indicator */
#round-indicator {
  flex-shrink: 0;
  font-family: var(--font-game);
  font-size: 13px;
  color: var(--faint);
}
#round-current { color: var(--muted); }
.round-sep { margin: 0 1px; }

/* ═══════════════════════════════════════════════
   QUESTION BANNER
═══════════════════════════════════════════════ */
#question-banner {
  background: var(--bg-question);
  border-bottom: 1px solid rgba(100,180,255,0.15);
  padding: 10px 20px;
  text-align: center;
  flex-shrink: 0;
}
#question-label {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: #5b8fb9; margin-bottom: 3px;
  font-family: var(--font-game);
}
#question-text {
  font-family: var(--font-body);
  font-size: 16px; font-weight: 300;
  color: #e0e8ff; line-height: 1.45;
}

/* ═══════════════════════════════════════════════
   TIMELINE SECTION
═══════════════════════════════════════════════ */
#timeline-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 16px 10px;
  position: relative;
  overflow: hidden;
}

/* Zoom controls */
#zoom-controls {
  position: absolute;
  top: 8px; right: 18px;
  display: flex; gap: 4px; z-index: 10;
}
.zoom-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--muted); font-size: 16px;
  width: 28px; height: 28px;
  cursor: pointer; line-height: 1;
  transition: background 0.15s;
}
.zoom-btn:active { background: rgba(255,255,255,0.14); }

/* Viewport – clips the timeline */
#timeline-viewport {
  position: relative;
  width: 100%;
  overflow: visible;
}

/* Container – positions all dots */
#timeline-container {
  position: relative;
  width: 100%;
  height: 120px;
  cursor: crosshair;
}

/* The line itself */
#timeline-line {
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 2px;
  background: rgba(255,255,255,0.13);
  transform: translateY(-50%);
}

/* Fade edges */
.fade-left, .fade-right {
  position: absolute; top: 0; height: 100%;
  width: 48px; z-index: 3; pointer-events: none;
}
.fade-left  { left: 0;  background: linear-gradient(to right, var(--bg-card) 0%, transparent 100%); }
.fade-right { right: 0; background: linear-gradient(to left,  var(--bg-card) 0%, transparent 100%); }

/* Dashed extensions */
.dash-left, .dash-right {
  position: absolute; top: 50%; height: 1px;
  width: 44px; transform: translateY(-50%);
  background: repeating-linear-gradient(
    to right,
    rgba(255,255,255,0.28) 0px, rgba(255,255,255,0.28) 4px,
    transparent 4px, transparent 8px
  );
}
.dash-left  { left: 0; }
.dash-right {
  right: 0;
  background: repeating-linear-gradient(
    to left,
    rgba(255,255,255,0.28) 0px, rgba(255,255,255,0.28) 4px,
    transparent 4px, transparent 8px
  );
}

/* Arrow caps */
.arrow-left, .arrow-right {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,0.22); font-size: 11px; z-index: 4;
}
.arrow-left  { left: 4px; }
.arrow-right { right: 4px; }

/* ── Dots ──────────────────────────────────────── */
.dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
}

.dot-green {
  width: 7px; height: 7px;
  background: var(--green);
  border: 1px solid var(--green-border);
  box-shadow: 0 0 4px var(--green-glow);
}

.dot-red {
  width: 18px; height: 18px;
  background: var(--red);
  border: 2px solid var(--red-border);
  box-shadow: 0 0 10px var(--red-glow);
  cursor: grab;
  z-index: 10;
  touch-action: none;
  transition: box-shadow 0.15s;
}
.dot-red:active, .dot-red.dragging {
  cursor: grabbing;
  box-shadow: 0 0 18px var(--red-glow);
  transform: translate(-50%, -50%) scale(1.15);
}
.dot-red.locked {
  cursor: default;
  opacity: 0.85;
}

.dot-orange {
  width: 7px; height: 7px;
  background: var(--orange);
  border: 1px solid var(--orange-border);
  box-shadow: 0 0 4px var(--orange-glow);
}

/* Stacked dots label */
.dot-stack-count {
  position: absolute;
  top: -8px; right: -8px;
  background: var(--faint);
  color: #fff;
  font-size: 9px; font-weight: 600;
  border-radius: 50%;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* Year label under dot */
.year-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  font-family: var(--font-game);
  font-weight: 400;
  color: var(--green);
  white-space: nowrap;
  pointer-events: none;
  z-index: 15;
  background: transparent;
}
#year-labels {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 20;
}
.year-label.pending  { color: var(--orange); }
.year-label.red-label {
  color: var(--red);
  top: calc(50% + 12px);
  font-size: 20px;
}

/* ═══════════════════════════════════════════════
   STATUS ROW
═══════════════════════════════════════════════ */
#status-row {
  display: flex; gap: 5px;
  justify-content: center;
  margin: 7px 0 5px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.status-badge {
  font-size: 10px;
  font-family: var(--font-game);
  border-radius: 20px;
  padding: 2px 9px;
}
.status-badge.done {
  background: rgba(110,201,149,0.14);
  color: var(--green);
  border: 1px solid rgba(110,201,149,0.28);
}
.status-badge.waiting {
  background: rgba(255,255,255,0.04);
  color: var(--faint);
  border: 1px solid rgba(255,255,255,0.07);
}

/* ═══════════════════════════════════════════════
   BUTTON ROW
═══════════════════════════════════════════════ */
#button-row {
  background: var(--bg-panel);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 7px 16px;
  display: flex; gap: 8px;
  justify-content: center;
  flex-shrink: 0;
}

.game-btn {
  border-radius: var(--radius-sm);
  padding: 7px 0;
  font-size: 13px;
  font-family: var(--font-game);
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  flex: 1; max-width: 130px;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  border: 1px solid transparent;
}
.game-btn:active:not(:disabled) { transform: scale(0.97); }
.game-btn:disabled { cursor: not-allowed; }

.btn-fortsatt {
  background: rgba(255,255,255,0.05);
  color: rgba(180,180,200,0.45);
  border-color: rgba(255,255,255,0.07);
}
.btn-fortsatt:not(:disabled) {
  color: var(--muted);
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.btn-fortsatt:not(:disabled):hover {
  background: rgba(255,255,255,0.13);
}

.btn-spela {
  background: rgba(45,106,79,0.2);
  color: rgba(216,243,220,0.3);
  border-color: rgba(100,200,130,0.08);
}
.btn-spela:not(:disabled) {
  background: #2d6a4f;
  color: #d8f3dc;
  border-color: rgba(100,200,130,0.35);
  box-shadow: 0 0 10px rgba(45,106,79,0.4);
}
.btn-spela:not(:disabled):hover {
  background: #38815f;
}

.btn-klar {
  background: var(--bg-question);
  color: var(--blue-accent);
  border-color: rgba(100,150,220,0.35);
}
.btn-klar:not(:disabled) {
  box-shadow: 0 0 10px rgba(15,52,96,0.5);
}
.btn-klar:not(:disabled):hover {
  background: #163d6e;
}
.btn-klar:disabled {
  opacity: 0.35;
}

/* ═══════════════════════════════════════════════
   RESULT OVERLAY
═══════════════════════════════════════════════ */
#result-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  text-align: center;
  min-width: 240px; max-width: 360px;
  display: flex; flex-direction: column; gap: 8px;
  animation: fadeUp 0.25s ease;
}

#result-icon { font-size: 32px; }

#result-year-label {
  font-size: 11px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--faint);
  font-family: var(--font-game);
}
#result-year {
  font-family: var(--font-game);
  font-size: 42px; font-weight: 600;
  color: var(--green); letter-spacing: 2px;
}
#result-message {
  font-size: 14px; color: var(--muted);
  font-weight: 300;
}
#result-points {
  font-family: var(--font-game);
  font-size: 20px; font-weight: 600;
  color: #fff; margin: 4px 0 8px;
}

/* ═══════════════════════════════════════════════
   GAME OVER OVERLAY
═══════════════════════════════════════════════ */
#gameover-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  text-align: center;
  min-width: 260px; max-width: 400px;
  display: flex; flex-direction: column; gap: 10px;
  animation: fadeUp 0.3s ease;
}
#gameover-title { font-family: var(--font-game); font-size: 26px; font-weight: 300; }
#gameover-subtitle { color: var(--muted); font-size: 13px; font-weight: 300; margin-bottom: 6px; }

.final-score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-family: var(--font-game);
}
.final-rank  { font-size: 12px; color: var(--faint); width: 20px; }
.final-name  { font-size: 15px; font-weight: 400; flex: 1; text-align: left; padding-left: 8px; }
.final-score { font-size: 18px; font-weight: 600; color: var(--green); }

/* ═══════════════════════════════════════════════
   WINNER OVERLAY
═══════════════════════════════════════════════ */
#winner-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 200, 50, 0.35);
  border-radius: var(--radius-lg);
  padding: 32px 40px;
  text-align: center;
  min-width: 260px; max-width: 380px;
  display: flex; flex-direction: column; gap: 10px;
  animation: fadeUp 0.35s ease;
  box-shadow: 0 0 40px rgba(255, 200, 50, 0.15);
}
#winner-trophy {
  font-size: 52px;
  line-height: 1;
  animation: trophyBounce 0.6s ease;
}
#winner-title {
  font-family: var(--font-game);
  font-size: 22px;
  font-weight: 300;
  color: #f5c842;
  letter-spacing: 0.05em;
}
#winner-name {
  font-family: var(--font-game);
  font-size: 30px;
  font-weight: 600;
  color: #fff;
}
#winner-score {
  font-size: 13px;
  color: var(--muted);
  font-weight: 300;
}
#winner-subtitle {
  font-size: 18px;
  color: #f5c842;
  font-weight: 300;
  margin-top: 2px;
}

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

/* ═══════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  70%  { transform: translate(-50%, -50%) scale(1.15); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.dot-pop { animation: popIn 0.3s ease forwards; }

@keyframes dotDisappear {
  to { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}
.dot-exit { animation: dotDisappear 0.25s ease forwards; }

/* ═══════════════════════════════════════════════
   LANDSCAPE ENFORCEMENT
   Visas om skärmen råkar vara stående
═══════════════════════════════════════════════ */
#rotate-prompt {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-deep);
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 32px;
}
#rotate-prompt .rotate-icon { font-size: 48px; }
#rotate-prompt p { color: var(--muted); font-size: 15px; font-weight: 300; }

@media (orientation: portrait) and (max-width: 600px) {
  #rotate-prompt { display: flex; }
}
