/* ============================================================
   GCCDLE — game.css
   Board, search input, dropdown, end banner, legend,
   stats modal body. Relies on tokens from styles.css.
   ============================================================ */

/* ── Game header ──────────────────────────────────────────── */
.game-header {
  padding: clamp(1.75rem, 5vw, 2.75rem) 0 0.75rem;
  border-bottom: 1px solid var(--c-border);
}

.game-header__inner {
  text-align: center;
}

.game-header__eyebrow {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
  margin-bottom: 0.45rem;
}

.game-header__title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: clamp(1.6rem, 5.5vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--c-gold-mid);
  margin-bottom: 0.35rem;
}

.game-header__sub {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  color: var(--c-text-muted);
  min-height: 1.2em;
}

/* ── Main game area ───────────────────────────────────────── */
.game-main {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

/* ── Error state ──────────────────────────────────────────── */
.game-error {
  background: var(--c-fc-wrong-bg);
  border: 1px solid var(--c-fc-wrong-border);
  border-radius: var(--r-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.game-error__msg {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  color: var(--c-fc-wrong-text);
}

/* ── Search area ──────────────────────────────────────────── */
.search-area {
  max-width: 520px;
  margin: 0 auto 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
}

.search-wrap {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 3rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border-hi);
  border-radius: var(--r-lg);
  padding: 0 1rem 0 2.8rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.93rem;
  color: var(--c-text-primary);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.search-input::placeholder {
  color: var(--c-text-muted);
}

.search-input:focus {
  border-color: var(--c-gold-deep);
  box-shadow: 0 0 0 3px rgba(200, 150, 46, 0.15);
}

.search-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  line-height: 1;
}

/* ── Dropdown ─────────────────────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(3rem + 6px);
  left: 0;
  right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border-hi);
  border-radius: var(--r-lg);
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
}

.search-dropdown[hidden] { display: none; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--c-border);
  transition: background var(--dur-fast);
  outline: none;
}

.dropdown-item:last-child { border-bottom: none; }

.dropdown-item:hover,
.dropdown-item[aria-selected="true"] {
  background: rgba(232, 184, 75, 0.07);
}

.dropdown-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--c-border);
  background: var(--c-raised);
}

.dropdown-monogram {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-raised);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 0.65rem;
  color: var(--c-gold-deep);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.dropdown-info {
  flex: 1;
  min-width: 0;
}

.dropdown-ign {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--c-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-team {
  font-family: 'Inter', sans-serif;
  font-size: 0.73rem;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.dropdown-inactive {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  background: var(--c-raised);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: 0.1rem 0.32rem;
  flex-shrink: 0;
}

/* ── Give up button ───────────────────────────────────────── */
.give-up-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  padding: 0.42rem 1.1rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}

.give-up-btn:hover {
  color: var(--c-fc-wrong-text);
  border-color: var(--c-fc-wrong-border);
  background: rgba(42, 14, 14, 0.4);
}

.give-up-btn:focus-visible {
  outline: 2px solid var(--c-gold-mid);
  outline-offset: 2px;
}

/* ── Board ────────────────────────────────────────────────── */
.board-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.25rem;
}

.board-inner {
  width: fit-content;
  margin: 0 auto;
}

.board-header,
.board-row {
  display: grid;
  /* Player · Agent · Region · Nationality · Team · Debut */
  grid-template-columns: 155px 105px 105px 140px 155px 90px;
  gap: 5px;
  min-width: 775px;
  margin-bottom: 5px;
}

.board-header {
  margin-bottom: 8px;
}

.board-row {
  perspective: 900px;
}

.board-col {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  text-align: center;
  padding: 0.25rem 0;
}

/* ── Board cells ──────────────────────────────────────────── */
.board-cell {
  border-radius: var(--r-md);
  padding: 0.55rem 0.45rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  text-align: center;
  border: 1px solid transparent;
}

/* Flip-in animation — sequential per-cell, 0.5s each, 0.28s stagger */
@keyframes cell-flip {
  0%   { transform: rotateX(-90deg); opacity: 0; }
  100% { transform: rotateX(0deg);   opacity: 1; }
}

.board-cell.is-flipped {
  animation: cell-flip 0.5s var(--ease) both;
  transform-origin: top center;
}

