:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #17212f;
  --muted: #5d6d83;
  --line: #d8e0ec;
  --accent: #0d5bd7;
  --accent-soft: #e7efff;
  --good: #1f7a35;
  --warn: #b76a06;
  --bad: #b01b2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #f7f9fd 0%, #edf2fa 100%);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  min-height: 100vh;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

h1,
h2,
h3 {
  margin: 0 0 0.6rem 0;
  line-height: 1.2;
}

h1 {
  color: #123d8f;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.2rem;
}

p,
li {
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 5px 18px rgba(16, 44, 84, 0.08);
}

.hero-card {
  border-top: 5px solid var(--accent);
  background: linear-gradient(135deg, #ffffff 0%, #f2f6ff 100%);
}

.hero-card p {
  color: #38506f;
  font-size: 1.02rem;
  max-width: 78ch;
}

.stage-card {
  border-color: #b9ccee;
  box-shadow: 0 8px 24px rgba(13, 91, 215, 0.1);
}

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

.split-grid > .card {
  margin-bottom: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.9rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--ink);
}

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

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.55rem;
  border: 1px solid #b8c7da;
  border-radius: 8px;
  background: #fff;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(13, 91, 215, 0.28);
  outline-offset: 2px;
}

/* Hide default spinner controls on numeric inputs for cleaner classroom entry fields. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

button {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
}

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

button.primary:hover:not(:disabled) {
  background: #0949ad;
}

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

button.secondary {
  background: var(--accent-soft);
  border-color: #cad8f6;
  color: #123d8f;
}

button.danger {
  background: #ffe8eb;
  border-color: #f5b8c0;
  color: #8e1022;
}

.status {
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  margin-top: 0.5rem;
}

.status.good {
  color: var(--good);
  background: #e8f7eb;
  border-color: #b9e4c2;
}

.status.warn {
  color: var(--warn);
  background: #fff5e6;
  border-color: #f2d8b0;
}

.status.bad {
  color: var(--bad);
  background: #ffecee;
  border-color: #f3c4cc;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.35rem 0.8rem;
  font-size: 0.95rem;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

th,
td {
  border: 1px solid #d5deeb;
  padding: 0.42rem 0.48rem;
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: #f2f6fd;
}

tr.leaderboard-you td {
  background: #eef4ff;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #edf1f8;
  color: #38506f;
  font-size: 0.8rem;
  font-weight: 700;
}

.round-timer {
  font-weight: 800;
  font-size: 1.15rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #123d8f;
}

.round-timer.closing {
  background: #fff5e6;
  color: var(--warn);
}

.round-timer.expired {
  background: #ffecee;
  color: var(--bad);
}

.offer-banner {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  margin: 0.6rem 0;
  background: #f9fbff;
}

.offer-banner.partner {
  border-left-color: var(--good);
  background: #f4fbf5;
}

.offer-banner-payoffs {
  margin-top: 0.35rem;
}

.offer-preview-box {
  border: 1px dashed #b8c7da;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  background: #fafcff;
  min-height: 2.2rem;
}

.offer-feed {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
}

.offer-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
  background: #fff;
}

.offer-item.own {
  border-left: 4px solid var(--accent);
}

.offer-item.partner {
  border-left: 4px solid var(--good);
}

.offer-item.rejected,
.offer-item.superseded {
  opacity: 0.6;
}

.offer-item.accepted {
  background: #e8f7eb;
}

.offer-who {
  font-weight: 700;
}

tr.status-quo-row td {
  background: #fff5e6;
}

.called-price-callout {
  margin: 0.35rem 0 0.2rem;
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 800;
  color: #0d5bd7;
}

.phase {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.phase-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.65rem 0 1rem;
  padding: 0;
  counter-reset: phase-step;
  list-style: none;
}

.phase-steps li {
  position: relative;
  min-height: 4.4rem;
  padding: 0.7rem 0.7rem 0.7rem 2.65rem;
  border: 1px solid #cad8f6;
  border-radius: 10px;
  background: #f7faff;
  font-size: 0.9rem;
}

.phase-steps li::before {
  counter-increment: phase-step;
  content: counter(phase-step);
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

small.note {
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 720px) {
  main {
    padding: 0.8rem;
  }

  .split-grid {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .called-price-callout {
    font-size: 1.5rem;
  }

  .phase-steps {
    grid-template-columns: 1fr;
  }

  .phase-steps li {
    min-height: auto;
  }

  button {
    width: 100%;
  }

  .row > * {
    flex: 1 1 100%;
  }
}

/* Permit market additions */

.book-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.book-grid h4 {
  margin: 0 0 0.3rem 0;
}

.ticker {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  max-height: 12rem;
  overflow-y: auto;
  font-size: 0.92rem;
}

.ticker li {
  border-bottom: 1px dashed var(--line);
  padding: 0.25rem 0.1rem;
}

.ticker li.own-trade {
  font-weight: 700;
  background: #eef4ff;
}

.value-schedule td, .value-schedule th {
  padding: 0.25rem 0.45rem;
}

.chart-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
  overflow-x: auto;
}

.chart-legend {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.chart-legend .swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.35rem;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.position-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.position-kv .cell {
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

.position-kv .cell .label {
  color: var(--muted);
  font-size: 0.82rem;
}

.position-kv .cell .value {
  font-weight: 800;
  font-size: 1.15rem;
}
