/* ============================================================
   Teammate Tag - dark mode, player stack, connection bars
   ============================================================ */

:root {
  --bg: #0e1116;
  --bg-elevated: #161b22;
  --bg-hover: #1f2530;
  --border: #2a313c;
  --border-strong: #3a414e;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6b7280;
  --accent: #4f9dff;
  --accent-hover: #6cadff;
  --good: #3fb950;
  --bad: #ff6b6b;
  --burn: #ff9352;
  --burn-bg: #2a1d12;
  --strike-empty: #3a414e;
  --strike-1: #f4c870;
  --strike-2: #ff9352;
  --strike-3: #ff5b3a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.4;
  min-height: 100vh;
}

body { padding-bottom: 2rem; }

/* ---------- Header ---------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

header .title h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.subtitle:empty {
  display: none;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-toggles {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-toggles label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}

.header-toggles input[type="checkbox"] {
  accent-color: var(--accent);
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.exit-btn {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

/* ---------- Common ---------- */
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

button.primary {
  background: var(--accent);
  color: #0a0e14;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

/* ---------- Screens ---------- */
.screen {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ---------- Home screen (mode picker) ---------- */
.home {
  max-width: 640px;
  margin: 2.5rem auto 0;
}

.profile-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.profile-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.profile-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.profile-name-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.profile-name-row input {
  min-width: 220px;
}

.profile-name-row button.secondary {
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
}

.profile-screen-card {
  max-width: 720px;
}

.profile-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.profile-detail {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

.profile-detail-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-bottom: 0.25rem;
}

.profile-detail strong {
  font-size: 1.2rem;
}

.home h2 {
  margin: 0 0 1rem 0;
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: center;
}

.mode-tiles {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.mode-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  transition: border-color 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.mode-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.mode-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.mode-tile-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.mode-tile-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
}

.mode-tile-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.back-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.75rem;
  font-family: inherit;
}

.back-btn:hover { color: var(--accent); }

.banner-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.fr-answer-reveal {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.fr-answer-reveal ul {
  list-style: none;
  margin: 0.5rem 0 0 0;
  padding: 0;
}

.fr-answer-reveal li {
  padding: 0.2rem 0;
}

button.secondary {
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
}

button.secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Film Review specific ---------- */
.fr-stats {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.fr-stats .stat-hit { color: var(--good); font-weight: 700; }
.fr-stats .stat-foul { color: var(--strike-1); font-weight: 700; }
.fr-stats .stat-strike { color: var(--bad); font-weight: 700; }

#fr-pair-names {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.25rem;
}

#fr-pair-names .arrow {
  color: var(--text-muted);
  margin: 0 0.5rem;
}

.fr-guess-form input { flex: 1; }
.fr-guess-form #fr-year-input { max-width: 90px; flex: 0 0 auto; }


.team-autocomplete-wrap {
  flex: 1;
}

.team-autocomplete-wrap .autocomplete-list li {
  justify-content: flex-start;
}

.fr-stats .stat-sep {
  color: var(--text-dim);
  font-weight: 400;
}

.exit-btn {
  color: var(--bad);
}

.exit-btn:hover {
  color: #ff8a8a;
  border-color: var(--bad);
}

/* ---------- Start screen ---------- */
.start-card {
  max-width: 540px;
  margin: 3rem auto 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.start-card h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.6rem;
  color: var(--text);
}

.start-card p { margin: 0 0 1.5rem 0; }

.form-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.form-row label {
  width: 5.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-row input { flex: 1; }

.start-card button.primary {
  margin-top: 1rem;
  width: 100%;
  padding: 0.75rem;
  font-size: 1.05rem;
}

/* ---------- Game layout ---------- */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}

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

@media (max-width: 700px) {
  .profile-name-row {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-name-row input {
    min-width: 0;
    width: 100%;
  }

  .profile-detail-grid {
    grid-template-columns: 1fr;
  }
}

.game-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

/* Pre-game countdown: shows 3, 2, 1 in the timer slot only (no overlay). */
.timer.countdown {
  color: var(--accent);
}

/* ---------- Turn card (input area, fixed at top) ---------- */
.turn-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  position: sticky;
  top: 1rem;
  z-index: 10;
}

.turn-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.turn-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  color: var(--accent);
}

.timer {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--bad);
  letter-spacing: -0.02em;
}

.turn-prompt {
  font-size: 1.15rem;
  margin-bottom: 0.85rem;
}

