/* Who Was Alive? Base chrome, result, share and stats styles copied from verse-fill/styles.css. */
:root {
  --em-deep: #071f14;
  --em-mid: #0e3b26;
  --em-glow: #1d6b45;
  --gold: #f5c451;
  --gold-bright: #ffd76a;
  --gold-deep: #a06b1c;
  --gold-shadow: #7a4c12;
  --cream: #fdf6e3;
  --cream-dim: rgba(253, 246, 227, 0.72);
  --glass: rgba(6, 26, 17, 0.55);
  --glass-line: rgba(245, 196, 81, 0.35);
  --good-glow: #8df0b4;
  --bad-glow: #ff9b9b;
  --brass-face: #d8a64c;
  --brass-mid: #b07c2e;
  --brass-dark: #96692a;
  --brass-edge: #74521a;
  --brass-press: #5d3a0e;
  --brass-ink: #3a2508;
  --font-display: "Lilita One", "Arial Rounded MT Bold", "Outfit", system-ui, sans-serif;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--em-deep);
}

body {
  color: var(--cream);
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 224, 130, 0.5) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 10%, rgba(255, 224, 130, 0.4) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 24%, rgba(255, 224, 130, 0.45) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 26% 44%, rgba(255, 224, 130, 0.3) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 92% 56%, rgba(255, 224, 130, 0.35) 0 2px, transparent 3px),
    radial-gradient(circle at 8% 78%, rgba(255, 224, 130, 0.3) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 60% 88%, rgba(255, 224, 130, 0.3) 0 1.5px, transparent 2.5px),
    radial-gradient(ellipse at 50% 16%, var(--em-glow) 0%, var(--em-mid) 52%, var(--em-deep) 100%);
  background-repeat: no-repeat;
  background-size: cover;
}

main {
  width: min(96vw, 920px);
  margin: 1.1rem auto 2rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1rem + 1.2vw, 2rem);
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--cream-dim);
  font-weight: 700;
}

.game-title-styled {
  background: none;
  -webkit-background-clip: initial;
  -webkit-text-fill-color: initial;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--gold-bright);
  text-shadow: 0 3px 0 var(--gold-shadow), 0 8px 18px rgba(0, 0, 0, 0.5);
}

.game-brand-logo {
  border-radius: 14px;
  border: 2px solid rgba(231, 180, 90, 0.55);
  box-shadow: 0 0 22px rgba(245, 196, 81, 0.35), 0 8px 16px rgba(0, 0, 0, 0.4);
}

.panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* --- Bottom actions --- */

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-top: 1rem;
  padding-bottom: 0.15rem;
}

.actions button {
  white-space: nowrap;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0.62rem 0.8rem;
  min-height: 2.85rem;
  background: var(--glass);
  color: var(--cream);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.actions button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.actions .start-action {
  order: -1;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0.07em;
  padding: 0.7rem 1.7rem;
  background: linear-gradient(180deg, var(--gold-bright) 0%, #efa93d 100%);
  color: #4a2a08;
  border: 2px solid var(--gold-deep);
  box-shadow: 0 5px 0 var(--gold-shadow), 0 0 26px rgba(245, 196, 81, 0.35);
}

.actions .start-action:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--gold-shadow), 0 0 32px rgba(245, 196, 81, 0.5);
}

.actions .start-action:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--gold-shadow), 0 0 18px rgba(245, 196, 81, 0.35);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- Modals (arcade skin via scoped theme vars) --- */

/* leaderboard.js's gear handler injects inline display:block on this overlay,
   so the layout must center the card without relying on grid/flex */
.settings-modal,
.summary-modal {
  position: fixed;
  inset: 0;
  /* Above the fixed site header (.header-row, z-index 9999 in theme.css), which otherwise
     covers the top of the card: its title and close button. */
  z-index: 10000;
  background: rgba(4, 18, 12, 0.68);
  overflow-y: auto;
  padding: 1rem;
}

.summary-modal {
  z-index: 10001;
}

.settings-card,
.summary-card {
  --text: #fdf6e3;
  --muted: rgba(253, 246, 227, 0.65);
  --accent: #ffd76a;
  --accent-soft: rgba(6, 26, 17, 0.55);
  --line: rgba(245, 196, 81, 0.3);
  --panel: rgba(6, 26, 17, 0.55);
  --bg: rgba(6, 26, 17, 0.45);
  width: min(92vw, 520px);
  max-height: min(86vh, 700px);
  overflow: auto;
  margin: max(7vh, 1rem) auto;
  background: linear-gradient(180deg, #124631 0%, #0a2a1b 100%);
  border: 2px solid rgba(231, 180, 90, 0.55);
  border-radius: 14px;
  padding: 0.85rem;
  color: var(--cream);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.summary-card {
  width: min(92vw, 460px);
  padding: 1rem;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(245, 196, 81, 0.25);
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}

.settings-header h2,
.summary-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 1.25rem;
  color: var(--gold-bright);
}

.summary-card h2 {
  margin-bottom: 0.55rem;
}

.popup-close {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--cream-dim);
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
}

