:root {
  color-scheme: dark;
  --ink: #fff7f8;
  --muted: #c9b8bd;
  --line: rgba(255, 255, 255, 0.16);
  --paper: #100c11;
  --panel: rgba(27, 20, 28, 0.9);
  --panel-solid: #1b141c;
  --accent: #e85d7a;
  --accent-strong: #ff8aa1;
  --rose: #ff4f7b;
  --gold: #f1c66a;
  --teal: #31b7a9;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 79, 123, 0.18), transparent 34%),
    linear-gradient(135deg, #100c11, #231927 48%, #121820);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1280px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.game-panel,
.summary-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.game-panel::before,
.summary-panel::before {
  content: "♡";
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 0;
  color: rgba(255, 255, 255, 0.08);
  font-size: 4.8rem;
  line-height: 1;
  pointer-events: none;
}

.game-panel > *,
.summary-panel > * {
  position: relative;
  z-index: 1;
}

.game-panel {
  display: grid;
  grid-template-rows: auto auto auto auto;
  min-height: auto;
}

.summary-panel {
  padding: 18px;
  align-self: stretch;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 12, 17, 0.72);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 7vw, 2.35rem);
  line-height: 1;
}

h1 span,
h2 span {
  color: var(--accent-strong);
}

h2 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

.scorebox {
  min-width: 116px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  text-align: right;
  background: rgba(255, 255, 255, 0.08);
}

.scorebox span,
.scorebox strong {
  display: block;
}

.scorebox span {
  color: var(--muted);
  font-size: 0.78rem;
}

.scorebox strong {
  color: var(--gold);
  font-size: 1.55rem;
}

.photo-stage {
  position: relative;
  width: 100%;
  height: clamp(260px, 48dvh, 520px);
  overflow: hidden;
  background: #08070a;
}

.photo-stage::before {
  content: "Loading memory...";
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  background: #08070a;
}

.photo-stage.photo-loading::before {
  display: grid;
}

.photo-stage.photo-error::before {
  content: "Photo failed to load";
  display: grid;
  color: var(--accent-strong);
}

.photo-stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72));
  pointer-events: none;
}

.photo-stage img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  background: #08070a;
}

.photo-meta {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  font-weight: 800;
}

.guess-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(16, 12, 17, 0.84);
}

.map-card,
.date-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.map-card-expanded {
  grid-column: 1 / -1;
}

.map-card-expanded .map {
  min-height: min(58dvh, 520px);
  aspect-ratio: 1.1 / 1;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-title span {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

.map {
  position: relative;
  width: 100%;
  min-height: 260px;
  aspect-ratio: 1.2 / 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #16232a;
}

.leaflet-container {
  font: inherit;
  background: #16232a;
}

.leaflet-control-attribution {
  font-size: 0.66rem;
}

.map-pin {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
}

.guess-marker .map-pin {
  background: var(--rose);
}

.answer-marker .map-pin {
  background: var(--teal);
}

.date-slider-wrap {
  padding: 14px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.date-card input[type="range"] {
  width: 100%;
  height: 44px;
  accent-color: var(--rose);
}

.date-card input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
}

.date-range-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.75rem;
}

.primary-action,
.secondary-action {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.primary-action {
  width: 100%;
  margin-top: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--rose), #b8325c);
  box-shadow: 0 12px 24px rgba(255, 79, 123, 0.24);
}

.primary-action::before {
  content: "♥ ";
}

.primary-action:disabled {
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.68);
  background: #6c5a63;
  box-shadow: none;
}

.secondary-action {
  padding: 0 16px;
  color: #2b101a;
  background: var(--gold);
}

.result-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.result-panel p {
  margin-bottom: 4px;
  color: var(--muted);
}

.result-panel strong {
  display: block;
}

#roundScore {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#roundScore span,
#roundScore strong {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.86rem;
}

#roundScore b,
#roundScore strong {
  color: var(--gold);
}

.round-list {
  padding-left: 22px;
  margin: 18px 0;
}

.round-list li {
  padding: 10px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.round-list strong {
  display: block;
  color: var(--ink);
}

.final-card {
  padding: 16px;
  border: 1px solid rgba(241, 198, 106, 0.48);
  border-radius: 8px;
  background: rgba(241, 198, 106, 0.13);
}

.final-card span,
.final-card strong {
  display: block;
}

.final-card strong {
  margin: 4px 0 14px;
  color: var(--gold);
  font-size: 2rem;
}

@media (min-width: 920px) {
  .app-shell {
    min-height: 100vh;
    padding: 16px;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 14px;
  }

  .game-panel {
    min-height: calc(100vh - 32px);
  }

  .photo-stage {
    height: min(56vh, 620px);
  }

  .guess-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
    gap: 12px;
    padding: 12px;
  }

  .map {
    min-height: 0;
    aspect-ratio: 2.05 / 1;
  }

  .map-card-expanded .map {
    min-height: 420px;
    aspect-ratio: 2.35 / 1;
  }
}

@media (max-width: 520px) {
  .topbar,
  .result-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .scorebox {
    width: 100%;
    text-align: left;
  }

  .photo-meta {
    flex-direction: column;
  }

  .photo-stage {
    height: clamp(240px, 44dvh, 390px);
  }

  .map,
  .map-card-expanded .map {
    min-height: 310px;
    aspect-ratio: 1.05 / 1;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .section-title span {
    text-align: left;
  }
}
