:root {
  color-scheme: light;
  --bg: #f6f8f6;
  --surface: #ffffff;
  --surface-strong: #fbfdfb;
  --surface-soft: #eef7f4;
  --ink: #101715;
  --muted: #5d6b66;
  --dim: #77837f;
  --line: #dce5e0;
  --line-strong: #c4d3ce;
  --accent: #be123c;
  --accent-strong: #e11d48;
  --accent-soft: #fff1f3;
  --accent-line: #fac7d2;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --teal-soft: #e2f3f0;
  --danger: #be123c;
  --danger-soft: #fff1f3;
  --focus: #0f766e;
  --shadow: 0 18px 45px rgba(17, 24, 22, 0.08);
  --shadow-soft: 0 10px 26px rgba(17, 24, 22, 0.06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1513;
  --surface: #141d1a;
  --surface-strong: #121b18;
  --surface-soft: #172823;
  --ink: #edf5f2;
  --muted: #a9bab4;
  --dim: #72847d;
  --line: #2b3b36;
  --line-strong: #3f554e;
  --accent: #fb7185;
  --accent-strong: #fda4af;
  --accent-soft: #351923;
  --accent-line: #6b2a3a;
  --teal: #2dd4bf;
  --teal-strong: #7ddfd3;
  --teal-soft: #153a34;
  --danger: #fb7185;
  --danger-soft: #351923;
  --focus: #7ddfd3;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.22);
}

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

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--teal);
  border-radius: 10px;
  padding: 0 16px;
  background: var(--teal);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  background: var(--teal-strong);
  border-color: var(--teal-strong);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button.danger {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button.danger:hover:not(:disabled),
button.danger:focus-visible:not(:disabled) {
  border-color: #f59aac;
  background: #ffe4e9;
  color: #9f1239;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  outline: none;
}

select {
  cursor: pointer;
}

input::placeholder {
  color: #8a9792;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

button:focus,
a:focus {
  outline: 2px solid rgba(15, 118, 110, 0.42);
  outline-offset: 2px;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p,
li {
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  width: min(1320px, calc(100% - clamp(16px, 4vw, 40px)));
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px) 0 48px;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(18px, 3vw, 34px);
  align-items: start;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(20px, 4vw, 44px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.site-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
}

.topbar-brand {
  color: var(--teal-strong);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-kicker,
.eyebrow,
.section-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-kicker {
  color: var(--teal-strong);
}

.eyebrow,
.section-label {
  color: var(--accent-strong);
}

.brand-product {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.top-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--teal-soft);
  color: var(--teal-strong);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
}

.top-action-button:hover,
.top-action-button:focus-visible {
  filter: brightness(1.08);
}

.hero-copy,
.play-column,
.side-column,
.card,
.session-card {
  min-width: 0;
}

.hero-panel h1 {
  max-width: 18ch;
  margin: 10px 0 8px;
  color: var(--ink);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 820;
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-subtitle {
  max-width: 76ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.25vw, 1.08rem);
  font-weight: 450;
  line-height: 1.58;
}

.session-card {
  width: min(100%, 360px);
  justify-self: start;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface-strong);
}

.session-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.session-card code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 22px;
  align-items: start;
}

.play-column,
.side-column {
  display: grid;
  min-width: 0;
}

.play-column {
  gap: 18px;
}

.side-column {
  position: sticky;
  top: 18px;
  gap: 14px;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.side-column .card {
  padding: 16px;
  background: var(--surface-strong);
  box-shadow: none;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card h2 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 820;
  line-height: 1.2;
}

.status-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--teal-soft);
  color: var(--teal-strong);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.clue-card {
  border-left: 6px solid var(--accent);
  padding: 24px;
  box-shadow: var(--shadow);
}

.latest-clue {
  min-height: 5rem;
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 450;
  line-height: 1.62;
}

.feedback-card p,
.error-card p {
  margin: 0;
}

#feedback {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.55;
}

.subtle,
.empty,
.source-meta {
  color: var(--muted);
}

#resolved-guess {
  margin-top: 8px;
  font-size: 0.86rem;
}

.guess-card {
  background: var(--surface-strong);
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  gap: 10px;
  align-items: stretch;
}

.guess-row input,
.guess-row button {
  min-height: 46px;
}

.setup-card {
  display: grid;
  gap: 10px;
}

.setup-card .card-header {
  margin-bottom: 0;
}

.setup-card label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

#start-button {
  width: 100%;
}

.metric-list {
  display: grid;
  gap: 0;
  margin-top: 10px;
}

.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.metric-row:first-child {
  border-top: 0;
}

.metric-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-row strong {
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
}

.feedback-content,
.feedback-copy {
  min-width: 0;
}

.feedback-card.is-result {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: var(--shadow);
}

.feedback-card.is-result .section-label {
  color: var(--teal-strong);
}

.feedback-card.is-result .feedback-content {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.feedback-card.is-result #feedback {
  color: var(--teal-strong);
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.45;
}

