:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #657184;
  --line: #d8dee8;
  --paper: #f7f3e8;
  --panel: #ffffff;
  --grass: #17745a;
  --grass-dark: #0e4f40;
  --gold: #d9a441;
  --red: #c84646;
  --blue: #2c6bb3;
  --shadow: 0 18px 44px rgba(24, 32, 42, .14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(135deg, rgba(23, 116, 90, .18), transparent 36%),
    radial-gradient(circle at 82% 18%, rgba(217, 164, 65, .2), transparent 28%),
    var(--paper);
}

button {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 46px;
}

.shell--legal {
  width: min(860px, calc(100% - 32px));
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 22px;
  align-items: stretch;
  min-height: 390px;
  padding: 34px;
  overflow: hidden;
  border: 1px solid rgba(24, 32, 42, .12);
  border-radius: 8px;
  background:
    linear-gradient(130deg, rgba(24, 32, 42, .72), rgba(14, 79, 64, .82)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='620' viewBox='0 0 1200 620'%3E%3Crect width='1200' height='620' fill='%2317745a'/%3E%3Cg fill='none' stroke='rgba(255,255,255,.28)' stroke-width='8'%3E%3Cpath d='M80 70h1040v480H80z'/%3E%3Cpath d='M600 70v480'/%3E%3Ccircle cx='600' cy='310' r='92'/%3E%3Cpath d='M80 220h132v200H80M1120 220h-132v200h132'/%3E%3C/g%3E%3Cg fill='%23f7f3e8' fill-opacity='.9'%3E%3Ccircle cx='936' cy='126' r='22'/%3E%3Ccircle cx='272' cy='482' r='15'/%3E%3Ccircle cx='780' cy='470' r='10'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  box-shadow: var(--shadow);
}

.hero__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
}

.kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  line-height: .96;
  letter-spacing: 0;
}

.title-keep {
  white-space: nowrap;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.lead {
  max-width: 660px;
  color: rgba(255, 255, 255, .84);
  font-size: 1.08rem;
  line-height: 1.55;
}

.hero__actions,
.explain {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.language-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
}

.lang-button {
  min-width: 42px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.lang-button.is-active {
  color: #111820;
  background: var(--gold);
}

.sound-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  cursor: pointer;
  font-weight: 900;
}

.sound-button.is-active {
  color: #111820;
  border-color: transparent;
  background: var(--gold);
}

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.button--primary {
  color: #111820;
  background: var(--gold);
  box-shadow: 0 10px 24px rgba(217, 164, 65, .34);
}

.button--ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, .42);
  background: rgba(255, 255, 255, .1);
}

.button--secondary {
  color: #fff;
  background: var(--grass-dark);
}

.status-panel,
.board,
.summary,
.explain,
.legal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
}

.status-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  min-height: 260px;
}

.label,
dt {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

#statusText {
  display: block;
  font-size: 1.35rem;
  line-height: 1.25;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--grass), var(--gold));
  transition: width .25s ease;
}

.speed-control {
  display: grid;
  gap: 10px;
}

.speed-control label {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.speed-control .label {
  margin-bottom: 0;
}

#speedLabel {
  font-size: .92rem;
}

#speedRange {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
}

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

.stats div {
  min-width: 0;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.explain {
  justify-content: space-between;
  margin: 22px 0;
  padding: 18px 20px;
}

.explain p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, .78fr) minmax(0, 1.22fr);
  gap: 22px;
}

.board {
  min-width: 0;
  padding: 18px;
}

.board--scroll {
  height: 650px;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: .76rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge--muted {
  background: #6c7888;
}

.current-tip {
  display: grid;
  gap: 14px;
  align-content: center;
  min-height: 280px;
  padding: 22px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--grass-dark), #24394b);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  transform-origin: center;
}

.current-tip.pop {
  animation: popTip .34s ease;
}

@keyframes popTip {
  0% { transform: scale(.96); }
  45% { transform: scale(1.045); }
  100% { transform: scale(1); }
}

.empty {
  color: rgba(255, 255, 255, .74);
  line-height: 1.5;
}

.tip-round {
  color: var(--gold);
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tip-match {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 10px;
  align-items: center;
  text-align: center;
}

.team {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35em;
  max-width: 100%;
  min-width: 0;
  font-size: clamp(1.65rem, 3vw, 2rem);
  font-weight: 900;
  line-height: 1.08;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.flag {
  display: inline-block;
  line-height: 1;
}

.flag-drawn {
  position: relative;
  display: inline-block;
  width: 1.35em;
  height: .82em;
  overflow: hidden;
  border-radius: .08em;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(24, 32, 42, .16);
  line-height: 1;
}

.flag-drawn--england::before,
.flag-drawn--england::after,
.flag-drawn--scotland::before,
.flag-drawn--scotland::after {
  content: "";
  position: absolute;
}

.flag-drawn--england::before {
  top: 0;
  bottom: 0;
  left: 41%;
  width: 18%;
  background: #c8102e;
}

.flag-drawn--england::after {
  top: 38%;
  right: 0;
  left: 0;
  height: 24%;
  background: #c8102e;
}

.flag-drawn--scotland {
  background: #0065bd;
}

.flag-drawn--scotland::before,
.flag-drawn--scotland::after {
  top: 45%;
  left: -16%;
  width: 132%;
  height: 12%;
  background: #fff;
}

.flag-drawn--scotland::before {
  transform: rotate(31deg);
}

.flag-drawn--scotland::after {
  transform: rotate(-31deg);
}

.team:last-child {
  text-align: center;
}

.score {
  min-width: 92px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #111820;
  background: var(--gold);
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
}

.tip-score-row {
  display: grid;
  grid-template-columns: 4.8rem auto 4.8rem;
  gap: 14px;
  align-items: center;
}

.tip-score-flag {
  font-size: 4.65rem;
  line-height: 1;
  text-align: center;
}

.tip-line {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  line-height: 1.45;
}

.match-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100% - 42px);
  margin: 0;
  padding: 0 4px 8px 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  list-style: none;
}

