/* === Self-hosted Fonts === */
@font-face {
  font-family: 'Bebas Neue';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/bebas-neue-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/saira-condensed-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/saira-condensed-500.woff2') format('woff2');
}

@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/saira-condensed-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/saira-condensed-700.woff2') format('woff2');
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --field: #2d6b30;
  --field-dark: #1f5022;
  --field-deep: #163a18;
  --chalk: #f5f0e8;
  --leather: #6b3e1f;
  --leather-light: #a87544;
  --correct: rgba(245, 240, 232, 0.92);
  --close: #a87544;
  --miss: #1a3a1c;
  --miss-border: #2a5a2e;
  --text-primary: #ffffff;
  --text-secondary: #d4dcc8;
  --text-muted: #9aab8a;
  --border: rgba(245, 240, 232, 0.15);
  --chalk-line: rgba(245, 240, 232, 0.1);
  --chalk-hover: rgba(245, 240, 232, 0.08);
  --chalk-hash: rgba(245, 240, 232, 0.07);
  --chalk-subtle: rgba(245, 240, 232, 0.06);
  --chalk-highlight: rgba(245, 240, 232, 0.4);
  --chalk-border-light: rgba(245, 240, 232, 0.12);
  --overlay: rgba(0, 0, 0, 0.3);
  --overlay-light: rgba(0, 0, 0, 0.2);
  --overlay-heavy: rgba(0, 0, 0, 0.6);
  --overlay-input: rgba(0, 0, 0, 0.35);
  --leather-bg: rgba(168, 117, 68, 0.6);
  --leather-border: rgba(168, 117, 68, 0.5);
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Saira Condensed', sans-serif;
}

/* === THE FIELD === */
body {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;

  /* Turf base with mow stripes */
  background-color: var(--field);
  background-image:
    /* Mow stripe pattern — alternating light/dark turf bands */
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 60px,
      rgba(0, 0, 0, 0.03) 60px,
      rgba(0, 0, 0, 0.03) 120px
    ),
    /* Subtle grass grain texture */
    repeating-linear-gradient(
      92deg,
      transparent 0px,
      transparent 2px,
      rgba(0, 0, 0, 0.02) 2px,
      rgba(0, 0, 0, 0.02) 4px
    );
}

/* Sideline borders */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-left: 3px solid var(--chalk-line);
  border-right: 3px solid var(--chalk-line);
}

/* Hash marks — short horizontal ticks along left and right sidelines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    /* Left hash ticks */
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 22px,
      var(--chalk-hash) 22px,
      var(--chalk-hash) 24px,
      transparent 24px,
      transparent 40px
    ),
    /* Right hash ticks */
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 22px,
      var(--chalk-hash) 22px,
      var(--chalk-hash) 24px,
      transparent 24px,
      transparent 40px
    );
  background-size: 20px 40px, 20px 40px;
  background-position: 4px top, calc(100% - 4px) top;
  background-repeat: repeat-y, repeat-y;
}

/* === Yard Markers === */
.yard-markers {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.yard-marker {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
}

/* The yard line itself */
.yard-marker::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  background: var(--chalk-line);
}

.ym-left, .ym-right {
  position: absolute;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--chalk-subtle);
  letter-spacing: 6px;
  user-select: none;
  line-height: 1;
  top: -0.9rem;
}

/* Left number — rotated so top of text points toward top of page (toward endzone) */
.ym-left {
  left: 28px;
  transform: rotate(-90deg);
  transform-origin: center center;
}

/* Right number — rotated opposite direction */
.ym-right {
  right: 28px;
  transform: rotate(90deg);
  transform-origin: center center;
}

/* Yard marker positions (CSP-safe — no inline styles) */
.ym-10  { top: 120px; }
.ym-20  { top: 240px; }
.ym-30  { top: 360px; }
.ym-40  { top: 480px; }
.ym-50  { top: 600px; }
.ym-40b { top: 720px; }
.ym-30b { top: 840px; }
.ym-20b { top: 960px; }
.ym-10b { top: 1080px; }


/* === Header === */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 720px;
  padding: 14px 20px;
  position: relative;
  z-index: 2;
  background: rgba(31, 80, 34, 0.85);
  backdrop-filter: blur(4px);
  border-bottom: 2px solid var(--chalk-line);
}

