:root {
  color-scheme: dark;
  --bg: #10130f;
  --panel: #181d1a;
  --panel-strong: #202720;
  --line: #354035;
  --line-bright: #526050;
  --text: #eef3e8;
  --muted: #a9b4a5;
  --accent: #ffcf4d;
  --good: #45c46a;
  --bad: #f06d64;
  --grass: #2e7945;
  --grass-dark: #236239;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(119, 215, 232, 0.14), transparent 28rem),
    radial-gradient(circle at top left, rgba(255, 207, 77, 0.08), transparent 26rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="search"] {
  border: 1px solid var(--line);
  color: var(--text);
  background: #121612;
}

button {
  cursor: pointer;
}

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

button:hover:not(:disabled),
select:hover,
input[type="search"]:focus {
  border-color: var(--line-bright);
}

.app-shell {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.top-metrics,
.layout,
.stage-header,
.stage-actions,
.match-grid,
.match-actions,
.button-row,
.section-title,
.slider-row,
.scoreboard,
.score-team,
.momentum {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 10px 4px 18px;
}

.top-metrics {
  gap: 10px;
}

.metric,
.source-pill,
.rating-pill,
.small-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 26, 0.85);
  color: var(--muted);
  padding: 8px 11px;
  font-size: 0.78rem;
}

.metric span,
.metric strong {
  display: block;
}

.metric strong {
  color: var(--text);
  font-size: 1rem;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 3.1rem);
}

h2 {
  font-size: clamp(1.3rem, 2vw, 2rem);
}

.layout {
  align-items: stretch;
  gap: 14px;
}

.manager-panel,
.squad-panel {
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workspace {
  min-width: 0;
  flex: 1;
}

.panel-section,
.tool-panel,
.scoreboard {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 26, 0.92);
  box-shadow: var(--shadow);
}

.panel-section,
.tool-panel {
  padding: 13px;
}

.tool-panel.grow {
  flex: 1;
}

.section-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 39px;
  border-radius: 7px;
  padding: 0 10px;
  outline: none;
}

.small-button,
.stage-header button,
.phase-buttons button,
.segmented button,
.match-actions button,
.player-money button,
#beginCareerButton {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 10px;
  font-weight: 800;
}

.stage-header button,
.match-actions button:first-child,
.phase-buttons button.active,
.segmented button.active,
#beginCareerButton {
  background: var(--accent);
  color: #16140a;
  border-color: transparent;
}

.fixture-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #121612;
}

.fixture-card span,
.fixture-card p {
  color: var(--muted);
  font-size: 0.8rem;
}

.fixture-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1rem;
}

.fixture-card p {
  margin: 0;
}

.phase-buttons,
.segmented {
  display: grid;
  gap: 6px;
}

.phase-buttons {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 12px;
}

.slider-row {
  gap: 10px;
  margin: 10px 0;
}

.slider-row.compact {
  width: 210px;
  margin: 0 0 0 auto;
}

.slider-row span {
  width: 74px;
  color: var(--muted);
  font-size: 0.84rem;
}

.slider-row strong {
  width: 34px;
  text-align: right;
  font-size: 0.84rem;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.stage-view {
  display: none;
}

.stage-view.active {
  display: block;
}

.stage-header {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.stage-actions {
  gap: 8px;
}

.prep-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pregame-layout {
  display: flex;
  justify-content: center;
}

.lineup-panel {
  width: min(1180px, 100%);
}

.player-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-top: 10px;
  padding-right: 4px;
}

.player-row,
.lineup-item,
.lineup-slot,
.ladder-row,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(18, 22, 18, 0.86);
}

.player-row {
  display: grid;
  grid-template-columns: 1fr 126px;
  gap: 10px;
  align-items: center;
  padding: 9px;
}

.player-row.injured {
  border-color: rgba(240, 109, 100, 0.58);
}

.player-main b,
.lineup-item b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.player-main span,
.player-main em,
.lineup-item span,
.source-copy {
  color: var(--muted);
  font-size: 0.75rem;
}

.player-main em {
  display: block;
  color: var(--bad);
  font-style: normal;
}

.player-money {
  text-align: right;
}

