:root {
  --bg: #141210;
  --surface: #1e1b18;
  --border: #524840;
  --text: #e8e4de;
  --muted: #c0b8ae;
  --accent: #2d9b5a;
  --accent-hover: #38c070;
  --revealed: #4abe78;
  --solved: #0f2d1c;
  --solved-border: #2d9b5a;
  --key-bg: #524840;
  --key-used: #2a2520;
  --danger: #e05252;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Landing ── */
#landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

#landing h1 { font-size: 2.8rem; letter-spacing: 0.05em; }
#landing-date { color: var(--muted); font-size: 0.95rem; }
.tagline { font-size: 1.1rem; }

#concert-preview {
  margin: 0.5rem 0;
  font-size: 1.05rem;
  font-weight: bold;
}

#start-btn {
  margin-top: 0.5rem;
  padding: 0.85rem 2rem;
  font-size: 1.1rem;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
#start-btn:hover { background: var(--accent-hover); }

/* ── Game layout ── */
#game { max-width: 700px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

header {
  text-align: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  position: relative;
}
header h1 { font-size: 2rem; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
#concert-info { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
.sep { color: var(--muted); font-size: 0.7em; vertical-align: middle; }
#musicians {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

#guesses-info { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.75rem; }
#guesses-info strong { color: var(--text); }

#progress-bar-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 0.3rem;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.5s ease;
}
#progress-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#help-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#help-btn:hover { color: var(--text); border-color: var(--muted); }

#restart-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.4rem;
}
#restart-btn:hover { color: var(--danger); }

.help-link {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
}
.help-link:hover { color: var(--text); }

#landing-help-btn { margin-top: 0.5rem; display: block; }

/* ── Help modal ── */
#help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#help-modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem;
  width: min(92vw, 460px);
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  max-height: 90vh;
  overflow-y: auto;
}

#help-modal h2 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}

#help-modal > p {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.help-section {
  margin-bottom: 1.1rem;
}

.help-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.help-section p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.help-tip {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

#help-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
#help-close:hover { color: var(--text); }

#help-got-it {
  width: 100%;
  padding: 0.7rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#help-got-it:hover { background: var(--accent-hover); }

/* ── Setlist board ── */
#setlist-board { margin-bottom: 2rem; }

.encore-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0.75rem 0;
}
.encore-divider::before,
.encore-divider::after {
  content: '';
  display: inline-block;
  width: 30%;
  height: 1px;
  background: var(--border);
  vertical-align: middle;
  margin: 0 0.5em;
}

.setlist-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid transparent;
}
.setlist-row:hover { background: #2a2520; }
.setlist-row.solved {
  background: var(--solved);
  border-color: var(--solved-border);
  cursor: default;
}
.setlist-row.solved:hover { background: var(--solved); }

.song-num {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 2rem;
  text-align: right;
  flex-shrink: 0;
}

.song-blanks {
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  color: var(--text);
  word-break: break-word;
}

.song-word { white-space: nowrap; }

.song-blanks .revealed-letter { color: var(--revealed); }

.song-note {
  font-family: 'Georgia', serif;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  letter-spacing: normal;
}

/* ── Keyboard ── */
#keyboard-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 2rem;
}

.letter-btn {
  width: 38px;
  height: 38px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text);
  background: var(--key-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, opacity 0.1s;
}
.letter-btn:hover:not(:disabled) { background: #d5d1cb; }
.letter-btn:disabled {
  background: var(--key-used);
  color: #aaa;
  cursor: not-allowed;
  opacity: 0.5;
}

/* ── Mobile letter picker ── */
#mobile-letter-picker { display: none; margin-bottom: 1.5rem; }

@media (max-width: 600px) {
  #keyboard-container { display: none !important; }

  #mobile-letter-picker {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.75rem 1rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 50;
  }

  /* Push page content above the fixed bar */
  #game main { padding-bottom: 9rem; }
}

#used-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0.75rem;
  min-height: 1.5rem;
}

.used-letter-chip {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 6px;
  background: var(--key-used);
  color: #888;
  border-radius: 3px;
}

