.qv2-frame { max-width: 1380px; margin-inline: auto; padding: clamp(12px, 2vw, 28px); }
.qv2-frame:has(.qm-root, .qt-root, .qd-room, .qb-podium) { max-width: none; padding: 0; }
.qv2-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: #fff; }
.qv2-tools > p { margin: 0; }
.qv2-tools > p:empty { display: none; }
.qv2-student-connection { position: fixed; z-index: 20; inset: 10px 16px auto; margin: 0; padding: 10px; background: #fff; border-radius: 8px; }
.qv2-student-connection:empty { display: none; }
.qv2-panel { max-width: 680px; margin: clamp(12px, 5vw, 40px) auto; padding: 24px; background: white; border-radius: 18px; }
.qv2-panel label { display: block; margin: 12px 0; }
.qv2-panel input, .qv2-panel select, .qv2-tools input { font: inherit; }
.qv2-panel ul { display: grid; gap: 12px; padding-inline-start: 20px; }
.qv2-panel [role=status] { min-height: 1.5em; }

body:has(.qv2-entry-frame) {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #dceee7, transparent 62%), #f5f8f3;
}
.qv2-entry-frame { max-width: 1032px; padding: clamp(16px, 4vw, 44px); }
.qv2-entry-nav { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.qv2-entry-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #bcd6cd;
  border-radius: 12px;
  background: #fff;
  color: #174e45;
  font-weight: 700;
  text-decoration: none;
}
.qv2-entry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid #bed7cd;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 18px 48px #24584c15;
}
.qv2-entry-intro {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 12px;
  padding: clamp(24px, 5vw, 50px);
  background: radial-gradient(ellipse at 82% 8%, #2a7062, transparent 64%), #133e36;
  color: #fff;
}
.qv2-entry-intro img { width: clamp(110px, 15vw, 176px); height: auto; }
.qv2-entry-intro h1 { margin: 0; color: inherit; font-size: clamp(27px, 3.9vw, 42px); line-height: 1.18; letter-spacing: -.035em; }
.qv2-entry-intro p { max-width: 30ch; margin: 0; color: #e5f3eb; font-weight: 500; line-height: 1.55; word-break: keep-all; }
.qv2-entry-form { display: grid; align-content: center; gap: 20px; padding: clamp(24px, 5vw, 50px); color: #183731; }
.qv2-entry-form label { display: grid; gap: 8px; font-weight: 750; }
.qv2-entry-form :is(input, select, button) {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #9abbb1;
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
}
.qv2-entry-form input {
  min-height: 60px;
  background: #f4faf7;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .22em;
}
.qv2-entry-form input::placeholder { color: #59736b; }
.qv2-entry-form button { border-color: #176355; background: #176355; color: #fff; font-weight: 800; cursor: pointer; }
.qv2-entry-form button:hover { background: #114d42; }
.qv2-entry-frame :is(a, input, select, button):focus-visible { outline: 3px solid #146855; outline-offset: 3px; }
@media (max-width: 640px) {
  .qv2-entry { grid-template-columns: minmax(0, 1fr); border-radius: 22px; }
  .qv2-entry-intro { gap: 8px; }
  .qv2-entry-intro p { max-width: none; }
  .qv2-entry-form { gap: 16px; }
}

.qv2-room-expiry { position: fixed; z-index: 4; top: 70px; right: 14px; max-width: calc(100vw - 28px); margin: 0; padding: 9px 12px; border-radius: 9px; background: #fff1c9; color: #704710; font-weight: 700; pointer-events: none; }

.qv2-room-invitation { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; flex-basis: 100%; margin-top: 10px; }
.qv2-room-invitation canvas { width: 160px; max-width: 100%; height: auto; border-radius: 6px; background: white; }
.qv2-room-invitation-actions { display: grid; justify-items: start; gap: 8px; }
.qv2-room-invitation-actions [role="status"] { padding: 0; margin: 0; font-size: 12px; }
.qv2-room-invitation-actions [role="status"]:empty { display: none; }
@media (max-width: 600px) {
  .qm-lobby-overview:has(.qv2-room-invitation) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qm-lobby-pin:has(.qv2-room-invitation) { grid-column: 1 / -1; }
}

@media (orientation: landscape) and (max-height: 680px) {
  .qm-header + .qm-student-lobby .qm-lobby-card { padding-block: 20px; }
}

.qb-room .qb-student-results {
  display: grid;
  justify-content: center;
  justify-items: stretch;
  grid-template-columns: minmax(0, 680px);
  gap: 10px;
}
.qb-student-results > [role="status"] { margin: 0; }
.qb-result-hero {
  display: flex;
  align-items: center;
  gap: clamp(14px, 4vw, 32px);
  padding: clamp(16px, 4vw, 32px);
  border-radius: 16px;
  background: linear-gradient(110deg, #17382dd9, #102820e8),
    #1b4738 url('/assets/quiz/brawl-podium-v1/forest-ceremony.webp') center / cover;
  color: #fff9e8;
}
.qb-result-hero h2 { margin: 2px 0; font-size: clamp(29px, 5vw, 52px); line-height: 1.1; }
.qb-result-hero p { margin: 5px 0; }
.qb-result-kicker { font-size: .875rem; font-weight: 750; letter-spacing: .05em; }
.qb-result-hero .qb-result-xp { font-size: clamp(20px, 3vw, 32px); font-weight: 800; color: #f9e59a; }
.qb-result-note { color: #465c58; font-size: .875rem; }
.qb-result-hero .qb-results-avatar {
  width: clamp(78px, 18vw, 160px);
  height: clamp(78px, 18vw, 160px);
  filter: drop-shadow(0 9px 12px #051b15b3);
}
.qb-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 0;
  text-align: center;
}
.qb-result-stats > div { padding: 8px 3px; border-radius: 10px; background: #edf4ef; color: #234638; }
.qb-result-stats dt { font-size: .875rem; }
.qb-result-stats dd { margin: 0; font-size: 1.1rem; font-weight: 750; }
.qb-result-presentation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.qb-result-presentation a {
  display: inline-flex;
  align-items: center;
  padding-inline: 18px;
  text-decoration: none;
}
.qb-result-teacher { padding: clamp(12px, 3vw, 20px); }
.qb-result-teacher h2 { margin: 0; }
.qb-result-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qb-result-tools .qm-secondary { border: 1px solid #cad7e3; }
.qb-result-tools [aria-pressed="true"] { background: #1f4939; color: #fff; border-color: #1f4939; }
.qb-result-teacher select { padding: 6px 10px; margin-bottom: 8px; }
.qb-result-table-wrap { overflow-x: auto; }
.qb-result-teacher table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.qb-result-teacher th, .qb-result-teacher td { padding: 10px 8px; border-bottom: 1px solid #e2e9ee; text-align: left; }
.qb-result-teacher th { background: #f2f6f4; }
.qb-result-teacher tbody tr:nth-child(even) { background: #f8faf9; }

.qb-podium {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  box-sizing: border-box;
  isolation: isolate;
  overflow: hidden;
  padding: 0 clamp(10px, 3vw, 44px) 14px;
  background: linear-gradient(180deg, #0c2719e8 0%, #0b2b1b9c 35%, #0b2b1b20 70%, #0b2618ad 100%),
    #143d2c url('/assets/quiz/brawl-podium-v1/forest-ceremony.webp') center / cover;
  color: #fff8e5;
  text-align: center;
}
.qb-podium-header { position: relative; z-index: 5; padding: clamp(16px, 4vh, 44px) 0 0; }
.qb-podium-header p { margin: 5px 0; }
.qb-podium-header .qb-result-kicker { color: #f4dc99; }
.qb-podium-header h1 { margin: 4px 0; font-size: clamp(30px, 5.5vw, 74px); line-height: 1.05; text-shadow: 0 4px 18px #061e14; }
.qb-podium-status { min-height: 1.5em; color: #fff0b8; }
.qb-podium-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.qb-podium-controls[hidden] { display: none; }
.qb-podium-controls button {
  border: 1px solid #e6d3a4;
  border-radius: 10px;
  min-height: 44px;
  padding: 8px 14px;
  color: #fff9e7;
  background: #132e24e8;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.qb-podium-controls .qb-podium-start { background: #f5dfa0; color: #183b2a; }
.qb-podium-controls button:disabled { opacity: .57; cursor: default; }
.qb-podium-groups {
  position: relative;
  flex: 1;
  width: min(100%, 1400px);
  min-height: clamp(340px, 58vh, 640px);
  margin-inline: auto;
}
.qb-podium-groups::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 66%, #ffe49d99, #ffe49d00 55%);
  opacity: 0;
  content: '';
}
.qb-podium[data-reveal="1"] .qb-podium-groups::after { animation: qb-podium-glow 1350ms ease-out; }
.qb-podium-group {
  --slot: 50%;
  --pedestal: clamp(138px, 28vw, 420px);
  --avatar: clamp(65px, 21vh, 222px);
  --top-space: .22;
  --medal: #f9e298;
  position: absolute;
  z-index: 3;
  bottom: min(3vh, 28px);
  left: var(--slot);
  width: min(48vw, 650px);
  padding-bottom: calc(var(--pedestal) * var(--top-space));
  transform: translateX(-50%);
  animation: qb-podium-arrive 1350ms ease-out both;
  text-shadow: 0 2px 8px #061d14, 0 2px 12px #061d14;
}
.qb-podium-group[data-rank="2"] {
  --slot: 20%;
  --pedestal: clamp(96px, 21vw, 310px);
  --avatar: clamp(57px, 17vh, 174px);
  --top-space: .14;
  --medal: #dce9ed;
  z-index: 2;
  width: 33%;
}
.qb-podium-group[data-rank="3"] {
  --slot: 80%;
  --pedestal: clamp(90px, 18vw, 272px);
  --avatar: clamp(51px, 15vh, 156px);
  --top-space: .12;
  --medal: #f2c9a0;
  z-index: 1;
  width: 32%;
}
.qb-podium-medal {
  display: inline-block;
  margin: 0 0 5px;
  border-radius: 99px;
  padding: 4px 14px;
  background: var(--medal);
  color: #173226;
  font-size: clamp(15px, 2.5vw, 33px);
  text-shadow: none;
}
.qb-podium-winners {
  display: flex;
  justify-content: center;
  gap: clamp(2px, 1vw, 14px);
  list-style: none;
  padding: 0;
  margin: 0;
}
.qb-podium-winners li { display: grid; min-width: 0; justify-items: center; align-content: end; }
.qb-podium .qb-results-avatar { width: var(--avatar); height: var(--avatar); filter: drop-shadow(0 7px 11px #0a2016a0); }
.qb-podium-winners[data-count="2"] .qb-results-avatar, .qb-podium-winners[data-count="3"] .qb-results-avatar {
  width: min(var(--avatar), 10vw);
  height: min(var(--avatar), 10vw);
}
.qb-podium-winners strong { font-size: clamp(12px, 2.05vw, 34px); overflow-wrap: anywhere; }
.qb-podium-score { display: block; margin: 0; color: #ffedac; font-size: clamp(19px, 3vw, 48px); line-height: 1.15; }
.qb-podium-pedestal {
  position: absolute;
  z-index: -1;
  bottom: 0;
  left: 50%;
  width: var(--pedestal);
  max-width: 100%;
  height: auto;
  transform: translateX(-50%);
}
.qb-podium-names {
  position: absolute;
  bottom: 10px;
  left: 50%;
  min-width: max-content;
  padding: 3px 7px;
  background: #0b2c21ed;
  border-radius: 5px;
  transform: translateX(-50%);
}
.qb-podium-names summary { cursor: pointer; }
.qb-podium-names ul { max-height: 24vh; overflow: auto; list-style: none; padding: 0 5px; }
.qb-podium-names li { display: flex; align-items: center; gap: 5px; }
.qb-podium-names .qb-results-avatar { width: 34px; height: 34px; }
@keyframes qb-podium-arrive {
  0% { opacity: 0; left: 50%; transform: translate(-50%, 36px) scale(.92); }
  42%, 56% { opacity: 1; left: 50%; transform: translate(-50%, -10px) scale(1.07); }
  100% { opacity: 1; left: var(--slot); transform: translateX(-50%); }
}
@keyframes qb-podium-glow { 35% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .qb-podium-group, .qb-podium[data-reveal="1"] .qb-podium-groups::after { animation: none; }
}
