/* Auto Year Guessr.
 *
 * Dark page so the photo is the brightest thing on it. Blue for the thing you
 * can press, amber for the answer; nothing here relies on red or green.
 * Decades run down the left of the photo, the years of the chosen decade run
 * along the bottom, and the arrow keys follow the same directions.
 */

:root {
  --bg: #0f1216;
  --panel: #181d24;
  --panel-solid: #141920;
  --ink: #eceff3;
  --ink-dim: rgba(236, 239, 243, 0.64);
  --edge: rgba(236, 239, 243, 0.16);
  --accent: #648fff; /* Cornflower blue. */
  --answer: #ffb000; /* Amber. */
  --radius: 8px;
  --font:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--ink-dim);
}

.fine {
  font-size: 0.8125rem;
  line-height: 1.4;
  margin: 0;
}

a {
  color: var(--accent);
}

code,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* Top bar. */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--edge);
}

.title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar .btn {
  padding: 8px 12px;
  font-size: 0.875rem;
}

.session-score {
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  font-size: 0.875rem;
  margin-right: 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Game column. */

.game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
}

.decade-column {
  display: grid;
  grid-auto-rows: minmax(0, 44px);
  align-content: center;
  gap: 4px;
  width: 64px;
  padding: 8px 4px 8px 8px;
  flex: none;
}

.photo-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.photo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.photo-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--ink-dim);
}

/* Chips: the decade column and the year row share one look. */

.chip {
  min-height: 0;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* Year picker. */

.picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 8px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.year-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.year-row .chip {
  min-height: 44px;
  font-size: 0.8125rem;
}

.picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.picker-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guess-display {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.guess-display.empty {
  color: var(--ink-dim);
  font-size: 1rem;
}

.hint {
  display: none;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-dim);
}

/* Buttons. */

.btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
  min-width: 96px;
}

.btn-quiet {
  background: transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--answer);
  outline-offset: 2px;
}

.flagged {
  color: var(--answer);
}

/* Reveal sheet. */

.reveal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--panel-solid);
  border-top: 1px solid var(--edge);
  max-height: 70%;
  overflow: auto;
}

.reveal-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.truth-year {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--answer);
  font-variant-numeric: tabular-nums;
}

.result-line {
  font-size: 1.125rem;
}

.car-line {
  margin: 0;
  font-size: 1.125rem;
}

.reveal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Toast. */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--answer);
  color: var(--bg);
  font-weight: 600;
  z-index: 3;
}

/* Stats and settings overlays. */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow: auto;
  z-index: 2;
}

.overlay-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.overlay h2 {
  margin: 0;
  font-size: 1.25rem;
}

.overlay h3 {
  margin: 24px 0 0;
  font-size: 1rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0;
}

.summary div {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 8px 16px;
}

.summary dt {
  font-size: 0.8125rem;
  color: var(--ink-dim);
}

.summary dd {
  margin: 0;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
}

.table th,
.table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--edge);
}

.table th {
  font-weight: 500;
  color: var(--ink-dim);
}

.bar-col {
  width: 40%;
}

.bar {
  height: 8px;
  background: var(--accent);
  border-radius: 4px;
}

.textarea {
  width: 100%;
  font: inherit;
  font-size: 0.8125rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 8px;
  resize: vertical;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.select {
  min-height: 44px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

/* Wider screens. */

@media (min-width: 768px) {
  .title {
    font-size: 1rem;
  }

  .topbar .btn {
    padding: 8px 16px;
    font-size: 1rem;
  }

  .session-score {
    margin-right: 8px;
  }

  .decade-column {
    width: 96px;
    gap: 8px;
    padding: 16px 8px 16px 16px;
  }

  .chip {
    font-size: 0.9375rem;
  }

  .picker {
    padding: 16px 24px 24px;
  }

  .year-row {
    gap: 8px;
  }

  .year-row .chip {
    font-size: 1rem;
  }

  .hint {
    display: block;
  }

  .reveal {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(720px, 100%);
    border: 1px solid var(--edge);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
  }

  .summary {
    grid-template-columns: repeat(4, 1fr);
  }
}
