@import url("https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Bebas+Neue&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  margin: 0;
}

body.overlay-fit {
  display: block;
  position: relative;
  min-width: 100vw;
  min-height: 100vh;
}

body.overlay-fit.overlay-native,
html.overlay-native {
  overflow: hidden;
}

body:not(.overlay-fit) {
  display: flex;
  align-items: center;
  justify-content: center;
}

body.overlay-fit .frame {
  position: absolute;
  margin: 0;
  transform-origin: center center;
}

body.overlay-fit.overlay-native .frame {
  top: 0;
  left: 0;
  transform: none !important;
}

.overlay-error {
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem;
  background: rgba(180, 40, 40, 0.95);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

.hidden {
  display: none !important;
}

.frame-bg {
  object-fit: cover;
}

.frame-bg[src=""],
.frame-bg:not([src]) {
  opacity: 0;
}

body.overlay-embed {
  background: transparent;
}

html:has(body.overlay-embed) {
  background: transparent;
}

body.overlay-embed .frame {
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.35);
}

body.overlay-embed.overlay-fit .frame-bg {
  opacity: 1;
}

.frame {
  background: linear-gradient(165deg, #1a1040 0%, #0d1528 45%, #1a0a12 100%);
  --q-left: 9.7%;
  --q-top: 24.8%;
  --q-width: 82.9%;
  --q-height: 13.8%;
  --a-left: 11%;
  --a-top: 41.8%;
  --a-width: 82%;
  --a-height: 4.2%;
  --f-left: 25.6%;
  --f-top: 54.7%;
  --f-width: 66.9%;
  --f-height: 38.8%;
  --f-pad-top: 1.1%;
  --f-pad-x: 0.4%;
  --live-top: 14%;
  --live-left: 50%;
  --c-top: 26.6%;
  --c-right: 42.9%;
  --interaction-top: 19.5%;
  --interaction-left: 5%;
  --interaction-width: 90%;
  --grid-avatar: 10.5%;
  --grid-points: 22%;
  --grid-check: 10%;
  --grid-gap: 1.1%;
  --feed-pad-left: 1.2%;
  --feed-pad-right: 5.2%;
  --points-inset: 5%;
  --check-inset: 0%;
  --scale-live: 1;
  --scale-counter: 1.85;
  --scale-question: 1.65;
  --scale-answer: 1;
  --scale-feed-avatar: 1;
  --scale-feed-name: 2;
  --scale-feed-points: 1.55;
  --scale-feed-check: 1;

  position: relative;
  width: 1080px;
  height: 1920px;
  flex-shrink: 0;
  overflow: hidden;
  color: #fff;
}

.frame-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 0;
}

.slot-live {
  position: absolute;
  z-index: 4;
  top: var(--live-top);
  left: var(--live-left);
  transform: translateX(-50%) scale(var(--scale-live));
  transform-origin: center top;
  pointer-events: none;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.4em 1.1em 0.4em 0.75em;
  border-radius: 999px;
  background: linear-gradient(
    125deg,
    rgba(200, 25, 55, 0.92) 0%,
    rgba(120, 8, 28, 0.95) 55%,
    rgba(80, 5, 20, 0.95) 100%
  );
  border: 2px solid rgba(255, 120, 140, 0.75);
  box-shadow:
    0 0 24px rgba(255, 50, 80, 0.55),
    0 4px 16px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

.live-dot {
  flex-shrink: 0;
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  background: #ff3048;
  box-shadow:
    0 0 6px #fff,
    0 0 14px #ff3048,
    0 0 22px rgba(255, 48, 72, 0.9);
}

.live-text {
  font-family: "Bebas Neue", "Rajdhani", sans-serif;
  font-size: clamp(1.1rem, 2.8vw, 1.65rem);
  font-weight: 400;
  letter-spacing: 0.28em;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 14px rgba(255, 90, 110, 0.9),
    0 2px 4px rgba(0, 0, 0, 0.45);
  padding-right: 0.12em;
}

.slot-counter {
  position: absolute;
  z-index: 3;
  top: var(--c-top);
  right: var(--c-right);
  font-size: calc(1.15rem * var(--scale-counter));
  font-weight: 700;
  color: #7adfff;
  text-shadow: 0 0 10px rgba(0, 180, 255, 0.55);
}

.slot-interaction {
  position: absolute;
  z-index: 3;
  top: var(--interaction-top);
  left: var(--interaction-left);
  width: var(--interaction-width);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slot-interaction.hidden {
  display: none;
}

.interaction-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.interaction-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.28em 0.65em;
  border-radius: 999px;
  background: rgba(8, 16, 32, 0.72);
  border: 1px solid rgba(122, 223, 255, 0.35);
  font-size: 0.72rem;
  line-height: 1.2;
}

.interaction-pill--muted {
  border-color: rgba(255, 255, 255, 0.15);
  opacity: 0.88;
}

.interaction-pill-label {
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-size: 0.68rem;
}

.interaction-pill-value {
  font-weight: 800;
  color: #9ee8ff;
  font-size: 0.95rem;
}

.interaction-last {
  margin: 0;
  padding: 0.4em 0.65em;
  border-radius: 8px;
  background: rgba(6, 10, 22, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  line-height: 1.35;
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
  min-height: 1.6em;
}

.interaction-last-label {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
}

.interaction-last-body {
  color: #fff;
  word-break: break-word;
}

.interaction-last--ok .interaction-last-body {
  color: #7dffb8;
}

.interaction-last--bad .interaction-last-body {
  color: #ff9f9f;
}

.interaction-last--pop {
  animation: interaction-pop 0.45s ease-out;
}

.fx-flash,
.fx-celebration {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.fx-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.frame.flash-correct .fx-flash::after {
  background: radial-gradient(circle at 50% 35%, rgba(61, 214, 140, 0.45), transparent 62%);
  opacity: 1;
  animation: fx-flash-fade 0.65s ease-out forwards;
}

.frame.flash-wrong .fx-flash::after {
  background: radial-gradient(circle at 50% 35%, rgba(255, 90, 90, 0.35), transparent 62%);
  opacity: 1;
  animation: fx-flash-fade 0.55s ease-out forwards;
}

.fx-confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  opacity: 0;
  animation: fx-confetti-fall var(--dur, 1.8s) cubic-bezier(0.25, 0.8, 0.35, 1) forwards;
}

.layer-winner .winner-burst {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, rgba(255, 213, 74, 0.35) 0%, transparent 55%);
  opacity: 0;
  pointer-events: none;
}

.layer-winner:not(.hidden) .winner-burst {
  animation: winner-burst-pulse 1.4s ease-out infinite;
}

.winner-avatar {
  display: none;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  margin: 0 auto 0.35rem;
  overflow: hidden;
  border: 2px solid rgba(255, 213, 74, 0.85);
  box-shadow: 0 0 20px rgba(255, 213, 74, 0.5);
}

.winner-avatar:not(:empty),
.winner-avatar.winner-avatar--initial {
  display: flex;
  align-items: center;
  justify-content: center;
}

.winner-avatar.winner-avatar--initial {
  font-weight: 800;
  font-size: 1.35rem;
  background: linear-gradient(135deg, #7c5cff, #ff6b9f);
  color: #fff;
}

.winner-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.winner-answer {
  margin-top: 0.35rem;
  font-size: calc(0.95rem * var(--scale-question));
  color: #b8f5d4;
  text-align: center;
  font-weight: 600;
}

.layer-winner.winner-celebrate {
  animation: winner-card-pop 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.slot-puzzle {
  position: absolute;
  z-index: 2;
  left: var(--q-left);
  top: var(--q-top);
  width: var(--q-width);
  height: var(--q-height);
  overflow: hidden;
}

.slot-puzzle .layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.35rem 1rem;
  transform: scale(var(--scale-question));
  transform-origin: center center;
}

.hint-line {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffd54a;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  line-height: 1.2;
}

.hint-line:empty {
  display: none;
}

.question-text {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 0 16px rgba(0, 150, 255, 0.35);
}

.idle-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #7adfff;
}

.idle-sub {
  margin-top: 0.4rem;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.75);
}

