:root {
  --ink: #171717;
  --paper: #f4f1ef;
  --line: rgba(23, 23, 23, 0.16);
  --muted: #6d6967;
  --display: "Segma", sans-serif;
  --sans: "Segma", sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(255,255,255,.95), transparent 30rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.scoreboard {
  width: min(100%, 1920px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(10px, 2vmin, 44px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(8px, 1.8vmin, 36px);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(190px, .75fr) 1.5fr minmax(190px, .75fr);
  align-items: center;
  padding-bottom: clamp(8px, 1.6vmin, 34px);
  border-bottom: 1px solid var(--line);
}

.brand { width: clamp(100px, 16vw, 300px); line-height: 0; }
.brand img { display: block; width: 100%; height: auto; }

.heading { text-align: center; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: clamp(10px, .75vw, 13px); font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.heading h1 { margin: 0; font-family: var(--display); font-size: clamp(24px, 4vmin, 72px); font-weight: 400; line-height: .95; }
.heading h1 em { font-weight: 400; }

.topbar-actions {
  justify-self: end;
  display: flex;
  gap: clamp(6px, .8vmin, 12px);
}

.reset-button,
.fullscreen-button {
  width: clamp(36px, 5vmin, 52px);
  min-height: clamp(36px, 5vmin, 52px);
  padding: 0;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: background .2s, color .2s, transform .15s;
  display: grid;
  place-items: center;
}
.reset-button > span:first-child,
.fullscreen-button > span:first-child { font-size: clamp(18px, 2.2vmin, 24px); line-height: 1; }
.reset-button:hover,
.fullscreen-button:hover { background: var(--ink); color: white; }
.reset-button:active,
.fullscreen-button:active { transform: scale(.97); }
.fullscreen-button[hidden] { display: none; }

.teams-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(6px, 1.2vmin, 24px);
  min-height: 0;
}

.team-card {
  --team: #777;
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto 1fr;
  align-items: center;
  padding: clamp(7px, 1.5vmin, 30px);
  isolation: isolate;
}
.team-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: clamp(7px, .55vw, 11px);
  background: var(--team);
}
.team-card--light::before { border-right: 1px solid var(--line); }
.team-card::after {
  content: "";
  position: absolute;
  width: 19rem;
  height: 19rem;
  right: -10rem;
  bottom: -13rem;
  border-radius: 50%;
  background: var(--team);
  opacity: .08;
  z-index: -1;
}

.team-name {
  grid-column: 1 / -1;
  margin: 0;
  padding-left: clamp(5px, 1vmin, 12px);
  font-family: var(--display);
  font-size: clamp(15px, 2.4vmin, 44px);
  font-weight: 400;
  line-height: 1;
}
.team-name span { color: var(--team-ink, var(--team)); }

.score {
  min-width: 1.5em;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(38px, 9vmin, 150px);
  font-variant-numeric: tabular-nums;
  line-height: .85;
}
.score.bump { animation: bump .24s ease-out; }

.score-button {
  width: clamp(32px, 6vmin, 88px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--team-ink, var(--team)) 55%, transparent);
  border-radius: 50%;
  background: white;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: clamp(20px, 3.4vmin, 48px);
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(0,0,0,.05);
  transition: transform .15s, background .18s, color .18s;
  touch-action: manipulation;
}
.score-button:first-of-type { justify-self: start; }
.score-button:last-of-type { justify-self: end; }
.score-button:hover { background: var(--team); color: color-mix(in srgb, var(--team-ink, var(--team)) 70%, black); transform: translateY(-2px); }
.team-card:not(.team-card--light) .score-button:hover { color: white; }
.score-button:active { transform: scale(.92); }
.score-button:focus-visible, .reset-button:focus-visible, .fullscreen-button:focus-visible, .dialog-button:focus-visible { outline: 3px solid var(--team, #171717); outline-offset: 3px; }

.footer { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.footer p { margin: 0; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: #4b8f64; }

.reset-dialog[hidden] { display: none; }
.reset-dialog { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(20,18,18,.52); backdrop-filter: blur(8px); }
.reset-dialog__panel { width: min(100%, 470px); padding: 38px; background: #fff; border-top: 8px solid #171717; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.reset-dialog h2 { margin: 0 0 10px; font-family: var(--display); font-size: 38px; font-weight: 400; line-height: 1.05; }
.reset-dialog__panel > p:not(.eyebrow) { color: var(--muted); }
.reset-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.dialog-button { min-height: 48px; padding: 0 18px; border: 1px solid var(--ink); cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.dialog-button--quiet { background: white; color: var(--ink); }
.dialog-button--primary { background: var(--ink); color: white; }

@keyframes bump { 50% { transform: scale(1.12); color: var(--team-ink, var(--team)); } }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; row-gap: clamp(5px, 1vmin, 12px); }
  .heading { grid-row: 2; grid-column: 1 / -1; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .teams-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .scoreboard { padding: 8px; gap: 7px; }
  .brand { width: clamp(90px, 30vw, 130px); }
  .heading h1 { font-size: clamp(22px, 7vw, 32px); }
  .reset-button, .fullscreen-button { font-size: 9px; letter-spacing: .04em; }
  .team-card::before { width: 5px; }
  .footer { font-size: 8px; letter-spacing: .03em; }
}

/* M¨®viles y tablets en horizontal: prioriza el espacio de juego. */
@media (max-height: 500px) {
  .scoreboard { padding: 6px 8px; gap: 5px; grid-template-rows: auto 1fr; }
  .topbar { grid-template-columns: auto 1fr auto; padding-bottom: 5px; }
  .brand { width: clamp(82px, 16vw, 130px); }
  .heading { grid-column: 2; grid-row: 1; }
  .heading .eyebrow { display: none; }
  .heading h1 { font-size: clamp(20px, 5.5vh, 29px); }
  .topbar-actions { grid-column: 3; grid-row: 1; }
  .reset-button, .fullscreen-button { width: 30px; min-height: 30px; font-size: 8px; }
  .teams-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .team-name { font-size: clamp(13px, 4vh, 19px); }
  .score { font-size: clamp(34px, 14vh, 62px); }
  .score-button { width: clamp(28px, 10vh, 42px); font-size: clamp(18px, 6vh, 25px); }
  .footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
