/* ========================================
   DILEMMLE — MIDNIGHT OBSERVATORY
   Curious, playful, calm, slightly mysterious
======================================== */

/* LIGHT MODE */
:root {
  --background-color: #f5f2ec;
  --text-color: #292c3b;
  --card: #eae7e2;
  --border: #d7d3d0;

  /* Interface accents */
  --yellow: #e9bc72;
  --green: #597c78;
  --blue: #777fb2;
  --red: #c96f68;
  --gray: #9999a3;

  /* Guess tiles */
  --tile-green: #597c78;
  --tile-yellow: #e9bc72;

  --border-radius: 10px;
}

/* DARK MODE */
[data-theme="dark"] {
  --background-color: #191d2b;
  --text-color: #f4f0e8;
  --card: #262b3d;
  --border: #41465c;

  /* Interface accents */
  --yellow: #e9bc72;
  --green: #668c83;
  --blue: #8e96c8;
  --red: #e1847b;
  --gray: #9699ad;

  /* Guess tiles */
  --tile-green: #668c83;
  --tile-yellow: #8a713e;
}

/* COLORBLIND MODE */
[data-colorblind="true"] {
  --tile-green: #287a9b;
  --tile-yellow: #c76d35;
}

html {
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  max-width: 740px;
  margin: 0 auto;
  padding: 5px 16px 0;
}

h1,
h2,
h3,
#subheader {
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.top-header {
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
}

.top-header .title-container {
  text-align: center;
}

.top-header .title-container #title {
  font-size: 2rem;
  margin: 20px 0 6px;
  line-height: 1.1;
  letter-spacing: 0.3rem;
}

.top-header .title-container #subheader {
  font-size: 1rem;
  margin: 0 0 10px;
  line-height: 1.2;
  font-weight: 450;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

button:not(.stepper):active:not(:disabled) {
  transform: scale(0.96);
}

.icon-button {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition:
    background-color 0.23s ease,
    transform 0.12s ease;
  color: var(--text-color);
}

.menu,
.buttons {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.buttons {
  gap: 10px;
  justify-content: flex-end;
}

.icon-button svg {
  width: 30px;
  height: auto;
}

.icon-button:hover {
  background: var(--border);
}

.fill-hover svg {
  fill: transparent;
  transition: fill 0.23s ease;
}

.fill-hover:hover svg {
  fill: var(--text-color);
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--border-radius);
  background: var(--card);
  font-weight: 600;
  transition: transform 0.12s ease;
}

.streak-pill svg {
  width: 20px;
  height: 20px;
  color: var(--yellow);
}

main {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 24px 0;
}

section .section-header {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 30px;
}

.dilemma-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
}

.dilemma-text {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 12px;
}

.your-side {
  margin: 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.side-kicker {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.side-chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--text-color);
  color: var(--background-color);
  font-weight: 700;
  font-size: 1rem;
}

.slider {
  margin-top: 20px;
  background-color: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
  padding: 40px;
}

.guess-display {
  text-align: center;
  margin-top: 16px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

#guess-slider {
  --thumb: 32px;
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--yellow) 0,
    var(--yellow)
      calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--fill, 50) / 100),
    var(--border)
      calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--fill, 50) / 100),
    var(--border) 100%
  );
  cursor: pointer;
}

#guess-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: var(--text-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: grab;
  transition: transform 0.15s ease;
}

#guess-slider:active::-webkit-slider-thumb {
  transform: scale(1.2);
  cursor: grabbing;
}

#guess-slider::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: var(--text-color);
  border: none;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

#guess-slider:active::-moz-range-thumb {
  transform: scale(1.2);
}

#guess-slider::-moz-range-track {
  height: 12px;
  border-radius: 999px;
  background: var(--border);
}

#guess-slider::-moz-range-progress {
  height: 12px;
  border-radius: 999px;
  background: var(--yellow);
}

#guess-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stepper {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: var(--text-color);
  color: var(--background-color);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease;
}

.stepper:hover {
  opacity: 0.85;
}

.stepper:active {
  transform: scale(0.9);
}

