/* Game page styles for Dating Buildings */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: #0d1117;
  color: #e0e0e0;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ── Shared controls ─────────────────────────────────────────────────────────── */

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: #1d4ed8;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: #2563eb; }
.btn-primary:disabled { background: #1e293b; color: #475569; cursor: default; }

.btn-secondary {
  padding: 10px 16px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: #334155; color: #e2e8f0; }

.ctrl-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 8px;
}

/* ── Map link (always-visible back button) ────────────────────────────────────── */

.map-link {
  position: fixed;
  top: 12px;
  right: 12px;
  font-size: 20px;
  text-decoration: none;
  background: rgba(22, 33, 62, 0.92);
  border: 1px solid #0f3460;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: background 0.15s;
}
.map-link:hover { background: #1e3a5f; }

/* ── Landing ──────────────────────────────────────────────────────────────────── */

#screen-landing {
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.landing-inner {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.landing-logo { font-size: 56px; line-height: 1; margin-bottom: 16px; }

.landing-inner h1 {
  font-size: 30px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.tagline {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.intro {
  font-size: 15px;
  color: #94a3b8;
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ── Question screen ──────────────────────────────────────────────────────────── */

#screen-question {
  background: #0d1117;
  min-height: 100dvh;
  overflow: hidden;
}

.q-progress {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(15, 23, 42, 0.5);
  z-index: 2;
}
.progress-fill {
  height: 100%;
  background: #2563eb;
  transition: width 0.4s ease;
  width: 0;
}

.q-counter {
  position: absolute;
  top: 10px;
  left: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #e2e8f0;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
  z-index: 2;
  white-space: nowrap;
}

.q-stage {
  position: relative;
  flex: 1;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 35%),
    #0d1117;
  overflow: hidden;
}

.q-image-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0d1117 0%, #111827 100%);
}
.q-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center top;
}
.q-address {
  position: absolute;
  top: 14px;
  right: 56px; /* sits left of the fixed map icon (36px + 8px gap + 12px) */
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 110px); /* don't overlap counter on left */
}

.q-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  /* auto height so open state only takes as much space as content needs */
  height: auto;
  max-height: 75dvh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: rgba(9, 13, 20, 0.94);
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
  transform: translateY(var(--drawer-offset, calc(100% - 30px)));
  transition: transform 0.3s ease;
  will-change: transform;
}

#screen-question.drawer-collapsed { --drawer-offset: calc(100% - 30px); }
#screen-question.drawer-peek      { --drawer-offset: calc(100% - 175px); }
#screen-question.drawer-open      { --drawer-offset: 0px; }

.q-drawer.dragging {
  transition: none;
}

.q-drawer-handle {
  width: 100%;
  padding: 10px 18px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  touch-action: none;
}

.q-drawer-handle:active {
  cursor: grabbing;
}

.q-drawer-grip {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: #475569;
  align-self: center;
}

.q-drawer-body {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.q-controls {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.ctrl-section {
  display: flex;
  flex-direction: column;
}
.ctrl-section-year { gap: 8px; }

.q-footer {
  flex-shrink: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(9,13,20,0), rgba(9,13,20,0.96) 18%, rgba(9,13,20,1) 58%);
  border-top: 1px solid rgba(51, 65, 85, 0.75);
}

.q-footer .btn-primary {
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32);
}