.popup-close:hover {
  color: var(--cream);
}

.settings-grid {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.setting {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--cream);
}

.setting input[type="range"],
.setting select {
  width: 100%;
}

.setting input[type="checkbox"],
.setting input[type="range"] {
  accent-color: var(--gold);
}

.setting select {
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  background: var(--glass);
  color: var(--cream);
}

.setting-help {
  color: var(--cream-dim);
  font-size: 0.82rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Who Was Alive? --- */

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

.wa-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
}

.puzzle-label,
.try-count {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  font-size: 1.15rem;
}

/* --- The moment --- */

.moment-panel {
  margin-top: 0.6rem;
}

.moment-card {
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, #fdf6e3 0%, #f6ecd2 100%);
  border: 3px solid var(--brass-face);
  box-shadow: 0 0 22px rgba(245, 196, 81, 0.25), 0 8px 18px rgba(0, 0, 0, 0.4);
  color: var(--brass-ink);
  text-align: center;
}

.moment-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-dark);
}

.moment-text {
  margin: 0.2rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.moment-year {
  margin: 0.3rem 0 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: #1d6b45;
}

.moment-note {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--brass-dark);
}

/* --- The tiles --- */

.board-panel {
  margin-top: 0.9rem;
}

.board-prompt {
  margin: 0 0 0.55rem;
  text-align: center;
  font-weight: 800;
  color: var(--cream);
}

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.tile {
  width: 100%;
  min-height: 3.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.5rem 0.45rem;
  border-radius: 14px;
  border: 2px solid var(--glass-line);
  background: var(--glass);
  color: var(--cream);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.tile:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--gold-bright);
}

.tile:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.tile.is-picked {
  background: linear-gradient(180deg, var(--gold-bright) 0%, #efa93d 100%);
  border-color: var(--gold-deep);
  color: #4a2a08;
  box-shadow: 0 4px 0 var(--gold-shadow);
}

.tile:disabled {
  opacity: 1;
  cursor: default;
}

.tile.is-right {
  border-color: var(--good-glow);
}

.tile.is-wrong {
  border-color: var(--bad-glow);
  border-style: dashed;
}

.tile.was-alive {
  background: #2f9e5b;
  color: #fff;
  box-shadow: none;
}

.tile.was-not {
  background: rgba(253, 246, 227, 0.1);
  color: var(--cream);
  box-shadow: none;
}

.tile-mark {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.tile.is-right .tile-mark::before {
  content: "✓\00a0";
}

.tile.is-wrong .tile-mark::before {
  content: "✗\00a0";
}

.check-row {
  display: flex;
  justify-content: center;
  margin-top: 0.9rem;
}

.check-btn {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
  background: linear-gradient(180deg, var(--gold-bright) 0%, #efa93d 100%);
  color: #4a2a08;
  border: 2px solid var(--gold-deep);
  box-shadow: 0 5px 0 var(--gold-shadow), 0 0 26px rgba(245, 196, 81, 0.35);
}

.check-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--gold-shadow);
}

.feedback {
  min-height: 1.3em;
  margin: 0.6rem 0 0;
  text-align: center;
  color: var(--gold-bright);
  font-weight: 800;
}

/* --- The reveal chart --- */

.reveal {
  margin: 0.9rem 0 0;
  text-align: left;
}

.reveal-caption {
  margin-bottom: 0.5rem;
  color: var(--cream-dim);
  font-weight: 700;
  font-size: 0.9rem;
}

.reveal-rows {
  --line: 50%;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.reveal-row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 38%) 1fr;
  align-items: center;
  gap: 0.5rem;
}

.reveal-name {
  display: grid;
  min-width: 0;
  color: var(--cream);
  text-decoration: none;
  line-height: 1.15;
}

a.reveal-name strong {
  text-decoration: underline;
  text-decoration-color: rgba(255, 215, 106, 0.5);
  text-underline-offset: 2px;
}

a.reveal-name:hover strong,
a.reveal-name:focus-visible strong {
  color: var(--gold-bright);
}

.reveal-name strong {
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.reveal-span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cream-dim);
}

.reveal-track {
  position: relative;
  height: 1.1rem;
  border-radius: 6px;
  background: rgba(253, 246, 227, 0.08);
}

.reveal-track::after {
  content: "";
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  left: var(--line);
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--gold-bright);
  box-shadow: 0 0 8px rgba(255, 215, 106, 0.7);
}

/* Bars sit above the moment line, so a short life that crosses it still shows. */
.reveal-bar {
  z-index: 1;
  box-shadow: 0 0 0 2px rgba(7, 31, 20, 0.85);
}