#mobile-letter-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#mobile-letter-form {
  display: flex;
  gap: 0.5rem;
}

#mobile-letter-input {
  width: 3.5rem;
  padding: 0.6rem 0.5rem;
  font-family: 'Courier New', monospace;
  font-size: 1.4rem;
  font-weight: bold;
  text-align: center;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 5px;
}
#mobile-letter-input:focus { outline: 2px solid var(--accent); border-color: transparent; }

#mobile-letter-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#mobile-letter-btn:hover { background: var(--accent-hover); }
#mobile-letter-btn:disabled { background: var(--key-used); color: #aaa; cursor: not-allowed; }

#mobile-letter-feedback {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  min-height: 1.2em;
  color: var(--danger);
}

/* ── Give up ── */
#give-up-container {
  text-align: center;
  margin-bottom: 1.5rem;
}
#give-up-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}
#give-up-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ── Revealed (game-over) song row ── */
.setlist-row.revealed .song-blanks { color: var(--muted); }

/* ── Correct-guess animation ── */
@keyframes letter-pop {
  0%   { opacity: 0; transform: translateY(-6px) scale(0.85); }
  60%  { transform: translateY(2px) scale(1.08); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes row-glow {
  0%   { background: var(--solved); box-shadow: none; }
  25%  { background: rgba(74, 190, 120, 0.25); box-shadow: 0 0 16px rgba(74, 190, 120, 0.3); }
  100% { background: var(--solved); box-shadow: none; }
}
.setlist-row.just-solved {
  animation: row-glow 0.9s ease-out forwards;
}
.setlist-row.just-solved .revealed-letter {
  display: inline-block;
  animation: letter-pop 0.35s ease-out both;
}

/* ── Game over banner ── */
#game-over-banner {
  text-align: center;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-top: 1rem;
}
#game-over-message { font-size: 1.1rem; margin-bottom: 1rem; }
#share-btn {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#share-btn:hover { background: var(--accent-hover); }

/* ── Modal ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#modal {
  background: var(--surface);
  border-radius: 10px;
  padding: 2rem;
  width: min(90vw, 420px);
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

#modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
#modal-close:hover { color: var(--text); }

/* ── Modal cell input ── */
#modal-cells {
  display: block;
  margin-bottom: 1.5rem;
  font-family: 'Courier New', monospace;
  font-size: 1.15rem;
  line-height: 1.6;
  cursor: default;
  user-select: none;
  word-break: break-word;
}

.cell-fixed {
  display: inline-block;
  text-align: center;
  min-width: 1ch;
  margin: 0 2px;
  vertical-align: bottom;
  color: var(--revealed);
  font-weight: bold;
}

.cell-blank {
  display: inline-block;
  text-align: center;
  min-width: 1ch;
  margin: 0 2px;
  vertical-align: bottom;
  color: var(--muted);
  cursor: pointer;
}
.cell-blank.active  { color: var(--accent); }
.cell-blank.filled  { color: var(--text); font-weight: bold; }

.cell-word  { display: inline-block; white-space: nowrap; vertical-align: bottom; }
.cell-space { display: inline-block; min-width: 1.6ch; }
.cell-punc  { display: inline-block; min-width: 0.7ch; text-align: center; color: var(--muted); }

#modal-hidden-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

#modal-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

#modal-actions button {
  padding: 0.6rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#modal-actions button:hover { background: var(--accent-hover); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
.modal-shake { animation: shake 0.4s ease-out; }

@keyframes checkmark-pop {
  0%   { opacity: 0; transform: scale(0.4); }
  60%  { transform: scale(1.3); }
  100% { opacity: 1; transform: scale(1); }
}

#modal-feedback {
  text-align: center;
  font-size: 0.9rem;
  min-height: 1.2em;
  color: var(--danger);
}
#modal-feedback.correct {
  color: var(--revealed);
  font-size: 2.5rem;
  line-height: 1;
  animation: checkmark-pop 0.35s ease-out both;
}