.era-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.era-btn {
  --era-color: #475569;
  min-height: 62px;
  padding: 8px 6px;
  background: color-mix(in srgb, var(--era-color) 10%, #0d1117);
  border: 1.5px solid color-mix(in srgb, var(--era-color) 35%, transparent);
  border-radius: 8px;
  color: color-mix(in srgb, var(--era-color) 80%, #94a3b8);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 3px;
  transition: all 0.12s;
}
.era-btn:hover   { background: color-mix(in srgb, var(--era-color) 18%, #0d1117); border-color: var(--era-color); }
.era-btn.selected { background: color-mix(in srgb, var(--era-color) 22%, #0d1117); border-color: var(--era-color); color: var(--era-color); }

.era-name  { font-size: 15px; font-weight: 600; line-height: 1.2; }
.era-years { font-size: 11px; opacity: 0.6; }

.year-slider {
  width: 100%;
  height: 24px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.year-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 30px;
  margin-top: -11px;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.year-slider::-moz-range-track {
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.year-slider::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.year-slider::-moz-range-thumb {
  width: 60px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.year-slider-wrap {
  position: relative;
  padding: 4px 0 2px;
}

.year-pill {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #1d4ed8;
  border-radius: 999px;
  padding: 5px 12px;
  min-width: 58px;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.year-period-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 999px;
  background: #2563eb;
  transform: translateY(-50%);
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.year-period-band {
  height: 100%;
  width: var(--period-width, 0%);
  margin-left: var(--period-left, 0%);
  border-radius: 999px;
  background: #facc15;
  opacity: 0;
  transition: opacity 0.15s ease, width 0.15s ease, margin-left 0.15s ease;
}

.year-period-band.active {
  opacity: 0.95;
}

.year-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #64748b;
  padding: 0 2px;
}


/* ── Result screen ────────────────────────────────────────────────────────────── */

#screen-result {
  background: #0d1117;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

.r-stage {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
}

.r-image-wrap {
  position: absolute;
  inset: 0;
}

.r-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
  filter: brightness(0.82);
}

/* Result drawer */
.r-drawer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: auto;
  max-height: 75dvh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: rgba(9, 13, 20, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
  transform: translateY(var(--r-drawer-offset, 0px));
  transition: transform 0.3s ease;
  will-change: transform;
}

.r-drawer-open { --r-drawer-offset: 0px; }
.r-drawer-peek { --r-drawer-offset: calc(100% - 130px); }

.r-drawer-handle {
  width: 100%;
  padding: 10px 18px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.r-drawer-grip {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: #475569;
  align-self: center;
}

.r-address {
  color: #e2e8f0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.r-drawer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.r-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.r-footer {
  flex-shrink: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(9,13,20,0), rgba(9,13,20,0.96) 18%, rgba(9,13,20,1) 58%);
  border-top: 1px solid rgba(51, 65, 85, 0.75);
}

.score-great { color: #22c55e; }
.score-ok    { color: #f59e0b; }
.score-low   { color: #ef4444; }

.r-comparison {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.r-block {
  flex: 1;
  background: #1e293b;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.r-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.r-year {
  font-size: 26px;
  font-weight: 800;
  color: #e2e8f0;
  line-height: 1;
  margin-bottom: 3px;
}

.r-actual-year            { color: #e2e8f0; }
.r-actual-year.diff-great { color: #22c55e; }
.r-actual-year.diff-ok    { color: #f59e0b; }
.r-actual-year.diff-bad   { color: #ef4444; }

.r-era { font-size: 11px; color: #64748b; }

.r-pts-block { background: #16213e; }

/* Big total on top, two breakdown rows below */
.r-pts-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
}

.r-pts-total {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  flex-shrink: 0;
}

.r-pts-breakdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.r-pts-row { font-size: 10px; color: #94a3b8; line-height: 1.3; }

.r-reasoning {
  background: #1a2744;
  border-left: 3px solid #334155;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.55;
  max-height: clamp(90px, 20dvh, 150px);
  overflow-y: auto;
}

.r-emoji-section {}

.emoji-buttons {
  display: flex;
  gap: 8px;
}
.emoji-btn {
  flex: 1;
  font-size: 26px;
  background: #1e293b;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px 0;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1;
}
.emoji-btn:hover    { border-color: #334155; background: #263346; }
.emoji-btn.selected { border-color: #2563eb; background: #1e3a5f; }

/* ── Final screen ─────────────────────────────────────────────────────────────── */

#screen-final {
  align-items: center;
  padding: 28px 20px;
  overflow-y: auto;
}

.final-inner {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.final-title {
  font-size: 28px;
  font-weight: 800;
  color: #f8fafc;
  text-align: center;
}

.final-score {
  font-size: 24px;
  font-weight: 700;
  color: #60a5fa;
  text-align: center;
}

.final-rank {
  font-size: 18px;
  color: #e2e8f0;
  text-align: center;
}

.share-section {}
.share-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.share-input {
  flex: 1;
  padding: 9px 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 12px;
  font-family: monospace;
}
.copy-status { font-size: 12px; color: #22c55e; min-height: 16px; margin-top: 4px; }

.final-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.final-row {
  background: #1e293b;
  border-radius: 8px;
  padding: 10px 12px;
}

.final-addr   { font-size: 12px; color: #64748b; margin-bottom: 4px; }

.final-detail {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  flex-wrap: wrap;
}

.final-guess  { color: #94a3b8; font-weight: 600; }
.final-arrow  { color: #475569; }
.final-actual { font-weight: 700; }
.final-actual.diff-great { color: #22c55e; }
.final-actual.diff-ok    { color: #f59e0b; }
.final-actual.diff-bad   { color: #ef4444; }
.final-era    { font-size: 12px; color: #475569; flex: 1; text-align: right; }
.final-pts    { color: #60a5fa; font-weight: 700; white-space: nowrap; }

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

@media (min-width: 520px) {
  .era-buttons { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 780px) {
  .map-link {
    top: 10px;
    right: 10px;
  }

  .q-image-wrap {
    padding: 48px 0 70px;
  }

  .q-controls {
    gap: 10px;
  }

  .ctrl-label {
    margin-bottom: 6px;
  }

  .era-btn {
    min-height: 54px;
    padding: 7px 4px;
  }

  .year-ticks {
    display: none;
  }

  .q-footer {
    padding-top: 8px;
  }

  .q-footer .btn-primary {
    padding: 12px;
    font-size: 15px;
  }
}

@media (min-width: 800px) {
  .era-buttons { grid-template-columns: repeat(3, 1fr); }
  #screen-landing, #screen-final, #screen-question { padding: 48px 24px; }

  #screen-question, #screen-result {
    align-items: center;
  }
  .q-stage, #screen-result > * {
    width: 100%;
    max-width: 640px;
  }
}
