/* ===== Global Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;
  --purple-200: #e9d5ff;
  --purple-400: #a78bfa;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  --purple-800: #5b21b6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --green-500: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--purple-50), var(--gray-50));
  color: var(--gray-900);
  min-height: 100vh;
}

/* ===== App container ===== */
.app {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px;
}

.hidden { display: none !important; }

/* ===== Header ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.header h1 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--purple-700), var(--purple-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 6px; align-items: center; }
.btn-icon { font-size: 1.1rem; padding: 6px 10px; min-width: 36px; justify-content: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--purple-600); color: #fff; }
.btn-primary:hover { background: var(--purple-700); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-danger { background: transparent; color: var(--red-500); }
.btn-danger:hover { background: #fef2f2; color: var(--red-600); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ===== Landing page ===== */
/* ===== Game info bar ===== */
.game-info-bar {
  margin-bottom: 16px;
}
.info-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--purple-100);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}
.info-name {
  font-weight: 700;
  color: var(--purple-800);
}
.info-code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.85rem;
  color: var(--purple-600);
  background: #fff;
  padding: 2px 10px;
  border-radius: 4px;
}

/* ===== Game code display (modal) ===== */
.code-display {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.3em;
  color: var(--purple-700);
  background: var(--purple-50);
  border: 2px dashed var(--purple-200);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}

/* ===== Game code input ===== */
.input-code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 1.2rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

/* ===== Password toggle ===== */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrapper .input { flex: 1; padding-right: 40px; }
.btn-pw-toggle {
  position: absolute;
  right: 4px;
  padding: 4px 8px;
  font-size: 1rem;
  line-height: 1;
  min-width: auto;
}
.btn-pw-toggle img {
  display: block;
  width: 20px;
  height: 20px;
  opacity: 0.5;
}
.btn-pw-toggle:hover img { opacity: 0.8; }

/* ===== Advanced options ===== */
.advanced-toggle {
  font-size: 0.85rem;
  margin-bottom: 8px;
  padding-left: 0;
}
.advanced-section {
  border-top: 1px solid var(--gray-200);
  padding-top: 12px;
  margin-bottom: 12px;
}
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-label {
  font-size: 0.9rem;
  color: var(--gray-700);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.radio-input { accent-color: var(--purple-600); }

/* ===== Info bar notes ===== */
.info-notes {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-style: italic;
}

/* ===== Scoreboards ===== */
.scoreboards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.score-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--purple-600);
}
.score-card h2 {
  font-size: 1rem;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.score-card .score {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--purple-700);
  line-height: 1.1;
}
.score-card .target {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ===== Chart ===== */
.chart-container {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.chart-container h3 {
  font-size: 1rem;
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card h3 {
  font-size: 1rem;
  color: var(--gray-700);
  margin-bottom: 12px;
}

/* ===== Forms ===== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.4;
  min-height: 40px;
  transition: border-color 0.15s;
  width: 100%;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}
input[type="number"].input::-webkit-inner-spin-button,
input[type="number"].input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input:focus { outline: none; border-color: var(--purple-400); box-shadow: 0 0 0 3px var(--purple-100); }
.feedback { margin-top: 8px; font-size: 0.85rem; color: var(--red-500); min-height: 1.2em; }

/* ===== Game List ===== */
.game-list { display: flex; flex-direction: column; gap: 6px; }
.game-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}
.game-number {
  font-weight: 700;
  color: var(--purple-600);
  min-width: 32px;
}
.game-detail { flex: 1; font-size: 0.9rem; }
.game-date { font-size: 0.8rem; color: var(--gray-500); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin-bottom: 16px; font-size: 1.25rem; }
.modal .form-group { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header-row h2 { margin-bottom: 0; }
.info-modal { max-width: 520px; max-height: 80vh; overflow-y: auto; }
.info-content h4 {
  font-size: 0.95rem;
  color: var(--purple-700);
  margin: 16px 0 8px;
}
.info-content h4:first-child { margin-top: 0; }
.info-content ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.info-content li {
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.5;
}

.muted { color: var(--gray-500); font-size: 0.85rem; }

/* ===== Admin list ===== */
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.admin-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-item-name { font-weight: 700; color: var(--purple-700); text-align: left; }
.admin-item-name:hover { color: var(--purple-600); text-decoration: underline; }
.admin-item-meta { font-size: 0.8rem; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Dash component overrides ===== */
.Select-control { border-radius: var(--radius-sm) !important; }
.dash-dropdown .Select-control { border-color: var(--gray-200) !important; }

/* ===== Mobile responsive ===== */
/* ===== Winner banner ===== */
.winner-banner {
  text-align: center;
  background: linear-gradient(135deg, var(--purple-100), #fff);
  border: 2px solid var(--purple-400);
  border-radius: var(--radius);
  padding: 24px 16px;
  margin-bottom: 20px;
}
.winner-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--purple-700);
  margin-bottom: 4px;
}
.winner-subtitle {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-bottom: 16px;
}
.continue-form {
  border-top: 1px solid var(--purple-200);
  padding-top: 14px;
  margin-top: 4px;
}
.continue-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
  display: block;
  margin-bottom: 8px;
}
.continue-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.continue-input {
  max-width: 120px;
  text-align: center;
}

/* ===== Archive section ===== */
.archive-section {
  text-align: center;
  margin-bottom: 20px;
}
.btn-archive {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 24px 16px 16px;
  font-size: 0.8rem;
  color: var(--gray-500);
}
.app-footer a {
  color: var(--purple-600);
  text-decoration: none;
}
.app-footer a:hover {
  text-decoration: underline;
}
.footer-sep {
  color: var(--gray-300);
}
.footer-admin-link {
  color: var(--gray-400) !important;
  font-size: 0.75rem;
}
.footer-admin-link:hover {
  color: var(--gray-500) !important;
}
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn-link:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .header h1 { font-size: 1.2rem; }
  .score-card .score { font-size: 2rem; }
  .form-row { grid-template-columns: 1fr; }
  .code-display { font-size: 1.8rem; letter-spacing: 0.2em; }
  .info-bar-inner { flex-direction: column; gap: 6px; text-align: center; }
}
