/* Last Man Standing – mobile-first */

/* OLD THEME (revert by restoring these values):
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
*/

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --radius: 12px;
  --tap: 44px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.screen.hidden {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* Login */
#screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#screen-dashboard,
#screen-admin {
  display: block;
}

.login-card {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.login-logo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 1rem;
}

.login-card .form {
  width: 100%;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.tagline {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form label.optional {
  margin-top: 0.75rem;
}

.form label .muted {
  font-weight: normal;
  color: var(--text-muted);
}

.form input {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
}

/* All dropdowns match admin Selections team dropdown */
.form select,
.select-input,
.admin-selection-team {
  width: 100%;
  min-height: 40px;
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
}

.admin-selection-team {
  min-width: 160px;
}

.admin-selection-value {
  font-weight: 500;
}

.knocked-out-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}

.round-winner-card {
  border-left: 4px solid var(--success);
}

.round-winner-label {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.round-winner-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--success);
}

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

.form button[type="submit"],
.btn-primary {
  width: 100%;
  min-height: var(--tap);
  margin-top: 1.25rem;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.form button[type="submit"]:active,
.btn-primary:active {
  opacity: 0.9;
}

.error {
  margin-top: 1rem;
  color: var(--danger);
  font-size: 0.9rem;
}

.error.hidden {
  display: none;
}

.login-admin-link {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.login-admin-link button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

.admin-login-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.admin-login-block.hidden {
  display: none;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--tap);
  font-size: clamp(0.7rem, 2.2vw, 1rem);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.header-logo {
  width: clamp(40px, 12vw, 64px);
  height: clamp(40px, 12vw, 64px);
  object-fit: contain;
}

.header-title {
  font-weight: 600;
  font-size: 1.1em;
}

.header-round-badges {
  display: flex;
  align-items: center;
  gap: 0.25em;
  flex-shrink: 1;
  min-width: 0;
}

.header-badge {
  display: inline-block;
  padding: 0.2em 0.4em;
  font-size: 0.85em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-radius: 6px;
  background: var(--primary);
  color: var(--bg);
  white-space: nowrap;
}

.header-badge-alt {
  background: var(--surface2);
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.35em;
  flex-wrap: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.header-sep {
  color: var(--text-muted);
  font-weight: 400;
  user-select: none;
  flex-shrink: 0;
}

.header-player-name {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}

.header .btn-icon {
  font-size: 1em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-icon {
  min-width: var(--tap);
  min-height: 36px;
  padding: 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}

/* Container */
.container {
  padding: 1rem;
  max-width: 640px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.card-centred,
.card.card-centred {
  text-align: center;
}
.card-centred h2,
.card.card-centred h3,
.card.card-centred p,
.card.card-centred .form {
  text-align: center;
}
.card.card-centred .form label {
  text-align: center;
}
.card.card-centred .form {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.card.card-centred .form select,
.card.card-centred .form button,
.card.card-centred .pick-locked-team,
.card.card-centred .pick-locked-label {
  text-align: center;
}

#round-info .round-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1;
  padding-top: 0.06em;
}

/* Reduce the gap at the top of the stats card */
#dashboard-round-stats.card {
  padding-top: 0.75rem;
}
#dashboard-round-stats h3 {
  margin-top: 0 !important;
}

/* Reduce the gap at the top of the deadline/countdown card */
#countdown-section.card {
  padding-top: 0.75rem;
}
#countdown-section h3 {
  margin-top: 0 !important;
}

.status-banner {
  padding: 0.5rem;
  margin-bottom: 1rem;
}
.status-banner-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
}
.status-banner-through {
  background: rgba(63, 185, 80, 0.2);
  color: var(--success);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
}
.status-banner-knocked {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
}

.not-paid-banner {
  font-weight: 700;
  color: var(--warning);
  text-align: center;
  margin: 0;
}

.card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.members-subsection {
  margin-top: 1.25rem;
}

.members-subsection:first-of-type {
  margin-top: 0;
}

.card p {
  margin: 0.5rem 0;
}

.prize-card .prize-amount {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.status-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.status-badge.in {
  background: rgba(63, 185, 80, 0.2);
  color: var(--success);
}

.status-badge.out {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}

.subround-status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 0.5rem;
}
.subround-status-open {
  background: rgba(245, 158, 11, 0.25);
  color: #b45309;
}
.subround-status-complete {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success, #16a34a);
}
.subround-status-locked {
  background: rgba(148, 163, 184, 0.25);
  color: #94a3b8;
}
.subround-status-bold {
  font-weight: bold;
}
.subround-line-title {
  display: inline-block;
  margin-right: 0.5rem;
}

