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

:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-card: #1a1d2e;
  --bg-card-hover: #22263a;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --green-dark: #238636;
  --red: #f85149;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --pod-w: 140px;
  --team-h: 24px;
  --game-h: calc(var(--team-h) * 2 + 1px);
  --game-gap: 4px;
  --connector-w: 20px;
  --connector-color: #484f58;
  --winner-circle-size: 100px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Home Page ===== */
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
}

.home-hero {
  width: 100%;
  background: var(--bg-surface);
  padding: 3.5rem 2rem 3rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.ncaa-logo { width: 280px; max-width: 90%; margin-bottom: 1.25rem; }

.home-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
}

.home-subtitle { color: var(--text-secondary); font-size: 1.05rem; }

/* ===== Carousel Bar ===== */
.carousel-bar {
  width: 100%;
  overflow: hidden;
  background: rgba(88, 166, 255, 0.06);
  border-bottom: 1px solid rgba(88, 166, 255, 0.1);
  padding: 0.5rem 0;
}

.carousel-track {
  display: flex;
  align-items: center;
  width: max-content;
  animation: carousel-scroll 40s linear infinite;
}

.carousel-set {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 0.75rem;
}

.carousel-item {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  white-space: nowrap;
}

.carousel-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  flex-shrink: 0;
}

@keyframes carousel-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-12.5%); }
}

.home-content {
  max-width: 480px;
  width: 100%;
  padding: 2rem 1.5rem;
}

.home-instructions {
  margin-bottom: 1.5rem;
}

.home-instructions-steps {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.instruction-step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.instruction-step strong {
  color: var(--text);
}

.step-num {
  width: 1.25rem;
  height: 1.25rem;
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.home-actions { display: flex; flex-direction: column; gap: 1.25rem; }

@media (max-width: 480px) {
  .home-instructions-steps {
    flex-wrap: wrap;
  }
  .instruction-step {
    width: calc(50% - 0.25rem);
  }
}

.home-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  text-align: center;
}

.home-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }
.home-card p { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 1.25rem; line-height: 1.6; }

.create-mode-options {
  display: flex;
  gap: 0.75rem;
}

.create-mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.25rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
}

.create-mode-btn:hover {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.04);
}

.create-mode-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.create-mode-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.create-mode-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-back-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font);
  padding: 0.25rem 0;
  transition: color 0.15s;
}
.btn-back-link:hover { color: var(--text-secondary); }

.home-divider { display: flex; align-items: center; gap: 1rem; }
.home-divider::before, .home-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.home-divider span { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; }

.lookup-form { display: flex; gap: 0.5rem; }

.lookup-input {
  flex: 1;
  padding: 0.7rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lookup-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15); }
.lookup-input::placeholder { letter-spacing: 0; font-family: var(--font); font-size: 0.85rem; color: var(--text-muted); }

.lookup-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.lookup-divider::before, .lookup-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.lookup-divider span { color: var(--text-muted); font-size: 0.7rem; font-weight: 600; text-transform: lowercase; }

.phone-results {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.phone-results-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  padding-bottom: 0.25rem;
}

.phone-result-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.phone-result-item:hover {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.04);
}

.phone-result-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.phone-result-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.phone-result-id {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.phone-result-detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.phone-result-timestamp {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: auto;
  white-space: nowrap;
}

.error-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.85rem;
}

/* ===== Buttons ===== */
.btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
  letter-spacing: 0.3px;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--text-muted); }
