:root {
  --background: var(--md-sys-color-surface, #0f172a);
  --surface: var(--md-sys-color-surface-container, #1e293b);
  --surface-light: var(--md-sys-color-surface-container-high, #273549);
  --surface-border: var(--md-sys-color-outline, rgba(248, 250, 252, 0.16));

  --text-primary: var(--md-sys-color-on-surface, #f8fafc);
  --text-secondary: var(--md-sys-color-on-surface-variant, #94a3b8);
  --text-muted: #78859a;

  --primary: var(--md-sys-color-primary, #6366f1);
  --primary-light: #818cf8;
  --secondary: var(--md-sys-color-secondary, #34d399);

  --answer-red: #e73d4f;
  --answer-red-dark: #b91c35;

  --answer-blue: #287be0;
  --answer-blue-dark: #1d58aa;

  --answer-yellow: #f4b72b;
  --answer-yellow-dark: #c7840c;

  --answer-green: #24a860;
  --answer-green-dark: #14773f;

  --success: #34d399;
  --danger: var(--md-sys-color-error, #f87171);
  --warning: #f4b72b;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  font-family: Roboto, system-ui, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  color-scheme: dark;
  background: var(--background);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text-primary);
  background:
    radial-gradient(
      circle at 10% 0%,
      rgba(99, 102, 241, 0.22),
      transparent 34%
    ),
    radial-gradient(
      circle at 90% 100%,
      rgba(52, 211, 153, 0.1),
      transparent 30%
    ),
    var(--background);
}

button,
a {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(159, 103, 255, 0.8);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

/* =========================================================
   ESTRUTURA PRINCIPAL
   ========================================================= */

.screen-app {
  display: grid;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-rows:
    auto minmax(0, 1fr) auto;
  padding:
    calc(14px + var(--safe-top))
    calc(24px + var(--safe-right))
    calc(12px + var(--safe-bottom))
    calc(24px + var(--safe-left));
}

.screen-main {
  display: flex;
  width: min(100%, 1600px);
  min-height: 0;
  margin: 0 auto;
}

.screen-view {
  display: none;
  width: 100%;
  min-height: 0;
  animation: screenViewEnter 280ms ease-out;
}

.screen-view--active {
  display: flex;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 15px;
  color: var(--secondary);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

/* =========================================================
   CABEÇALHO
   ========================================================= */

.screen-topbar {
  z-index: 20;
  display: grid;
  width: min(100%, 1600px);
  min-height: 62px;
  grid-template-columns:
    minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  margin: 0 auto;
  gap: 20px;
}

.screen-brand {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-logo--screen {
  height: 48px;
}

.screen-brand__copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.screen-brand__copy strong {
  font-size: 1rem;
}

.screen-brand__copy small {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.screen-topbar__center {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.screen-topbar__center span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-connection {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  white-space: nowrap;
}

.screen-connection__indicator {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow:
    0 0 0 4px rgba(244, 183, 43, 0.13);
  animation: pulse 1.2s infinite;
}

.screen-connection--online
.screen-connection__indicator {
  background: var(--success);
  box-shadow:
    0 0 0 4px rgba(32, 200, 121, 0.13);
  animation: none;
}

.screen-connection--offline
.screen-connection__indicator {
  background: var(--danger);
  box-shadow:
    0 0 0 4px rgba(255, 93, 108, 0.13);
  animation: none;
}

/* =========================================================
   SEM SALA
   ========================================================= */

.no-room-view {
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  text-align: center;
}

.no-room-card {
  width: min(100%, 650px);
  border: 1px solid var(--surface-border);
  border-radius: 34px;
  padding: clamp(34px, 6vw, 70px);
  background: rgba(17, 24, 39, 0.83);
  box-shadow:
    0 30px 100px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.no-room-card__logo {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 28px;
  object-fit: contain;
}

.no-room-card h1 {
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.no-room-card p {
  max-width: 540px;
  margin: 24px auto 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.6;
}

.screen-action-link {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  margin-top: 30px;
  border: 1px solid rgba(159, 103, 255, 0.4);
  border-radius: 14px;
  padding: 13px 20px;
  gap: 10px;
  color: #ffffff;
  font-weight: 900;
  text-decoration: none;
  background: rgba(124, 58, 237, 0.18);
  transition:
    transform 140ms ease,
    filter 140ms ease;
}

.screen-action-link:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

/* =========================================================
   LOBBY
   ========================================================= */

.lobby-screen-view {
  align-items: center;
  justify-content: center;
  padding: 35px 0;
}

.lobby-screen-layout {
  display: grid;
  width: 100%;
  grid-template-columns:
    minmax(0, 1.1fr)
    minmax(390px, 0.8fr);
  align-items: center;
  gap: clamp(42px, 7vw, 120px);
}

.lobby-screen-hero {
  min-width: 0;
}

.lobby-screen-hero h1 {
  margin: 0;
  font-size: clamp(4rem, 9vw, 8.5rem);
  line-height: 0.85;
  letter-spacing: -0.075em;
}

.lobby-screen-hero > p {
  max-width: 760px;
  margin: 30px 0 0;
  color: var(--text-secondary);
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  line-height: 1.5;
}

.join-address {
  display: flex;
  min-width: 0;
  align-items: baseline;
  margin-top: 30px;
  gap: 12px;
  color: var(--text-secondary);
}

.join-address span {
  flex: 0 0 auto;
}

.join-address strong {
  overflow: hidden;
  color: var(--secondary);
  font-size: clamp(1rem, 2vw, 1.55rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-access-area {
  display: flex;
  align-items: stretch;
  margin-top: 27px;
  gap: 16px;
}

.screen-pin-card {
  width: max-content;
  border: 1px solid rgba(159, 103, 255, 0.45);
  border-radius: 24px;
  padding: 22px 30px;
  background: rgba(124, 58, 237, 0.14);
  box-shadow:
    0 20px 60px rgba(124, 58, 237, 0.14);
}

.lobby-access-area .screen-pin-card {
  display: flex;
  min-width: 320px;
  flex-direction: column;
  justify-content: center;
}

.screen-pin-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.screen-pin-card strong {
  font-size: clamp(2.8rem, 6vw, 5.5rem);
  line-height: 1;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.screen-qr-card {
  display: flex;
  min-width: 350px;
  align-items: center;
  border: 1px solid var(--surface-border);
  border-radius: 24px;
  padding: 14px;
  gap: 16px;
  background: rgba(17, 24, 39, 0.84);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.18);
}

.screen-qr-code {
  position: relative;
  display: grid;
  width: 146px;
  height: 146px;
  flex: 0 0 146px;
  overflow: hidden;
  place-items: center;
  border: 9px solid #ffffff;
  border-radius: 16px;
  color: #111827;
  background: #ffffff;
}

.screen-qr-code img,
.screen-qr-code canvas {
  display: block;
  width: 128px !important;
  height: 128px !important;
  max-width: 100%;
}

.screen-qr-card__copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.screen-qr-card__copy strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.screen-qr-card__copy span {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.screen-qr-code--error {
  border-color: rgba(255, 93, 108, 0.5);
  padding: 8px;
  color: #8a1725;
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  background: #fff0f2;
}

.screen-qr-code--warning {
  box-shadow:
    0 0 0 4px rgba(244, 183, 43, 0.3);
}

.lobby-hint {
  margin-top: 25px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.lobby-players-area {
  min-height: min(68vh, 680px);
  border: 1px solid var(--surface-border);
  border-radius: 30px;
  padding: clamp(24px, 4vw, 38px);
  background: rgba(17, 24, 39, 0.82);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.lobby-players-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--surface-border);
  gap: 20px;
}

.lobby-players-header > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lobby-players-header span {
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.lobby-players-header strong {
  display: grid;
  min-width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: var(--secondary);
  background: rgba(22, 199, 162, 0.1);
}

.waiting-pulse {
  display: flex;
  gap: 7px;
}

.waiting-pulse span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: waitingBounce 1.1s infinite ease-in-out;
}

.waiting-pulse span:nth-child(2) {
  animation-delay: 120ms;
}

.waiting-pulse span:nth-child(3) {
  animation-delay: 240ms;
}

.lobby-players-empty {
  display: flex;
  min-height: 360px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--text-muted);
  text-align: center;
}

.lobby-players-empty > div {
  margin-bottom: 14px;
  font-size: 3rem;
  opacity: 0.7;
}

.lobby-players-empty p {
  max-width: 320px;
  margin: 0;
  line-height: 1.55;
}

.lobby-players-list {
  display: flex;
  max-height: min(56vh, 550px);
  flex-direction: column;
  margin: 20px 0 0;
  overflow-y: auto;
  padding: 0 5px 0 0;
  gap: 10px;
  list-style: none;
}

.lobby-player-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--surface-border);
  border-radius: 15px;
  padding: 11px 14px;
  gap: 12px;
  background: rgba(255, 255, 255, 0.035);
  animation: playerEnter 300ms both;
}

.lobby-player-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
  background:
    linear-gradient(
      145deg,
      var(--primary-light),
      var(--primary)
    );
}

.lobby-player-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   PERGUNTA
   ========================================================= */

.question-screen-view {
  min-height: 0;
  flex-direction: column;
  padding: 24px 0;
}

.question-screen-header {
  display: flex;
  min-height: 130px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 30px;
}

.question-screen-header__copy {
  min-width: 0;
}

.question-counter {
  color: var(--secondary);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.question-screen-header h1 {
  max-width: 1250px;
  margin: 9px 0 0;
  font-size: clamp(2.1rem, 5vw, 5.2rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.screen-timer {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
  place-items: center;
}

.screen-timer__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.screen-timer__background,
.screen-timer__progress {
  fill: none;
  stroke-width: 8px;
}

.screen-timer__background {
  stroke: rgba(255, 255, 255, 0.1);
}

.screen-timer__progress {
  stroke: var(--secondary);
  stroke-linecap: round;
  stroke-dasharray: 320.44;
  stroke-dashoffset: 0;
  transition:
    stroke-dashoffset 100ms linear,
    stroke 180ms ease;
}

.screen-timer strong {
  z-index: 1;
  margin-top: -6px;
  font-size: 2rem;
  font-weight: 900;
}

.screen-timer > span {
  position: absolute;
  z-index: 1;
  margin-top: 37px;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.screen-timer--danger
.screen-timer__progress {
  stroke: var(--danger);
}

.screen-timer--danger strong {
  color: var(--danger);
}

.screen-answer-grid {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  grid-template-rows:
    repeat(2, minmax(160px, 1fr));
  gap: clamp(14px, 2vw, 22px);
}

.screen-answer {
  position: relative;
  display: flex;
  min-height: 170px;
  align-items: center;
  overflow: hidden;
  border-radius: clamp(20px, 3vw, 32px);
  padding: clamp(25px, 4vw, 48px);
  gap: clamp(20px, 3vw, 38px);
  box-shadow:
    0 12px 0 rgba(0, 0, 0, 0.2);
}

.screen-answer::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.18),
      transparent 45%,
      rgba(0, 0, 0, 0.12)
    );
  pointer-events: none;
}

.screen-answer--red {
  background:
    linear-gradient(
      145deg,
      var(--answer-red),
      var(--answer-red-dark)
    );
}

.screen-answer--blue {
  background:
    linear-gradient(
      145deg,
      var(--answer-blue),
      var(--answer-blue-dark)
    );
}

.screen-answer--yellow {
  background:
    linear-gradient(
      145deg,
      var(--answer-yellow),
      var(--answer-yellow-dark)
    );
}

.screen-answer--green {
  background:
    linear-gradient(
      145deg,
      var(--answer-green),
      var(--answer-green-dark)
    );
}

.screen-answer__shape {
  z-index: 1;
  width: clamp(50px, 6vw, 82px);
  height: clamp(50px, 6vw, 82px);
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.96);
  filter:
    drop-shadow(
      0 8px 12px rgba(0, 0, 0, 0.18)
    );
}

.screen-answer__shape--triangle {
  width: 0;
  height: 0;
  border-right:
    clamp(28px, 3.5vw, 45px)
    solid transparent;
  border-bottom:
    clamp(50px, 6vw, 80px)
    solid rgba(255, 255, 255, 0.96);
  border-left:
    clamp(28px, 3.5vw, 45px)
    solid transparent;
  background: transparent;
}

.screen-answer__shape--diamond {
  transform: rotate(45deg) scale(0.8);
}

.screen-answer__shape--circle {
  border-radius: 50%;
}

.screen-answer__shape--square {
  border-radius: 7px;
}

.screen-answer__content {
  z-index: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.screen-answer__letter {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.screen-answer__text {
  overflow: hidden;
  font-size: clamp(1.25rem, 2.4vw, 2.4rem);
  line-height: 1.15;
  text-overflow: ellipsis;
}

.question-screen-footer {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  margin-top: 22px;
  gap: 22px;
}

.received-answers {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text-secondary);
}

.received-answers span {
  font-size: 0.82rem;
}

.received-answers strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.response-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.response-progress__bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(
      90deg,
      var(--primary-light),
      var(--secondary)
    );
  transition: width 260ms ease;
}

/* =========================================================
   RESULTADOS
   ========================================================= */

.results-screen-view {
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  padding: 30px 0;
}

.results-screen-header,
.leaderboard-screen-header,
.finished-screen-header {
  margin-bottom: 30px;
  text-align: center;
}

.results-screen-header h1,
.leaderboard-screen-header h1,
.finished-screen-header h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.results-screen-header p,
.leaderboard-screen-header p,
.finished-screen-header p {
  margin: 17px 0 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 2vw, 1.3rem);
}

.results-screen-layout {
  display: grid;
  min-height: 0;
  grid-template-columns:
    minmax(0, 1fr) minmax(280px, 0.32fr);
  align-items: stretch;
  gap: 25px;
}

.screen-results-chart {
  display: grid;
  min-height: 430px;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  align-items: end;
  border: 1px solid var(--surface-border);
  border-radius: 30px;
  padding: clamp(24px, 4vw, 40px);
  gap: clamp(12px, 2vw, 25px);
  background: rgba(17, 24, 39, 0.83);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.25);
}

.screen-result-column {
  display: grid;
  min-width: 0;
  height: 100%;
  grid-template-rows: minmax(220px, 1fr) auto;
  gap: 15px;
}

.screen-result-column__visual {
  display: flex;
  min-height: 0;
  align-items: center;
  flex-direction: column;
}

.screen-result-column__value {
  min-height: 28px;
  margin-bottom: 12px;
  font-size: clamp(0.85rem, 1.4vw, 1.15rem);
  text-align: center;
}

.screen-result-column__track {
  position: relative;
  width: min(100%, 110px);
  flex: 1;
  overflow: hidden;
  border-radius: 16px 16px 7px 7px;
  background: rgba(255, 255, 255, 0.07);
}

.screen-result-column__bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 0;
  border-radius: inherit;
  transition: height 550ms ease;
}

.screen-result-column--red
.screen-result-column__bar {
  background:
    linear-gradient(
      180deg,
      var(--answer-red),
      var(--answer-red-dark)
    );
}

.screen-result-column--blue
.screen-result-column__bar {
  background:
    linear-gradient(
      180deg,
      var(--answer-blue),
      var(--answer-blue-dark)
    );
}

.screen-result-column--yellow
.screen-result-column__bar {
  background:
    linear-gradient(
      180deg,
      var(--answer-yellow),
      var(--answer-yellow-dark)
    );
}

.screen-result-column--green
.screen-result-column__bar {
  background:
    linear-gradient(
      180deg,
      var(--answer-green),
      var(--answer-green-dark)
    );
}

.screen-result-column--correct
.screen-result-column__track {
  box-shadow:
    0 0 0 4px #ffffff,
    0 0 30px rgba(255, 255, 255, 0.2);
}

.screen-result-column__answer {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.screen-result-column__answer > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.09);
}

.screen-result-column__text {
  overflow: hidden;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.correct-answer-card {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid rgba(32, 200, 121, 0.3);
  border-radius: 30px;
  padding: clamp(25px, 4vw, 42px);
  text-align: center;
  background:
    linear-gradient(
      180deg,
      rgba(32, 200, 121, 0.1),
      rgba(17, 24, 39, 0.84)
    );
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.24);
}

.correct-answer-card__label {
  color: var(--success);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.correct-answer-card > strong {
  display: grid;
  width: 100px;
  height: 100px;
  margin-top: 22px;
  place-items: center;
  border-radius: 28px;
  color: #ffffff;
  font-size: 3.4rem;
  background: var(--success);
  box-shadow:
    0 20px 60px rgba(32, 200, 121, 0.25);
}

.correct-answer-card > p {
  margin: 24px 0 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.correct-answer-card__stat {
  width: 100%;
  margin-top: 28px;
  border-top: 1px solid var(--surface-border);
  padding-top: 20px;
}

.correct-answer-card__stat span {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.correct-answer-card__stat strong {
  display: block;
  margin-top: 8px;
  color: var(--secondary);
  font-size: 2rem;
}

/* =========================================================
   RANKING
   ========================================================= */

.leaderboard-screen-view {
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  padding: 30px 0;
}

.screen-leaderboard-list {
  display: flex;
  width: min(100%, 900px);
  flex-direction: column;
  margin: 0 auto;
  padding: 0;
  gap: 11px;
  list-style: none;
}

.screen-leaderboard-item {
  display: grid;
  grid-template-columns:
    58px minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 15px 22px;
  gap: 16px;
  background: rgba(17, 24, 39, 0.84);
  animation: rankingEnter 360ms both;
}

.screen-leaderboard-item:first-child {
  border-color: rgba(244, 183, 43, 0.4);
  background:
    linear-gradient(
      90deg,
      rgba(244, 183, 43, 0.13),
      rgba(17, 24, 39, 0.84)
    );
}

.screen-leaderboard-position {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.08);
}

.screen-leaderboard-name {
  overflow: hidden;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-leaderboard-score {
  color: var(--secondary);
  font-size: clamp(0.95rem, 1.8vw, 1.2rem);
  white-space: nowrap;
}

.leaderboard-waiting-message {
  margin: 25px 0 0;
  color: var(--text-muted);
  text-align: center;
}

/* =========================================================
   RESULTADO FINAL E PÓDIO
   ========================================================= */

.finished-screen-view {
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  padding: 28px 0;
}

.podium {
  display: grid;
  width: min(100%, 1000px);
  min-height: 390px;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  align-items: end;
  margin: 0 auto;
  gap: clamp(10px, 2vw, 22px);
}

.podium-place {
  display: flex;
  min-width: 0;
  align-items: stretch;
  flex-direction: column;
  animation:
    podiumEnter 650ms
    cubic-bezier(0.2, 0.9, 0.2, 1)
    both;
}

.podium-place--first {
  animation-delay: 100ms;
}

.podium-place--second {
  animation-delay: 220ms;
}

.podium-place--third {
  animation-delay: 340ms;
}

.podium-player {
  display: flex;
  min-height: 130px;
  align-items: center;
  justify-content: flex-end;
  flex-direction: column;
  padding: 15px 10px 20px;
  text-align: center;
}

.podium-medal {
  margin-bottom: 10px;
  font-size: 2.5rem;
}

.podium-player__name {
  width: 100%;
  overflow: hidden;
  font-size: clamp(1rem, 2vw, 1.4rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-player__score {
  margin-top: 7px;
  color: var(--secondary);
  font-weight: 900;
}

.podium-base {
  display: grid;
  min-height: 140px;
  place-items: center;
  border: 1px solid var(--surface-border);
  border-radius: 25px 25px 8px 8px;
  background:
    linear-gradient(
      180deg,
      rgba(124, 58, 237, 0.32),
      rgba(17, 24, 39, 0.9)
    );
}

.podium-place--first .podium-base {
  min-height: 250px;
  border-color: rgba(244, 183, 43, 0.45);
  background:
    linear-gradient(
      180deg,
      rgba(244, 183, 43, 0.3),
      rgba(17, 24, 39, 0.9)
    );
}

.podium-place--second .podium-base {
  min-height: 190px;
}

.podium-place--third .podium-base {
  min-height: 145px;
}

.podium-base strong {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(3rem, 7vw, 6rem);
}

.podium-place--empty {
  opacity: 0.42;
}

.final-stats {
  display: grid;
  width: min(100%, 720px);
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  margin: 28px auto 0;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  border-radius: 22px;
  background: rgba(17, 24, 39, 0.82);
}

.final-stats > div {
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 18px 12px;
  gap: 7px;
}

.final-stats > div + div {
  border-left: 1px solid var(--surface-border);
}

.final-stats span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.final-stats strong {
  font-size: 1.5rem;
}

/* =========================================================
   CONTAGEM REGRESSIVA
   ========================================================= */

.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #ffffff;
  background:
    radial-gradient(
      circle,
      rgba(124, 58, 237, 0.5),
      rgba(8, 13, 26, 0.98) 62%
    );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.countdown-overlay span {
  color: var(--secondary);
  font-size: clamp(1rem, 3vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.countdown-overlay strong {
  margin-top: 15px;
  font-size: clamp(9rem, 28vw, 25rem);
  line-height: 0.85;
}

.countdown-value--animate {
  animation: countdownPop 430ms ease-out;
}

/* =========================================================
   CONFETES
   ========================================================= */

.confetti-container {
  position: fixed;
  inset: 0;
  z-index: 90;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -30px;
  opacity: 0.95;
  animation: confettiFall linear forwards;
}

/* =========================================================
   TOAST
   ========================================================= */

.screen-toast {
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 120;
  max-width: min(420px, calc(100vw - 48px));
  border: 1px solid var(--surface-border);
  border-radius: 15px;
  padding: 15px 19px;
  color: var(--text-primary);
  background: rgba(17, 24, 39, 0.97);
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.screen-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   RODAPÉ
   ========================================================= */

.screen-footer {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.68rem;
  text-align: center;
}

.noscript-message {
  padding: 20px;
  color: #ffffff;
  background: #b91c35;
  font-weight: 800;
  text-align: center;
}

/* =========================================================
   ANIMAÇÕES
   ========================================================= */

@keyframes screenViewEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes waitingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-8px);
  }
}

@keyframes playerEnter {
  from {
    opacity: 0;
    transform:
      scale(0.85)
      translateY(8px);
  }

  to {
    opacity: 1;
    transform:
      scale(1)
      translateY(0);
  }
}

@keyframes rankingEnter {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes podiumEnter {
  from {
    opacity: 0;
    transform: translateY(80px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes countdownPop {
  from {
    opacity: 0;
    transform: scale(1.7);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes confettiFall {
  from {
    transform:
      translate3d(0, -5vh, 0)
      rotate(0);
  }

  to {
    transform:
      translate3d(
        var(--confetti-x),
        110vh,
        0
      )
      rotate(
        var(--confetti-rotation)
      );
  }
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

/* =========================================================
   TELAS ATÉ 1200PX
   ========================================================= */

@media (max-width: 1200px) {
  .lobby-screen-layout {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(330px, 0.7fr);
    gap: 35px;
  }

  .lobby-access-area {
    flex-direction: column;
  }

  .lobby-access-area .screen-pin-card,
  .screen-qr-card {
    width: 100%;
    min-width: 0;
  }

  .screen-pin-card strong {
    font-size: clamp(2.7rem, 7vw, 4.8rem);
  }
}

/* =========================================================
   TELAS ATÉ 1100PX
   ========================================================= */

@media (max-width: 1100px) {
  .results-screen-layout {
    grid-template-columns: 1fr;
  }

  .correct-answer-card {
    display: grid;
    grid-template-columns:
      auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    text-align: left;
  }

  .correct-answer-card > strong {
    width: 76px;
    height: 76px;
    margin: 0;
    font-size: 2.5rem;
  }

  .correct-answer-card > p {
    margin: 0;
  }

  .correct-answer-card__stat {
    width: auto;
    margin: 0;
    border-top: 0;
    border-left: 1px solid var(--surface-border);
    padding-top: 0;
    padding-left: 20px;
    text-align: center;
  }
}

/* =========================================================
   TABLETS
   ========================================================= */

@media (max-width: 850px) {
  .screen-app {
    padding-right:
      calc(14px + var(--safe-right));
    padding-left:
      calc(14px + var(--safe-left));
  }

  .screen-topbar {
    grid-template-columns: 1fr auto;
  }

  .screen-topbar__center {
    display: none;
  }

  .screen-brand__copy small {
    display: none;
  }

  .lobby-screen-layout {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 28px 0;
  }

  .lobby-screen-hero {
    text-align: center;
  }

  .lobby-screen-hero h1 {
    font-size: clamp(3.4rem, 13vw, 6rem);
  }

  .join-address {
    justify-content: center;
  }

  .lobby-access-area {
    width: min(100%, 620px);
    margin-right: auto;
    margin-left: auto;
  }

  .screen-pin-card {
    margin-right: auto;
    margin-left: auto;
  }

  .screen-qr-card {
    justify-content: center;
    text-align: left;
  }

  .lobby-players-area {
    min-height: 270px;
  }

  .lobby-players-empty {
    min-height: 160px;
  }

  .question-screen-header {
    min-height: 100px;
  }

  .screen-timer {
    width: 95px;
    height: 95px;
    flex-basis: 95px;
  }

  .screen-timer strong {
    font-size: 1.6rem;
  }

  .screen-timer > span {
    margin-top: 29px;
  }

  .screen-answer-grid {
    grid-template-rows:
      repeat(2, minmax(135px, 1fr));
  }

  .screen-answer {
    min-height: 140px;
    padding: 22px;
  }

  .screen-results-chart {
    min-height: 370px;
  }

  .screen-result-column {
    grid-template-rows:
      minmax(180px, 1fr) auto;
  }
}

/* =========================================================
   CELULARES E TELAS ESTREITAS
   ========================================================= */

@media (max-width: 620px) {
  .screen-app {
    padding-top:
      calc(10px + var(--safe-top));
    padding-bottom:
      calc(10px + var(--safe-bottom));
  }

  .screen-topbar {
    min-height: 52px;
  }

  .brand-logo--screen {
    height: 36px;
  }

  .screen-connection span:last-child {
    display: none;
  }

  .lobby-screen-hero > p {
    font-size: 1rem;
  }

  .join-address {
    align-items: center;
    flex-direction: column;
    gap: 5px;
  }

  .join-address strong {
    max-width: 100%;
  }

  .screen-qr-card {
    align-items: center;
    flex-direction: column;
    text-align: center;
  }

  .screen-qr-code {
    width: 166px;
    height: 166px;
    flex-basis: 166px;
  }

  .screen-qr-code img,
  .screen-qr-code canvas {
    width: 148px !important;
    height: 148px !important;
  }

  .question-screen-header {
    min-height: 85px;
    margin-bottom: 12px;
  }

  .question-screen-header h1 {
    font-size: clamp(1.5rem, 7vw, 2.5rem);
  }

  .screen-timer {
    width: 76px;
    height: 76px;
    flex-basis: 76px;
  }

  .screen-timer strong {
    font-size: 1.25rem;
  }

  .screen-timer > span {
    margin-top: 23px;
    font-size: 0.58rem;
  }

  .screen-answer-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .screen-answer {
    min-height: 105px;
  }

  .screen-answer__shape {
    width: 48px;
    height: 48px;
  }

  .screen-answer__shape--triangle {
    width: 0;
    height: 0;
    border-right-width: 27px;
    border-bottom-width: 48px;
    border-left-width: 27px;
  }

  .question-screen-footer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .received-answers {
    justify-content: center;
  }

  .screen-results-chart {
    min-height: 320px;
    padding: 16px 10px;
    gap: 8px;
  }

  .screen-result-column {
    grid-template-rows:
      minmax(150px, 1fr) auto;
  }

  .screen-result-column__answer {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .screen-result-column__text {
    display: none;
  }

  .correct-answer-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .correct-answer-card > strong {
    margin: 0 auto;
  }

  .correct-answer-card__stat {
    width: 100%;
    border-top: 1px solid var(--surface-border);
    border-left: 0;
    padding-top: 16px;
    padding-left: 0;
  }

  .screen-leaderboard-item {
    grid-template-columns:
      46px minmax(0, 1fr) auto;
    padding: 12px;
    gap: 9px;
  }

  .screen-leaderboard-position {
    width: 38px;
    height: 38px;
  }

  .podium {
    min-height: 300px;
  }

  .podium-player {
    min-height: 110px;
    padding-right: 4px;
    padding-left: 4px;
  }

  .podium-medal {
    font-size: 2rem;
  }

  .podium-place--first .podium-base {
    min-height: 180px;
  }

  .podium-place--second .podium-base {
    min-height: 135px;
  }

  .podium-place--third .podium-base {
    min-height: 105px;
  }

  .final-stats {
    grid-template-columns: 1fr;
  }

  .final-stats > div + div {
    border-top: 1px solid var(--surface-border);
    border-left: 0;
  }
}

/* =========================================================
   TELAS BAIXAS / PAISAGEM
   ========================================================= */

@media (max-height: 760px) {
  .screen-topbar,
  .screen-footer {
    display: none;
  }

  .screen-app {
    grid-template-rows: minmax(0, 1fr);
    padding-top:
      calc(10px + var(--safe-top));
    padding-bottom:
      calc(10px + var(--safe-bottom));
  }

  .question-screen-view {
    padding-top: 0;
    padding-bottom: 0;
  }

  .question-screen-header {
    min-height: 85px;
    margin-bottom: 10px;
  }

  .question-screen-header h1 {
    font-size: clamp(1.7rem, 4vw, 3rem);
  }

  .screen-answer-grid {
    grid-template-rows:
      repeat(2, minmax(110px, 1fr));
    gap: 12px;
  }

  .screen-answer {
    min-height: 110px;
    padding: 18px 25px;
  }

  .question-screen-footer {
    margin-top: 14px;
  }

  .results-screen-header,
  .leaderboard-screen-header,
  .finished-screen-header {
    margin-bottom: 18px;
  }

  .screen-results-chart {
    min-height: 300px;
  }

  .podium {
    min-height: 260px;
  }

  .podium-player {
    min-height: 90px;
  }

  .podium-place--first .podium-base {
    min-height: 160px;
  }

  .podium-place--second .podium-base {
    min-height: 120px;
  }

  .podium-place--third .podium-base {
    min-height: 90px;
  }

  .final-stats {
    margin-top: 15px;
  }

  .final-stats > div {
    padding: 11px;
  }
}

/* =========================================================
   ALTO CONTRASTE
   ========================================================= */

@media (prefers-contrast: more) {
  :root {
    --surface-border:
      rgba(255, 255, 255, 0.32);
    --text-secondary: #dce3ef;
    --text-muted: #b3bfd1;
  }

  .screen-qr-card,
  .screen-pin-card,
  .lobby-players-area,
  .screen-results-chart,
  .correct-answer-card,
  .screen-leaderboard-item,
  .final-stats {
    border-width: 2px;
  }
}

/* =========================================================
   MOVIMENTO REDUZIDO
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}