:root {
  --bg: #101010;
  --paper: #f7f1e8;
  --ink: #f8f3ea;
  --muted: #c8c0b7;
  --line: rgba(255, 255, 255, 0.18);
  --orange: #e87522;
  --blue: #1390bd;
  --red: #c7352f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.app {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 14px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(54px, 10vw, 124px);
  line-height: 0.9;
  letter-spacing: 0;
}

.tagline {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.18;
  font-weight: 800;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: min(360px, 42vw);
}

.score {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.score span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.score strong {
  display: block;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 0.95;
}

.score.fidesz {
  border-left: 6px solid var(--orange);
}

.score.tisza {
  border-left: 6px solid var(--blue);
}

.stage {
  position: relative;
  height: min(58vw, 580px);
  min-height: 440px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #121212 0%, #050505 100%);
}

.fog {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background: repeating-linear-gradient(
    -8deg,
    rgba(232, 117, 34, 0.11) 0,
    rgba(232, 117, 34, 0.11) 22px,
    transparent 22px,
    transparent 56px
  );
  transition: opacity 180ms ease;
}

.words {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.stage-notice {
  position: absolute;
  left: 50%;
  top: 18%;
  z-index: 5;
  max-width: min(520px, calc(100% - 36px));
  padding: 11px 16px;
  border: 2px solid var(--blue);
  border-radius: 8px;
  background: rgba(247, 241, 232, 0.94);
  color: #111;
  font-size: clamp(18px, 3vw, 32px);
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px) rotate(-2deg) scale(0.94);
}

.admin-message {
  position: absolute;
  left: 50%;
  top: 14px;
  z-index: 6;
  width: min(680px, calc(100% - 28px));
  padding: 12px 16px;
  border: 2px solid var(--blue);
  border-radius: 8px;
  background: rgba(247, 241, 232, 0.96);
  color: #111;
  font-size: clamp(16px, 2.2vw, 24px);
  font-weight: 950;
  line-height: 1.18;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
}

.admin-message.show {
  animation: adminMessageShow 7s ease-out forwards;
}

.stage-notice.show {
  animation: noticePop 1.35s ease-out forwards;
}

.stage-notice.bad {
  border-color: var(--orange);
}

@keyframes adminMessageShow {
  0% {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  8%,
  84% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

@keyframes noticePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -10px) rotate(-2deg) scale(0.9);
  }
  15%,
  72% {
    opacity: 1;
    transform: translate(-50%, 0) rotate(-2deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 8px) rotate(-2deg) scale(0.98);
  }
}

.portrait {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  width: min(690px, 98vw);
  aspect-ratio: 536 / 385;
  transform: translateX(-50%);
}

.base-portrait,
.open-portrait {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.open-portrait {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 70ms linear;
  pointer-events: none;
}

.portrait.speaking .open-portrait {
  opacity: 1;
}

.word {
  position: absolute;
  left: 50%;
  top: 54%;
  max-width: 250px;
  padding: 10px 13px;
  border: 2px solid var(--orange);
  border-radius: 8px;
  background: var(--paper);
  color: #111;
  font-size: clamp(15px, 2.2vw, 24px);
  font-weight: 900;
  line-height: 1.05;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.25);
  animation: wordFly 4s linear forwards;
}

.word.checked {
  border-color: var(--blue);
}

.counter-claim {
  position: absolute;
  max-width: min(360px, calc(100% - 34px));
  padding: 10px 14px;
  border: 2px solid var(--blue);
  border-radius: 8px;
  background: rgba(247, 241, 232, 0.96);
  color: #111;
  font-size: clamp(16px, 2.2vw, 25px);
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.25);
  animation: counterClaim 2.8s ease-out forwards;
}

@keyframes wordFly {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.86) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.02) rotate(var(--rot));
  }
}

@keyframes counterClaim {
  0% {
    opacity: 0;
    transform: translate(0, 10px) scale(0.92) rotate(0deg);
  }
  12%,
  74% {
    opacity: 1;
    transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot));
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--dx) * 1.08), calc(var(--dy) - 18px)) scale(0.98) rotate(var(--rot));
  }
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.connection-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.connection-panel > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.connection-panel strong {
  color: var(--ink);
  white-space: nowrap;
}

.connection-panel span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(200, 192, 183, 0.12);
}

.connection-panel.is-live .connection-dot {
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(19, 144, 189, 0.2);
}

.connection-panel.is-ended .connection-dot,
.connection-panel.is-error .connection-dot {
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(232, 117, 34, 0.2);
}

.reconnect-button {
  min-height: 34px;
  padding: 6px 12px;
  background: var(--paper);
  color: #111;
  font-size: 14px;
}

button {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #111;
  font: inherit;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 900;
  cursor: pointer;
}

.fidesz-button {
  background: var(--orange);
}

.tisza-button {
  background: var(--blue);
  color: white;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.site-footer > * + *::before {
  content: "-";
  margin-right: 10px;
  color: rgba(200, 192, 183, 0.62);
}

.footer-link {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: inherit;
  font-weight: inherit;
  text-decoration: none;
}

.footer-link:hover {
  color: var(--ink);
  filter: none;
  text-decoration: underline;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-backdrop[hidden],
.modal[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171717;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.54);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 4vw, 34px);
  line-height: 1.05;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.text-modal {
  max-width: 680px;
}

.text-modal h3,
.text-modal h4 {
  color: var(--ink);
  line-height: 1.2;
}

.text-modal h3 {
  margin: 0 0 12px;
  font-size: 20px;
}

.text-modal h4 {
  margin: 18px 0 7px;
  font-size: 16px;
}

.text-modal p,
.text-modal li {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
}

.text-modal p {
  margin: 0 0 10px;
}

.text-modal ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.text-modal a {
  color: #45c5ef;
  overflow-wrap: anywhere;
}

.history-rows {
  display: grid;
  gap: 7px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(92px, 120px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.history-row.is-today {
  border-color: rgba(247, 241, 232, 0.28);
  background: rgba(255, 255, 255, 0.07);
}

.history-date {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.history-bar {
  display: grid;
  grid-template-columns: var(--fidesz-share, 50%) var(--tisza-share, 50%);
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.history-bar span:first-child {
  background: var(--orange);
}

.history-bar span:last-child {
  background: var(--blue);
}

.history-score {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-width: 116px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

.history-score .fidesz-value {
  color: #ff9b4e;
}

.history-score .tisza-value {
  color: #45c5ef;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.8) brightness(0.76);
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .scoreboard {
    min-width: 0;
  }

  .kicker {
    margin-bottom: 9px;
    font-size: 12px;
  }

  h1 {
    font-size: clamp(58px, 18vw, 92px);
  }

  .stage {
    min-height: 430px;
  }

  .portrait {
    width: min(720px, 128vw);
  }

  .connection-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .connection-panel > div {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .connection-panel strong {
    white-space: normal;
  }

  .site-footer {
    align-items: center;
    flex-direction: column;
    gap: 6px;
  }

  .site-footer > * + *::before {
    content: "";
    margin-right: 0;
  }

  .modal {
    padding: 13px;
  }

  .modal-head {
    gap: 10px;
  }

  .history-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .history-score {
    justify-content: space-between;
    min-width: 0;
  }
}