.player-money strong {
  display: block;
  margin-bottom: 5px;
}

.player-money button {
  width: 100%;
}

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

.notice span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: #121612;
  font-size: 0.8rem;
}

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

.lineup-slot {
  display: grid;
  grid-template-columns: 34px 110px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
}

.lineup-slot span,
.jersey {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: #15130a;
  font-weight: 900;
}

.lineup-slot strong {
  font-size: 0.85rem;
}

.scoreboard {
  justify-content: space-between;
  min-height: 76px;
  padding: 10px 14px;
}

.score-team {
  width: 38%;
  gap: 10px;
}

.score-team.away {
  justify-content: flex-end;
  text-align: right;
}

.score-team span,
.clock span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.score-team strong {
  display: block;
  font-size: 2.1rem;
  line-height: 1;
}

.clock {
  text-align: center;
}

.clock strong {
  display: block;
  font-size: 1.55rem;
}

.crest,
.mini-crest,
.club-logo {
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  color: white;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.crest img,
.mini-crest img,
.club-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.crest {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px 8px 16px 16px;
  font-size: 0.78rem;
}

.pitch-wrap {
  margin-top: 14px;
  border: 1px solid #567b58;
  border-radius: 8px;
  overflow: hidden;
  background: #162115;
  box-shadow: var(--shadow);
}

.pitch {
  position: relative;
  height: min(52vh, 560px);
  min-height: 390px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.045) 0 2px, transparent 2px 80px),
    repeating-linear-gradient(0deg, var(--grass) 0 44px, var(--grass-dark) 44px 88px);
}

.pitch::before,
.pitch::after {
  content: "";
  position: absolute;
  inset: 28px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  pointer-events: none;
}

.pitch::after {
  inset: 36% 42%;
  border-radius: 999px;
}

.tryline,
.halfway,
.twenty,
.ten {
  position: absolute;
  top: 28px;
  bottom: 28px;
  width: 2px;
  background: rgba(255, 255, 255, 0.72);
}

.tryline.left { left: 28px; }
.tryline.right { right: 28px; }
.halfway { left: 50%; }
.twenty.left { left: 24%; }
.twenty.right { right: 24%; }
.ten.left { left: 41%; opacity: 0.55; }
.ten.right { right: 41%; opacity: 0.55; }

.ball {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 12px;
  border-radius: 50%;
  background: #d48a3b;
  border: 2px solid #6e3718;
  transform: translate(-50%, -50%) rotate(-18deg);
  transition: left 420ms ease, top 420ms ease;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.4);
}

.player-dot {
  position: absolute;
  z-index: 3;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  color: white;
  font-size: 0.67rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
  transition: left 340ms ease, top 340ms ease;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34);
}

.match-actions {
  gap: 8px;
  margin: 12px 0;
}

.match-grid {
  align-items: stretch;
  gap: 14px;
}

.match-grid .tool-panel {
  width: 50%;
}

.momentum {
  gap: 10px;
}

.momentum span {
  width: 32px;
  font-weight: 900;
}

.momentum-track {
  height: 12px;
  flex: 1;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-strong);
}

.momentum-track div {
  height: 100%;
  width: 50%;
  background: var(--good);
  transition: width 400ms ease, background 400ms ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-card {
  padding: 10px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: 1.12rem;
}

.commentary {
  height: 150px;
  margin: 0;
  padding: 0 0 0 22px;
  overflow: auto;
}

.commentary li {
  margin: 0 0 8px;
  color: #dfe8dc;
  font-size: 0.86rem;
}

.lineup-list,
.ladder {
  display: grid;
  gap: 7px;
}

.lineup-item {
  display: grid;
  grid-template-columns: 28px 1fr 46px;
  gap: 8px;
  align-items: center;
  padding: 8px;
}

.jersey {
  color: white;
  background: var(--panel-strong);
}

.lineup-item strong {
  text-align: right;
  color: var(--muted);
  font-size: 0.72rem;
}

.ladder-row {
  display: grid;
  grid-template-columns: 20px 1fr 24px 24px 24px 24px 32px;
  gap: 4px;
  align-items: center;
  padding: 6px 6px;
  font-size: 0.75rem;
}

.ladder-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ladder-row span,
.ladder-row strong {
  text-align: center;
}

.ladder-row strong:last-child {
  font-weight: 900;
  color: var(--accent);
}

.ladder-header {
  border-color: var(--line-bright);
  background: rgba(24, 29, 26, 0.6);
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.7rem;
}

.ladder-header b {
  color: var(--muted);
}

.club-card {
  display: grid;
  gap: 10px;
}

.club-banner {
  min-height: 82px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
}

.club-banner .club-logo {
  width: 64px;
  height: 64px;
  border-radius: 12px 12px 20px 20px;
  font-size: 1.4rem;
}

.club-banner strong {
  display: block;
}

.club-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.club-metrics span {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
}

.club-metrics b {
  display: block;
  color: var(--text);
  font-size: 1rem;
}

.career-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 8, 6, 0.82);
  backdrop-filter: blur(10px);
}