.match {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e4e9ef;
  border-left: 5px solid var(--grass);
  border-radius: 8px;
  background: #fff;
}

.match.is-current {
  border-left-color: var(--gold);
  box-shadow: 0 8px 24px rgba(217, 164, 65, .18);
}

.match__round {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.match__teams {
  display: flex;
  flex-wrap: wrap;
  gap: 0 .35em;
  min-width: 0;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.match__note {
  display: flex;
  flex-wrap: wrap;
  gap: 0 .35em;
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.35;
}

.match__score {
  min-width: 58px;
  padding: 6px 8px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
  text-align: center;
}

.summary {
  margin-top: 22px;
  padding: 20px;
}

.summary[hidden] {
  display: none;
}

#winnerText {
  max-width: none;
  margin-bottom: 0;
  font-size: 1.1rem;
  line-height: 1.5;
}

.winner-hero {
  display: grid;
  gap: 6px;
  margin: 14px 0 12px;
  padding: 18px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--grass-dark), #172331);
}

.winner-hero__label {
  color: var(--gold);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.winner-hero strong {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

.winner-hero__flag {
  font-size: .9em;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 28px 0 18px;
  color: var(--muted);
  font-size: .92rem;
}

.site-footer a,
.legal a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover,
.legal a:hover {
  text-decoration: underline;
}

.legal {
  margin-top: 18px;
  padding: 22px;
  scroll-margin-top: 24px;
}

.legal h2 {
  margin-bottom: 16px;
  font-size: 1.45rem;
}

.legal h3 {
  margin: 20px 0 8px;
  font-size: 1rem;
}

.legal p {
  max-width: 860px;
  margin-bottom: 12px;
  color: #303c4b;
  line-height: 1.58;
}

.legal-header {
  margin-bottom: 18px;
  padding: 24px 0 4px;
}

.legal-header h1 {
  max-width: none;
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(2.1rem, 5vw, 4rem);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-bottom: 18px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, .84);
  font-weight: 900;
  text-decoration: none;
}

.back-link:hover {
  border-color: var(--grass);
}

.legal--standalone {
  margin-top: 0;
}

@media (max-width: 860px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 24px;
  }

  .board--scroll {
    height: 560px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: max(18px, calc(env(safe-area-inset-top, 0px) + 16px));
  }

  .hero {
    min-height: 0;
    padding: 20px;
  }

  .board {
    scroll-margin-top: max(18px, calc(env(safe-area-inset-top, 0px) + 16px));
  }

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

  .button {
    width: 100%;
  }

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

  .score {
    width: max-content;
    min-width: 88px;
  }

  .match__note {
    grid-column: auto;
  }
}

@media print {
  @page {
    margin: 12mm;
    size: A4;
  }

  body {
    color: #111820;
    font-size: 9.5pt;
    background: #fff;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .hero,
  .explain,
  .board,
  .summary {
    box-shadow: none;
  }

  .hero,
  .explain,
  .site-footer,
  .legal,
  .hero__actions,
  #printButton,
  #resetButton,
  #startButton {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .board {
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
  }

  .board:first-child {
    display: none;
  }

  .board--scroll {
    height: auto;
    overflow: visible;
  }

  .section-head {
    margin-bottom: 7mm;
    padding-bottom: 3mm;
    border-bottom: 1px solid #cfd6df;
  }

  .section-head h2 {
    font-size: 16pt;
  }

  .badge {
    min-height: 0;
    padding: 2px 7px;
    color: #111820;
    border: 1px solid #cfd6df;
    background: #fff;
    font-size: 8pt;
  }

  .match-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3mm;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .match {
    grid-template-columns: 21mm minmax(0, 1fr) 13mm;
    gap: 2mm;
    align-items: start;
    padding: 2.2mm 2.5mm;
    border: 1px solid #d8dee8;
    border-left: 2.5mm solid #17745a;
    border-radius: 0;
    box-shadow: none !important;
    break-inside: avoid;
  }

  .match__round {
    font-size: 6.8pt;
  }

  .match__teams {
    font-size: 8.8pt;
    line-height: 1.25;
  }

  .match__score {
    min-width: 0;
    padding: 0;
    color: #111820;
    background: transparent;
    font-size: 9pt;
  }

  .match__note {
    grid-column: 2 / 4;
    font-size: 7.7pt;
    line-height: 1.2;
  }

  .summary {
    margin-top: 8mm;
    padding: 4mm 0 0;
    border: 0;
    border-top: 1px solid #cfd6df;
    background: #fff;
    break-inside: avoid;
  }

  .summary .kicker {
    margin-bottom: 2mm;
    font-size: 7.5pt;
  }

  .summary h2 {
    margin-bottom: 2mm;
    font-size: 13pt;
  }

  #winnerText {
    font-size: 10pt;
    line-height: 1.35;
  }
}