.round-winner-card .lms-end-label {
  margin: 0;
  font-size: 1rem;
}
.round-winner-card .lms-winner-name {
  color: var(--success, #16a34a);
}

.stats-round-select-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.stats-round-select-row label {
  margin: 0;
}
.stats-round-details {
  margin-top: 0.5rem;
  padding: 0.5rem 0 0.75rem 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.75rem;
  text-align: center;
}
.stats-box:nth-child(1) { grid-column: 1 / span 4; }
.stats-box:nth-child(2) { grid-column: 5 / span 4; }
.stats-box:nth-child(3) { grid-column: 9 / span 4; }
.stats-box:nth-child(4) { grid-column: 1 / span 3; grid-row: 2; }
.stats-box:nth-child(5) { grid-column: 4 / span 3; grid-row: 2; }
.stats-box:nth-child(6) { grid-column: 7 / span 3; grid-row: 2; }
.stats-box:nth-child(7) { grid-column: 10 / span 3; grid-row: 2; }
.stats-box {
  padding: 0.75rem 0.65rem;
  min-width: 0;
  overflow: hidden;
  background: var(--surface2, rgba(255,255,255,0.05));
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  text-align: center;
}
.stats-box-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
}
.stats-box-value {
  font-weight: 600;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.stats-box-full {
  grid-column: 1 / -1;
}

.previous-round-winner {
  font-weight: bold;
  color: var(--success, #16a34a);
}

.warning {
  border-left: 4px solid var(--warning);
}

.warning-text {
  color: var(--warning);
  margin: 0;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Countdown to pick deadline */
.countdown-card {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
}

.countdown-label {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.countdown-time {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

/* Team pick buttons */
.pick-label {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.pick-locked-label {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.pick-locked-team {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.pick-locked .btn-link,
.pick-edit .btn-link {
  margin-left: 0;
}

.your-pick-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.your-pick-row:last-child {
  border-bottom: none;
}

.your-pick-week {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.your-pick-team {
  font-weight: 600;
  color: var(--primary);
}

.settings-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.add-member-code-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.add-member-code-row .settings-input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.add-member-code-row .btn-link {
  margin-left: 0;
  flex-shrink: 0;
}

.team-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.team-btn {
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}

.team-btn:not(.team-btn-used):hover,
.team-btn:not(.team-btn-used):active {
  background: rgba(88, 166, 255, 0.2);
  border-color: var(--primary);
}

.team-btn-used {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.7;
  cursor: default;
  pointer-events: none;
}

@media (min-width: 480px) {
  .team-buttons-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Selections list (mobile-friendly) */
.selection-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 0.5rem;
}

.selection-row .name {
  flex: 1;
  min-width: 0;
}

.selection-row .team {
  font-weight: 600;
  color: var(--primary);
}

/* Admin nav – bottom on mobile */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-nav button {
  min-height: 40px;
  min-width: 80px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.admin-nav button.active {
  color: var(--primary);
  background: rgba(88, 166, 255, 0.15);
}

.admin-content .list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-content .list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.95rem;
}

.admin-content .list li code {
  background: var(--surface2);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.btn-link {
  margin-left: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
}

.sub-round-block {
  margin-bottom: 1.5rem;
}

/* Admin Teams */
.teams-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.teams-add-row input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
}

.teams-add-row .btn-primary {
  width: auto;
  margin-top: 0;
  flex-shrink: 0;
}

.teams-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.teams-list-name {
  font-weight: 500;
}

.teams-list-actions .btn-link {
  margin-left: 0.25rem;
}

/* Admin deadline modal (calendar + clock) */
.deadline-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.deadline-modal.hidden {
  display: none !important;
}

.deadline-modal-inner {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 360px;
  width: 100%;
}

.deadline-modal-inner h4 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.deadline-modal-inner label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.deadline-modal-inner input[type="datetime-local"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.deadline-modal-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.deadline-modal-actions .btn-primary {
  width: auto;
  margin-top: 0;
}

.deadline-modal-actions .btn-link {
  margin-left: 0;
}

.winning-teams-inner .muted {
  margin-bottom: 1rem;
}

.winning-teams-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.winning-team-cb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.winning-team-cb input {
  width: auto;
  min-height: auto;
}

.members-list li {
  word-break: break-word;
}

.paid-no {
  color: var(--danger, #f85149);
  font-weight: bold;
}

.admin-selections-list .admin-selection-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-selections-list .admin-selection-row.knocked-out-row {
  color: var(--danger, #f85149);
}

.admin-selections-list .admin-selection-row.knocked-out-row .admin-selection-name,
.admin-selections-list .admin-selection-row.knocked-out-row .admin-selection-value {
  color: inherit;
}

.admin-selection-name {
  min-width: 120px;
  font-weight: 600;
}

.admin-selection-team {
  min-height: 40px;
  min-width: 160px;
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
}

/* Picks this game week: 2-column grid of team boxes */
#selections-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.picks-team-box {
  background: var(--surface2, rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.picks-team-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.picks-team-count {
  font-size: 0.9rem;
  color: var(--text-muted, rgba(255,255,255,0.7));
  margin-bottom: 0.5rem;
}

.picks-team-names {
  font-size: 0.8rem;
  color: var(--text-muted, rgba(255,255,255,0.7));
  line-height: 1.4;
}

.picks-pending-message {
  grid-column: 1 / -1;
  text-align: center;
}

#picks-history-section .select-input {
  margin-bottom: 0.75rem;
}

.picks-history-list {
  margin-top: 0.5rem;
}

.picks-history-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.picks-history-row:last-child {
  border-bottom: none;
}

.picks-history-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.picks-history-dot {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.picks-history-dot.won {
  background: #3fb950;
}

.picks-history-dot.knocked-out {
  background: #f85149;
}

.picks-history-name {
  font-weight: 500;
}

.picks-history-team {
  flex-shrink: 0;
  color: var(--text-muted, rgba(255,255,255,0.7));
}

.loading {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

/* EPL Integration: Team crests and fixtures */
.team-crest {
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.team-crest-list {
  margin-right: 0.5rem;
}

.pick-locked-team-with-crest {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fixtures-list {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface2);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
}

.fixtures-list h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.fixtures-ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fixture-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto 1fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.95rem;
}

.fixture-row:last-child {
  border-bottom: none;
}

.fixture-team {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixture-vs {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.deadline-passed-msg {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--danger);
  margin: 0 0 0.5rem;
}

/* Desktop: slightly larger tap targets and layout */
@media (min-width: 600px) {
  .container {
    padding: 1.5rem;
  }

  .card {
    padding: 1.5rem;
  }

  .admin-nav {
    flex-wrap: nowrap;
  }
}
