:root {
  --bg: #e8e9e6;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --surface-3: #f7f8f8;
  --text: #173f73;
  --muted: #657280;
  --line: #d9dee2;
  --primary: #1d4276;
  --primary-dark: #14315c;
  --primary-soft: #e3ebf4;
  --accent: #009ba4;
  --accent-dark: #007f86;
  --accent-darker: #006a70;
  --accent-soft: #e0f4f5;
  --warning: #9b6a00;
  --danger: #b23a48;
  --positive: #16805b;
  --shadow: 0 18px 45px rgba(29, 66, 118, 0.1);
  --shadow-soft: 0 8px 22px rgba(29, 66, 118, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f4f5f3 0%, var(--bg) 360px, #f6f7f6 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.link-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:not(:disabled):hover,
.link-button:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.primary {
  background: var(--accent-dark);
  color: #fff;
}

.primary:hover {
  background: var(--accent-darker);
}

.secondary {
  background: #fff;
  color: var(--primary);
  border-color: #b7ccdc;
}

.danger-light {
  background: #fff5f6;
  color: var(--danger);
  border-color: #f1c4ca;
}

.small {
  min-height: 30px;
  padding: 0 10px;
}

a {
  color: var(--primary);
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  color: var(--primary);
  line-height: 1.08;
  margin-bottom: 0;
}

h2 {
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

h3 {
  font-size: 1rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.landing-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 155, 164, 0.18), rgba(0, 155, 164, 0) 38%),
    linear-gradient(180deg, #f8f9f7 0%, #e6e8e5 100%);
}

.landing-panel {
  width: min(680px, 100%);
  border: 1px solid rgba(29, 66, 118, 0.14);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 44px);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 30px 90px rgba(29, 66, 118, 0.16);
}

.landing-copy {
  margin-bottom: 22px;
}

.landing-copy h1 {
  font-size: clamp(2.3rem, 7vw, 4.4rem);
  max-width: 8ch;
}

.join-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.join-card input {
  min-height: 56px;
  border-color: #b7ccdc;
  color: var(--primary);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.join-card button {
  min-height: 56px;
  padding: 0 28px;
}

.landing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.landing-status {
  margin-top: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(29, 66, 118, 0.12);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tabs button {
  background: rgba(255, 255, 255, 0.82);
  border-color: var(--line);
  color: var(--primary);
}

.tabs button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: 22px;
}

.panel + .panel {
  margin-top: 16px;
}

.backend-note,
.error-panel {
  margin-bottom: 16px;
}

.backend-note {
  border-color: var(--line);
  background: #fff;
}

.backend-note strong {
  color: var(--primary);
}

.backend-note p,
.error-panel p {
  margin-bottom: 0;
}

.master-access {
  margin-bottom: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setup-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.setup-lock {
  margin-bottom: 16px;
}

.setup-grid .wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.management-list {
  display: grid;
  gap: 10px;
}

.management-header {
  display: grid;
  gap: 8px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.management-row,
.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.team-row {
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 0.75fr) auto auto;
}

.game-row {
  grid-template-columns: minmax(150px, 1fr) 92px 78px 92px auto auto;
}

.add-row {
  margin-top: 14px;
}

.game-add-row {
  grid-template-columns: minmax(150px, 1fr) 92px 78px 92px auto;
}

.team-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.team-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-3);
}

.team-group-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.team-group-head h3 {
  margin-bottom: 0;
}

.team-name-row {
  grid-template-columns: minmax(150px, 1fr) auto auto;
}

.team-add-row {
  grid-template-columns: minmax(150px, 1fr) auto;
}

.game-setup-table {
  min-width: 940px;
}

.game-setup-table textarea {
  min-height: 84px;
}

.assignment-wrap table {
  min-width: 640px;
}

.assignment-table th,
.assignment-table td {
  text-align: center;
}

.assignment-table th:first-child {
  text-align: left;
}

.assignment-table small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
}

.assignment-checkbox {
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
}

.assigned-note {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 20px;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  min-height: 38px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(0, 120, 168, 0.25);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 120, 168, 0.08);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.dashboard {
  display: grid;
  gap: 16px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.game-card,
.summary-card,
.access-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.game-card {
  box-shadow: var(--shadow);
  border-top: 4px solid var(--accent);
}

.game-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.game-card-head h2 {
  margin-bottom: 0;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.metric-row div,
.round-display div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-3);
}

.metric-row span,
.round-display span,
.summary-card span,
.own-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-row strong,
.round-display strong,
.summary-card strong,
.own-summary strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 2px;
}