.slot-answer {
  position: absolute;
  z-index: 2;
  left: var(--a-left);
  top: var(--a-top);
  width: var(--a-width);
  height: var(--a-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  transform: scale(var(--scale-answer));
  transform-origin: center center;
}

.answer-value {
  width: 100%;
  font-size: 1.05rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-value.is-live {
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.slot-feed {
  position: absolute;
  z-index: 2;
  left: var(--f-left);
  top: var(--f-top);
  width: var(--f-width);
  height: var(--f-height);
  display: flex;
  flex-direction: column;
  padding: var(--f-pad-top) var(--feed-pad-right) 0.2rem var(--feed-pad-left);
  overflow: hidden;
}

.feed-list {
  position: relative;
  z-index: 1;
  list-style: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.feed-row {
  flex: 1 1 0;
  min-height: 0;
  max-height: 14.5%;
  display: grid;
  grid-template-columns: var(--grid-avatar) minmax(0, 1fr) var(--grid-points) var(--grid-check);
  column-gap: var(--grid-gap);
  align-items: center;
  width: 100%;
}

.feed-row--empty {
  visibility: hidden;
}

.feed-avatar {
  width: 100%;
  aspect-ratio: 1;
  max-height: 92%;
  border-radius: 50%;
  border: 2px solid #5ee0ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  transform: scale(var(--scale-feed-avatar));
  transform-origin: center center;
  color: #ffb347;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  justify-self: center;
}

.feed-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-row.rank-1 .feed-avatar {
  border-color: #ffd54a;
  box-shadow: 0 0 10px rgba(255, 213, 74, 0.5);
}

.feed-row.rank-2 .feed-avatar {
  border-color: #e8e8e8;
}

.feed-row.rank-3 .feed-avatar {
  border-color: #cd7f32;
}

.feed-name {
  font-weight: 700;
  font-size: calc(19px * var(--scale-feed-name));
  line-height: 1.15;
  color: #7adfff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 0.2rem;
  justify-self: start;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.feed-points {
  font-weight: 800;
  font-size: calc(18px * var(--scale-feed-points));
  line-height: 1.15;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  justify-self: center;
  align-self: center;
  margin-right: var(--points-inset);
  padding: 0 0.25rem;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.feed-check {
  width: 2.05rem;
  height: 2.05rem;
  min-width: 2.05rem;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: center;
  margin-right: var(--check-inset);
  transform: scale(var(--scale-feed-check));
  transform-origin: center center;
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.55);
}

.frame[data-layout="horizontal"] {
  width: 1920px;
  height: 1080px;
}

.frame[data-layout="horizontal"] .frame-bg {
  object-fit: contain;
}

body.calibrate-mode .slot-puzzle {
  outline: 2px dashed #7c5cff;
}

body.calibrate-mode .slot-answer {
  outline: 2px dashed #ffd54a;
}

body.calibrate-mode .slot-feed {
  outline: 2px dashed #ff9f43;
}

body.calibrate-mode .slot-counter {
  outline: 2px dashed #5ee0ff;
}

body.calibrate-mode .slot-live {
  outline: 2px dashed #ff5a78;
}
