/* /game/css/setup.css */

/* -------------------------------------------------------
   Hidden Cask — Setup screen styles
   Player setup, status pills, returning players,
   saved-for-later screen, bottle selector
------------------------------------------------------- */

/* -------------------------------------------------------
   Player row layout + mini status pills
------------------------------------------------------- */

.player-row {
  align-items: center;
}

.player-main {
  display: grid;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

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

.player-visible-input,
.name-input.player-visible-input {
  width: 100%;
  box-sizing: border-box;
}

/* Compact player status pills */
.player-status-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-left: 2px;
}

.player-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: auto !important;
  min-width: 0 !important;
  max-width: 150px;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;

  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: none !important;
}

/* Name + email pills are action buttons */
.player-name-pill,
.player-email-pill {
  appearance: none;
  -webkit-appearance: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: auto !important;
  min-width: 0 !important;
  max-width: 150px;

  min-height: 20px;
  padding: 2px 8px;

  border-radius: 999px;
  border: 1px solid rgba(139, 69, 19, 0.18);

  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;

  cursor: pointer;
  box-shadow: none !important;
  text-align: center;
}

/* Completed state */
.player-status-pill.is-good,
.player-name-pill.is-good,
.player-email-pill.is-good {
  background: #eef8ee;
  color: #2e7d32;
  border: 1px solid rgba(46, 125, 50, 0.22);
}

/* Missing/soft states kept for compatibility */
.player-status-pill.is-missing {
  background: #fff4f0;
  color: #9a3d1f;
  border: 1px solid rgba(154, 61, 31, 0.18);
}

.player-status-pill.is-soft {
  background: #fff8ec;
  color: #7a5a35;
  border: 1px solid rgba(139, 69, 19, 0.16);
}

/* Action state */
.player-name-pill.is-action,
.player-email-pill.is-action {
  background: #fff8ec;
  color: #7a5a35;
  border: 1px solid rgba(139, 69, 19, 0.18);
}

.player-name-pill.is-action:hover,
.player-name-pill.is-action:focus,
.player-email-pill.is-action:hover,
.player-email-pill.is-action:focus {
  background: #f3e1c3;
  color: #6f3510;
  border-color: rgba(139, 69, 19, 0.32);
  outline: none;
}

/*
  The old right-side email toggle/icon has been retired.
  Keep this here so cached/older markup cannot show the bulky box.
*/
.email-toggle,
.email-status-icon,
.player-email-btn,
.email-icon,
[data-email-toggle] {
  display: none !important;
}

/* Hide any old tooltip pseudo-elements from retired email controls */
.email-toggle::before,
.email-toggle::after,
.email-status-icon::before,
.email-status-icon::after,
.player-email-btn::before,
.player-email-btn::after,
.email-icon::before,
.email-icon::after,
[data-email-toggle]::before,
[data-email-toggle]::after {
  display: none !important;
  content: none !important;
}

/* Known player / saved email state */
.player-row.has-email .player-visible-input {
  border-color: rgba(46, 125, 50, 0.36) !important;
}

.player-row.has-name .player-visible-input {
  border-color: rgba(80, 55, 30, 0.22);
}

/* When typing email, visually hint that the active input is email mode */
.player-row.mode-email .player-visible-input {
  border-color: rgba(139, 69, 19, 0.42) !important;
  background: #fffaf3;
}

/* Player ready display state */
.player-visible-input.is-player-ready {
  background: #f4fbf3 !important;
  border-color: rgba(46, 125, 50, 0.36) !important;
  color: #2f5f31 !important;
  font-weight: 800;
  cursor: pointer;
}

.player-visible-input.is-player-ready:focus {
  background: #fff !important;
  color: #2d2118 !important;
}

.player-row.is-ready .player-visible-input.is-player-ready,
.player-row.has-name.has-email .player-visible-input.is-player-ready {
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.08);
}

@media (max-width: 700px) {
  .player-status-pills {
    margin-top: 2px;
  }

  .player-status-pill,
  .player-name-pill,
  .player-email-pill {
    max-width: 100%;
    font-size: 0.68rem;
  }
}

