
/* ─── Setup Screen ───────────────────────────────────────── */

#setupScreen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 560px;
  gap: 1rem;
}

#setupScreen.visible { display: flex; }

#setupScreen h2 {
  font-family: 'Salsa', cursive;
  color: saddlebrown;
  font-size: 2rem;
}

#setupScreen p {
  font-size: 1.25rem;
  color: #555;
  line-height: 1.5;
}

#setupScreen .code-block {
  background: #f8f4ec;
  border: 2px solid burlywood;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  color: #333;
  text-align: left;
  width: 100%;
  white-space: pre;
  overflow-x: auto;
}

#setupScreen .note { font-size: 1rem; color: #888; font-style: italic; }

/* ─── Game Area ──────────────────────────────────────────── */

#gameArea {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 1rem;
}

#gameArea.visible { display: flex; }

#instruction {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  color: black;
  margin: 0.8rem 0 0;
  text-align: center;
  padding: 0 1rem;
}

#instruction strong { color: saddlebrown; }

/* ─── Chain ──────────────────────────────────────────────── */

#chainContainer {
  width: min(420px, 97vw);
  padding: 0.75rem 0.5rem;
  margin: 0.5rem 0;
  display: flex;
  justify-content: center;
}

#chain {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0.25rem;
  width: 100%;
}

/* 3-column grid: [spacer] [cards] [logos]
   The spacer col mirrors the logo col width so cards stay centered. */
.chain-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 260px) 36px;
  column-gap: 8px;
  row-gap: 0.5rem;
  width: min(360px, 95vw);
}

/* Separator between the two chain halves */
.chain-gap-row {
  font-size: 1.4rem;
  color: #aaa;
  letter-spacing: 3px;
  text-align: center;
  padding: 0.3rem 0;
}

/* ─── Player Cards ───────────────────────────────────────── */

.player-card {
  background: white;
  border: 2px solid saddlebrown;
  border-radius: 10px;
  padding: 0.4rem 0.65rem;
  text-align: center;
  width: 100%;
  line-height: 1.25;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.player-card:hover  { box-shadow: 0 2px 10px rgba(0,0,0,0.15); }
.player-card:active { transform: scale(0.97); }

.player-card.active-inner {
  border-color: indianred !important;
  box-shadow: 0 0 10px rgba(70, 26, 0, 0.7);
}

.player-card.input-slot {
  cursor: default;
  border: 2px dashed peru;
  background: #fdf6e3;
}

.player-card.input-slot:hover  { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.player-card.input-slot:active { transform: none; }

.player-card.card-new {
  animation: cardIn 0.25s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.player-card .card-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: #222;
  word-break: break-word;
}

.player-card.start  { border-color: saddlebrown; background: wheat; }
.player-card.end    { border-color: saddlebrown; background: wheat; }
.player-card.middle { border-color: saddlebrown; background: wheat; }

.player-card.input-slot .card-name { color: #5f5f5f; }

/* ─── Card Delete Button ─────────────────────────────────── */

.card-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  justify-self: center;
  width: 24px;
  height: 24px;
  background: none;
  border: 2px solid saddlebrown;
  border-radius: 50%;
  color: saddlebrown;
  font-size: 1.1rem;
  line-height: 0;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.card-delete-btn:hover  { border-color: indianred; color: indianred; background-color: rgb(255, 220, 199); }
.card-delete-btn:active { transform: scale(0.9); }

/* ─── Side Logo ──────────────────────────────────────────── */

.chain-side-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
}

.team-logo-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  display: block;
}

/* ─── Input Area ─────────────────────────────────────────── */

#inputArea {
  display: flex;
  align-items: center;
  width: min(400px, 92vw);
  margin: 1rem 0;
  gap: 0.5rem;
}

#inputWrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

#sportSelect {
  font-family: "Afacad Flux", sans-serif;
  font-size: 1.2rem;
  font-weight: 500;
  padding: 0.55rem 0.4rem;
  border: 2px solid saddlebrown;
  border-radius: 10px;
  background: white;
  color: saddlebrown;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}

#sportSelect:focus { border-color: peru; }

#playerInput {
  width: 100%;
  font-size: 1.2rem;
  padding: 0.55rem 2.5rem 0.55rem 1rem;
  border: 2px solid saddlebrown;
  border-radius: 10px;
  background: white;
  color: #222;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  font-family: "Afacad Flux", sans-serif;
  font-weight: 500;
}

#playerInput:focus {
  border-color: peru;
  background: #fffdf5;
  box-shadow: 0 0 6px 2px rgba(205,133,63,0.25);
}

#clearInput {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #6d6d6d;
  cursor: pointer;
  display: none;
}

#clearInput.visible { display: block; }

#autocomplete {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: white;
  border: 2px solid saddlebrown;
  border-radius: 0 0 10px 10px;
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#autocomplete.visible { display: block; }

.ac-item {
  padding: 0.5rem 1rem;
  font-size: 1.2rem;
  cursor: pointer;
  border-bottom: 1px solid #f0e8d8;
  color: #333;
  transition: background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.focused { background: burlywood; }

.ac-item-years {
  font-size: 0.85rem;
  color: #464646;
  white-space: nowrap;
  flex-shrink: 0;
}

.ac-item:hover .ac-item-years,
.ac-item.focused .ac-item-years { color: #7a4a1e; }

.ac-item.no-results { color: #999; cursor: default; font-style: italic; }
.ac-item.no-results:hover { background: transparent; }

/* ─── Feedback ───────────────────────────────────────────── */

#feedback {
  font-size: 1.2rem;
  text-align: center;
  padding: 0.2rem 1rem;
  max-width: 500px;
  display: none;
}

#feedback.fb-error,
#feedback.fb-warn,
#feedback.fb-info,
#feedback.fb-win {
  display: block;
}

.fb-error, .fb-warn { color: #c62828; }
.fb-win              { color: #00831c; }
.fb-info             { color: black; }

/* ─── Stats Bar ──────────────────────────────────────────── */

#statsBar {
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  color: black;
  margin: 0.2rem 0 0.1rem;
}

/* ─── Buttons ────────────────────────────────────────────── */

#buttons {
  display: flex;
  gap: 2rem;
  margin: 0 0;
  flex-wrap: wrap;
  justify-content: center;
}

.button {
  font-family: "Afacad Flux", sans-serif;
  font-weight: 500;
  font-size: 1.2rem;
  padding: 0.4em 1em;
  background-color: moccasin;
  border: 2px solid saddlebrown;
  color: saddlebrown;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border 0.2s ease;
  margin-top: 1rem;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover { background-color: peru; border-color: peru; color: wheat; }
}
.button:active   { transform: scale(0.95); }
.button:disabled { opacity: 0.65; cursor: not-allowed; pointer-events: none; }

/* ─── Loading Bar ────────────────────────────────────────── */

#loadingBar {
  display: none;
  font-size: 1.2rem;
  color: sienna;
  margin-bottom: 3rem;
  align-items: center;
  gap: 0.5rem;
}

#loadingBar.visible { display: flex; }

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid burlywood;
  border-top-color: saddlebrown;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 600px) {
  #feedback { font-size: 1rem; }
  .player-card .card-name { font-size: 0.9rem; }
  .team-logo-img { width: 30px; height: 30px; }
  #buttons { gap: 0.8rem; }
  .button  { font-size: 1.1rem; padding: 0.4em 0.7em; }
}
