:root {
  --charcoal: #2b2724;
  --charcoal-2: #363029;
  --charcoal-3: #413a31;
  --cream: #f1e9dc;
  --cream-dim: #b9ad9a;
  --herb: #7c9a63;
  --herb-dim: #4f5f40;
  --tomato: #c1442e;
  --tomato-dim: #6e2a1e;
  --gold: #d4a017;
  --line: rgba(241, 233, 220, 0.14);
  --line-strong: rgba(241, 233, 220, 0.28);

  --font-display: "Fraunces", serif;
  --font-ui: "Space Grotesk", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--charcoal);
  color: var(--cream);
  font-family: var(--font-ui);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.page {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

/* ---- Header ---- */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 28px 0 16px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.wordmark-dot {
  color: var(--gold);
}

.puzzle-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cream-dim);
}

/* ---- Mode toggle ---- */

.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 14px 0 0;
}

.mode-button {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--cream-dim);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.mode-button:hover {
  border-color: var(--gold);
  color: var(--cream);
}

.mode-button[aria-selected="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--charcoal);
  font-weight: 500;
}

/* ---- Board ---- */

.board {
  flex: 1;
  padding-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.instruction {
  font-size: 1rem;
  color: var(--cream-dim);
  margin: 0 0 28px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
  min-height: 40px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--cream);
  background: var(--charcoal-2);
  border: 1px solid var(--line-strong);
  padding: 8px 14px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  animation: tag-in 320ms ease-out;
}

.tag--locked {
  color: var(--cream-dim);
  border-style: dashed;
  border-color: var(--line);
}

@keyframes tag-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.guesses-remaining {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  transition: background 200ms ease, transform 200ms ease;
}

.dot--used {
  background: var(--charcoal-3);
  border: 1px solid var(--line);
  transform: scale(0.85);
}

/* ---- Hint panel ---- */

.hint-panel {
  width: 100%;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--charcoal-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--herb);
  border-radius: 3px;
  text-align: left;
}

.hint-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--herb);
  margin: 0 0 6px;
}

.hint-fact {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--cream);
  margin: 0;
}

.hint-origin {
  font-size: 0.9rem;
  color: var(--cream);
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.hint-origin-flag {
  font-size: 1.3rem;
  margin-right: 6px;
}

/* ---- Guess form ---- */

.guess-form {
  display: flex;
  width: 100%;
  gap: 10px;
  margin-bottom: 20px;
}

.autocomplete {
  position: relative;
  flex: 1;
}

.guess-input {
  width: 100%;
  background: var(--charcoal-2);
  border: 1px solid var(--line-strong);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 3px;
}

.guess-input::placeholder {
  color: var(--cream-dim);
}

.guess-input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.guess-button {
  background: var(--gold);
  color: var(--charcoal);
  border: none;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 20px;
  border-radius: 3px;
  cursor: pointer;
}

.guess-button:hover {
  filter: brightness(1.08);
}

.guess-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.guess-button:focus-visible,
.share-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---- Suggestion dropdown ---- */

.suggest-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
  text-align: left;
  background: var(--charcoal-2);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.suggest-item {
  padding: 9px 12px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--cream);
  border-radius: 2px;
  cursor: pointer;
}

.suggest-item mark {
  background: none;
  color: var(--gold);
  font-weight: 600;
}

.suggest-item:hover,
.suggest-item--active {
  background: var(--charcoal-3);
}

/* ---- History ---- */

.history {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.history-item {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--tomato);
  text-decoration: line-through;
  text-decoration-color: var(--tomato-dim);
}

/* ---- Reveal panel ---- */

.reveal {
  margin-top: 20px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  width: 100%;
}

.reveal-status {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
}

.reveal-status--win {
  color: var(--herb);
}

.reveal-status--lose {
  color: var(--tomato);
}

.reveal-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 2rem;
  margin: 0 0 4px;
}

.reveal-origin {
  color: var(--cream-dim);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.tag-row--final {
  margin-bottom: 20px;
}

.reveal-fact {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--cream-dim);
  margin: 0 0 20px;
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
}

.reveal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.share-button {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 3px;
  cursor: pointer;
}

#newRoundButton {
  border-color: var(--herb);
  color: var(--herb);
}

.share-button:hover {
  border-color: var(--gold);
}

.share-confirm {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--herb);
  min-height: 1.2em;
  margin: 10px 0 0;
}

/* ---- Footer ---- */

.foot {
  text-align: center;
  padding: 24px 0 32px;
  color: var(--cream-dim);
  font-size: 0.8rem;
}

@media (max-width: 420px) {
  .reveal-name {
    font-size: 1.6rem;
  }
}
