:root {
  color-scheme: dark;
  --bg: #101113;
  --panel: #181b1f;
  --panel-2: #20242a;
  --text: #f5efe5;
  --muted: #aeb6bd;
  --accent: #f05d23;
  --gold: #f2b84b;
  --green: #3ccf91;
  --blue: #4ba3ff;
  --red: #ff4d5a;
  --purple: #9f7aea;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(240, 93, 35, 0.16), transparent 32%),
    linear-gradient(225deg, rgba(75, 163, 255, 0.13), transparent 34%),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 2vw, 28px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 430px);
  gap: 18px;
  align-items: start;
}

.court-panel,
.control-panel,
.ledger {
  background: rgba(24, 27, 31, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.court-panel,
.control-panel,
.ledger {
  padding: clamp(16px, 2vw, 24px);
}

.topbar,
.section-head,
.button-row,
.receipt-band,
.score-row,
.court-legend,
.action-row {
  display: flex;
  align-items: center;
}

.topbar,
.section-head {
  justify-content: space-between;
  gap: 12px;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.3rem, 5vw, 5rem);
  line-height: 0.92;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 1rem;
}

.lede {
  max-width: 660px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.4;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.score-row > div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--panel-2);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.score-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2vw, 2rem);
}

.court-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #0f0f10;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#court {
  display: block;
  width: 100%;
  aspect-ratio: 960 / 680;
  background: #b96b2d;
}

.court-legend {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(13, 15, 17, 0.72);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 0.78rem;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: -1px;
}

.cashed { background: var(--green); }
.half-right { background: var(--gold); }
.missed { background: var(--red); }
.cope { background: var(--purple); }
.pending { background: var(--blue); }

.receipt-band {
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #111418;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.receipt-band p,
.scope-note {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.ai-readback {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(242, 184, 75, 0.26);
  border-radius: 8px;
  background: rgba(242, 184, 75, 0.08);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.receipts,
.mini-receipts {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.receipts li,
.mini-receipts li {
  position: relative;
  padding-left: 16px;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.4;
}

.receipts li::before,
.mini-receipts li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

.profile-actions,
.control-panel,
.control-block,
form {
  display: grid;
  gap: 12px;
}

.control-panel {
  gap: 18px;
}

.control-block {
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.control-block:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.field {
  display: grid;
  gap: 7px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label,
legend {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #111418;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(242, 184, 75, 0.75);
  box-shadow: 0 0 0 3px rgba(242, 184, 75, 0.12);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 86px 86px;
  gap: 8px;
  align-items: center;
}

.stat-grid strong {
  color: var(--gold);
  font-size: 0.8rem;
  text-align: center;
}

.stat-grid label {
  color: var(--text);
}

.scope-pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(242, 184, 75, 0.14);
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.text-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 12px;
  font-weight: 800;
}

.primary-button {
  background: var(--gold);
  color: #17120a;
}

.ghost-button,
.text-button {
  background: var(--panel-2);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.11);
}

.button-row,
.action-row {
  gap: 8px;
}

.ledger {
  margin-top: 18px;
}

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

.entries {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.entry {
  padding: 13px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.entry header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.entry.cashed { border-color: rgba(60, 207, 145, 0.45); }
.entry.half-right { border-color: rgba(242, 184, 75, 0.45); }
.entry.missed { border-color: rgba(255, 77, 90, 0.45); }
.entry.cope { border-color: rgba(159, 122, 234, 0.45); }
.entry.pending { border-color: rgba(75, 163, 255, 0.45); }

.result-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.result-row button {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #111418;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.result-row button.active {
  color: #17120a;
  background: var(--gold);
}

.empty-state {
  margin-top: 14px;
  padding: 16px;
  border-radius: 8px;
  background: #111418;
  color: var(--muted);
}

@media (max-width: 980px) {
  .workspace,
  .ledger-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 12px;
  }

  .topbar,
  .receipt-band,
  .section-head,
  .button-row,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .score-row,
  .two-col {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr 72px 72px;
  }
}
