:root {
  --bg-page: #000000;
  --surface-1: #101114;
  --surface-2: #191b20;
  --surface-3: #23262d;
  --line: #343844;
  --text: #ffffff;
  --text-soft: #d8dde8;
  --text-muted: #a8b0bf;
  --accent: #ff8a21;
  --accent-2: #39d98a;
  --focus: #7bdcff;
  --danger: #ff5d73;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 600px;
  height: 600px;
  margin: 0;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html.install-mode,
body.install-mode {
  width: 100%;
  min-width: 320px;
  height: auto;
  min-height: 100%;
  overflow: auto;
  background: #090b0f;
}

#app {
  width: 600px;
  height: 600px;
  padding: 8px;
  position: relative;
}

.screen {
  width: 584px;
  height: 584px;
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: 8px;
}

.hidden {
  display: none !important;
}

h2,
p {
  margin: 0;
}

.install-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(57, 217, 138, 0.11), transparent 34%),
    #090b0f;
}

.install-content {
  width: min(920px, 100%);
  display: grid;
  gap: 28px;
}

.install-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.install-mark {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
}

.install-brand h1 {
  margin: 0;
  color: var(--text);
  font-size: 34px;
  line-height: 1.05;
  font-weight: 900;
}

.install-brand p,
.install-copy p,
.install-mobile p {
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.42;
}

.install-desktop {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: center;
  gap: 30px;
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.install-qr {
  width: 320px;
  height: 320px;
  display: block;
  border-radius: var(--radius);
  background: #ffffff;
}

.install-copy {
  display: grid;
  gap: 14px;
}

.install-copy h2 {
  color: var(--text);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
}

.install-url {
  max-width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.install-mobile {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.install-action {
  min-height: 88px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border-radius: var(--radius);
  background: var(--accent-2);
  color: #07120c;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  text-decoration: none;
}

.install-action:focus-visible {
  outline: none;
  box-shadow: 0 0 20px rgba(123, 220, 255, 0.5);
}

@media (max-width: 720px) {
  .install-page {
    align-items: stretch;
    padding: 20px;
  }

  .install-content {
    align-content: center;
  }

  .install-brand {
    align-items: flex-start;
  }

  .install-brand h1 {
    font-size: 30px;
  }
}

.game-status {
  justify-self: start;
  min-width: 112px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.game-status.live {
  color: #07120c;
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.score-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.game-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow: hidden;
}

.game-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 1fr);
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 700;
}

#game-count {
  justify-self: end;
  white-space: nowrap;
}

.game-footer {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
}

.matchup-row {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.matchup-row.has-series {
  grid-template-columns: minmax(0, 1fr) minmax(72px, auto) minmax(0, 1fr);
  gap: 14px;
}

.team-row {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  transition: transform 180ms ease;
}

.series-record {
  align-self: center;
  justify-self: center;
  min-width: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text-soft);
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: transform 180ms ease;
}

.team-label {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.team-code {
  max-width: 100%;
  font-size: 64px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-name {
  max-width: 100%;
  font-size: 20px;
  line-height: 1.2;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-score {
  width: 100%;
  min-width: 0;
  text-align: center;
  font-size: 128px;
  line-height: 0.9;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.team-row.leading .team-code,
.team-row.leading .team-score {
  color: var(--accent);
}

.game-card.score-position-up .team-row,
.game-card.score-position-up .series-record {
  transform: translateY(-124px);
}

.game-card.score-position-up .game-footer {
  height: 230px;
}

.play-by-play {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text-soft);
  font-size: var(--play-font-size, 22px);
  line-height: 1.08;
  text-align: center;
  overflow-wrap: anywhere;
  overflow: hidden;
}

.loading-container,
.error-container,
.empty-state {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}

.loading-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 5px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text,
.empty-state p,
.error-message {
  max-width: 420px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.32;
}

.error-icon,
.empty-symbol {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent);
  font-size: 36px;
  font-weight: 900;
}

.error-icon {
  color: var(--danger);
}