.btn-back { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); padding: 0.4rem 0.9rem; font-size: 0.8rem; border-radius: 6px; }
.btn-back:hover { background: var(--bg-card); color: var(--text); }
.btn-save { background: var(--accent); color: #fff; }
.btn-save:hover:not(:disabled) { background: var(--accent-hover); }
.btn-submit { background: var(--green-dark); color: #fff; }
.btn-submit:hover:not(:disabled) { background: var(--green); }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.7rem;
  cursor: pointer;
  margin-left: 0.5rem;
  font-family: var(--font);
  transition: all 0.15s;
  font-weight: 600;
}
.btn-copy:hover { background: var(--bg-card); color: var(--text); border-color: var(--text-muted); }

.submitted-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.submitted-badge {
  background: rgba(63, 185, 80, 0.1);
  color: var(--green);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.8rem;
  border: 1px solid rgba(63, 185, 80, 0.4);
}
.submitted-timestamp {
  color: var(--text-secondary);
  font-size: 0.65rem;
  white-space: nowrap;
}

.btn-share {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.4);
}
.btn-share:hover:not(:disabled) {
  background: rgba(88, 166, 255, 0.2);
  border-color: var(--accent);
}

.modal-close-btn {
  margin-top: 0.75rem;
}

/* ===== Bracket Page ===== */
.bracket-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.bracket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.bracket-header-center {
  text-align: center;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.bracket-header-logo { height: 32px; }

.bracket-id { font-size: 0.75rem; color: var(--text-secondary); }
.bracket-id strong {
  color: var(--text);
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

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

/* ===== Progress Bar ===== */
.progress-bar-container {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 50px;
  z-index: 99;
}

.progress-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 120px;
}
.progress-info strong { color: var(--accent); }

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-fill.complete { background: var(--green); }

/* ===== Instructions Banner ===== */
.instructions-banner {
  background: rgba(88, 166, 255, 0.06);
  border-bottom: 1px solid rgba(88, 166, 255, 0.15);
  padding: 0.5rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.instructions-banner .dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}
.instructions-banner .dismiss:hover { color: var(--text-secondary); }

/* ===== Save Toast ===== */
.save-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  color: var(--green);
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 200;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.25s ease, toastOut 0.25s ease 1.5s forwards;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ============================================
   BRACKET LAYOUT — Flexbox alignment system
   ============================================ */

.bracket-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem 1.5rem;
  gap: 0;
  overflow-x: auto;
  flex: 1;
}

.bracket-left,
.bracket-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== Region ===== */
.region {
  display: flex;
  align-items: stretch;
}

.region-name-vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.2rem;
  white-space: nowrap;
  color: var(--text-muted);
}

.region-left .region-name-vertical {
  order: -1;
  transform: rotate(180deg);
}
.region-right .region-name-vertical {
  order: 1;
}