/* -------------------------------------------------------
   Returning player panel
------------------------------------------------------- */

.hc-returning-host-panel {
  margin: 14px 0 4px;
  padding: 0;
}

.hc-returning-host-panel[hidden] {
  display: none !important;
}

.hc-returning-host-inner {
  border: 1px solid rgba(120, 80, 35, 0.22);
  background: #fffaf1;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(57, 38, 20, 0.07);
}

.hc-returning-host-copy {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  color: #3f2a18;
}

.hc-returning-host-copy strong {
  font-size: 1.02rem;
}

.hc-returning-host-copy span {
  font-size: 0.92rem;
  opacity: 0.82;
  line-height: 1.35;
}

.hc-returning-host-actions,
.hc-picker-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.hc-returning-btn {
  border: 1px solid rgba(120, 80, 35, 0.22);
  background: #fff;
  color: #4a2b15;
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(70, 43, 20, 0.08);
}

.hc-returning-btn:hover,
.hc-returning-btn:focus,
.hc-returning-btn:active {
  background: #8b4a1f;
  color: #fff;
  border-color: #8b4a1f;
  filter: none;
  transform: translateY(-1px);
  outline: none;
}

.hc-returning-btn:hover *,
.hc-returning-btn:focus *,
.hc-returning-btn:active * {
  color: #fff;
}

.hc-returning-primary {
  background: #8b4a1f;
  color: #fff;
  border-color: #8b4a1f;
}

.hc-returning-light {
  background: #fff;
  color: #4a2b15;
  border-color: rgba(120, 80, 35, 0.28);
}

/* Previous player picker */
.hc-previous-player-picker {
  margin-top: 12px;
  border-top: 1px solid rgba(120, 80, 35, 0.14);
  padding-top: 12px;
}

.hc-previous-player-picker[hidden] {
  display: none !important;
}

.hc-picker-title {
  font-weight: 900;
  color: #3f2a18;
  margin-bottom: 8px;
}

.hc-picker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.hc-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(120, 80, 35, 0.16);
  background: #fff;
  border-radius: 12px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 500;
  color: #3f2a18;
}

.hc-picker-item input {
  width: 16px;
  height: 16px;
}

/* -------------------------------------------------------
   Saved-for-later setup screen
------------------------------------------------------- */

.hc-saved-later-card {
  margin: 0 auto 24px;
  padding: 26px;
  max-width: 860px;
  border-radius: 20px;
  background: #fff8ec;
  border: 1px solid rgba(139, 69, 19, 0.24);
  box-shadow: 0 14px 34px rgba(42, 27, 12, 0.12);
  color: #3f2a18;
  text-align: center;
}

.hc-saved-later-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #efe2cc;
  color: #7a431d;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hc-saved-later-card h2 {
  margin: 0 0 10px;
  color: #3f2a18;
}

.hc-saved-later-card p {
  margin: 0 auto 16px;
  max-width: 660px;
  line-height: 1.5;
}

.hc-saved-later-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 14px 0 18px;
}

.hc-saved-later-meta span {
  background: #fff;
  border: 1px solid rgba(139, 69, 19, 0.18);
  border-radius: 999px;
  padding: 8px 12px;
}

.hc-saved-later-link {
  margin: 16px auto 20px;
  max-width: 720px;
  text-align: left;
}

.hc-saved-later-link label {
  display: block;
  margin-bottom: 6px;
  font-weight: 900;
  color: #3f2a18;
}

.hc-saved-later-link > div {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 14px;
  padding: 10px;
}

.hc-saved-later-link code {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #4a2b15;
  font-size: 0.86rem;
}

.hc-saved-later-actions,
.hc-spread-word-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.hc-saved-later-actions {
  margin: 18px 0 22px;
}

.hc-saved-later-card button,
.hc-spread-word-actions a {
  border: 1px solid rgba(120, 80, 35, 0.24);
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(70, 43, 20, 0.09);
}

.hc-saved-later-primary,
#hc-copy-host-link,
#hc-copy-game-link {
  background: #8b4513;
  color: #fff;
  border-color: #8b4513;
}