.header-left, .header-right {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.header-left { width: 44px; }
.header-right { width: 84px; }

.header-center {
  text-align: center;
}

.logo {
  font-family: var(--font-display);
  font-size: 3.2rem;
  letter-spacing: 10px;
  padding-left: 10px; /* compensate for trailing letter-spacing */
  color: var(--chalk);
  line-height: 1;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 0 40px var(--chalk-line);
}

.puzzle-number {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 4px;
  margin-top: -2px;
}

.icon-btn {
  background: var(--overlay-light);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--chalk-highlight);
  color: var(--chalk);
  background: var(--overlay);
}

/* === Main === */
main {
  width: 100%;
  max-width: 720px;
  padding: 16px 20px;
  flex: 1;
  position: relative;
  z-index: 2;
}

/* === Guess Input === */
.guess-input-area {
  position: relative;
  margin-bottom: 20px;
  z-index: 10;
}

.input-wrapper {
  display: flex;
  gap: 8px;
}

#player-input {
  flex: 1;
  background: var(--overlay);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  outline: none;
  transition: all 0.15s ease;
}

#player-input:focus {
  border-color: var(--chalk);
  box-shadow: 0 0 0 1px var(--chalk);
}

#player-input::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
  opacity: 0.7;
}

#submit-btn {
  background: var(--chalk);
  color: var(--field-dark);
  border: none;
  border-radius: 4px;
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

/* Diagonal stripe on button */
#submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  right: -5px;
  width: 20px;
  height: 100%;
  background: rgba(0, 0, 0, 0.06); /* stripe accent */
  transform: skewX(-12deg);
}

#submit-btn:disabled {
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-muted);
  cursor: not-allowed;
}

#submit-btn:disabled::before {
  display: none;
}

#submit-btn:not(:disabled):hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--overlay);
}

/* === Autocomplete === */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(22, 58, 24, 0.97);
  border: 2px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  z-index: 100;
  display: none;
  box-shadow: 0 8px 24px var(--overlay-heavy);
}

.autocomplete-list.open {
  display: block;
}

.autocomplete-list li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 500;
  transition: background 0.1s ease;
}

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

.autocomplete-list li + li {
  border-top: 1px solid var(--chalk-subtle);
}

/* === Results Grid === */
.results-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.grid-header {
  display: grid;
  grid-template-columns: 1.6fr repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 6px;
  padding: 6px 8px;
  background: rgba(15, 40, 18, 0.9);
  border-radius: 4px;
  border-left: 3px solid var(--chalk);
  position: relative;
  z-index: 2;
}

.header-cell {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: #fff;
  text-align: center;
  letter-spacing: 2px;
  padding: 4px 2px;
}

.guess-row {
  display: grid;
  grid-template-columns: 1.6fr repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 5px;
}

.guess-cell {
  border-radius: 3px;
  padding: 6px 3px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  opacity: 0;
  transform: rotateX(90deg);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  word-break: break-word;
  line-height: 1.2;
}

.guess-cell.player-name {
  font-size: 0.95rem;
  background: var(--overlay-input);
  color: #fff;
  border: 1px solid var(--chalk-border-light);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.guess-cell.revealed {
  opacity: 1;
  transform: rotateX(0deg);
}

/* CORRECT — chalk white, like a yard line painted on the field */
.guess-cell.correct {
  background: var(--correct);
  color: #0a1f0c;
  font-weight: 700;
}

/* CLOSE — football leather */
.guess-cell.close {
  background: var(--leather-bg);
  color: #fff;
  border: 1px solid var(--leather-border);
}

/* MISS — blends into the turf */
.guess-cell.miss {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--chalk-hover);
  color: var(--text-secondary);
}

.guess-cell .arrow {
  font-size: 0.85rem;
  margin-left: 2px;
  opacity: 0.8;
}

/* === Guesses Remaining === */
.guesses-remaining {
  text-align: center;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-top: 16px;
  letter-spacing: 4px;
}