.career-modal.hidden {
  display: none;
}

.career-dialog {
  width: min(980px, 100%);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}

.career-team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
  max-height: 58vh;
  overflow: auto;
}

.career-team {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border-radius: 8px;
  text-align: left;
  padding: 8px;
}

.career-team.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mini-crest {
  width: 40px;
  height: 40px;
  border-radius: 8px 8px 14px 14px;
  font-size: 0.72rem;
}

@media (max-width: 1200px) {
  .layout {
    display: grid;
    grid-template-columns: 300px 1fr;
  }

  .squad-panel {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
  }
}

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

  .topbar,
  .layout,
  .stage-header,
  .prep-grid,
  .match-grid,
  .match-actions,
  .squad-panel {
    display: block;
  }

  .manager-panel,
  .squad-panel,
  .match-grid .tool-panel {
    width: 100%;
  }

  .manager-panel,
  .squad-panel,
  .tool-panel,
  .match-grid .tool-panel + .tool-panel {
    margin-top: 12px;
  }

  .top-metrics,
  .stage-actions,
  .match-actions {
    margin-top: 10px;
  }

  .slider-row.compact {
    width: 100%;
    margin-top: 10px;
  }

  .lineup-editor,
  .career-team-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .lineup-slot {
    grid-template-columns: 34px 92px 1fr;
  }

  .pitch {
    min-height: 430px;
  }
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  max-height: calc(100vh - 400px);
  overflow: auto;
  padding-right: 4px;
}

.strategy-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121612;
  padding: 10px;
  text-align: left;
  transition: all 200ms ease;
}

.strategy-card:hover:not(:disabled) {
  border-color: var(--line-bright);
  background: rgba(24, 29, 26, 0.6);
}

.strategy-card.selected {
  border-color: var(--accent);
  background: rgba(255, 207, 77, 0.12);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.strategy-card strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.strategy-card span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.live-calls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.live-calls-header {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.live-call-btn {
  width: 100%;
  min-height: auto;
  padding: 8px;
  margin-bottom: 6px;
  text-align: left;
  border-radius: 7px;
  transition: all 200ms ease;
}

.live-call-btn strong {
  display: block;
  font-size: 0.87rem;
}

.live-call-btn span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.live-call-btn:not(:disabled):hover {
  border-color: var(--line-bright);
  background: rgba(69, 196, 106, 0.14);
}

.live-call-btn.used {
  background: rgba(18, 22, 18, 0.4);
  border-color: var(--line);
  opacity: 0.5;
}

.live-calls-exhausted {
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 8px;
}

.game-strategy-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: calc(100vh - 300px);
  overflow: auto;
}

.decision-dialog {
  width: min(600px, 90%);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.decision-dialog h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.decision-dialog p {
  color: var(--muted);
  margin: 0 0 20px;
}

.decision-choices {
  display: grid;
  gap: 10px;
}

.decision-choice {
  min-height: 44px;
  padding: 12px;
  border-radius: 7px;
  background: rgba(255, 207, 77, 0.1);
  border: 1px solid var(--line-bright);
  color: var(--text);
  font-weight: 700;
  transition: all 200ms ease;
}

.decision-choice:hover {
  background: rgba(255, 207, 77, 0.18);
  border-color: var(--accent);
}

.decision-choice:active {
  transform: scale(0.98);
}