.reveal-bar,
.key-bar {
  position: absolute;
  top: 0.15rem;
  bottom: 0.15rem;
  border-radius: 999px;
}

.reveal-bar.is-life,
.key-bar.is-life {
  background: #8df0b4;
}

.reveal-bar.is-story,
.key-bar.is-story {
  background: repeating-linear-gradient(90deg, #8df0b4 0 6px, rgba(141, 240, 180, 0.45) 6px 9px);
}

.reveal-row.was-not .reveal-bar {
  filter: grayscale(1) brightness(0.9);
}

.reveal-axis {
  display: flex;
  justify-content: space-between;
  margin: 0.35rem 0 0 calc(min(38%, 100%) + 0.5rem);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cream-dim);
}

.reveal-key {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cream-dim);
}

.key-bar {
  position: relative;
  display: inline-block;
  top: 0;
  width: 1.6rem;
  height: 0.6rem;
  vertical-align: 0;
}

@media (max-width: 560px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .moment-text {
    font-size: 1.2rem;
  }
}

.result-panel {
  margin-top: 1rem;
  padding: 1rem 1.1rem !important;
  border-radius: 16px !important;
  background: var(--glass) !important;
  border: 1px solid var(--glass-line) !important;
  text-align: center;
}

.result-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  font-size: 1.7rem;
}

.result-copy {
  margin: 0.4rem 0;
  font-weight: 700;
}

.result-learn a {
  color: var(--gold-bright);
  font-weight: 800;
}

.result-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.result-actions button,
.help-modal-play {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  background: var(--glass);
  color: var(--cream);
  border: 1px solid var(--glass-line);
}

.result-actions .start-action,
#help-play-btn {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  background: linear-gradient(180deg, var(--gold-bright) 0%, #efa93d 100%);
  color: #4a2a08;
  border: 2px solid var(--gold-deep);
  box-shadow: 0 4px 0 var(--gold-shadow);
}

.share-status {
  min-height: 1.2em;
  margin: 0.6rem 0 0;
  white-space: pre-line;
  color: var(--cream-dim);
  font-weight: 600;
}

.next-puzzle {
  margin: 0.3rem 0 0;
  color: var(--cream-dim);
  font-weight: 700;
}

.help-list {
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.settings-profile-row,
.theme-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.stats-row p {
  margin: 0;
  display: grid;
}

.stats-row strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.8rem;
  color: var(--gold-bright);
}

.stats-row span {
  font-size: 0.78rem;
  color: var(--cream-dim);
  font-weight: 700;
}

.dist-title {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
}

.distribution {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.distribution li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dist-label {
  width: 1rem;
  font-weight: 800;
}

.dist-bar {
  display: inline-block;
  text-align: right;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(253, 246, 227, 0.18);
  font-weight: 800;
}

.dist-bar.is-today {
  background: #2f9e5b;
}

.challenge-banner {
  margin: 0.8rem 0 0;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 215, 106, 0.2), rgba(255, 215, 106, 0.08));
  border: 2px solid rgba(255, 215, 106, 0.6);
  color: var(--gold-bright);
  font-weight: 800;
  text-align: center;
}

.help-challenge {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 106, 0.55);
  color: var(--gold-bright);
  font-weight: 800;
}

.share-card {
  width: min(94vw, 560px);
}

.share-image {
  display: block;
  width: min(100%, 300px);
  aspect-ratio: 1;
  margin: 0 auto 0.7rem;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.share-text {
  margin: 0 0 0.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: rgba(6, 26, 17, 0.6);
  border: 1px solid var(--glass-line);
  font: 700 0.9rem/1.35 "Outfit", system-ui, sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: all;
  color: var(--cream);
}

.share-native {
  display: block;
  width: 100%;
  margin-bottom: 0.7rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  background: linear-gradient(180deg, var(--gold-bright) 0%, #efa93d 100%);
  color: #4a2a08;
  border: 2px solid var(--gold-deep);
  box-shadow: 0 4px 0 var(--gold-shadow);
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.share-target {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.8rem;
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  color: #fff;
  background: rgba(253, 246, 227, 0.12);
  border: 1px solid rgba(253, 246, 227, 0.3);
}

.share-target[hidden] {
  display: none;
}

.share-target:hover,
.share-target:focus-visible {
  filter: brightness(1.12);
  outline: 2px solid var(--gold-bright);
  outline-offset: 1px;
}

.share-x { background: #000; border-color: #444; }
.share-facebook { background: #1877f2; border-color: #1877f2; }
.share-whatsapp { background: #1fa855; border-color: #1fa855; }
.share-reddit { background: #ff4500; border-color: #ff4500; }

.share-facebook span {
  font-family: Georgia, serif;
  font-weight: 900;
}

@media (max-width: 560px) {
  .stats-row strong {
    font-size: 1.4rem;
  }

  .share-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