[data-region="south"] .region-name-vertical { color: var(--accent); }
[data-region="west"] .region-name-vertical { color: #a371f7; }
[data-region="east"] .region-name-vertical { color: #f78166; }
[data-region="midwest"] .region-name-vertical { color: var(--green); }

/* ===== Region Rounds ===== */
.region-rounds {
  display: flex;
  align-items: stretch;
}

/* ===== Round Column ===== */
.round-column {
  display: flex;
  flex-direction: column;
}

.round-col-label {
  text-align: center;
  font-size: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 0 0.25rem;
  white-space: nowrap;
  height: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.round-games {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-around;
}

/* Game slot — each game sits centered in its flex space */
.game-slot {
  display: flex;
  align-items: center;
  flex: 1;
}

/* ===== Game Card ===== */
.game {
  display: flex;
  flex-direction: column;
  width: var(--pod-w);
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.15s ease;
}

.game:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.game-team {
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.12s ease;
  height: var(--team-h);
  font-size: 0.65rem;
  position: relative;
  user-select: none;
  color: var(--text);
}

.game-team + .game-team {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.game-team.has-team:hover {
  background: var(--bg-card-hover);
}

.game-team.winner {
  font-weight: 700;
  background: rgba(88, 166, 255, 0.06);
}

.game-team.loser {
  opacity: 0.3;
}

.game-team.empty {
  cursor: default;
  opacity: 0.25;
}

.seed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  min-width: 22px;
  height: 100%;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.2);
}

.game-team.winner .seed {
  color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
}

.team-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.65rem;
  color: var(--text);
  flex: 1;
  padding: 0 6px;
}

.team-name.tbd {
  color: var(--text-muted);
  font-size: 0.55rem;
  letter-spacing: 2px;
}

/* ===== Region-Specific Game Accents ===== */
[data-region="south"] .game { border-left: 2px solid rgba(88, 166, 255, 0.3); }
[data-region="west"] .game { border-left: 2px solid rgba(163, 113, 247, 0.3); }
[data-region="east"] .game { border-right: 2px solid rgba(247, 129, 102, 0.3); }
[data-region="midwest"] .game { border-right: 2px solid rgba(63, 185, 80, 0.3); }

[data-region="south"] .game-team.winner { background: rgba(88, 166, 255, 0.08); }
[data-region="west"] .game-team.winner { background: rgba(163, 113, 247, 0.08); }
[data-region="east"] .game-team.winner { background: rgba(247, 129, 102, 0.08); }
[data-region="midwest"] .game-team.winner { background: rgba(63, 185, 80, 0.08); }

[data-region="south"] .game-team.winner .seed { color: var(--accent); background: rgba(88, 166, 255, 0.12); }
[data-region="west"] .game-team.winner .seed { color: #a371f7; background: rgba(163, 113, 247, 0.12); }
[data-region="east"] .game-team.winner .seed { color: #f78166; background: rgba(247, 129, 102, 0.12); }
[data-region="midwest"] .game-team.winner .seed { color: var(--green); background: rgba(63, 185, 80, 0.12); }

/* ===== SVG Connectors ===== */
.connector-col {
  display: flex;
  flex-direction: column;
  width: var(--connector-w);
  min-width: var(--connector-w);
}

.connector-label-spacer {
  height: 16px;
  flex-shrink: 0;
}

.connector-games {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.connector-pair {
  flex: 1;
  display: flex;
  align-items: stretch;
}

.connector-line {
  flex: 1;
  position: relative;
}

.connector-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.conn-stroke {
  stroke: var(--connector-color);
  stroke-width: 1.5;
  fill: none;
}

[data-region="south"] .conn-stroke { stroke: rgba(88, 166, 255, 0.35); }
[data-region="west"] .conn-stroke { stroke: rgba(163, 113, 247, 0.35); }
[data-region="east"] .conn-stroke { stroke: rgba(247, 129, 102, 0.35); }
[data-region="midwest"] .conn-stroke { stroke: rgba(63, 185, 80, 0.35); }

/* ===== Final Four ===== */
.final-four {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  min-width: 300px;
  align-self: center;
}

.ff-label-row {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-bottom: 0.4rem;
}

.ff-round-label {
  font-size: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-align: center;
}

.ff-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ff-semi {
  display: flex;
  align-items: center;
  gap: 0;
}

.ff-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.ff-connector-arm {
  width: 14px;
  height: 1.5px;
  background: var(--connector-color);
}

/* ===== Winner Circle ===== */
.winner-circle {
  width: var(--winner-circle-size);
  height: var(--winner-circle-size);
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border);
  transition: all 0.3s ease;
}

.winner-circle.has-winner {
  border-color: var(--green);
  background: rgba(63, 185, 80, 0.06);
  box-shadow: 0 0 30px rgba(63, 185, 80, 0.12);
  animation: winnerGlow 3s ease-in-out infinite;
}

@keyframes winnerGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(63, 185, 80, 0.08); }
  50% { box-shadow: 0 0 40px rgba(63, 185, 80, 0.2); }
}

.winner-seed {
  font-size: 0.5rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.winner-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--green);
  text-align: center;
  padding: 0 0.5rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-placeholder {
  font-size: 1.5rem;
  color: var(--text-muted);
  font-weight: 800;
}

.winner-label {
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--text-muted);
  margin-top: 0.25rem;
  transition: color 0.3s ease;
}

.winner-circle.has-winner ~ .winner-label {
  color: var(--green);
}

