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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #14181c;
  color: #eef2f5;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  background: #2e8b3d;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 20px;
  background: rgba(10, 14, 18, 0.82);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.hud-team0 {
  color: #6ea0ff;
}

.hud-team1 {
  color: #ff8a75;
}

#hud-score {
  font-size: 26px;
  min-width: 84px;
  text-align: center;
}

#hud-clock {
  font-variant-numeric: tabular-nums;
  padding-left: 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.25);
}

#hud-half {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.75;
  text-transform: uppercase;
}

#btn-pause {
  pointer-events: auto; /* #hud disables pointer events */
  font-size: 13px;
  padding: 4px 10px;
  line-height: 1;
}

/* ---------- Menu ---------- */

#menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  background: rgba(12, 16, 20, 0.92);
  text-align: center;
  overflow-y: auto;
  padding: 20px 12px;
}

/* Overlays taller than the stage must scroll, not clip. flex centering
   (justify-content) pushes overflow off the unreachable top edge, so center
   with auto margins instead: centered when short, scrollable when tall. */
#menu > :first-child,
#builder > :first-child,
#league > :first-child {
  margin-top: auto;
}

#menu > :last-child,
#builder > :last-child,
#league > :last-child {
  margin-bottom: auto;
}

.menu-primary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 560px;
}

.title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f4f8fb;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
}

.menu-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.btn {
  font: inherit;
  font-weight: 700;
  color: #eef2f5;
  background: #2a3138;
  border: 2px solid #454f58;
  border-radius: 10px;
  padding: 10px 26px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover {
  background: #343d46;
  border-color: #5c6873;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  font-size: 18px;
  min-width: 160px;
  padding: 10px 22px;
  background: #2f6fe0;
  border-color: #2258b8;
}

.btn-primary:hover {
  background: #3d7cec;
  border-color: #2f6fe0;
}

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.difficulty-label {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  margin-right: 6px;
}

.btn-diff,
.btn-switch,
.btn-controls,
.btn-goalie,
.btn-arrow,
.btn-keeperbox {
  font-size: 15px;
  padding: 7px 18px;
}

.btn-diff.selected,
.btn-switch.selected,
.btn-controls.selected,
.btn-goalie.selected,
.btn-arrow.selected,
.btn-keeperbox.selected {
  background: #2f6fe0;
  border-color: #6ea0ff;
}

/* ---------- Controls legend ---------- */

.controls-legend {
  display: flex;
  gap: 56px;
  margin-top: 8px;
}

.legend-col ul {
  list-style: none;
  text-align: left;
  font-size: 15px;
  line-height: 1.8;
}

.legend-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  text-align: left;
}

.legend-p1 {
  color: #6ea0ff;
}

.legend-p2 {
  color: #ff8a75;
}

.key {
  display: inline-block;
  min-width: 26px;
  padding: 1px 8px;
  margin-right: 8px;
  background: #22282e;
  border: 1px solid #454f58;
  border-bottom-width: 3px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.legend-pause {
  font-size: 14px;
  opacity: 0.75;
}

/* ---------- Team builder ---------- */

#builder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  background: #0d1115;
  overflow-y: auto;
  padding: 20px 12px;
}

.builder-title {
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.builder-cols {
  display: flex;
  gap: 24px 48px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.builder-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 360px;
}

.builder-name,
.builder-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.builder-name input {
  font: inherit;
  font-weight: 700;
  color: #eef2f5;
  background: #22282e;
  border: 2px solid #454f58;
  border-radius: 8px;
  padding: 6px 10px;
  flex: 1;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.slider-name {
  width: 150px;
  text-align: right;
  opacity: 0.8;
  text-transform: capitalize;
}

.slider-row input[type='range'] {
  flex: 1;
  min-width: 90px;
  accent-color: #2f6fe0;
}

.slider-val {
  width: 40px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.btn-formation {
  font-size: 14px;
  padding: 6px 14px;
  margin-right: 6px;
}

.btn-formation.selected {
  background: #2f6fe0;
  border-color: #6ea0ff;
}

#budget {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
}

.budget-bar {
  flex: 1;
  height: 8px;
  background: #22282e;
  border-radius: 4px;
  overflow: hidden;
}

#budget-fill {
  height: 100%;
  background: #69dd8a;
}

#attrs {
  display: flex;
  gap: 20px;
}

.attr-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attr-col .slider-name {
  width: 58px;
  font-size: 12px;
}

.attr-col .slider-val {
  width: 18px;
}

.attr-pos {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6ea0ff;
}

.builder-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#opponent {
  font: inherit;
  font-weight: 700;
  color: #eef2f5;
  background: #2a3138;
  border: 2px solid #454f58;
  border-radius: 10px;
  padding: 8px 12px;
}

/* ---------- AI League ---------- */

#league {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  background: #0d1115;
  overflow-y: auto;
  padding: 20px 12px;
}

.league-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* The sign-in disclosure sits on its own line above the email row: as a plain
   flex child it stretched the row and pushed the input to the edge. */
.league-privacy-note {
  /* The box must stay a full flex line or the email row fits beside it and
     the note never gets its own line — so constrain the TEXT with padding
     instead of max-width, which would shrink the box and undo the break. */
  flex-basis: 100%;
  padding: 0 max(16px, calc((100% - 640px) / 2));
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0.75;
}

.league-privacy-note a {
  color: #7cc4ff; /* default link blue is unreadable on this background */
}

.league-user {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.8;
}

.league-email {
  font: inherit;
  font-weight: 700;
  color: #eef2f5;
  background: #22282e;
  border: 2px solid #454f58;
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 220px;
}

.league-status {
  font-size: 14px;
  min-height: 18px;
  color: #69dd8a;
}

.league-status-error {
  color: #ff8b6b;
}

.league-panel {
  max-height: 40vh;
  overflow-y: auto;
}

.league-table {
  border-collapse: collapse;
  font-size: 15px;
}

.league-table th,
.league-table td {
  padding: 6px 14px;
  text-align: left;
}

.league-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.league-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

.league-link {
  font: inherit;
  font-weight: 700;
  color: #6ea0ff;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.league-link:hover {
  text-decoration: underline;
}

.league-challenge {
  font-size: 13px;
  padding: 4px 12px;
}

.league-form {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
}

.league-history-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 10px 0 6px;
  color: #6ea0ff;
}

.league-loading {
  font-size: 14px;
  opacity: 0.7;
}

#replay-note {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  background: rgba(10, 14, 18, 0.82);
  border-radius: 8px;
  font-size: 13px;
  color: #ffcf6e;
  pointer-events: none;
}

/* ---------- Banner ---------- */

#banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(12, 16, 20, 0.65);
  pointer-events: none;
}

#banner button {
  pointer-events: auto;
}

#banner-text {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

#pause-actions {
  display: flex;
  gap: 12px;
}

/* ---------- Guide ---------- */

#guide {
  position: absolute;
  inset: 0;
  background: #0d1115;
  overflow-y: auto;
  padding: 40px 20px 56px;
}

.guide-body {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.guide-body .builder-title {
  text-align: center;
}

.guide-body h2 {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6ea0ff;
  margin-top: 14px;
}

.guide-body p,
.guide-body li {
  font-size: 15px;
  line-height: 1.55;
  color: #c7d0d8;
}

.guide-body ul {
  list-style: disc;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-body strong {
  color: #eef2f5;
}

#btn-guide-back {
  align-self: center;
  margin-top: 18px;
}