/* The category-by-category unfold is a signature part of the game, so it plays
   even when the OS "reduce motion" setting is on — just slightly quicker there. */
@media (prefers-reduced-motion: reduce) {
  .board-cell.is-flipped {
    animation-duration: 0.32s;
  }
}

/* Feedback color states */
.board-cell--green {
  background: var(--c-fc-correct-bg);
  border-color: var(--c-fc-correct-border);
  color: var(--c-fc-correct-text);
}

.board-cell--yellow {
  background: var(--c-fc-partial-bg);
  border-color: var(--c-fc-partial-border);
  color: var(--c-fc-partial-text);
}

.board-cell--red {
  background: var(--c-fc-wrong-bg);
  border-color: var(--c-fc-wrong-border);
  color: var(--c-fc-wrong-text);
}

.board-cell--gray {
  background: var(--c-fc-unknown-bg);
  border-color: var(--c-fc-unknown-border);
  color: var(--c-fc-unknown-text);
}

/* Player cell overrides */
.board-cell--player {
  background: var(--c-surface);
  border-color: var(--c-border);
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  text-align: left;
}

.board-cell--player.is-winner {
  background: var(--c-fc-correct-bg);
  border-color: var(--c-fc-correct-border);
}

/* Avatar / monogram inside board */
.cell-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--c-border);
  background: var(--c-raised);
}

.cell-monogram {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-raised);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 0.65rem;
  color: var(--c-gold-deep);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.cell-player-info {
  flex: 1;
  min-width: 0;
}

.cell-ign {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.83rem;
  color: var(--c-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-inactive {
  display: inline-block;
  font-size: 0.56rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  background: var(--c-raised);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: 0.07rem 0.28rem;
  margin-top: 0.2rem;
}

/* Value / label inside scored cells */
.cell-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  line-height: 1.25;
  word-break: break-word;
}

.cell-arrow {
  font-size: 0.72rem;
  margin-top: 0.18rem;
  line-height: 1;
}

/* ── End banner ───────────────────────────────────────────── */
.end-banner {
  max-width: 520px;
  margin: 0 auto 1.5rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border-hi);
  border-radius: var(--r-xl);
  overflow: hidden;
  position: relative;
}

.end-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--c-gold-mid), transparent);
  opacity: 0.45;
  pointer-events: none;
}

.end-banner__inner {
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.end-banner__outcome {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  color: var(--c-gold-mid);
}

.end-banner__outcome--lose {
  color: var(--c-text-secondary);
}

.end-banner__player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.end-banner__player-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-text-primary);
}

.end-banner__player-sub {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

.end-banner__guesses {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  color: var(--c-text-secondary);
}

.end-banner__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-share {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--c-gold-mid);
  color: var(--c-void);
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast);
}

.btn-share:hover {
  background: var(--c-gold-bright);
  transform: translateY(-1px);
}

.btn-share:focus-visible {
  outline: 2px solid var(--c-gold-mid);
  outline-offset: 2px;
}

.btn-home {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--c-border-hi);
  color: var(--c-text-secondary);
  padding: 0.6rem 1.4rem;
  border-radius: var(--r-md);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}

.btn-home:hover {
  color: var(--c-text-primary);
  border-color: var(--c-text-muted);
}

.btn-home:focus-visible {
  outline: 2px solid var(--c-gold-mid);
  outline-offset: 2px;
}

.end-banner__next {
  font-family: 'Inter', sans-serif;
  font-size: 0.71rem;
  color: var(--c-text-muted);
}

/* ── Share toast ──────────────────────────────────────────── */
.share-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-raised);
  border: 1px solid var(--c-border-hi);
  border-radius: var(--r-md);
  padding: 0.55rem 1.2rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  color: var(--c-text-primary);
  z-index: 9999;
  white-space: nowrap;
  animation: toast-in 0.22s var(--ease) both;
  pointer-events: none;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .share-toast { animation: none; }
}

