:root {
  --chs-card: rgba(255, 255, 255, 0.92);
  --chs-line: rgba(255, 255, 255, 0.18);
  --chs-ink: rgba(31, 26, 36, 0.95);
  --chs-muted: rgba(31, 26, 36, 0.72);
  --chs-accent: #6b2d4a;
  --chs-accent-soft: rgba(107, 45, 74, 0.14);
  --chs-ok: #1f7a4a;
  --chs-ok-bg: rgba(46, 160, 96, 0.16);
  --chs-bad-bg: rgba(200, 72, 72, 0.12);
  --chs-gold: #d4a853;
  --chs-win: rgba(212, 168, 83, 0.22);
}

.page--chs {
  width: 100%;
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chs-stage {
  width: 100%;
  max-width: min(100%, 920px);
  margin: 0 auto;
  text-align: center;
  padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}

.section--chs {
  width: 100%;
  padding-top: 1.25rem;
  padding-bottom: 2.25rem;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.chs-head {
  margin-bottom: 1rem;
  width: 100%;
}

.chs-head__line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  width: 100%;
  max-width: 100%;
  line-height: 1.35;
}

.chs-head .section__title {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.55rem);
  line-height: 1.3;
  max-width: none;
  white-space: nowrap;
}

.chs-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(0.88rem, 1.7vw, 1.02rem);
  line-height: 1.35;
  max-width: none;
}

.chs-subtitle::before {
  content: "—";
  margin-right: 0.45rem;
  opacity: 0.65;
}

.chs-online {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin: 0.65rem auto 0;
  width: 100%;
  max-width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(46, 160, 96, 0.12);
  border: 1px solid rgba(46, 160, 96, 0.28);
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(0.78rem, 1.6vw, 0.88rem);
  line-height: 1.4;
  box-sizing: border-box;
}

.chs-online[hidden] {
  display: none !important;
}

.chs-online__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #3ecf7a;
  box-shadow: 0 0 0 2px rgba(62, 207, 122, 0.25);
  flex-shrink: 0;
  animation: chs-pulse 2s ease-in-out infinite;
}

@keyframes chs-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.chs-online strong {
  color: #b8f0d0;
  font-weight: 700;
}

.chs-online__time {
  opacity: 0.82;
}

.chs-online__time::before {
  content: "· ";
}

.chs-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 1.15rem;
}

.chs-stat {
  background: var(--chs-card);
  border: 1px solid var(--chs-line);
  border-radius: 14px;
  padding: 0.55rem 0.5rem;
  text-align: center;
  min-height: 3.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chs-stat__k {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--chs-muted);
}

.chs-stat__v {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--chs-accent);
}

.chs-empty {
  margin: 2rem auto;
  opacity: 0.8;
}

.chs-empty[hidden],
.chs-play[hidden],
.chs-actions[hidden] {
  display: none !important;
}

.chs-prompt {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.chs-prompt--ok {
  color: #b8f0d0;
}

.chs-prompt--bad {
  color: #f0c8c8;
}

.chs-duel {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: center;
  gap: 15px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

.chs-vs {
  align-self: center;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  padding: 0;
}

.chs-card {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: var(--chs-card);
  color: var(--chs-ink);
  border-radius: 16px;
  padding: 0;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 240px;
  flex: 0 0 auto;
  margin: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.chs-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(107, 45, 74, 0.45);
}

.chs-card:disabled {
  cursor: default;
}

.chs-card--picked.chs-card--correct {
  border-color: var(--chs-ok);
  background: linear-gradient(180deg, var(--chs-ok-bg), var(--chs-card));
  box-shadow: 0 0 0 1px rgba(46, 160, 96, 0.25);
}

.chs-card--picked.chs-card--wrong {
  opacity: 0.72;
}

.chs-card--winner {
  border-color: var(--chs-gold);
  background: linear-gradient(180deg, var(--chs-win), var(--chs-card));
  box-shadow: 0 0 0 1px rgba(212, 168, 83, 0.35);
}

.chs-card__cover {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  max-width: 240px;
  margin: 0;
  object-fit: cover;
  border-radius: 0;
  box-shadow: none;
  display: block;
  flex-shrink: 0;
}

.chs-card__title,
.chs-card__author,
.chs-card__cta,
.chs-card__bar-wrap {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.chs-card__title {
  margin-top: 0.65rem;
  font-size: clamp(0.88rem, 2vw, 1rem);
  font-weight: 700;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.chs-card__author {
  font-size: 0.78rem;
  color: var(--chs-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.1rem;
}

.chs-card__cta {
  margin-top: 0.25rem;
  padding-bottom: 0.8rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--chs-accent);
}

.chs-card--revealed .chs-card__cta {
  display: none;
}

.chs-card__bar-wrap {
  width: 100%;
  margin-top: 0.35rem;
  padding-bottom: 0.85rem;
  box-sizing: border-box;
}

.chs-card__bar-wrap[hidden] {
  display: none !important;
}

.chs-card__bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(107, 45, 74, 0.15);
  overflow: hidden;
  position: relative;
}

.chs-card__bar::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--chs-accent), #8f3d5e);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.chs-card--winner .chs-card__bar::after {
  background: linear-gradient(90deg, #1f7a4a, #3ecf7a);
}

.chs-card__bar--animate::after {
  width: var(--chs-bar-pct, 0%);
}

.chs-card__plays {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--chs-accent);
}

.chs-card--winner .chs-card__plays {
  color: var(--chs-ok);
}


.chs-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  background: var(--chs-accent);
  color: #fff;
}

.chs-pill--link {
  background: var(--chs-accent);
  color: #fff;
}

.chs-pill--link:hover {
  background: #8f3d5e;
  color: #fff;
}

.chs-pill--secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--chs-line);
  color: rgba(255, 255, 255, 0.92);
}

.chs-pill--secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.chs-duel--locked .chs-card:not(.chs-card--revealed) {
  pointer-events: none;
}

.chs-duel--done {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 15px;
}

.chs-duel--done .chs-vs {
  display: none;
}

.chs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.65rem;
  width: 100%;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 720px) {
  .chs-duel {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: min(100%, 280px);
  }

  .chs-duel--done {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: center;
    gap: 15px;
    max-width: 100%;
    width: 100%;
  }

  .chs-duel--done .chs-card {
    width: calc(50% - 7.5px);
    max-width: 168px;
  }

  .chs-duel--done .chs-card__title {
    font-size: 0.74rem;
    -webkit-line-clamp: 2;
  }

  .chs-duel--done .chs-card__author {
    font-size: 0.68rem;
    -webkit-line-clamp: 1;
  }

  .chs-duel--done .chs-card__plays {
    font-size: 0.72rem;
  }

  .chs-vs {
    order: 1;
    padding: 0.1rem 0;
  }

  .chs-card:first-of-type {
    order: 0;
  }

  .chs-card:last-of-type {
    order: 2;
  }

  .chs-card {
    width: 100%;
    max-width: 240px;
  }

  .chs-card__cover {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
}

@media (max-width: 768px) {
  .section--chs {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  }

  .chs-head .section__title {
    white-space: normal;
  }

  .chs-head__line {
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
  }

  .chs-subtitle::before {
    display: none;
  }

  .chs-stats {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .section--chs {
    padding-top: 0.85rem;
  }

  .chs-online {
    border-radius: 12px;
    padding: 0.5rem 0.65rem;
  }

  .chs-pill {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 0;
    min-height: 2.65rem;
  }

  #btn-chs-next {
    flex: 1 1 100%;
  }
}