/* ===== Confirm Dialog ===== */
.confirm-warning {
  color: var(--red) !important;
  font-weight: 600;
  font-size: 0.95rem !important;
  line-height: 1.7 !important;
}
.confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(1, 4, 9, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.modal h2 { font-size: 1.3rem; margin-bottom: 0.5rem; color: var(--text); font-weight: 700; }
.modal p { color: var(--text-secondary); margin-bottom: 1.25rem; line-height: 1.6; font-size: 0.9rem; }

.modal-id {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.modal-id-value {
  font-family: 'Courier New', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 3px;
  background: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ===== Loading ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-size: 1rem;
  color: var(--text-secondary);
  background: var(--bg);
}

/* ===== Home Page Extras ===== */
.create-bracket-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.small-input {
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
}

.name-input {
  font-family: var(--font);
  letter-spacing: 0;
  text-align: left;
}

.org-created {
  text-align: center;
}

.org-created-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.org-created-id {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.org-created-id span {
  font-family: 'Courier New', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
}

.org-created-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Organization Dashboard ===== */
.org-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.org-hero {
  text-align: center;
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.org-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.org-id-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.org-id-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.org-id-value {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 3px;
}

.org-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.org-stat-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

.org-table-wrap {
  flex: 1;
  padding: 1.5rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.org-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.org-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.org-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.org-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.org-table tbody tr:hover {
  background: var(--bg-surface);
}

.org-td-name {
  font-weight: 600;
  color: var(--text);
}

.champion-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text);
}

.champion-seed {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.1rem 0.3rem;
  border-radius: 2px;
}

.no-champion {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.org-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.org-progress-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.org-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.org-progress-fill.complete {
  background: var(--green);
}

.org-progress-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 35px;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
}

.status-submitted {
  background: rgba(63, 185, 80, 0.1);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.status-progress {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.7rem;
}

/* ===== Org Mobile Cards (hidden on desktop) ===== */
.org-mobile-list { display: none; }

.org-mobile-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.org-mobile-card:hover { border-color: var(--accent); }

.org-mobile-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.org-mobile-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.org-mobile-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.org-td-timestamp { white-space: nowrap; }
.timestamp-text {
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.org-mobile-card-timestamp {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 0.15rem;
}

/* ===== Mobile Responsive ===== */

/* --- Small screens: Home, Bracket, Org --- */
@media (max-width: 600px) {
  /* Home hero */
  .home-hero {
    padding: 2rem 1rem 1.75rem;
  }
  .ncaa-logo { width: 200px; }
  .home-title { font-size: 1.5rem; }
  .home-subtitle { font-size: 0.9rem; }

  /* Home content */
  .home-content { padding: 1.25rem 1rem; }
  .home-card { padding: 1.25rem; }
  .home-card h2 { font-size: 1rem; }
  .home-card p { font-size: 0.8rem; margin-bottom: 1rem; }

  .create-mode-btn { padding: 1rem 0.5rem; }
  .create-mode-icon { font-size: 1.25rem; }
  .create-mode-label { font-size: 0.8rem; }

  .lookup-input { padding: 0.6rem 0.7rem; font-size: 0.9rem; }
  .lookup-form { flex-direction: column; }
  .lookup-form .btn { width: 100%; }

  /* Carousel */
  .carousel-item { font-size: 0.65rem; letter-spacing: 1px; }
  .carousel-set { gap: 1rem; padding: 0 0.5rem; }

  /* Bracket header */
  .bracket-header {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .bracket-header-center { gap: 0.5rem; }
  .bracket-header-logo { height: 24px; }
  .bracket-id { font-size: 0.65rem; }
  .bracket-id strong { font-size: 0.65rem; }
  .btn-back { padding: 0.3rem 0.6rem; font-size: 0.7rem; }

  .bracket-header-actions {
    gap: 0.35rem;
    flex-wrap: wrap;
  }
  .bracket-header-actions .btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.7rem;
  }
  .submitted-badge { padding: 0.25rem 0.6rem; font-size: 0.65rem; }
  .submitted-timestamp { font-size: 0.55rem; }

  /* Progress bar */
  .progress-bar-container {
    padding: 0.4rem 0.75rem;
    gap: 0.5rem;
    top: auto;
    position: relative;
  }
  .progress-info { font-size: 0.65rem; min-width: 90px; }

  /* Instructions banner */
  .instructions-banner { padding: 0.4rem 0.75rem; font-size: 0.7rem; }

  /* Bracket container — horizontal scroll */
  .bracket-container {
    padding: 0.5rem 0.25rem 1rem;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }

  /* Scale down bracket pods for mobile */
  :root {
    --pod-w: 110px;
    --team-h: 22px;
    --connector-w: 14px;
    --winner-circle-size: 75px;
  }

  .round-col-label { font-size: 0.4rem; height: 14px; }
  .region-name-vertical { font-size: 0.45rem; letter-spacing: 2px; }
  .game-team { font-size: 0.6rem; }
  .seed { width: 18px; min-width: 18px; font-size: 0.5rem; }
  .team-name { font-size: 0.6rem; padding: 0 4px; }
  .team-name.tbd { font-size: 0.5rem; }

  /* Final Four */
  .final-four { min-width: 220px; padding: 0 0.15rem; }
  .ff-round-label { font-size: 0.4rem; }
  .ff-connector-arm { width: 10px; }
  .winner-name { font-size: 0.65rem; }
  .winner-seed { font-size: 0.4rem; }
  .winner-placeholder { font-size: 1.2rem; }
  .winner-label { font-size: 0.4rem; letter-spacing: 2px; }

  /* Modals */
  .modal { padding: 1.5rem 1.25rem; border-radius: 12px; }
  .modal h2 { font-size: 1.1rem; }
  .modal p { font-size: 0.8rem; }
  .modal-id-value { font-size: 1.1rem; letter-spacing: 2px; padding: 0.4rem 0.75rem; }
  .confirm-actions { flex-direction: column; gap: 0.5rem; }
  .confirm-actions .btn { width: 100%; }

  /* Save toast */
  .save-toast { bottom: 1rem; right: 1rem; font-size: 0.7rem; padding: 0.5rem 1rem; }

  /* Org dashboard */
  .org-hero { padding: 1.5rem 1rem 1rem; }
  .org-name { font-size: 1.2rem; }
  .org-id-value { font-size: 0.85rem; }
  .org-stats { font-size: 0.7rem; }
  .org-table-wrap { padding: 1rem 0.75rem; }

  .org-table { font-size: 0.75rem; }
  .org-table th { padding: 0.4rem 0.5rem; font-size: 0.6rem; }
  .org-table td { padding: 0.5rem; }

  /* Swap table for card list on mobile */
  .org-desktop-table { display: none; }
  .org-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* --- Very small screens (phones in portrait) --- */
@media (max-width: 380px) {
  .home-title { font-size: 1.3rem; }
  .ncaa-logo { width: 160px; }
  .home-card { padding: 1rem; }
  .create-mode-options { gap: 0.5rem; }
  .create-mode-btn { padding: 0.75rem 0.4rem; }
  .create-mode-label { font-size: 0.75rem; }
  .create-mode-desc { font-size: 0.6rem; }

  :root {
    --pod-w: 95px;
    --team-h: 20px;
    --connector-w: 10px;
    --winner-circle-size: 65px;
  }

  .seed { width: 16px; min-width: 16px; font-size: 0.45rem; }
  .team-name { font-size: 0.55rem; padding: 0 3px; }
  .game-team { font-size: 0.55rem; }
  .final-four { min-width: 180px; }
  .winner-name { font-size: 0.55rem; }
}

/* --- Touch improvements --- */
@media (hover: none) and (pointer: coarse) {
  .game-team {
    min-height: 28px;
  }
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
  .btn-back, .btn-copy, .btn-sm {
    min-height: 36px;
  }
  .create-mode-btn {
    min-height: 80px;
  }
}

/* ===== Print ===== */
@media print {
  .bracket-header-actions, .btn-back, .btn-copy, .progress-bar-container, .instructions-banner, .save-toast { display: none; }
  body { background: #fff; color: #000; }
}
