:root {
  --bg: #040904;
  --bg-panel: #071107;
  --fg: #33ff33;
  --fg-bright: #9eff9e;
  --fg-dim: #1c851c;
  --fg-muted: #145c14;
  --border: #25b825;
  --warn: #b8ff33;
  --err: #ff5533;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Courier New", Consolas, "Lucida Console", monospace;
  font-size: 15px;
  line-height: 1.45;
  text-shadow: 0 0 6px rgba(51, 255, 51, 0.35);
  -webkit-tap-highlight-color: rgba(51, 255, 51, 0.2);
}

.crt-scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px,
    rgba(0, 0, 0, 0.22) 4px
  );
}

.terminal {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.term-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.term-title {
  font-weight: bold;
  letter-spacing: 0.06em;
  color: var(--fg-bright);
}

.blink-cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

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

.status-line {
  padding: 6px 10px;
  border: 1px solid var(--fg-dim);
  background: var(--bg-panel);
  margin-bottom: 12px;
  color: var(--fg-bright);
}

.ascii-banner {
  color: var(--fg-bright);
  font-size: clamp(6.5px, 2.05vw, 11px);
  line-height: 1.15;
  overflow-x: hidden;
  margin: 0 0 16px;
  text-align: center;
}

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

.term-box {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 16px;
  box-shadow: inset 0 0 18px rgba(51, 255, 51, 0.06);
}

.term-box h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--fg-bright);
  border-bottom: 1px dashed var(--fg-muted);
  padding-bottom: 6px;
  letter-spacing: 0.05em;
}

.box-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.box-head h2 {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.06em;
}

input {
  background: #020502;
  border: 1px solid var(--border);
  color: var(--fg-bright);
  font-family: inherit;
  font-size: 16px;
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
  text-transform: uppercase;
  border-radius: 0;
}

input[type="password"] {
  text-transform: none;
}

input:focus {
  border-color: var(--fg-bright);
  box-shadow: 0 0 8px rgba(51, 255, 51, 0.35);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.space-top {
  margin-top: 14px;
}

.term-btn {
  background: #041204;
  color: var(--fg);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-shadow: inherit;
  touch-action: manipulation;
}

.term-btn:hover:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
}

.term-btn.primary {
  border-color: var(--fg-bright);
  color: var(--fg-bright);
}

.term-btn.small {
  padding: 4px 9px;
  font-size: 12px;
}

.term-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.dim-note {
  color: var(--fg-dim);
  font-size: 13px;
}

.error-msg {
  color: var(--err);
  border: 1px solid var(--err);
  padding: 8px 12px;
  margin-top: 14px;
  text-shadow: none;
}

.managers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.manager-chip {
  border: 1px solid var(--fg-dim);
  padding: 4px 10px;
  font-size: 13px;
}

.manager-chip.you {
  border-color: var(--fg-bright);
  color: var(--fg-bright);
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
}

.team-card {
  border: 1px solid var(--fg-muted);
  background: #030803;
  color: var(--fg);
  font-family: inherit;
  min-height: 64px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  touch-action: manipulation;
}

.team-card:hover:not(:disabled) {
  border-color: var(--fg-bright);
  background: #0a1f0a;
}

.team-card.selected {
  border: 2px solid var(--fg-bright);
  background: #0d2b0d;
  color: var(--fg-bright);
}

.team-card.taken {
  opacity: 0.45;
  cursor: not-allowed;
}

.team-card .tc-name {
  font-weight: bold;
}

.team-card .tc-stats {
  font-size: 12px;
  color: var(--fg-dim);
}

.season-top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: bold;
  color: var(--fg-bright);
}

.match-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0 14px;
}

.team-side.right {
  text-align: right;
}

.team-big {
  font-size: 20px;
  font-weight: bold;
  color: var(--fg-bright);
}

.score-center {
  text-align: center;
  min-width: 110px;
}

.score-big {
  font-size: 32px;
  font-weight: bold;
  color: var(--fg-bright);
  letter-spacing: 0.08em;
}

.clock-big {
  font-size: 16px;
  color: var(--warn);
}

.progress-wrap {
  height: 12px;
  border: 1px solid var(--border);
  background: #020502;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--fg);
  transition: width 0.12s linear;
}

.goal-index-box {
  border-top: 1px dashed var(--fg-muted);
  padding-top: 10px;
}

.goal-index-title {
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.goal-feed {
  min-height: 90px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.goal-row {
  color: var(--fg-bright);
}

.other-live {
  margin-top: 12px;
  border-top: 1px dashed var(--fg-muted);
  padding-top: 8px;
  font-size: 13px;
  color: var(--fg-dim);
}

.fixtures-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 8px;
}

.fixture-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--fg-muted);
  background: #030803;
}

.fixture-row.human {
  border-color: var(--fg-bright);
  color: var(--fg-bright);
}

.fixture-row .f-home { text-align: right; }
.fixture-row .f-score { font-weight: bold; min-width: 48px; text-align: center; }

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

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.standings-table th,
.standings-table td {
  padding: 5px 8px;
  text-align: right;
  border-bottom: 1px solid #0e2c0e;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.standings-table th {
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
}

.standings-table tr.human-row {
  background: #0d2b0d;
  color: var(--fg-bright);
  font-weight: bold;
}

.standings-table tr.champ-row td:first-child {
  color: var(--warn);
}

.prompt-bar {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.season-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 640px) {
  .terminal {
    padding: 12px 10px 92px;
  }

  .term-box {
    padding: 12px;
  }

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

  .team-card .tc-name {
    font-size: 14px;
  }

  .team-card .tc-stats {
    font-size: 11px;
  }

  .match-header {
    gap: 6px;
  }

  .team-big {
    font-size: 15px;
    word-break: break-word;
  }

  .score-center {
    min-width: 82px;
  }

  .score-big {
    font-size: 24px;
  }

  .clock-big {
    font-size: 14px;
  }

  .fixtures-list {
    grid-template-columns: 1fr;
  }

  .standings-table {
    font-size: 12px;
  }

  .standings-table th,
  .standings-table td {
    padding: 5px 4px;
  }

  .prompt-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(4, 9, 4, 0.96);
    border-top: 2px solid var(--border);
  }

  .prompt-bar .term-btn {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
  }
}