.result-image {
  width: 92px;
  height: 118px;
  border: 1px solid var(--teal);
  border-radius: 10px;
  background: var(--surface);
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.16);
}

.sources-list,
.event-log,
.clues-list {
  margin: 0;
  padding: 0;
}

.sources-list {
  display: grid;
  gap: 10px;
  list-style: none;
}

.sources-list li {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.sources-list li:first-child {
  padding-top: 0;
  border-top: 0;
}

.sources-list a {
  color: var(--teal-strong);
  font-weight: 850;
  text-decoration: none;
}

.sources-list a:hover,
.sources-list a:focus {
  text-decoration: underline;
}

.source-meta {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
}

.clues-list {
  display: grid;
  gap: 12px;
  list-style: none;
}

.clues-list li {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 12px;
  min-height: 2rem;
}

.clues-list li::before {
  position: absolute;
  top: 2rem;
  bottom: -12px;
  left: 1rem;
  width: 1px;
  background: linear-gradient(180deg, rgba(225, 29, 72, 0.5), rgba(15, 118, 110, 0.18));
  content: "";
}

.clues-list li:last-child::before,
.clues-list li.empty::before {
  display: none;
}

.clue-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  font-weight: 850;
}

.clue-text {
  align-self: center;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}

.clues-list .empty {
  display: block;
  min-height: auto;
  color: var(--muted);
  font-size: 0.94rem;
}

.error-card {
  border-color: var(--accent-line);
  background: var(--danger-soft);
}

.error-card h2 {
  margin: 0 0 6px;
  color: var(--accent-strong);
}

.loading-card {
  border-color: var(--line);
  padding: 12px 16px;
  background: var(--surface-soft);
  box-shadow: none;
}

.loading-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 1.7rem;
}

.loading-message {
  margin: 0;
  color: var(--teal-strong);
  font-size: 0.96rem;
  font-weight: 750;
}

.spinner {
  width: 1.45rem;
  height: 1.45rem;
  flex: 0 0 auto;
  border: 2px solid rgba(15, 118, 110, 0.16);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.typing-dots {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
  flex: 0 0 auto;
}

.typing-dots span {
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: var(--teal);
  animation: dotPulse 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

.debug-card {
  border-style: dashed;
  border-color: #b8c8c2;
  background: var(--surface-strong);
  box-shadow: none;
}

.debug-card summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--teal-strong);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
  list-style-position: inside;
  text-transform: uppercase;
}

.debug-card summary span {
  color: var(--teal-strong);
  font-weight: 850;
}

.debug-card summary small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.debug-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.debug-events-cell {
  min-width: 0;
}

.debug-card h3 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

pre,
.event-log {
  overflow: auto;
  min-height: 2.2rem;
  max-height: 12rem;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  white-space: pre-wrap;
}

.event-log {
  padding-left: 1.45rem;
}

.event-log li {
  margin: 0.28rem 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    opacity: 0.34;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-0.16rem);
  }
}

@media (max-width: 920px) {
  .hero-panel,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-panel h1 {
    font-size: 2.25rem;
  }

  .play-column {
    order: 0;
    width: 100%;
  }

  .side-column {
    display: contents;
    position: static;
  }

  .setup-card {
    order: 2;
  }

  .status-card {
    order: 3;
  }

  .sources-card {
    order: 4;
  }

  .debug-card {
    order: 5;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .page-shell {
    width: min(100% - 24px, 1320px);
    padding-top: 12px;
  }

  .hero-panel {
    gap: 16px;
    margin-bottom: 16px;
    border-radius: 14px;
    padding: 20px;
  }

  .site-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .top-action-button,
  .brand-product {
    min-height: 30px;
    padding: 5px 10px;
  }

  .hero-panel h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .session-card {
    width: 100%;
  }

  .game-layout {
    gap: 14px;
  }

  .play-column {
    gap: 12px;
  }

  .card,
  .side-column .card {
    padding: 16px;
  }

  .clue-card {
    padding: 18px;
  }

  .latest-clue {
    min-height: 4rem;
    font-size: 1rem;
  }

  .guess-row {
    grid-template-columns: 1fr 1fr;
  }

  .guess-row input {
    grid-column: 1 / -1;
  }

  .guess-row button {
    width: 100%;
    min-width: 0;
  }

  .feedback-card.is-result .feedback-content {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
  }

  .result-image {
    width: 76px;
    height: 98px;
  }

  .loading-head {
    gap: 8px;
  }

  .debug-card summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}


/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  width: min(1320px, calc(100% - clamp(16px, 4vw, 40px)));
  margin: 0 auto;
  padding: 0 0 36px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px 24px;
  padding: 16px 18px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.footer-text {
  margin: 0;
  font-size: 0.92rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.footer-links a {
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 850;
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  text-decoration: underline;
}

@media (max-width: 560px) {
  .footer-inner {
    flex-direction: column;
  }

  .footer-links {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