.stepper:disabled {
  opacity: 0.35;
  cursor: default;
}

.stepper:disabled:active {
  transform: none;
}

.stepper svg {
  width: 20px;
  height: 20px;
  display: block;
}

.submit {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.primary-button {
  margin-top: 16px;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  background: var(--text-color);
  color: var(--background-color);
  cursor: pointer;
  transition:
    background-color 0.23s ease,
    transform 0.12s ease;
}

.primary-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.primary-button:hover {
  background: var(--yellow);
  color: var(--text-color);
  transition: background-color 0.23s ease;
}

.vote-cta {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  border-radius: 999px;
  width: max-content;
  max-width: calc(100vw - 2rem);
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    bottom 0.45s cubic-bezier(0.18, 0.9, 0.3, 1.15),
    opacity 0.35s ease,
    visibility 0.35s;
}
.vote-cta.show {
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#vote-cta:active {
  transform: translateX(-50%) scale(0.96);
}

.vote-cta-arrow {
  display: block; /* sits on its own line, centered by the pill's text-align */
  font-size: 1.15rem;
  line-height: 1.2;
  animation: vote-cta-nudge 1.6s ease-in-out infinite;
}

@keyframes vote-cta-nudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vote-cta-arrow {
    animation: none;
  }
}

#share-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 14px 32px;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--red);
  color: #fff;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

#share-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(3, 3, 3, 0.55);
}

#share-btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 2px 8px rgba(144, 190, 109, 0.4);
}

#share-btn svg {
  width: 20px;
  height: 20px;
}

.tiles {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
}

.tile-empty {
  border: 2px dashed var(--border);
  background: transparent;
}

.tile {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: var(--border-radius);
  font-weight: 700;
  color: #fff;
}

.tile.green {
  background: var(--tile-green);
}

.tile.yellow {
  background: var(--tile-yellow);
  color: var(--text-color);
}

.tile.gray {
  background: #9a9aa0;
}

.swatch {
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  border-radius: 6px;
  vertical-align: -0.15em;
  margin-right: 0.4em;
}

.swatch.green {
  background: var(--tile-green);
}

.swatch.yellow {
  background: var(--tile-yellow);
}

.swatch.gray {
  background: #9a9aa0;
}

.game-message {
  font-weight: 600;
  min-height: 1.5em;
  text-align: center;
  margin-top: 25px;
}

.reveal {
  margin-top: 16px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

.reveal[hidden] {
  display: none;
}

.split-bar {
  height: 36px;
  border-radius: var(--border-radius);
  background: var(--border);
  overflow: hidden;
}

.split-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: var(--border-radius);
  transition: width 0.8s ease;
}

.split-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-weight: 600;
  margin-bottom: 30px;
}

.vote-options {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.vote-button {
  flex: 1;
  padding: 20px;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  color: var(--text-color);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease,
    transform 0.12s ease;
}

.vote-button:hover:not(:disabled) {
  border-color: var(--text-color);
}

.vote-button.selected {
  background: var(--text-color);
  color: var(--background-color);
  border-color: var(--text-color);
}

.vote-button.dimmed {
  opacity: 0.4;
}

.vote-button:disabled {
  cursor: default;
}

#vote-message {
  color: var(--tile-green);
  font-size: 1.05rem;
  margin-top: 40px;
}

.menu {
  position: relative;
}

.nav-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  padding: 8px;
  background: var(--background-color);
  border: 2px solid var(--border);
  border-radius: 16px;
}

.nav-panel[hidden] {
  display: none;
}

.nav-panel a,
.nav-panel .nav-btn {
  padding: 12px 16px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 600;
}

.nav-panel a:hover,
.nav-panel .nav-btn:hover {
  background: var(--card);
}

.nav-btn {
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--background-color);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}

.modal-card .icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 1.6rem;
  line-height: 1;
}

#calendar-months {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 12px;
}

.cal-legend {
  text-align: center;
  opacity: 0.7;
  font-size: 0.85rem;
  margin: 4px 0 0;
}

