/* ── Overlay views ── */
.mp-overlay {
  position: fixed;
  inset: 0;
  top: 60px;
  z-index: 800;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 40px;
  overflow-y: auto;
  overscroll-behavior: none;
}
.mp-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
}
.mp-card h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 4px;
  text-align: center;
}
.mp-card .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  text-align: center;
}
.mp-card.wide { max-width: 600px; }

/* ── Lobby card ── */
#view-lobby {
  padding: 40px 20px;
  align-items: flex-start;
}
#view-lobby > .mp-card {
  margin: auto;
}
#lobby-card {
  border-radius: 18px;
  padding: 40px 44px;
  max-width: 420px;
}
.card-brand {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  color: var(--purple);
  letter-spacing: -.5px;
  margin-bottom: 4px;
}
.card-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.join-teacher-name {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: -2px 0 10px;
}

/* ── Game bar ── */
#mp-game-bar { display: none; }

/* ── Waiting room player pills ── */
#waiting-players, #w-student-players, #w-player-pills, #lobby-names, #w-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  min-height: 60px;
  justify-content: center;
}
.player-pill {
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  animation: fadeIn .2s ease;
}
.pill-avatar {
  display: block;
  flex-shrink: 0;
}
.pill-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--btn-text);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes fadeIn { from { opacity:0; transform:scale(.9); } to { opacity:1; transform:none; } }

/* ── Code display ── */
.code-display {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 10px;
  color: var(--purple);
  text-align: center;
  margin: 8px 0 4px;
  font-family: monospace;
}
.code-sub {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Spinner ── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--btn-border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Podium (game ended) ── */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}
.podium-place { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podium-name  { font-size: 13px; font-weight: 700; max-width: 90px; word-break: break-word; text-align: center; }
.podium-score { font-size: 11px; color: var(--text-muted); text-align: center; }
.podium-block { border-radius: 8px 8px 0 0; width: 80px; }
.podium-place.p1 .podium-block { height: 120px; background: #D69E2E; }
.podium-place.p2 .podium-block { height: 90px;  background: #A0AEC0; }
.podium-place.p3 .podium-block { height: 70px;  background: #C05621; }
.podium-medal        { font-size: 28px; }
.podium-medal-avatar { display: block; margin: 0 auto 2px; }

/* ── Final leaderboard (game ended) ── */
.final-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--btn-border);
  margin-bottom: 6px;
}
.final-lb-row:nth-child(1) { background: rgba(246,201,14,.13); border-color: rgba(246,201,14,.53); }
.final-lb-row:nth-child(2) { background: rgba(203,213,224,.10); border-color: rgba(203,213,224,.53); }
.final-lb-row:nth-child(3) { background: rgba(246,150,100,.13); border-color: rgba(246,150,100,.53); }
.final-medal { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.final-name  { flex: 1; font-weight: 600; font-size: 14px; color: var(--btn-text); }
.final-guesses { font-size: 13px; color: var(--text-muted); }
.final-won { font-size: 14px; color: #ef5350; }

/* ── Show-all-results toggle ── */
.show-all-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.show-all-btn:hover { background: var(--btn-hover-bg, rgba(0,0,0,.06)); }

/* ── End-game stats strip ── */
.end-stats-strip { text-align: center; margin: 16px 0; }
.end-stats-strip .stat-pill {
  display: inline-block; padding: 6px 14px; margin: 4px;
  background: var(--surface); border: 1.5px solid var(--btn-border);
  border-radius: 20px; font-size: 14px; font-weight: 600; color: var(--btn-text);
}
.end-stats-strip .stat-pill i { margin-right: 5px; }

/* ── Lobby numpad ── */
.lobby-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
}

.lobby-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.lobby-num-btn {
  height: 54px;
  background: var(--surface-2);
  border: 1.5px solid var(--btn-border);
  border-radius: 10px;
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  color: var(--btn-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, transform .06s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.lobby-num-btn:hover                  { background: var(--purple-light); }
.lobby-num-btn:active,
.lobby-num-btn.pressed                { transform: scale(.93); background: var(--purple-light); }
.lobby-go-btn:active                  { transform: scale(.93); }
.lobby-del-btn { font-size: 18px; color: var(--text-muted); }
.lobby-go-btn  { background: var(--purple); color: #fff; border-color: var(--purple); font-size: 20px; }
.lobby-go-btn:hover  { background: var(--purple-dark); border-color: var(--purple-dark); }
.lobby-go-btn:disabled { background: var(--surface-2); color: var(--text-muted); border-color: var(--btn-border); cursor: default; transform: none; }

/* ── QR modal ── */
#globe-qr-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
#globe-qr-modal {
  background: var(--surface); border-radius: 18px; padding: 36px 40px;
  text-align: center; width: 340px; max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.2); position: relative;
}
#globe-qr-close {
  position: absolute; top: 14px; right: 16px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--btn-border); background: var(--surface-2);
  font-size: 18px; line-height: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: center; color: var(--btn-text);
}
#globe-qr-close:hover { background: #FCEBEB; border-color: #E24B4A; color: #A32D2D; }
#globe-qr-modal h2 { font-size: 17px; font-weight: 700; color: var(--btn-text); margin-bottom: 4px; }
.globe-qr-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
#globe-qr-canvas { display: flex; justify-content: center; margin-bottom: 16px; }
#globe-qr-canvas img, #globe-qr-canvas canvas { border-radius: 8px; border: 4px solid #fff; box-shadow: 0 2px 12px rgba(0,0,0,.1); }
.globe-qr-code-text { font-size: 28px; font-weight: 800; letter-spacing: .18em; color: var(--purple); margin-bottom: 6px; }
.globe-qr-url { font-size: 11px; color: var(--text-muted); word-break: break-all; margin-bottom: 18px; line-height: 1.5; }
.globe-qr-copy-btn {
  width: 100%; padding: 10px; background: var(--purple); color: #fff;
  border: none; border-radius: 9px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .12s;
}
.globe-qr-copy-btn:hover { background: var(--purple-dark); }

/* ── DiceBear avatar images ─────────────────────────────────── */
#w-my-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--purple-light);
  margin: 0 auto 8px;
  background: var(--surface-2);
  flex-shrink: 0;
}
#w-my-avatar img { width: 100%; height: 100%; display: block; }

img.pill-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}
img.podium-medal-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: block;
  margin: 0 auto 2px;
}
img.lb-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── Countdown overlay ── */
.mp-countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.mp-countdown-num {
  font-size: 120px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  animation: mp-cd-pop .85s ease forwards;
}
.mp-countdown-go {
  font-size: 72px;
  font-weight: 900;
  color: var(--purple);
  animation: mp-cd-pop .85s ease forwards;
}
@keyframes mp-cd-pop {
  0%   { transform: scale(1.6); opacity: 0; }
  30%  { transform: scale(1);   opacity: 1; }
  65%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(.9);  opacity: 0; }
}