.turn-prompt #current-player-name {
  font-weight: 700;
  color: var(--text);
}

.guess-form {
  display: flex;
  gap: 0.5rem;
}

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

.autocomplete-wrap input { width: 100%; }

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0.25rem 0 0 0;
  padding: 0;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
}

.autocomplete-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.autocomplete-list li:last-child { border-bottom: none; }

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--bg-hover);
}

.autocomplete-list .ac-name { font-weight: 500; }

.autocomplete-list .ac-years {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
}

.feedback {
  min-height: 1.4em;
  margin-top: 0.75rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.feedback .ok { color: var(--good); font-weight: 500; }
.feedback .bad { color: var(--bad); }
.feedback .burn { color: var(--burn); font-weight: 700; }
.feedback .muted-inline { color: var(--text-muted); font-size: 0.9em; }

/* ---------- Card stack ---------- */
.card-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Newest cards inserted at the top of this container */
}

/* Connection bar (between cards) */
.connection-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.5rem 0.6rem 1rem;
  background: transparent;
  border-left: 2px solid var(--border-strong);
  margin-left: 1.25rem;
  position: relative;
}

.fr-link-spacer {
  height: 18px;
  margin-left: 1.25rem;
  border-left: 2px solid transparent;
}

.connection-arrow {
  font-size: 1.3rem;
  color: var(--accent);
  flex-shrink: 0;
}

.connection-seasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

.season-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.18rem 0.55rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.season-pill.burned {
  background: var(--burn-bg);
  border-color: var(--burn);
  color: var(--burn);
}

.season-pill .x-marks {
  display: inline-flex;
  gap: 1px;
}

.x-mark {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 1.5px;
  background: var(--strike-empty);
  position: relative;
}

.x-mark.s1 { background: var(--strike-1); }
.x-mark.s2 { background: var(--strike-2); }
.x-mark.s3 { background: var(--strike-3); }

/* ---------- Player card ---------- */
.player-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.player-card.seed {
  border-color: var(--accent);
  border-width: 1px;
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

.headshot {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--text-dim);
  font-weight: 700;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.headshot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg);
}

.headshot .initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

.player-info { min-width: 0; }

.player-info .name {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.player-info .years {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  margin-top: 2px;
}

.player-info .teams-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-top: 0.55rem;
  margin-bottom: 0.2rem;
}

.player-info .teams {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--text);
}

.player-info .teams li {
  padding: 1px 0;
}

.player-info .seed-badge {
  display: inline-block;
  background: var(--accent);
  color: #0a0e14;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* ---------- Card slide-in animation ---------- */
.player-card.slide-in,
.connection-bar.slide-in {
  animation: slideDown 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
  transform-origin: top;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Side panel ---------- */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

.side-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.side-section[hidden] { display: none; }

.side-section h3 {
  margin: 0 0 0.45rem 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.lineup-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.88rem;
  max-height: 400px;
  overflow-y: auto;
}

.lineup-list li { padding: 1px 0; }

.lineup-list li.last {
  font-weight: 700;
  color: var(--accent);
}

.out-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
}

.out-list li {
  padding: 0.2rem 0.4rem;
  background: var(--burn-bg);
  color: var(--burn);
  border-radius: 3px;
  margin-bottom: 3px;
  font-weight: 600;
}

#out-empty { margin: 0; }

/* ---------- Inline game-over banner (replaces turn-card on game end) ---------- */
.game-over-banner {
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 1rem;
  z-index: 10;
  text-align: center;
}

#fr-summary-banner {
  position: static;
  top: auto;
}

#winner-text {
  margin: 0 0 0.4rem 0;
  font-size: 1.8rem;
  color: var(--accent);
}

#game-over-summary {
  margin: 0 0 1rem 0;
}

#play-again-btn {
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
}

/* ---------- Rules modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

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

.modal-close:hover { color: var(--text); }

.modal-content h2 {
  margin: 0 0 0.75rem 0;
  font-size: 1.4rem;
  color: var(--text);
}

.modal-content h3 {
  margin: 1.25rem 0 0.5rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.modal-content p {
  margin: 0 0 0.5rem 0;
  line-height: 1.55;
  color: var(--text);
}

ul.glossary {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
  line-height: 1.55;
}

ul.glossary li { padding: 0.2rem 0; }

ul.glossary b {
  color: var(--accent);
}

/* ---------- Scrollbar (subtle in dark mode) ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
