:root {
  --black: #000000;
  --blue: #1010ff;
  --cyan: #00ffff;
  --yellow: #ffff00;
  --white: #ffffff;
  --red: #ff0000;
  --green: #00ff55;
  --dim: #b9b9b9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--black);
  color: var(--cyan);
  font-family: "Courier New", "Lucida Console", "Consolas", monospace;
  font-weight: 900;
  font-variant-ligatures: none;
  font-synthesis: weight;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

body {
  min-width: 320px;
  min-height: 100vh;
}

/* Teletekst/bitmap utisak bez spoljnog font fajla. */
.title-bar h1,
.clock,
.event-row,
.last-label,
.last-line,
.connection,
.empty {
  text-shadow: 0.035em 0 currentColor;
}

.teletext-shell {
  width: 100vw;
  height: 100vh;
  padding: clamp(2px, .45vh, 6px) clamp(6px, 1vw, 18px) clamp(6px, 1vh, 14px);
  background: #000;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(4px, .7vh, 10px);
}

.title-bar {
  position: relative;
  min-height: clamp(34px, 5.3vh, 58px);
  background: var(--blue);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 clamp(8px, 1vw, 18px);
  color: var(--yellow);
}

.title-bar h1 {
  grid-column: 2;
  margin: 0;
  font-size: clamp(23px, 3.4vmin, 51px);
  line-height: 1;
  letter-spacing: .13em;
  white-space: nowrap;
}

.clock {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  color: var(--yellow);
  font-size: clamp(17px, 2.4vmin, 36px);
  line-height: 1;
  letter-spacing: .1em;
  white-space: nowrap;
}

.connection {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--white);
  font-size: clamp(9px, 1.05vmin, 14px);
  letter-spacing: .08em;
  white-space: nowrap;
}

.connection .dot {
  width: clamp(7px, .8vmin, 11px);
  height: clamp(7px, .8vmin, 11px);
  background: var(--yellow);
  border-radius: 50%;
}
.connection.online .dot { background: var(--green); }
.connection.offline .dot { background: var(--red); }
.connection.connecting .dot { background: var(--yellow); }

.events-panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.events {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: repeat(10, minmax(0, 1fr));
  align-items: stretch;
}

.event-row {
  display: grid;
  grid-template-columns:
    clamp(72px, 6.5vw, 130px)
    clamp(120px, 11vw, 220px)
    minmax(0, 1fr)
    clamp(88px, 7.5vw, 150px)
    clamp(170px, 12vw, 240px);
  column-gap: clamp(10px, 1.1vw, 22px);
  align-items: center;
  min-height: 0;
  font-size: clamp(20px, min(3.5vh, 2.5vw), 48px);
  line-height: 1;
  letter-spacing: .015em;
  white-space: nowrap;
}

.event-row .status {
  color: var(--yellow);
  width: 100%;
  text-align: left;
  justify-self: start;
}

.event-row .league {
  color: var(--yellow);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  justify-self: start;
}

.event-row .match {
  color: var(--cyan);
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: .4em;
  overflow: hidden;
}

.event-row .match .team-name:first-child {
  justify-self: end;
  text-align: right;
}

.event-row .match .team-name:last-child {
  justify-self: start;
  text-align: left;
}

.event-row .dash {
  color: var(--white);
  justify-self: center;
}

.team-name {
  display: inline-flex;
  align-items: center;
  gap: .28em;
  min-width: 0;
}

.red-card {
  display: inline-block;
  width: .48em;
  height: .72em;
  flex: 0 0 auto;
  background: var(--red);
  border: max(1px, .04em) solid #ff7777;
  vertical-align: .02em;
}