.hc-saved-later-light,
.hc-spread-word-actions a {
  background: #fff;
  color: #4a2b15;
}

.hc-spread-word-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(139, 69, 19, 0.14);
}

.hc-spread-word-box h3 {
  margin: 0 0 8px;
  color: #3f2a18;
}

/* -------------------------------------------------------
   Bottle selector / catalogue autocomplete
------------------------------------------------------- */

/* Allow bottle dropdowns to escape card/grid boundaries */
.hc-step-card,
.hc-bottle-grid,
.bottle-autocomplete {
  overflow: visible;
}

.bottle-autocomplete {
  position: relative;
}

.bottle-autocomplete .selected-pill .pill-text {
  font-size: 0.95rem;
  font-weight: 500;
}

.bottle-autocomplete .selected-pill .hc-tick {
  color: #1a7f37;
  font-weight: 700;
  margin-left: 2px;
}

.bottle-autocomplete .clear {
  display: none;
}

.bottle-autocomplete.slot-selected .clear {
  display: inline-flex;
}

/* Keep the active bottle selector above neighbouring mobile fields */
.bottle-autocomplete.is-open {
  z-index: 10000;
}

.bottle-autocomplete.is-open .autocomplete-list {
  z-index: 10001;
}

/* Desktop/tablet dropdown opens above the field */
.bottle-autocomplete .autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  top: auto;
  z-index: 9999;

  background: #fff;
  border: 1px solid rgba(120, 76, 35, 0.22);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
  overflow: hidden;

  touch-action: manipulation;
}

.bottle-autocomplete .autocomplete-list .ac-results {
  max-height: min(320px, 48vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff !important;
}

/* Individual bottle rows */
.bottle-autocomplete .autocomplete-list .ac-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;

  padding: 9px 16px !important;
  line-height: 1.28;
  cursor: pointer;

  background: #fff !important;
  color: #191919;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.bottle-autocomplete .autocomplete-list .ac-item:hover,
.bottle-autocomplete .autocomplete-list .ac-item.is-active {
  background: #f5eadb !important;
  color: #5b2d0c !important;
}

.bottle-autocomplete .autocomplete-list .ac-item span span {
  color: #747474;
  font-weight: 400;
}

.bottle-autocomplete .autocomplete-list .ac-item.is-duplicate {
  background: #fff7ed !important;
}

.bottle-autocomplete .autocomplete-list .ac-item.is-duplicate:hover {
  background: #f5eadb !important;
}

.bottle-autocomplete .autocomplete-list .empty {
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #6b6258;
  background: #fff;
}

/* Sticky custom-bottle footer */
.bottle-autocomplete .ac-sticky-footer,
.bottle-autocomplete .hc-custom-bottle-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;

  padding: 10px 14px;
  background: #fbf6ee !important;
  border-top: 1px solid rgba(139, 69, 19, 0.18);
  box-shadow: 0 -6px 14px rgba(255, 255, 255, 0.92);
  cursor: default !important;
}

.bottle-autocomplete .ac-add-missing {
  width: 100%;
  padding: 10px 12px;

  border: 1px dashed rgba(139, 69, 19, 0.45);
  border-radius: 10px;
  background: #fffaf3;
  color: #6b3a12;

  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  box-shadow: none;
}

.bottle-autocomplete .ac-add-missing:hover {
  background: #fff2dc;
  border-color: rgba(139, 69, 19, 0.75);
  color: #4d2409;
}

/* Custom bottle selected state */
.bottle-autocomplete .hc-custom-badge {
  display: inline-flex;
  align-items: center;

  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;

  background: #fff3cd;
  color: #7a4a00;
  border: 1px solid rgba(122, 74, 0, 0.18);

  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: middle;
  white-space: nowrap;
}

.bottle-autocomplete.slot-custom .selected-pill {
  border-color: rgba(122, 74, 0, 0.28);
  background: #fffaf0;
}

/* Missing/custom bottle SweetAlert modal */
.hc-missing-bottle-modal {
  text-align: left;
  color: #2d2118;
}

