:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --subtle: #8b949e;
  --accent: #2f81f7;
  --good: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}

.subtle {
  color: var(--subtle);
  font-size: 14px;
}

.center {
  text-align: center;
  padding: 24px 0;
}

.error {
  color: var(--bad);
  font-size: 14px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--subtle);
}

/* ---- login ---- */

#login-view {
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  font-size: 28px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--subtle);
}

input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 17px;
  width: 100%;
}

input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
}

button.primary {
  background: var(--accent);
  padding: 14px;
  font-weight: 600;
  font-size: 17px;
}

button.ghost {
  background: none;
  color: var(--subtle);
  padding: 8px 10px;
  font-size: 14px;
}

a.ghost {
  color: var(--subtle);
  text-decoration: none;
  padding: 8px 10px;
  font-size: 14px;
}

/* ---- bars & pills ---- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bar h2 {
  font-size: 18px;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill.muted {
  background: var(--border);
  color: var(--subtle);
}

.pill.good {
  background: rgba(63, 185, 80, 0.18);
  color: var(--good);
}

.pill.bad {
  background: rgba(248, 81, 73, 0.18);
  color: var(--bad);
}

.pill.warn {
  background: rgba(210, 153, 34, 0.18);
  color: var(--warn);
}

.pill.live {
  background: rgba(248, 81, 73, 0.22);
  color: var(--bad);
}

/* ---- match list ---- */

.search input {
  font-size: 16px;
}

.match-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.match-card {
  position: relative;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.match-card:active {
  border-color: var(--accent);
}

.match-names {
  font-size: 16px;
  font-weight: 600;
  padding-right: 52px;
}

.match-score {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.match-meta {
  font-size: 13px;
  color: var(--subtle);
}

.match-card .pill.live {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* ---- scoreboard ---- */

.scoreboard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto 44px;
  gap: 10px;
  align-items: baseline;
}

.score-name {
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-sets {
  font-variant-numeric: tabular-nums;
  color: var(--subtle);
  letter-spacing: 0.15em;
}

.score-game {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--accent);
}

/* ---- tap zone ---- */

.tap-zone {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.tap-button {
  flex: 1;
  min-height: 26dvh;
  border-radius: 16px;
  background: var(--panel);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-user-select: none;
  user-select: none;
}

.tap-button:active {
  background: #1c2532;
  border-color: var(--accent);
  transform: scale(0.99);
}

.tap-label {
  font-size: 24px;
  font-weight: 700;
  padding: 0 12px;
  text-align: center;
}

.tap-sub {
  font-size: 13px;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---- chips ---- */

.tap-chips {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  min-height: 44px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
}

.chip-label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-status {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--subtle);
}

.chip[data-status="sending"] .chip-status {
  color: var(--warn);
}

.chip[data-status="pending"] .chip-status {
  color: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.chip[data-status="green"] {
  border-color: rgba(63, 185, 80, 0.55);
}

.chip[data-status="green"] .chip-status {
  color: var(--good);
  font-weight: 700;
}

.chip[data-status="red"] {
  border-color: rgba(248, 81, 73, 0.55);
}

.chip[data-status="red"] .chip-status {
  color: var(--bad);
  font-weight: 700;
}

.chip[data-status="unconfirmed"] .chip-status,
.chip[data-status="voided"] .chip-status {
  color: var(--subtle);
}

.chip.mismatch {
  border-color: var(--warn);
}

.chip.corrected {
  opacity: 0.75;
}

.chip-actions {
  display: flex;
  gap: 6px;
}

.chip-actions button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ---- warning banner ---- */

.warning-banner {
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

/* ---- toast ---- */

#toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- admin ---- */

table.admin {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.admin th,
table.admin td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
  white-space: nowrap;
}

table.admin th {
  color: var(--subtle);
  font-weight: 600;
}

.admin-scroll {
  overflow-x: auto;
}

.admin-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-form input {
  width: auto;
  flex: 1;
  min-width: 140px;
}

.credentials {
  background: rgba(47, 129, 247, 0.12);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  word-break: break-all;
}

/* ---- gentle farmer ---- */

.gf-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gf-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gf-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gf-title {
  font-size: 16px;
  font-weight: 600;
}

.gf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--subtle);
}

.gf-field select,
.gf-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  width: 100%;
}

.gf-register,
.gf-score-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.gf-score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.gf-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--subtle);
}

.gf-check input {
  width: auto;
}

.fill-banner {
  background: rgba(248, 81, 73, 0.18);
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- gentle farmer control: a dense monitoring table, not a phone form ---- */

.view.wide {
  max-width: min(1500px, 100vw);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* Numeric columns read as columns only when the digits line up. */
.gf-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.gf-stale {
  color: var(--subtle);
}

@media (min-width: 900px) {
  .view.wide table.admin {
    font-size: 14px;
  }

  .view.wide table.admin th,
  .view.wide table.admin td {
    padding: 10px 12px;
  }

  /* The market name is the only wide column; let it take the slack. */
  .view.wide table.admin td:first-child,
  .view.wide table.admin th:first-child {
    white-space: normal;
    min-width: 260px;
  }

  .view.wide table.admin tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
  }
}

/* Editable cells: the price inputs sit inline in a dense table, so they are
   sized to their content rather than the browser's default form width. */
.gf-px {
  width: 5.5em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.gf-side-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Working quote and reward share, under the side's controls. */
.gf-sub {
  font-size: 12px;
  color: var(--subtle);
  white-space: nowrap;
}

.gf-reward {
  display: block;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--subtle);
}

/* The reason a side is not quoting — the first thing to read when a row looks
   wrong, so it gets a warning tone rather than the muted one. */
.gf-reason {
  font-size: 12px;
  color: var(--warn, #d8a657);
  white-space: nowrap;
}