.event-row .score {
  color: var(--white);
  width: 100%;
  text-align: right;
  justify-self: stretch;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.score-sep {
  color: var(--white);
  display: inline-block;
  width: 1.15em;
  text-align: center;
  margin: 0;
}

.goal-score {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: .08em;
}

.scorer-score {
  color: var(--yellow);
}

.cancelled-score {
  color: var(--red);
}

.goal-marker {
  color: var(--green);
  font-size: .62em;
  line-height: 1;
  vertical-align: middle;
}

.event-row .half {
  color: var(--dim);
  width: 100%;
  justify-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.event-row.new-event {
  animation: teleFlash 900ms steps(2, end);
}

@keyframes teleFlash {
  0%, 45% { background: var(--yellow); color: #000; }
  46%, 100% { background: transparent; }
}

.empty {
  grid-row: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--yellow);
  font-size: clamp(18px, 2.3vmin, 32px);
  text-align: center;
}

.last-change {
  background: var(--blue);
  min-height: clamp(64px, 10.5vh, 112px);
  padding: clamp(4px, .6vh, 8px) clamp(8px, 1.1vw, 18px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.last-label {
  color: var(--yellow);
  font-size: clamp(9px, 1.2vmin, 16px);
  letter-spacing: .18em;
  margin-bottom: clamp(1px, .3vh, 4px);
  text-align: center;
}

.last-line {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(90px, 1fr) minmax(360px, 58vw) minmax(90px, 1fr);
  gap: clamp(8px, 1.2vw, 24px);
  align-items: center;
  font-size: clamp(24px, min(4.6vh, 3.1vw), 59px);
  line-height: 1;
  white-space: nowrap;
}

.last-country {
  color: var(--white);
  justify-self: start;
  text-align: left;
}

.last-match {
  color: var(--cyan);
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: .35em;
  overflow: hidden;
}

.last-match .team-name:first-child {
  justify-self: end;
  text-align: right;
}

.last-match .team-name:last-child {
  justify-self: start;
  text-align: left;
}

.last-dash {
  justify-self: center;
  color: var(--white);
}

.last-score {
  color: var(--white);
  text-align: center;
  font-size: 1.12em;
}

.last-change.flash {
  animation: lastFlash 800ms steps(2, end);
}

@keyframes lastFlash {
  0%, 45% { filter: brightness(1.8); }
  46%, 100% { filter: none; }
}


@media (max-width: 760px) {
  .event-row {
    grid-template-columns: minmax(0, .9fr) minmax(220px, 1.8fr) minmax(0, .9fr);
    gap: 6px;
  }
  .left-meta, .right-meta { gap: 7px; }
  .event-row .league, .event-row .half { display: none; }
  .last-line {
    grid-template-columns: minmax(52px, .6fr) minmax(220px, 2fr) minmax(70px, .7fr);
    gap: 6px;
  }
}
.error-box {
  margin: 0;
  padding: 6px 10px;
  border: 2px solid var(--red);
  color: var(--yellow);
  background: #220000;
  font-size: clamp(11px, 1.2vmin, 15px);
  white-space: pre-wrap;
  max-height: 12vh;
  overflow: auto;
}
.hidden { display: none; }

/* Uzak ekran: iskoristi dodatni prostor za krupniji teletekst. */
@media (min-width: 1500px) and (min-height: 850px) {
  .event-row { font-size: clamp(28px, min(3.6vh, 2.6vw), 51px); }
  .last-line { font-size: clamp(34px, min(4.8vh, 3.25vw), 63px); }
}

/* Uski ekrani: zadrži svih 10 događaja bez horizontalnog skrola. */
@media (max-width: 760px) {
  .teletext-shell {
    padding-left: 5px;
    padding-right: 5px;
  }

  .title-bar {
    grid-template-columns: auto 1fr auto;
    padding: 0 5px;
  }

  .title-bar h1 {
    letter-spacing: .045em;
    font-size: clamp(17px, 5.2vw, 27px);
  }

  .clock {
    font-size: clamp(12px, 3.7vw, 20px);
    letter-spacing: .03em;
  }

  .connection span:last-child { display: none; }

  .event-row {
    grid-template-columns: 50px 48px minmax(0, 1fr) 60px;
    gap: 4px;
    font-size: clamp(12px, 3.9vw, 20px);
    text-align: center;
    letter-spacing: .01em;
  }
  .event-row .half { display: none; }

  .last-line {
    grid-template-columns: minmax(105px, 25vw) 45px minmax(0, 1fr) 62px;
    gap: 4px;
    font-size: clamp(14px, 4.5vw, 24px);
  }
}

@media (max-width: 900px) {
  .event-row {
    grid-template-columns: 5.2ch 9ch minmax(0, 1fr) 4.8ch 6.5ch;
    column-gap: .45em;
  }
}

/* U v2.1 gol se označava samo žutom cifrom, bez zelene tačke. */
.goal-marker { display: none !important; }

/* v2.2 */
.header-right {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: clamp(8px, .7vw, 14px);
}

.header-right .connection {
  grid-column: auto;
  grid-row: auto;
}

.settings-button {
  border: 0;
  padding: 0;
  width: clamp(28px, 2.3vmin, 38px);
  height: clamp(28px, 2.3vmin, 38px);
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--white);
  font: inherit;
  font-size: clamp(19px, 2vmin, 30px);
  line-height: 1;
  cursor: pointer;
}

.settings-button:hover,
.settings-button:focus-visible {
  color: var(--yellow);
  outline: none;
}

.event-row .team-name,
.last-match .team-name {
  color: var(--white);
}

@media (max-width: 760px) {
  .header-right { gap: 3px; }
}
