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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1d24;
  color: #e8e8e8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 6px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
#logo-mark { height: 36px; width: auto; display: block; }

h1 {
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 900;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  line-height: 1;
  color: #e8e8e8;
}
/* logo green: fine for large display text, too low contrast for body copy */
h1 .dle { color: #378f33; }

#hud { display: flex; gap: 16px; align-items: center; font-size: 0.9rem; }
#hud b { color: #ffcc00; }

#name-wrap { display: inline-flex; align-items: center; }
#btn-name.has-name {
  background: transparent;
  border-color: transparent;
  color: #ffcc00;
  font-weight: 600;
  text-decoration: underline dotted #6b7280;
  text-underline-offset: 4px;
}
#name-input {
  width: 140px;
  background: #2a2f3a;
  color: #e8e8e8;
  border: 1px solid #ffcc00;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 16px;
}
#name-input:focus { outline: none; }

/* one-time nudge toward the name field */
#name-hint {
  position: absolute;
  z-index: 60;
  width: max-content;
  max-width: min(270px, calc(100vw - 24px));
  background: #ffcc00;
  color: #1a1d24;
  border-radius: 10px;
  padding: 11px 12px 11px 14px;
  font-size: 0.84rem;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}
#name-hint::before {           /* arrow pointing up at the button */
  content: "";
  position: absolute;
  top: -7px;
  left: var(--arrow-x, 24px);
  width: 14px;
  height: 14px;
  background: #ffcc00;
  transform: rotate(45deg);
  border-radius: 3px;
}
#name-hint b { font-weight: 700; }
#name-hint .dismiss {
  flex: none;
  background: transparent;
  border: 0;
  color: #1a1d24;
  font-size: 1.05rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.6;
  border-radius: 5px;
}
#name-hint .dismiss:hover { opacity: 1; }
#name-hint .dismiss:focus-visible { outline: 2px solid #1a1d24; opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  #name-hint { animation: hint-in 0.22s ease-out; }
  @keyframes hint-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
  }
}

#modes {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#modes button, #actions button, #btn-stats, #btn-name {
  background: #2a2f3a;
  color: #e8e8e8;
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}
#modes button:hover, #actions button:hover, #btn-stats:hover { background: #353c4a; }
#modes button.active { background: #ffcc00; color: #1a1d24; border-color: #ffcc00; font-weight: 600; }

main { width: 100%; max-width: 900px; padding: 0 16px 40px; }

#frame-wrap {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
#frame { max-width: 100%; max-height: 100%; display: block; }

#frame-nav {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}
#frame-nav .fnav {
  background: #2a2f3a;
  color: #e8e8e8;
  border: 1px solid #3a4150;
  border-radius: 6px;
  min-width: 40px;
  padding: 6px 0;
  font-size: 0.9rem;
  cursor: pointer;
}
#frame-nav .fnav:hover:not(:disabled) { background: #353c4a; }
#frame-nav .fnav.current { background: #ffcc00; color: #1a1d24; border-color: #ffcc00; font-weight: 600; }
#frame-nav .fnav:disabled { opacity: 0.35; cursor: not-allowed; }

#controls { margin-top: 16px; }

.mode-panel { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.hidden { display: none !important; }

label { display: flex; gap: 8px; align-items: center; font-size: 0.95rem; }

select {
  background: #2a2f3a;
  color: #e8e8e8;
  border: 1px solid #3a4150;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 1rem;
}

/* stretch, not the .mode-panel `center`, so grid items fill their row */
#panel-choice, #panel-season { display: grid; gap: 8px; align-items: stretch; }
/* 1fr rows: every option matches the tallest one, however many lines it wraps to */
#panel-choice {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  grid-auto-rows: 1fr;
}
#panel-season { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }

.opt {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 58px;
  background: #2a2f3a;
  border: 1px solid #3a4150;
  color: #e8e8e8;
  border-radius: 8px;
  padding: 12px 10px;
  font-size: 0.95rem;
  line-height: 1.3;
  cursor: pointer;
}
.opt:hover { background: #353c4a; }
.opt.selected { background: #ffcc00; color: #1a1d24; font-weight: 600; }

#panel-exact { flex-direction: column; }
#panel-exact > div:last-of-type, #panel-exact .selects { display: flex; gap: 14px; }

#search-wrap { position: relative; width: 100%; max-width: 520px; }
#search {
  width: 100%;
  background: #2a2f3a;
  color: #e8e8e8;
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
}
#search:focus { outline: none; border-color: #ffcc00; }
#search-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  list-style: none;
  background: #232833;
  border: 1px solid #3a4150;
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
}
#search-list li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.92rem;
  display: flex;
  gap: 10px;
}
#search-list li .code { color: #ffcc00; font-weight: 600; min-width: 62px; }
#search-list li:hover, #search-list li.hl { background: #353c4a; }

#panel-timeline { flex-direction: column; }
#timeline-slider { width: 100%; accent-color: #ffcc00; }
#timeline-label { font-size: 1.2rem; font-weight: 600; color: #ffcc00; }

#actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
#btn-guess { background: #ffcc00; color: #1a1d24; font-weight: 600; }
#btn-guess:hover { background: #ffd83d; }
#btn-guess:disabled { opacity: 0.4; cursor: not-allowed; }
#btn-report { border-color: #6b4040; color: #d9a0a0; }
#btn-report:hover { background: #3d2b2b; }

#daily-info { margin-top: 14px; text-align: center; }
#daily-title { font-size: 0.95rem; color: #aab; margin-bottom: 8px; }
#daily-history { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#daily-history li {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  background: #2a2f3a;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
}
#daily-history .sq { font-size: 1.1rem; }
#daily-history .dir { color: #aab; font-size: 0.85rem; }
#btn-share {
  margin-top: 10px;
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
#btn-share:hover { background: #5abf60; }

#daily-stats { margin-top: 16px; }
#daily-streak { font-size: 1rem; margin-bottom: 10px; }
#daily-streak b { color: #ffcc00; }
#daily-dist { display: flex; flex-direction: column; gap: 4px; max-width: 420px; margin: 0 auto 10px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.dist-row .lbl { width: 18px; text-align: right; color: #aab; }
.dist-row .bar-wrap { flex: 1; }
.dist-row .bar {
  background: #3a4150;
  border-radius: 4px;
  height: 18px;
  min-width: 22px;
  color: #e8e8e8;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}
.dist-row .bar.mine { background: #4caf50; }
#daily-today { color: #aab; font-size: 0.9rem; }

#leaderboard { margin-top: 18px; }
#leaderboard h2 { font-size: 1rem; margin-bottom: 8px; }
#leaderboard table { margin: 0 auto; border-collapse: collapse; font-size: 0.92rem; }
#leaderboard td { padding: 5px 12px; border-bottom: 1px solid #2a2f3a; text-align: left; }
#leaderboard tr.you td { color: #ffcc00; font-weight: 600; }

#feedback {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  text-align: center;
  font-size: 1.05rem;
  background: #2a2f3a;
}
#feedback.good { border: 1px solid #4caf50; }
#feedback.bad { border: 1px solid #e05252; }
#feedback b { color: #ffcc00; }
.watch-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  margin: 10px auto 0;
  background: #2a2f3a;
  border: 1px solid #ffcc00;
  border-radius: 8px;
  padding: 8px 16px;
  color: #ffcc00;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}
.watch-link:hover { background: #353c4a; }
.watch-link svg { flex: none; opacity: .85; }
.watch-link:hover svg { opacity: 1; }

#site-footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid #2a2f3a;
  text-align: center;
}
/* the injected button ships at a fixed size; scale it down so it sits in the
   footer rather than shouting from it */
#bmc-slot { display: flex; justify-content: center; margin-bottom: 14px; }
#bmc-slot .bmc-btn, #bmc-slot a {
  transform: scale(0.8);
  transform-origin: center;
  opacity: 0.9;
}
#bmc-slot a:hover { opacity: 1; }

#site-footer .credit { font-size: 0.85rem; color: #aab; }
#site-footer .disclaimer {
  margin: 8px auto 0;
  max-width: 620px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #6f7787;
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  header { flex-direction: column; gap: 6px; padding: 8px 12px 4px; }
  h1 { font-size: 1.3rem; }
  #logo-mark { height: 32px; }
  #modes { padding: 0 12px 4px; }
  /* keep the whole hud on one line instead of spending a row on it */
  #hud { flex-wrap: wrap; justify-content: center; gap: 6px 10px; font-size: 0.82rem; }
  #btn-stats, #btn-name { padding: 5px 10px; font-size: 0.82rem; }
  #name-input { width: 110px; padding: 5px 8px; }

  #modes {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    width: 100%;
    padding: 0 12px 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #modes::-webkit-scrollbar { display: none; }
  #modes button { flex: 0 0 auto; padding: 9px 13px; font-size: 0.88rem; }

  main { padding: 0 10px 30px; }

  #panel-exact .selects { flex-direction: column; width: 100%; gap: 10px; }
  #panel-exact label { flex-direction: column; align-items: stretch; gap: 4px; }
  /* 16px inputs stop iOS from zooming the page on focus */
  select, #search { font-size: 16px; width: 100%; }
  #search-wrap { max-width: none; }

  #actions { flex-wrap: wrap; gap: 8px; }
  #btn-guess, #btn-next { flex: 1 1 100%; padding: 13px; font-size: 1.05rem; }
  #btn-skip, #btn-report { flex: 1 1 40%; padding: 11px 6px; font-size: 0.9rem; }

  #frame-nav { flex-wrap: wrap; }
  #frame-nav .fnav { min-width: 46px; padding: 10px 0; font-size: 1rem; }

  #panel-choice { grid-template-columns: 1fr; }
  .opt { padding: 13px 10px; }
  #panel-season { grid-template-columns: repeat(5, 1fr); }

  #daily-history li { font-size: 0.88rem; flex-wrap: wrap; }
  #leaderboard td { padding: 5px 8px; }
}

#stats-panel { margin-top: 20px; }
#stats-panel h2 { font-size: 1.05rem; margin-bottom: 10px; }
#stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
#stats-table th, #stats-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #2a2f3a; }
#stats-summary { margin-top: 10px; font-size: 0.9rem; color: #aab; }