/* ── Legend ───────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.2rem;
  justify-content: center;
  margin-top: 1rem;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.38rem;
}

.legend__swatch {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.legend__swatch--green  { background: var(--c-fc-correct-bg);  border-color: var(--c-fc-correct-border); }
.legend__swatch--yellow { background: var(--c-fc-partial-bg);  border-color: var(--c-fc-partial-border); }
.legend__swatch--red    { background: var(--c-fc-wrong-bg);    border-color: var(--c-fc-wrong-border); }
.legend__swatch--gray   { background: var(--c-fc-unknown-bg);  border-color: var(--c-fc-unknown-border); }

.legend__label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  color: var(--c-text-muted);
}

/* ── Stats modal body ─────────────────────────────────────── */
.stats-modal-body {
  padding: 1.4rem 1.75rem 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}

@media (max-width: 440px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stats-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  background: var(--c-raised);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 0.85rem 0.5rem;
  text-align: center;
}

.stats-cell__num {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 1.45rem;
  color: var(--c-gold-mid);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stats-cell__label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  line-height: 1.35;
}

.dist-section { margin-top: 0; }

.dist-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 0.7rem;
}

.dist-bars {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.dist-bar-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.dist-bar-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-text-muted);
  width: 1.6rem;
  text-align: right;
  flex-shrink: 0;
}

.dist-bar-track {
  flex: 1;
  height: 22px;
  background: var(--c-raised);
  border-radius: 3px;
  overflow: hidden;
}

.dist-bar-fill {
  height: 100%;
  background: var(--c-gold-deep);
  border-radius: 3px;
  min-width: 28px;
  display: flex;
  align-items: center;
  padding-left: 0.45rem;
  transition: width 0.42s var(--ease);
}

.dist-bar-fill--highlight {
  background: var(--c-gold-mid);
}

.dist-bar-count {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--c-void);
}

/* ── Nationality cell — flag + name ──────────────────────── */
.cell-nat-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  flex-wrap: wrap;
  text-align: center;
}

.nat-flag {
  width: 18px;
  height: 13px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

/* ── End-banner avatar ───────────────────────────────────── */
.end-banner__avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--c-gold-deep);
  background: var(--c-raised);
  flex-shrink: 0;
}

.end-banner__monogram {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--c-raised);
  border: 2px solid var(--c-gold-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--c-gold-deep);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

/* ── Give-up confirm dialog ──────────────────────────────── */
.modal__body {
  padding: 1.5rem 1.75rem;
}

.modal__message {
  font-family: 'Inter', sans-serif;
  font-size: 0.93rem;
  color: var(--c-text-secondary);
  line-height: 1.7;
}

.modal__footer--actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-modal-cancel {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--c-border-hi);
  color: var(--c-text-secondary);
  padding: 0.6rem 1.2rem;
  border-radius: var(--r-md);
  cursor: pointer;
  min-height: 44px;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}

.btn-modal-cancel:hover {
  color: var(--c-text-primary);
  border-color: var(--c-text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.btn-modal-cancel:focus-visible {
  outline: 2px solid var(--c-gold-mid);
  outline-offset: 2px;
}

.btn-modal-confirm {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--c-fc-wrong-bg);
  border: 1px solid var(--c-fc-wrong-border);
  color: var(--c-fc-wrong-text);
  padding: 0.6rem 1.2rem;
  border-radius: var(--r-md);
  cursor: pointer;
  min-height: 44px;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.btn-modal-confirm:hover {
  background: rgba(42, 14, 14, 0.75);
  border-color: #a03535;
}

.btn-modal-confirm:focus-visible {
  outline: 2px solid var(--c-fc-wrong-border);
  outline-offset: 2px;
}

/* ── Footer credit ───────────────────────────────────────── */
.footer__credit {
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  color: var(--c-text-muted);
  line-height: 1.6;
}

.footer__credit a {
  color: var(--c-gold-deep);
  text-decoration: none;
}

.footer__credit a:hover {
  color: var(--c-gold-mid);
}

/* ── Mobile improvements ─────────────────────────────────── */
@media (max-width: 600px) {
  .give-up-btn {
    min-height: 44px;
    padding: 0.55rem 1.4rem;
  }

  .search-input {
    height: 3.25rem;
    font-size: 1rem; /* prevent iOS zoom-on-focus */
  }

  .modal__footer--actions {
    justify-content: stretch;
  }

  .modal__footer--actions .btn-modal-cancel,
  .modal__footer--actions .btn-modal-confirm {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .end-banner__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-share,
  .btn-home {
    text-align: center;
    justify-content: center;
  }

  .nat-flag {
    width: 16px;
    height: 12px;
  }
}