/* === Modals === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-heavy);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--field-dark);
  border: 2px solid var(--chalk-border-light);
  border-radius: 6px;
  padding: 28px;
  max-width: 440px;
  width: 100%;
  position: relative;
  box-shadow: 0 20px 60px var(--overlay-heavy);
  max-height: 80vh;
  overflow-y: auto;
}

/* Top accent bar on modal — like a broadcast lower third */
.modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--chalk) 0%, var(--leather-light) 50%, var(--chalk) 100%);
  border-radius: 6px 6px 0 0;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: 14px;
  letter-spacing: 4px;
}

.modal p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
}

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

/* === Close Details List === */
.close-details {
  list-style: none;
  margin: 8px 0 12px;
  padding: 0;
}

.close-details li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  padding-left: 12px;
  position: relative;
}

.close-details li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* === Legend === */
.legend {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-swatch.correct { background: var(--correct); }
.legend-swatch.close { background: var(--leather-bg); border: 1px solid var(--leather-border); }
.legend-swatch.miss { background: var(--overlay-light); border: 1px solid var(--chalk-subtle); }

/* === Game Over Modal === */
.gameover-modal h2 {
  font-size: 2.2rem;
}

.gameover-modal .result-message {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.gameover-modal .answer-reveal {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--chalk);
  margin-bottom: 20px;
  letter-spacing: 3px;
}

.gameover-modal .share-block {
  background: var(--overlay);
  border: 1px solid var(--chalk-hover);
  border-radius: 4px;
  padding: 14px;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 14px;
  white-space: pre;
  color: var(--text-secondary);
  display: inline-block;
  text-align: left;
}

.gameover-modal .share-block-wrapper {
  text-align: center;
  margin-bottom: 14px;
}

.share-btn {
  background: var(--chalk);
  color: var(--field-dark);
  border: none;
  border-radius: 4px;
  padding: 12px 24px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 3px;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.share-btn + .share-btn {
  margin-top: 10px;
}

.share-btn::before {
  content: '';
  position: absolute;
  top: 0;
  right: -5px;
  width: 24px;
  height: 100%;
  background: rgba(0, 0, 0, 0.06); /* stripe accent */
  transform: skewX(-12deg);
}

.share-btn:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--overlay);
}

.share-btn.copied {
  background: var(--leather-light);
  color: #fff;
}

/* === Stats Modal === */
.stats-modal h2 {
  font-size: 2.2rem;
}

.stats-modal .result-message {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* === Responsive === */
@media (max-width: 500px) {
  .logo {
    font-size: 2.4rem;
    letter-spacing: 6px;
  }

  .logo-football {
    width: 28px;
    height: 17px;
  }


  .yard-markers {
    display: none;
  }

  .grid-header, .guess-row {
    grid-template-columns: 1.4fr repeat(7, 1fr);
    gap: 3px;
  }

  .guess-cell {
    padding: 5px 2px;
    font-size: 0.9rem;
    min-height: 40px;
  }

  .header-cell {
    font-size: 0.95rem;
  }

  .modal {
    padding: 22px;
  }

  #submit-btn {
    padding: 10px 14px;
    font-size: 1.1rem;
  }
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--chalk-border-light);
  border-radius: 3px;
}

/* === Animations === */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.4s ease;
}

.error-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--field-dark);
  color: var(--text-primary);
  border: 2px solid var(--border);
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.error-toast.visible {
  opacity: 1;
}

/* === Roster Modal === */
.roster-modal {
  max-width: 500px;
  max-height: 85vh;
}

.roster-content {
  overflow-y: auto;
  max-height: calc(85vh - 100px);
}

.roster-conference-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 4px;
  color: var(--chalk);
  padding: 8px 0 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 10px;
}

.roster-conference-name + .roster-conference-name,
.roster-division + .roster-conference-name {
  margin-top: 20px;
}

.roster-division {
  margin-bottom: 14px;
}

.roster-division-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: var(--text-secondary);
  padding: 2px 0;
  margin-bottom: 6px;
}

.roster-team {
  margin-bottom: 10px;
  padding-left: 10px;
}

.roster-team-name {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--chalk);
  margin-bottom: 2px;
}

.roster-players {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.roster-player {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* === Loading Indicator === */
.loading-indicator {
  text-align: center;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 4px;
  padding: 40px 0;
  opacity: 0.7;
}

/* === Hidden === */
.hidden {
  display: none !important;
}