.card-actions {
  margin-top: 14px;
  min-height: 38px;
  display: flex;
  align-items: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.summary-card small,
.own-summary small {
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--primary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #edf1f4;
}

tbody tr:hover td {
  background: #f8fafb;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--primary-soft);
  color: var(--primary);
}

.status-running,
.status-submitted {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-between_rounds,
.status-draft {
  background: #fff3d2;
  color: var(--warning);
}

.status-completed,
.status-cancelled {
  background: #edf1f4;
  color: var(--muted);
}

.sale-label {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  margin-left: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.context-label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.password {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  margin-bottom: 10px;
}

.access-card a {
  display: inline-block;
  margin-bottom: 10px;
}

.filters,
.transfer-grid,
.bid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.team-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
}

.team-shell {
  max-width: 1180px;
}

.team-hero {
  margin-bottom: 18px;
  padding: 22px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 155, 164, 0.28), rgba(0, 155, 164, 0) 42%),
    var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.team-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.team-hero .eyebrow,
.team-hero h1 {
  color: #fff;
}

.team-hero h1 {
  font-size: clamp(2.2rem, 6vw, 4rem);
}

.team-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.team-master-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.team-hero-meta {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.team-hero-metric {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
}

.team-hero-metric span,
.team-hero-empty {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.78rem;
  font-weight: 800;
}

.team-hero-metric strong {
  display: block;
  margin-top: 3px;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1.1;
}

.team-hero-game strong {
  font-size: 1.2rem;
}

.team-bid-screen {
  display: grid;
  gap: 16px;
}

.team-bids-panel {
  min-height: 280px;
}

.team-bids-head {
  align-items: flex-start;
}

.team-bids-head .eyebrow {
  margin-bottom: 2px;
}

.team-bids-head .primary {
  min-width: 126px;
}

.team-bid-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed #cbd5df;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--primary);
  font-size: 1.15rem;
}

.empty-state span {
  display: block;
  margin-top: 4px;
}

.bid-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 27, 48, 0.46);
}

.bid-sheet {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(10, 27, 48, 0.28);
  padding: 20px;
}

.bid-sheet-grip {
  display: none;
}

.bid-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.bid-sheet-head h2 {
  margin-bottom: 0;
}

.bid-sheet-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.bid-sheet-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-3);
}

.bid-sheet-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.bid-sheet-summary strong {
  display: block;
  margin-top: 2px;
  color: var(--primary);
  font-size: 1.05rem;
}

.bid-sheet .bid-form {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.bid-sheet-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
}

.round-display {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.own-summary {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.auth-card {
  width: min(420px, 100%);
}

.empty,
.muted {
  color: var(--muted);
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--danger);
}

.compact-label {
  min-width: 220px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  body {
    background: #f2f3f1;
  }

  button,
  .link-button,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  .shell {
    width: min(100% - 20px, 560px);
    padding: 16px 0 28px;
  }

  .topbar,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .landing-shell {
    align-items: stretch;
    padding: 12px;
  }

  .landing-panel {
    align-self: center;
    padding: 22px 16px;
  }

  .landing-copy h1 {
    max-width: none;
  }

  .join-card {
    grid-template-columns: 1fr;
  }

  .join-card button,
  .landing-actions .link-button {
    width: 100%;
  }

  h1 {
    font-size: 2rem;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .tabs button {
    width: 100%;
  }

  .team-shell {
    width: 100%;
    padding: 0 0 28px;
  }

  .team-hero {
    margin-bottom: 12px;
    padding: 18px 12px 14px;
    border-radius: 0 0 8px 8px;
    box-shadow: none;
  }

  .team-hero-top {
    gap: 10px;
    margin-bottom: 14px;
  }

  .team-hero h1 {
    font-size: 2.4rem;
  }

  .team-hero-actions {
    gap: 6px;
  }

  .team-hero-actions .status-pill,
  .team-master-link {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .team-hero-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .team-hero-game {
    grid-column: 1 / -1;
  }

  .team-hero-metric {
    padding: 10px;
  }

  .team-hero-metric strong {
    font-size: 1.35rem;
  }

  .team-hero-game strong {
    font-size: 1.05rem;
  }

  .team-shell .tabs {
    width: calc(100% - 24px);
    margin: 0 auto 12px;
  }

  .team-bid-screen {
    padding: 0 12px 24px;
  }

  .panel {
    padding: 16px;
  }

  .team-bids-panel {
    min-height: 360px;
    box-shadow: none;
  }

  .team-bids-head {
    flex-direction: row;
    align-items: center;
  }

  .team-bids-head .primary {
    min-width: 112px;
  }

  .setup-grid,
  .setup-columns,
  .field-grid.two,
  .team-grid {
    grid-template-columns: 1fr;
  }

  .management-row,
  .team-row,
  .team-name-row,
  .team-add-row,
  .add-row,
  .game-row,
  .game-add-row {
    grid-template-columns: 1fr;
  }

  .management-header {
    display: none;
  }

  .round-display {
    grid-template-columns: 1fr;
  }

  .filters,
  .transfer-grid,
  .bid-form {
    grid-template-columns: 1fr;
  }

  .bid-form {
    margin-bottom: 0;
  }

  .bid-form .primary {
    width: 100%;
  }

  .bid-sheet-backdrop {
    place-items: end stretch;
    padding: 0;
  }

  .bid-sheet {
    width: 100%;
    max-height: calc(100vh - 24px);
    overflow: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
    padding: 10px 16px 16px;
  }

  .bid-sheet-grip {
    display: block;
    width: 44px;
    height: 4px;
    margin: 0 auto 14px;
    border-radius: 999px;
    background: #c9d2dc;
  }

  .bid-sheet-head {
    align-items: center;
  }

  .bid-sheet-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bid-sheet-actions {
    grid-template-columns: 1fr 1fr;
  }

  .compact-label {
    min-width: 0;
  }

  .responsive-table {
    min-width: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 10px;
    padding: 8px 10px;
  }

  .responsive-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid #edf1f4;
    padding: 9px 0;
    text-align: right;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }

  .own-summary {
    padding: 14px;
  }
}
