* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 16px;
  font-size: 16px;
}

h1 {
  margin-bottom: 12px;
  font-size: 26px;
  line-height: 1.15;
}

.top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.random-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: stretch;
}

select,
button {
  padding: 12px 14px;
  font-size: 16px;
  min-height: 44px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.bonus-spin-btn {
  background: linear-gradient(135deg, #6a11cb, #2575fc);
  color: white;
  border: none;
  font-weight: bold;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(37, 117, 252, 0.25);
}

.bonus-spin-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.reset-all-btn {
  background: #b91c1c;
  color: white;
  border: none;
  font-weight: bold;
}

.reset-all-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.bonus-position-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.bonus-position-label {
  font-size: 12px;
  color: #555;
  font-weight: bold;
}

#bonusPositionDisplay {
  background: #f4f6ff;
  border: 1px solid #c9d4ff;
  color: #222;
}

.side-panel {
  border: 1px solid #ddd;
  background: #fafafa;
  padding: 12px;
  border-radius: 8px;
}

.side-panel h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.side-panel .subtext {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
}

.used-teams-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.used-team-pill {
  border: 1px solid #cfcfcf;
  background: white;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.wheels-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.wheel-wrap {
  border: 1px solid #ddd;
  background: #fafafa;
  padding: 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-title {
  width: 100%;
  font-weight: bold;
  margin-bottom: 10px;
}

.wheel-pointer {
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid #dc2626;
  margin-bottom: 8px;
  align-self: center;
}

.mini-wheel-pointer {
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid #dc2626;
  margin-bottom: 8px;
  align-self: center;
}

#wheelCanvas,
#seasonWheelCanvas,
#weekWheelCanvas {
  border: 1px solid #ccc;
  border-radius: 50%;
  background: white;
  max-width: 100%;
  height: auto;
}

.wheel-meta {
  width: 100%;
  margin-top: 10px;
  font-size: 13px;
  color: #444;
}

.wheel-selected {
  font-weight: bold;
  margin-top: 6px;
}

.team-card {
  border: 1px solid #ddd;
  background: #fafafa;
  padding: 12px;
  border-radius: 8px;
}

.team-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.team-name {
  font-weight: bold;
  font-size: 18px;
  margin-bottom: 4px;
}

.team-code {
  font-size: 14px;
  color: #555;
  margin-bottom: 10px;
}

.team-note {
  font-size: 12px;
  color: #666;
  line-height: 1.35;
}

.locked-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.unlocked-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.status-panel {
  margin-top: 18px;
  border-top: 1px solid #e5e7eb;
  padding-top: 14px;
}

#status {
  margin: 0 0 10px 0;
  font-weight: bold;
}

#meta {
  margin: 0;
  padding: 10px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  white-space: pre-wrap;
}

.roster-wrap {
  margin: 18px 0 22px;
  padding: 12px;
  border: 1px solid #ddd;
  background: #fafafa;
}

.roster-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.roster-title {
  font-weight: bold;
  font-size: 18px;
}

.roster-summary {
  font-size: 14px;
  color: #444;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.roster-slot {
  border: 1px solid #ccc;
  background: white;
  padding: 10px;
  border-radius: 8px;
  min-height: 110px;
}

.slot-name {
  font-size: 12px;
  font-weight: bold;
  color: #666;
  margin-bottom: 6px;
}

.slot-player {
  font-weight: bold;
  margin-bottom: 4px;
}

.slot-meta {
  font-size: 12px;
  color: #444;
  white-space: pre-line;
  margin-bottom: 8px;
}

.slot-empty {
  color: #999;
  font-style: italic;
}

.slot-remove {
  padding: 6px 8px;
  font-size: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
  margin-top: 14px;
}

th,
td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eee;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

.bonus-highlight {
  background: #ede9fe !important;
}

.bonus-highlight td {
  border-color: #a78bfa;
}

.bonus-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: bold;
  background: #7c3aed;
  color: white;
}

.action-cell {
  min-width: 180px;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-stack select,
.action-stack button {
  font-size: 12px;
  padding: 6px 8px;
  min-height: unset;
}

pre {
  background: #111;
  color: #eee;
  padding: 12px;
  overflow: auto;
  font-size: 12px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  .wheels-grid {
    grid-template-columns: 1fr;
  }

  .top-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    margin: 12px;
    font-size: 15px;
  }

  h1 {
    font-size: 22px;
  }

  .top-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .wheels-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .random-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .random-buttons > button,
  .random-buttons > .bonus-position-wrap {
    width: 100%;
  }

  .wheel-wrap,
  .team-card,
  .side-panel,
  .roster-wrap {
    padding: 10px;
  }

  .team-name {
    font-size: 20px;
  }

  .team-code {
    font-size: 16px;
  }

  .wheel-title,
  .roster-title {
    font-size: 18px;
  }

  .wheel-meta,
  .roster-summary,
  .team-note,
  .side-panel .subtext {
    font-size: 14px;
  }

  .roster-grid {
    grid-template-columns: 1fr 1fr;
  }

  .roster-slot {
    min-height: 96px;
  }

  .leaderboard-side-panel .leaderboard-submit-row {
    flex-direction: column;
  }

  .leaderboard-side-panel #leaderboardTable th,
  .leaderboard-side-panel #leaderboardTable td {
    font-size: 13px;
    padding: 7px 5px;
  }
}

@media (max-width: 480px) {
  .roster-grid {
    grid-template-columns: 1fr;
  }
}

.slot-remove:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.leaderboard-wrap {
  margin: 18px 0 22px;
  padding: 12px;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 8px;
}

.leaderboard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.leaderboard-title {
  font-weight: bold;
  font-size: 18px;
}

.leaderboard-submit-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

#leaderboardName {
  padding: 10px 12px;
  font-size: 16px;
  min-height: 44px;
  min-width: 220px;
}

.leaderboard-message {
  font-size: 13px;
  color: #555;
  margin-bottom: 10px;
}

.leaderboard-side-panel .leaderboard-submit-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.leaderboard-side-panel .leaderboard-submit-row input {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.leaderboard-side-panel .leaderboard-submit-row button {
  width: fit-content;
  white-space: nowrap;
}

.leaderboard-table-wrap {
  overflow: hidden;
  margin-top: 10px;
  width: 100%;
}

.leaderboard-side-panel #leaderboardTable {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 0;
  min-width: 0;
}

.leaderboard-side-panel #leaderboardTable th,
.leaderboard-side-panel #leaderboardTable td {
  padding: 8px 6px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-side-panel #leaderboardTable th:nth-child(1),
.leaderboard-side-panel #leaderboardTable td:nth-child(1) {
  width: 52px;
}

.leaderboard-side-panel #leaderboardTable th:nth-child(2),
.leaderboard-side-panel #leaderboardTable td:nth-child(2) {
  width: 90px;
}

.leaderboard-side-panel #leaderboardTable th:nth-child(3),
.leaderboard-side-panel #leaderboardTable td:nth-child(3) {
  width: 70px;
}

.leaderboard-side-panel #leaderboardTable th:nth-child(4),
.leaderboard-side-panel #leaderboardTable td:nth-child(4) {
  width: 88px;
}