* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --red: #e33535;
  --black: #101015;
  --blue: #111f50;
  --gold: #e0c05b;
  --grass: #1d7b39;
  --line: rgba(245, 255, 236, 0.82);
  --glass: rgba(7, 12, 21, 0.76);
  --glass-strong: rgba(8, 12, 20, 0.9);
  --text: #f7fbff;
  --muted: #b8c6d9;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #05090f;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

#app {
  position: relative;
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #071019;
}

.hud {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  pointer-events: none;
}

.scoreboard {
  display: grid;
  grid-template-columns: minmax(120px, auto) 92px minmax(120px, auto);
  align-items: stretch;
  overflow: hidden;
  min-width: min(540px, calc(100vw - 28px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(14, 20, 32, 0.92), rgba(3, 7, 13, 0.76));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.team-strip,
.clock-stack {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
}

.team-strip {
  gap: 13px;
  padding: 0 18px;
  font-size: clamp(0.8rem, 1.3vw, 1rem);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.team-strip strong {
  min-width: 34px;
  font-size: clamp(1.55rem, 2.6vw, 2rem);
  line-height: 1;
}

.team-strip.eag {
  background: linear-gradient(90deg, rgba(160, 14, 25, 0.95), rgba(22, 20, 25, 0.95));
}

.team-strip.paris {
  background: linear-gradient(90deg, rgba(11, 22, 57, 0.96), rgba(26, 45, 104, 0.96));
}

.clock-stack {
  flex-direction: column;
  border-inline: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(2, 4, 8, 0.62);
}

.clock-stack span {
  font-size: 1.08rem;
  font-weight: 900;
}

.clock-stack small {
  color: var(--gold);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.power-meter {
  position: absolute;
  left: 50%;
  bottom: 30px;
  z-index: 4;
  display: grid;
  grid-template-columns: 64px minmax(160px, 240px);
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  pointer-events: none;
}

.power-meter.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.power-meter span {
  padding: 7px 9px;
  border-radius: 6px;
  background: rgba(4, 8, 13, 0.82);
  color: #fff4bc;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

.power-meter div {
  overflow: hidden;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(2, 7, 12, 0.74);
}

.power-meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #43da6a, #ffe66b, #f05a52);
  box-shadow: 0 0 18px rgba(255, 224, 89, 0.55);
}

.match-toast {
  position: absolute;
  top: 108px;
  left: 50%;
  z-index: 4;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(4, 7, 12, 0.72);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.28);
  color: #fff;
  font-weight: 900;
  opacity: 0;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -12px) scale(0.98);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

.match-toast.active {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(1, 6, 11, 0.42), rgba(1, 3, 7, 0.78));
  backdrop-filter: blur(7px);
}

#menuScreen {
  background:
    linear-gradient(90deg, rgba(4, 7, 13, 0.78), rgba(4, 7, 13, 0.5)),
    linear-gradient(180deg, rgba(1, 5, 10, 0.25), rgba(1, 3, 7, 0.74)),
    url("./assets/guingamp-cup-night.png") center / cover no-repeat;
}

.screen.active {
  display: flex;
}

.menu-panel,
.modal-panel {
  width: min(680px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(11, 19, 33, 0.92), rgba(8, 12, 19, 0.93)),
    linear-gradient(90deg, rgba(227, 53, 53, 0.16), rgba(224, 192, 91, 0.12));
  box-shadow: 0 26px 120px rgba(0, 0, 0, 0.56);
}

.menu-panel {
  padding: clamp(24px, 4vw, 42px);
  background:
    linear-gradient(135deg, rgba(11, 19, 33, 0.78), rgba(8, 12, 19, 0.86)),
    linear-gradient(90deg, rgba(227, 53, 53, 0.16), rgba(224, 192, 91, 0.12));
  backdrop-filter: blur(8px);
}

.modal-panel {
  padding: 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 12ch;
  font-size: clamp(3rem, 9vw, 6.4rem);
}

h2 {
  font-size: clamp(2.3rem, 6vw, 4.3rem);
}

.fixture-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 28px;
  color: #ecf4ff;
  font-size: clamp(0.86rem, 1.8vw, 1rem);
  font-weight: 800;
}

.fixture-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.kit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 950;
  line-height: 1;
}

.red-black {
  background: linear-gradient(90deg, var(--red) 0 48%, #111 48% 100%);
}

.blue-gold {
  background: linear-gradient(90deg, #0d1d58 0 72%, var(--gold) 72% 100%);
}

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

.setting-block {
  display: grid;
  gap: 8px;
}

.setting-block label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.segmented {
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.62);
}

.segmented button,
.toggle,
.modal-actions button,
.primary-action {
  min-height: 42px;
  background: rgba(255, 255, 255, 0.06);
  color: #edf5ff;
  font-weight: 900;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.segmented button {
  flex: 1;
  padding: 0 12px;
}

.segmented button + button {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.segmented button:hover,
.toggle:hover,
.modal-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.segmented .selected,
.toggle.selected {
  background: linear-gradient(180deg, rgba(224, 192, 91, 0.95), rgba(171, 126, 35, 0.92));
  color: #071019;
}

.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
}

.toggle span {
  width: 24px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18);
}

.toggle.selected span {
  background: #071019;
}

.primary-action {
  width: 100%;
  min-height: 58px;
  margin-top: 24px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--red), #f28f3b);
  color: #fff;
  font-size: 1.08rem;
  box-shadow: 0 16px 54px rgba(227, 53, 53, 0.28);
}

.primary-action:hover {
  transform: translateY(-1px);
}

.pause-panel {
  width: min(500px, 100%);
}

.controls-grid,
.stats-grid {
  display: grid;
  gap: 8px 14px;
  margin-top: 22px;
}

.controls-grid {
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 1fr);
}

.controls-grid span,
.stat-label {
  color: var(--muted);
  font-weight: 700;
}

.controls-grid strong,
.stat-value {
  color: #fff;
  font-weight: 900;
  text-align: right;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 26px;
}

.modal-actions button {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
}

.final-panel {
  width: min(680px, 100%);
}

.final-score {
  margin-top: 18px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 950;
  text-align: center;
}

.stats-grid {
  grid-template-columns: 1fr auto auto;
  padding: 18px 0 0;
}

.stat-row {
  display: contents;
}

.stat-row > * {
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.stat-home {
  color: #ff7777;
  font-weight: 900;
}

.stat-away {
  color: #85a7ff;
  font-weight: 900;
  text-align: right;
}

.pom {
  margin: 22px 0 0;
  color: #fff4bc;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 720px) {
  .scoreboard {
    grid-template-columns: minmax(78px, auto) 76px minmax(78px, auto);
    min-width: calc(100vw - 20px);
  }

  .team-strip {
    gap: 8px;
    padding: 0 10px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .fixture-row {
    flex-wrap: wrap;
  }

  .modal-actions {
    flex-direction: column;
  }

  .power-meter {
    grid-template-columns: 56px minmax(140px, 56vw);
  }
}
