:root {
  --font-display: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, "Fira Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-display);
  text-align: center;
  background: #000000;
  color: #fffefe;
  margin: 0;
  padding: clamp(24px, 6vw, 48px) 16px;
}

h1 {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  padding-left: 0.4em; /* offset trailing tracking so it stays centered */
  margin: 0 0 12px;
  color: #fffefe;
}

#mode-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid #4d4d4d;
  margin: 0 0 20px;
}

.mode-option {
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8a8a8a;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.mode-option + .mode-option {
  border-left: 1px solid #4d4d4d;
}

.mode-option:hover {
  color: #0093d3;
}

.mode-option.active {
  color: #000000;
  background: #0093d3;
}

#score {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #8a8a8a;
  margin: 0 0 32px;
  white-space: nowrap;
}

#score.clickable {
  cursor: pointer;
}

#score.clickable:hover {
  color: #0093d3;
}

#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(5px, 1.6vw, 12px);
  width: min(94vw, 460px);
  margin: 0 auto;
}

.card {
  background: #333333;
  border: 1px solid #4d4d4d;
  border-radius: 0;
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4%;
  padding: 6%;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.card svg {
  width: 50%;
  height: auto;
  display: block;
}

.card.selected {
  border-color: #fffefe;
  box-shadow: inset 0 0 0 1px #fffefe;
}

/* Found-set review highlight — cyan, distinct from the magenta selection. */
.card.review {
  border-color: #0093d3;
  box-shadow: inset 0 0 0 2px #0093d3;
}

.card.new {
  animation: pop 0.3s ease;
}

@keyframes pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Brief border flash on every card after a guess: white = a set, magenta = not. */
.card.flash-good {
  animation: flash-good 0.45s ease;
}

.card.flash-bad {
  animation: flash-bad 0.45s ease;
}

@keyframes flash-good {
  0%,
  100% {
    border-color: #4d4d4d;
    box-shadow: none;
  }
  35% {
    border-color: #fffefe;
    box-shadow: inset 0 0 0 2px #fffefe;
  }
}

@keyframes flash-bad {
  0%,
  100% {
    border-color: #4d4d4d;
    box-shadow: none;
  }
  35% {
    border-color: #cc016b;
    box-shadow: inset 0 0 0 2px #cc016b;
  }
}

#matches {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #8a8a8a;
  min-height: 14px;
  margin-top: 28px;
}

#new-game {
  margin-top: 24px;
  padding: 9px 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8a8a8a;
  background: transparent;
  border: 1px solid #4d4d4d;
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

#new-game:hover {
  border-color: #0093d3;
  color: #0093d3;
}

#share-button {
  margin-top: 24px;
  padding: 9px 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #000000;
  background: #0093d3;
  border: 1px solid #0093d3;
  border-radius: 0;
  cursor: pointer;
  transition: opacity 0.12s ease;
}

#share-button:hover {
  opacity: 0.85;
}

/* Help "?" button — sits in the New Game slot in daily mode. Mirrors #new-game
   but square, since it holds a single glyph. */
#help-button {
  margin-top: 24px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: #8a8a8a;
  background: transparent;
  border: 1px solid #4d4d4d;
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

#help-button:hover {
  border-color: #0093d3;
  color: #0093d3;
}

/* Help modal: full-viewport translucent backdrop with a centered bordered panel. */
#help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

#help-modal.open {
  opacity: 1;
  visibility: visible;
}

#help-panel {
  position: relative;
  background: #1a1a1a;
  border: 1px solid #4d4d4d;
  padding: 32px 24px 28px;
  width: min(92vw, 420px);
  text-align: left;
  transform: scale(0.98);
  transition: transform 0.12s ease;
}

#help-modal.open #help-panel {
  transform: scale(1);
}

#help-close {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1;
  color: #8a8a8a;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.12s ease;
}

#help-close:hover {
  color: #0093d3;
}

#help-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #fffefe;
  text-align: center;
  padding-left: 0.22em; /* offset trailing tracking so it stays centered */
  margin: 0 0 14px;
}

#help-panel p {
  font-size: 13px;
  line-height: 1.5;
  color: #c4c4c4;
  margin: 0 0 20px;
}

#help-panel strong {
  color: #fffefe;
  font-weight: 600;
}

/* Each example is a row of four mini cards. */
.help-example + .help-example {
  margin-top: 10px;
}

.help-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.help-card {
  background: #333333;
  border: 1px solid #4d4d4d;
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4%;
  padding: 6%;
}

.help-card svg {
  width: 56%;
  height: auto;
  display: block;
}