.hc-missing-bottle-modal .hc-missing-intro {
  margin: 0 0 14px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #5f5348;
  text-align: left;
}

.hc-missing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  align-items: start;
}

.hc-missing-grid label {
  display: block;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  color: #5b4634;
}

.hc-missing-grid label span {
  display: block;
  margin: 0 0 4px;
}

.hc-missing-grid .hc-wide {
  grid-column: 1 / -1;
}

.hc-missing-grid .swal2-input,
.hc-missing-grid .swal2-select,
.hc-missing-grid .swal2-textarea {
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  font-size: 0.95rem;
}

.hc-missing-grid .swal2-input,
.hc-missing-grid .swal2-select {
  height: 42px;
  min-height: 42px;
}

.hc-missing-grid .swal2-textarea {
  min-height: 96px;
}

.hc-more-fields {
  margin-top: 4px;
  padding: 10px;

  border: 1px solid rgba(139, 69, 19, 0.18);
  border-radius: 12px;
  background: #fffaf0;
}

.hc-more-fields summary {
  margin-bottom: 8px;
  cursor: pointer;
  font-weight: 900;
  color: #6b3a12;
}

.hc-more-fields:not([open]) summary {
  margin-bottom: 0;
}

.hc-inner-grid {
  margin-top: 10px;
}

.hc-missing-note {
  margin: 12px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #7a6b5d;
}

/* -------------------------------------------------------
   Mobile setup refinements
------------------------------------------------------- */

@media (max-width: 700px) {
  .hc-missing-grid,
  .hc-picker-list {
    grid-template-columns: 1fr;
  }

  .hc-returning-btn {
    width: 100%;
  }

  .player-status-pill,
  .player-name-pill,
  .player-email-pill {
    max-width: 100%;
    font-size: 0.68rem;
  }

  /* Mobile dropdown opens below the field for reliable touch selection */
  .bottle-autocomplete .autocomplete-list {
    top: calc(100% + 6px);
    bottom: auto;
    z-index: 10001;
  }

  .bottle-autocomplete .autocomplete-list .ac-results {
    max-height: min(260px, 38vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bottle-autocomplete .autocomplete-list .ac-item,
  .bottle-autocomplete .ac-add-missing {
    min-height: 44px;
    touch-action: manipulation;
  }

  .hc-saved-later-card {
    padding: 20px;
  }

  .hc-saved-later-link > div,
  .hc-saved-later-actions,
  .hc-spread-word-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hc-saved-later-card button,
  .hc-spread-word-actions a {
    width: 100%;
    text-align: center;
  }
}

/* -------------------------------------------------------
   Player entry repair
   Current index.html uses separate name + email inputs.
   Older game.css forces .player-visible-input to display:block,
   which makes hidden inputs appear and overlap.
------------------------------------------------------- */

#playersGrid .player-input-wrap {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas: "field" !important;
  align-items: center !important;
  gap: 6px !important;
  width: 100% !important;
  min-width: 0 !important;
}

#playersGrid .player-visible-input,
#playersGrid .player-ready-display {
  grid-area: field !important;
}

/* Critical: respect hidden fields */
#playersGrid .player-visible-input[hidden],
#playersGrid .player-ready-display[hidden],
#playersGrid input[hidden] {
  display: none !important;
}

/* Current setup uses status pills, not the old email square button */
#playersGrid .email-toggle {
  display: none !important;
}

/* Keep the visible active field full width */
#playersGrid .player-visible-input:not([hidden]) {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Ready button replaces the field once both name and email are complete */
#playersGrid .player-ready-display {
  width: 100% !important;
  min-height: 42px !important;
  padding: 10px 13px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(46, 125, 50, 0.36) !important;
  background: #f4fbf3 !important;
  color: #2f5f31 !important;
  font-weight: 900 !important;
  text-align: left !important;
  cursor: pointer !important;
  box-shadow: none !important;
}

#playersGrid .player-ready-display:hover,
#playersGrid .player-ready-display:focus {
  background: #eef8ee !important;
  outline: none !important;
}