.cal-month h3 {
  font-family: "Space Grotesk", system-ui, sans-serif;
  margin: 0 0 8px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-dow {
  font-size: 0.75rem;
  opacity: 0.6;
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.85rem;
}

.cal-day.hit {
  background: var(--yellow);
  color: #141414;
  font-weight: 700;
}

.cal-day.today {
  outline: 2px solid var(--text-color);
  outline-offset: -2px;
}

.cal-day.future {
  opacity: 0.35;
}

.cal-day.pad {
  visibility: hidden;
}

.howto-steps {
  padding-left: 21px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  line-height: 1.6;
  font-size: 1.05rem;
}

.howto-steps ul {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

#howto-play {
  display: block;
  margin: 24px auto 0;
}

footer {
  text-align: center;
  padding: 20px;
  margin-top: 20px;
  border-top: 2px solid var(--border);
  font-size: 0.6rem;
  color: var(--text-color);
  letter-spacing: 0.2rem;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ------ MOBILE ------*/

@media (min-width: 721px) {
  .vote-cta {
    display: none;
  }
}

@media (max-width: 720px) {
  .top-header .title-container {
    display: none;
  }

  .icon-button {
    width: 54px;
    height: 54px;
  }

  .icon-button svg {
    width: 32px;
  }

  .buttons {
    gap: 6px;
  }

  .streak-pill {
    padding: 10px 14px;
    font-size: 1rem;
  }

  .streak-pill svg {
    width: 22px;
    height: 22px;
  }

  .slider {
    padding: 24px 20px;
  }

  .vote-button {
    padding: 16px 12px;
  }
}

/* ---- auth + stats modals ---- */
#auth-form input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0;
  padding: 12px;
  font: inherit;
  color: var(--text-color);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
}

.auth-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.auth-buttons .primary-button {
  flex: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
  margin: 16px 0;
}

.stats-grid strong {
  display: block;
  font-size: 1.6rem;
}

.stats-grid span {
  font-size: 0.8rem;
  opacity: 0.7;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.dist-row > span {
  width: 14px;
  font-weight: bold;
}

.dist-bar {
  background: var(--green);
  color: var(--text-color);
  padding: 4px 8px;
  border-radius: 4px;
  min-width: 24px;
  text-align: right;
  font-weight: bold;
}

/* ---- settings modal ---- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-row p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  opacity: 0.7;
}

.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.12s ease;
  flex-shrink: 0;
  padding: 0;
}

.toggle[aria-checked="true"] {
  background: var(--green);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.toggle[aria-checked="true"] .toggle-knob {
  transform: translateX(22px);
}

.primary-button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ---- most divisive modal ---- */
.divisive-intro {
  margin: 0 0 16px;
  font-size: 0.9rem;
  opacity: 0.7;
}

.divisive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.divisive-item {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
  padding: 14px 16px;
}

.divisive-q {
  margin: 0 0 10px;
  font-weight: 600;
}

.divisive-rank {
  opacity: 0.6;
}

.divisive-bar {
  height: 14px;
  border-radius: var(--border-radius);
  background: var(--border);
  overflow: hidden;
}

.divisive-bar div {
  height: 100%;
  background: var(--tile-green);
}

.divisive-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.divisive-meta {
  margin: 8px 0 0;
  font-size: 0.75rem;
  opacity: 0.6;
}

.divisive-empty {
  text-align: center;
  padding: 16px 0;
  font-weight: 600;
}

/* ---- streak tooltip ---- */
.buttons {
  position: relative;
}

button.streak-pill {
  border: none;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-color);
  cursor: pointer;
}

.streak-tip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(280px, calc(100vw - 32px));
  padding: 14px 16px;
  background: var(--background-color);
  border: 2px solid var(--border);
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.streak-tip[hidden] {
  display: none;
}

.streak-tip p {
  margin: 6px 0 0;
}

/* pointer aimed at the streak pill; --arrow-x is set from JS */
.streak-tip::before {
  content: "";
  position: absolute;
  top: -8px;
  left: var(--arrow-x, 50%);
  width: 14px;
  height: 14px;
  background: var(--background-color);
  border-top: 2px solid var(--border);
  border-left: 2px solid var(--border);
  transform: translateX(-50%) rotate(45deg);
}
