/* ═══════════════════════════════════════
   3D AVATAR DISPLAY SYSTEM
   Works with RGBA PNGs (background-removed).
   Usage: wrap any avatar <img> in <div class="av3d [av3d--sm|md|lg]">
   The wrapper must be position:relative and have a defined size.
═══════════════════════════════════════ */

/* Size presets — set on the .av3d wrapper */
.av3d       { --av-size: 60px;  }
.av3d--sm   { --av-size: 44px;  }
.av3d--md   { --av-size: 80px;  }
.av3d--lg   { --av-size: 130px; }
.av3d--xl   { --av-size: 160px; }

.av3d {
  position: relative;
  display: inline-block;
  width:  var(--av-size);
  height: var(--av-size);
  /* 3D perspective applied here so children inherit it */
  perspective: 400px;
  perspective-origin: 50% 80%;
  /* Reserve space below for ground shadow ellipse */
  padding-bottom: calc(var(--av-size) * 0.18);
  box-sizing: content-box;
}

/* The avatar image itself */
.av3d > img {
  position: relative;
  z-index: 2;
  width:  var(--av-size);
  height: var(--av-size);
  object-fit: contain;
  display: block;
  /* Multi-layer drop shadows:
     layer 1 — directional key light (upper-left source)
     layer 2 — ambient fill (softer, wider)
     layer 3 — contact shadow nub at feet */
  filter:
    drop-shadow(3px 6px 6px rgba(0,0,0,0.30))
    drop-shadow(-1px 2px 8px rgba(0,0,0,0.15))
    drop-shadow(0 12px 4px rgba(0,0,0,0.12));
  /* Floating animation is applied per-instance via av3d-float-* classes */
  will-change: transform, filter;
  transform-style: preserve-3d;
}

/* Ground oval shadow — ::before */
.av3d::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width:  calc(var(--av-size) * 0.72);
  height: calc(var(--av-size) * 0.14);
  background: radial-gradient(ellipse at center,
    rgba(30,60,30,0.38) 0%,
    rgba(30,60,30,0.14) 55%,
    transparent 100%);
  border-radius: 50%;
  filter: blur(calc(var(--av-size) * 0.04));
  z-index: 1;
  /* Shadow shrinks & dims at float peak */
  animation: av3d-shadow var(--av-dur, 2.4s) var(--av-delay, 0s) ease-in-out infinite;
  pointer-events: none;
}

/* Ground reflection — ::after
   A vertically-flipped ghost of the avatar fading out downward */
.av3d::after {
  content: '';
  position: absolute;
  bottom: calc(var(--av-size) * -0.08);
  left: 0;
  width:  var(--av-size);
  height: calc(var(--av-size) * 0.35);
  /* We can't copy the img directly in CSS; instead we render a subtle
     light-colored blur smear that reads as a wet-ground reflection */
  background: linear-gradient(to bottom,
    rgba(255,255,255,0.22) 0%,
    rgba(255,255,255,0.06) 50%,
    transparent 100%);
  border-radius: 50% 50% 0 0 / 60% 60% 0 0;
  filter: blur(calc(var(--av-size) * 0.035));
  z-index: 0;
  pointer-events: none;
  /* mask fades reflection top→bottom */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
  mask-image:         linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

/* ── Floating keyframes ── */

/* The avatar rises and falls, with a subtle 3-degree Y-axis rotation
   to sell the "floating in space" read. */
@keyframes av3d-float {
  0%, 100% {
    transform: translateY(0)          rotateY(0deg)      scale(1);
    filter:
      drop-shadow(3px 6px 6px rgba(0,0,0,0.30))
      drop-shadow(-1px 2px 8px rgba(0,0,0,0.15))
      drop-shadow(0 12px 4px rgba(0,0,0,0.12));
  }
  30% {
    transform: translateY(calc(var(--av-size) * -0.10)) rotateY(2.5deg) scale(1.01);
    filter:
      drop-shadow(4px 14px 10px rgba(0,0,0,0.22))
      drop-shadow(-1px 4px 12px rgba(0,0,0,0.10))
      drop-shadow(0 18px 6px rgba(0,0,0,0.08));
  }
  60% {
    transform: translateY(calc(var(--av-size) * -0.07)) rotateY(-1.5deg) scale(1.005);
    filter:
      drop-shadow(2px 10px 8px rgba(0,0,0,0.26))
      drop-shadow(-1px 3px 10px rgba(0,0,0,0.12))
      drop-shadow(0 15px 5px rgba(0,0,0,0.10));
  }
}

/* Ground shadow shrinks when avatar is high, swells at landing */
@keyframes av3d-shadow {
  0%, 100% { transform: translateX(-50%) scaleX(1)    scaleY(1);    opacity: 1;    }
  30%      { transform: translateX(-50%) scaleX(0.68) scaleY(0.62); opacity: 0.55; }
  60%      { transform: translateX(-50%) scaleX(0.80) scaleY(0.75); opacity: 0.72; }
}

/* Idle bob (minimal movement — use for waiting states) */
@keyframes av3d-bob {
  0%, 100% { transform: translateY(0)                        rotateY(0deg);    }
  50%      { transform: translateY(calc(var(--av-size)*-0.05)) rotateY(1.5deg); }
}

/* Jump-in celebrate (answer correct) */
@keyframes av3d-jump {
  0%        { transform: translateY(0)                            rotateY(0deg)   scaleY(1); }
  20%       { transform: translateY(calc(var(--av-size) * -0.26)) rotateY(-4deg)  scaleY(1.04); }
  45%       { transform: translateY(calc(var(--av-size) * -0.18)) rotateY(3deg)   scaleY(1.02); }
  65%       { transform: translateY(calc(var(--av-size) * -0.06)) rotateY(-1deg)  scaleY(1.01); }
  80%, 100% { transform: translateY(0)                            rotateY(0deg)   scaleY(1); }
}

/* Slump (wrong answer) */
@keyframes av3d-slump {
  0%   { transform: translateY(0)  rotate(0deg)  scale(1);    }
  20%  { transform: translateY(0)  rotate(-5deg) scale(0.96); }
  40%  { transform: translateY(0)  rotate(3deg)  scale(0.97); }
  60%  { transform: translateY(0)  rotate(-2deg) scale(0.98); }
  100% { transform: translateY(calc(var(--av-size)*0.03)) rotate(0deg) scale(0.99); }
}

/* Wiggle (answered, waiting) */
@keyframes av3d-wiggle {
  0%,100% { transform: rotate(-4deg) translateY(0); }
  50%     { transform: rotate(4deg)  translateY(calc(var(--av-size)*-0.04)); }
}

/* ── Animation state classes (apply to .av3d > img) ── */
.av3d > img.av-float  { animation: av3d-float var(--av-dur,  2.4s) var(--av-delay, 0s)   ease-in-out infinite; }
.av3d > img.av-bob    { animation: av3d-bob   var(--av-dur,  3.2s) var(--av-delay, 0s)   ease-in-out infinite; }
.av3d > img.av-wiggle { animation: av3d-wiggle var(--av-dur, 1.0s) var(--av-delay, 0s)   ease-in-out infinite; }
.av3d > img.av-jump   { animation: av3d-jump  0.7s ease-out forwards; }
.av3d > img.av-slump  { animation: av3d-slump 0.8s ease-out forwards; }

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .av3d > img,
  .av3d::before {
    animation: none !important;
    transition: none !important;
  }
}

/* ═══════════════════════════════════════
   HOME / LANDING SCREEN
═══════════════════════════════════════ */
.home-screen {
  min-height: 100vh;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: clamp(12px, 3vw, 28px);
  text-align: center;
}
.home-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.home-logo img {
  height: clamp(64px, 14vw, 110px);
  mask-image: radial-gradient(ellipse 68% 68% at center, black 28%, rgba(0,0,0,0.6) 52%, transparent 74%);
  -webkit-mask-image: radial-gradient(ellipse 68% 68% at center, black 28%, rgba(0,0,0,0.6) 52%, transparent 74%);
}
.home-logo-name {
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 900;
  color: rgba(255,255,255,0.95);
  letter-spacing: 0.08em;
  text-shadow: 0 1px 8px rgba(0,0,0,0.35), 0 0 20px rgba(80,200,150,0.3);
}
.home-avatars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(8px, 3vw, 32px);
  margin: 8px 0 0;
  position: relative;
  height: clamp(200px, 38vw, 280px);
}

.home-av-wrap-digi,
.home-av-wrap-mogi,
.home-av-wrap-jiji {
  position: relative;
  flex-shrink: 0;
}

/* Mogi цагаан (white) */
.home-av-wrap-mogi img,
[data-avatar="mogi"] { filter: brightness(10) saturate(0); }

/* Legacy selector kept for JS that still targets .home-av */
.home-av { object-fit: contain; display: block; }

.home-title {
  font-size: clamp(1.5rem, 5.5vw, 2.6rem);
  font-weight: 900;
  color: #fff;
  margin-top: clamp(8px, 2vw, 16px);
  text-shadow:
    0 2px 0 rgba(120,50,0,0.4),
    0 4px 12px rgba(120,50,0,0.3),
    0 0 32px rgba(255,200,100,0.5);
}
.home-sub {
  font-size: clamp(0.82rem, 2.2vw, 1rem);
  color: rgba(255,255,255,0.85);
  font-weight: 700;
  margin: 4px 0 clamp(14px, 3vw, 24px);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.home-btns {
  display: flex;
  gap: clamp(8px, 2vw, 14px);
  flex-wrap: wrap;
  justify-content: center;
}
.home-btn-admin,
.home-btn-player {
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  padding: clamp(12px, 2.5vw, 16px) clamp(20px, 5vw, 32px);
  border-radius: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.home-btn-player {
  background: linear-gradient(135deg, #ff9f2e 0%, #ff6b00 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(255,120,0,0.45);
}
.home-btn-player:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,120,0,0.55); }
.home-btn-admin {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.55);
  backdrop-filter: blur(6px);
}
.home-btn-admin:hover { background: rgba(255,255,255,0.26); transform: translateY(-2px); }

/* ═══════════════════════════════════════
   LOBBY / AVATAR SELECTION (Player)
═══════════════════════════════════════ */
.join-screen {
  min-height: 100vh;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(12px, 3vh, 28px) clamp(14px, 4vw, 40px);
  gap: clamp(10px, 2vh, 20px);
  overflow-y: auto;
}

.join-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.join-logo img {
  height: clamp(40px, 7vh, 56px);
  mask-image: radial-gradient(ellipse 68% 68% at center, black 28%, rgba(0,0,0,0.55) 52%, transparent 74%);
  -webkit-mask-image: radial-gradient(ellipse 68% 68% at center, black 28%, rgba(0,0,0,0.55) 52%, transparent 74%);
}
.join-logo h1 { font-size: clamp(1rem, 2.5vw, 1.3rem); font-weight: 900; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }

.join-title {
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  text-align: center;
}

/* Avatar selection cards */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 2.5vw, 22px);
  width: 100%;
  max-width: min(100%, clamp(320px, 80vw, 600px));
}
.avatar-card {
  background: rgba(255,255,255,0.92);
  border-radius: 20px;
  padding: 18px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 5px 16px var(--shadow);
  overflow: visible;
  position: relative;
}
.avatar-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 30px var(--shadow);
}
.avatar-card.selected {
  border-color: #4CAF50;
  background: linear-gradient(160deg, #f0fff4 0%, #e4f9e8 100%);
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 16px 36px rgba(76,175,80,0.28), 0 0 0 2px rgba(76,175,80,0.18);
}
/* .av3d wrapper inside card — let shadows overflow freely */
.avatar-card .card-av {
  overflow: visible;
  display: block;
}
/* Direct-child img only (fallback if av3d unavailable) */
.avatar-card > img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  filter: drop-shadow(2px 10px 18px rgba(0,0,0,0.25));
  transition: filter 0.2s, transform 0.2s;
}
.avatar-card .avatar-name {
  font-weight: 900;
  font-size: 0.92rem;
  color: var(--text);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.avatar-card.selected .avatar-name {
  color: #2e7d32;
}

/* Name input */
.name-input-wrap {
  width: 100%;
  max-width: min(100%, clamp(300px, 75vw, 520px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.name-input-wrap label {
  font-weight: 700;
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: var(--text-light);
}
.name-input {
  width: 100%;
  padding: clamp(12px, 2.5vw, 16px) clamp(14px, 3vw, 22px);
  font-family: 'Nunito', sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 700;
  border: 2px solid #d0e8d0;
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: #4CAF50; }
.name-input::placeholder { color: #aac; font-weight: 400; }

/* Join button */
.join-btn-wrap { width: 100%; max-width: min(100%, clamp(300px, 75vw, 520px)); }

/* Waiting in lobby (player) */
.player-waiting {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}
.player-waiting .avatar-big {
  position: relative;
  display: inline-block;
}
.player-waiting .decoration-big {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  animation: float 3s ease-in-out infinite;
}
.player-waiting h2 { font-size: clamp(1.2rem, 5vw, 1.7rem); font-weight: 900; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.3); text-align: center; }
.player-waiting p  { font-size: clamp(0.9rem, 3vw, 1.05rem); color: rgba(255,255,255,0.85); text-shadow: 0 1px 3px rgba(0,0,0,0.2); text-align: center; }
.player-waiting .dots span {
  display: inline-block;
  animation: blink 1.2s infinite;
}
.player-waiting .dots span:nth-child(2) { animation-delay: 0.2s; }
.player-waiting .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:0} 40%{opacity:1} }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
@keyframes float  { 0%,100%{transform:translateX(-50%) translateY(0)} 50%{transform:translateX(-50%) translateY(-8px)} }

/* ═══════════════════════════════════════
   QUIZ QUESTION (Player Phone)
═══════════════════════════════════════ */
.quiz-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Timer bar */
.timer-bar-wrap {
  padding: 12px 16px 0;
  flex-shrink: 0;
}
.timer-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.timer-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
  transition: width 0.9s linear, background 0.5s;
}
.timer-bar-fill.warn { background: linear-gradient(90deg, #FF9800, #FFB300); }
.timer-bar-fill.danger { background: linear-gradient(90deg, #FF5722, #FF6B6B); }

.q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  flex-shrink: 0;
}
.q-num { font-size: 0.85rem; font-weight: 700; color: rgba(255,255,255,0.8); }
.q-timer { font-size: 1.4rem; font-weight: 900; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }

.q-text-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(12px, 4vw, 32px);
  overflow-y: auto;
}
.q-text {
  font-size: clamp(0.95rem, 2.5vw, 1.3rem);
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.55;
  width: 100%;
  max-width: min(100%, clamp(320px, 88vw, 720px));
  background: rgba(255,255,255,0.72);
  border-radius: var(--radius);
  padding: clamp(14px, 3.5vw, 28px) clamp(16px, 4vw, 36px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px var(--shadow);
}

/* Answer buttons (Kahoot style) */
.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 2vw, 14px);
  padding: clamp(10px, 2vw, 16px) clamp(12px, 4vw, 32px) clamp(16px, 3vw, 24px);
  flex-shrink: 0;
  width: 100%;
  max-width: min(100%, clamp(340px, 92vw, 780px));
  align-self: center;
}
.ans-btn {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 14px);
  padding: clamp(13px, 2.8vh, 22px) clamp(12px, 3.5vw, 22px);
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(0.85rem, 2.4vw, 1.1rem);
  color: white;
  text-align: left;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}
.ans-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: rgba(255,255,255,0.12);
  border-radius: 16px 16px 0 0;
}
.ans-btn:hover:not(:disabled) { transform: scale(1.03); box-shadow: 0 6px 18px rgba(0,0,0,0.2); }
.ans-btn:active:not(:disabled) { transform: scale(0.97); }
.ans-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ans-btn .ans-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  font-weight: 900;
  flex-shrink: 0;
}

.ans-A { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.ans-B { background: linear-gradient(135deg, #3498db, #2980b9); }
.ans-C { background: linear-gradient(135deg, #f39c12, #d68910); }
.ans-D { background: linear-gradient(135deg, #27ae60, #229954); }

/* Answered state (waiting for others) */
.answered-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}
.answered-avatar {
  position: relative;
  display: inline-block;
}
@keyframes wiggle {
  0%,100%{transform:rotate(-5deg)} 50%{transform:rotate(5deg)}
}
.answered-screen h2 { font-size: 1.3rem; font-weight: 900; text-align: center; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* Result reveal (player) */
.result-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
.result-big-icon {
  font-size: clamp(3.5rem, 16vw, 6rem);
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
  line-height: 1;
}
.result-big-icon.correct { }
.result-big-icon.wrong { }
@keyframes popIn { from{transform:scale(0)} to{transform:scale(1)} }

.result-score-delta {
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  font-weight: 900;
  color: #a8ff78;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.result-score-delta.zero { color: rgba(255,255,255,0.6); }
.result-total {
  font-size: 1rem;
  color: rgba(255,255,255,0.9);
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.result-waiting {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
}

/* Final screen (player) */
.final-player {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}
.final-rank {
  font-size: clamp(2.8rem, 12vw, 4.5rem);
  font-weight: 900;
}
.final-rank-label { font-size: clamp(0.9rem, 3vw, 1.1rem); color: rgba(255,255,255,0.85); font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.final-score { font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 900; color: #ffe066; text-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* ═══════════════════════════════════════
   ADMIN SCREEN
═══════════════════════════════════════ */
.admin-screen {
  height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(6px, 1.2vw, 14px);
  gap: clamp(6px, 1vw, 12px);
}

/* Admin header */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 8px 12px;
  background: rgba(242,249,246,0.72);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px var(--shadow);
}
.admin-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-header img  {
  height: clamp(36px, 5vw, 56px);
  flex-shrink: 0;
  mask-image: radial-gradient(ellipse 68% 68% at center, black 28%, rgba(0,0,0,0.55) 52%, transparent 74%);
  -webkit-mask-image: radial-gradient(ellipse 68% 68% at center, black 28%, rgba(0,0,0,0.55) 52%, transparent 74%);
}
.admin-header-brand { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.admin-brand-name   { font-size: 0.68rem; font-weight: 800; color: var(--text-light); letter-spacing: 0.10em; text-transform: uppercase; line-height: 1; margin-bottom: 1px; }
.admin-header h1    { font-size: clamp(0.9rem, 1.4vw, 1.15rem); font-weight: 900; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.admin-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.tab-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 12px 12px 0 0;
  background: rgba(220,240,232,0.45);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: rgba(235,248,242,0.88);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow);
}

/* Admin content area */
.admin-content {
  flex: 1;
  overflow: hidden;
  background: rgba(235,248,242,0.72);
  backdrop-filter: blur(14px);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  display: flex;
  flex-direction: column;
}

/* ─── LOBBY TAB ─── */
.lobby-layout {
  display: grid;
  grid-template-columns: clamp(220px, 26%, 320px) 1fr;
  grid-template-rows: 1fr;
  height: 100%;
  gap: 0;
  overflow: hidden;
}

/* QR panel */
.qr-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border-right: 1px solid rgba(0,0,0,0.06);
  overflow-y: auto;
}
.qr-panel h2 { font-size: 1rem; font-weight: 900; color: #3a1f06; text-align: center; }
.qr-box {
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 16px var(--shadow);
}
.qr-url {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
  word-break: break-all;
  background: #f0f4f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
}
.player-count-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
}
.player-count-badge .count-num { font-size: 2rem; color: #4CAF50; }
.start-controls { display: flex; flex-direction: column; gap: 8px; width: 100%; }

/* Player list panel */
.player-list-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.player-list-panel h3 { font-size: 1rem; font-weight: 800; color: var(--text); flex-shrink: 0; }
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  overflow-y: auto;
  align-content: start;
}
.player-tile {
  background: white;
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px var(--shadow);
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
  animation: tileIn 0.3s ease;
}
@keyframes tileIn { from{opacity:0;transform:scale(0.8)} to{opacity:1;transform:scale(1)} }
.player-tile .tile-avatar-wrap {
  width: 52px; height: 52px;
  position: relative;
}
.player-tile .tile-avatar {
  width: 52px; height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.1));
}
.player-tile .tile-decoration {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.3rem;
}
.player-tile .tile-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-tile .tile-color-bar {
  width: 40px; height: 5px;
  border-radius: 3px;
}

/* ─── GAME QUESTION TAB (admin) ─── */
.admin-question-layout {
  display: grid;
  grid-template-columns: 1fr clamp(220px, 24vw, 300px);
  height: 100%;
  overflow: hidden;
}

.question-main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.question-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.question-text-big {
  font-size: clamp(1rem, 1.8vw, 1.6rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.4;
}
.choices-grid-admin {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice-admin {
  padding: clamp(8px, 1.2vw, 14px) clamp(10px, 1.5vw, 18px);
  border-radius: 14px;
  font-weight: 700;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.choice-admin .choice-letter {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  flex-shrink: 0;
}
.choice-admin.correct { border: 3px solid rgba(255,255,255,0.6); box-shadow: 0 0 20px rgba(255,255,255,0.3); }
.choice-admin.correct::after {
  content: '✓';
  position: absolute;
  right: 14px;
  font-size: 1.4rem;
  font-weight: 900;
}
.choice-A-bg { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.choice-B-bg { background: linear-gradient(135deg, #3498db, #2980b9); }
.choice-C-bg { background: linear-gradient(135deg, #f39c12, #d68910); }
.choice-D-bg { background: linear-gradient(135deg, #27ae60, #229954); }

/* Progress panel (right side of admin question) */
.answer-progress-panel {
  padding: 16px;
  border-left: 1px solid rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.progress-count {
  text-align: center;
}
.progress-count .big-num { font-size: 2.5rem; font-weight: 900; color: var(--text); line-height: 1; }
.progress-count .small-label { font-size: 0.85rem; color: var(--text-light); font-weight: 600; }

/* Timer (admin) */
.admin-timer {
  text-align: center;
  font-size: clamp(1.8rem, 3.5vw, 3.5rem);
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}
.admin-timer.warn   { color: #FF9800; animation: pulse 0.5s ease infinite; }
.admin-timer.danger { color: #FF5722; animation: pulse 0.3s ease infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.06)} }

/* Answered player list in progress */
.answer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
}
.answers-hidden-msg {
  text-align: center;
  padding: 12px 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #999;
  border: 2px dashed #ddd;
  border-radius: 10px;
  letter-spacing: 0.01em;
}
.answer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 1px 4px var(--shadow);
  animation: tileIn 0.2s ease;
}
.answer-row img { width: 28px; height: 28px; object-fit: contain; }
.answer-row .row-name { font-size: 0.85rem; font-weight: 700; flex: 1; }
.answer-row .row-status { font-size: 1.2rem; }
.answer-row .row-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
}

/* ─── VILLAGE VIEW (admin - all states) ─── */
.village-section {
  padding: 12px;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.village-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  align-items: flex-end;
  gap: 20px;
  padding: 20px 24px;
  background: linear-gradient(180deg, #c8e4f8 0%, #d6ecb0 55%, #96c96a 100%);
  border-radius: 20px;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.08);
  min-height: 280px;
  position: relative;
}
.village-wrap::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(180deg, transparent, rgba(110,190,80,0.3));
  border-radius: 0 0 20px 20px;
  pointer-events: none;
}
/* Ground dots/flowers */
.village-wrap::after {
  content: '🌸 🌼 🌺 🍀 🌸 🌼';
  position: absolute;
  bottom: 8px; left: 0; right: 0;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.6;
  pointer-events: none;
}

/* Player building unit */
.village-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}
.village-player:hover { transform: translateY(-4px); }

.vp-avatar-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 2px;
  /* size is now controlled by --av-size on the inner .av3d */
  overflow: visible; /* allow ground shadow + reflection to spill */
}
/* .av3d inside vp-avatar-wrap owns animation+filter; just ensure sizing */
.vp-avatar-wrap .av3d { display: inline-block; }
/* Hover brightness is preserved via the .av3d system's drop-shadow increase */
.vp-avatar-wrap:hover .av3d > img {
  filter:
    drop-shadow(4px 14px 20px rgba(0,0,0,0.40))
    drop-shadow(-1px 4px 10px rgba(0,0,0,0.20))
    drop-shadow(0 18px 6px rgba(0,0,0,0.14))
    brightness(1.05);
}
.vp-decoration {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4rem;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.15));
}
@keyframes bobFloat {
  0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)}
}

/* ─── Cozy Cottage Building ─── */
.building {
  --bcolor: #FF6B6B;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.5s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom center;
  filter: drop-shadow(2px 5px 10px rgba(50,15,0,0.32));
  position: relative;
}

/* ── Grow — building bounces upward + golden shimmer ── */
.building.grow-anim {
  animation: buildGrow 0.65s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes buildGrow {
  0%   { transform: scale(1) translateY(0); filter: drop-shadow(2px 5px 10px rgba(50,15,0,0.32)); }
  28%  { transform: scale(1.07) translateY(-7px); filter: drop-shadow(0 0 24px rgba(255,210,50,0.9)) drop-shadow(2px 5px 10px rgba(50,15,0,0.22)); }
  52%  { transform: scale(0.97) translateY(2px); }
  75%  { transform: scale(1.02) translateY(-2px); filter: drop-shadow(0 0 10px rgba(255,210,50,0.4)) drop-shadow(2px 5px 10px rgba(50,15,0,0.30)); }
  100% { transform: scale(1) translateY(0); filter: drop-shadow(2px 5px 10px rgba(50,15,0,0.32)); }
}

/* ── Wrong — violent shake + dark red crack flash ── */
.building.wrong-anim {
  animation: buildWrong 0.75s ease both;
}
@keyframes buildWrong {
  0%   { transform: translateX(0) rotate(0); filter: drop-shadow(2px 5px 10px rgba(50,15,0,0.32)); }
  8%   { transform: translateX(-8px) rotate(-2deg); filter: drop-shadow(0 0 20px rgba(220,30,30,0.95)) brightness(0.6) saturate(2.2); }
  20%  { transform: translateX(8px)  rotate(2deg);  filter: drop-shadow(0 0 16px rgba(200,20,20,0.80)) brightness(0.65) saturate(2); }
  32%  { transform: translateX(-6px) rotate(-1.5deg); filter: drop-shadow(0 0 10px rgba(200,20,20,0.60)) brightness(0.72); }
  44%  { transform: translateX(5px)  rotate(1deg);  filter: drop-shadow(0 0 6px rgba(200,20,20,0.40)); }
  55%  { transform: translateX(-3px) rotate(-0.5deg); }
  66%  { transform: translateX(3px)  rotate(0.5deg); }
  78%  { transform: translateX(-1px); }
  90%  { transform: translateX(1px); }
  100% { transform: translateX(0) rotate(0); filter: drop-shadow(2px 5px 10px rgba(50,15,0,0.32)); }
}

/* ── Peaked roof: wide triangle with shingle tiles + prominent eave ── */
.building-roof {
  width: 148px;
  height: 78px;
  position: relative;
  z-index: 3;
  flex-shrink: 0;
}
/* Triangular peak with visible shingle/tile lines */
.building-roof::before {
  content: '';
  position: absolute;
  bottom: 18px; left: 0; right: 0;
  height: 62px;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0,0,0,0)    0px, rgba(0,0,0,0)    9px,
      rgba(0,0,0,0.11) 9px, rgba(0,0,0,0.05) 11px
    ),
    linear-gradient(
      160deg,
      color-mix(in srgb, var(--bcolor) 92%, #fff) 0%,
      var(--bcolor) 40%,
      color-mix(in srgb, var(--bcolor) 58%, #180400) 100%
    );
  clip-path: polygon(0 100%, 50% 0%, 100% 100%);
}
/* Wide eave overhang */
.building-roof::after {
  content: '';
  position: absolute;
  bottom: 0; left: -12px; right: -12px;
  height: 18px;
  background: color-mix(in srgb, var(--bcolor) 46%, #180400);
  border-radius: 6px 6px 0 0;
  box-shadow:
    0 5px 14px rgba(0,0,0,0.32),
    inset 0 3px 6px rgba(255,255,255,0.13),
    inset 0 -2px 5px rgba(0,0,0,0.20);
}
/* Chimney with brick texture */
.building-chimney {
  position: absolute;
  top: 8px; right: 30px;
  width: 15px; height: 32px;
  background:
    repeating-linear-gradient(
      180deg,
      color-mix(in srgb, var(--bcolor) 32%, #2a0800) 0px 5px,
      color-mix(in srgb, var(--bcolor) 20%, #3a1200) 5px 7px
    );
  border-radius: 2px 2px 0 0;
  z-index: 4;
  box-shadow: 2px 0 6px rgba(0,0,0,0.28);
}
/* Chimney cap */
.building-chimney::before {
  content: '';
  position: absolute;
  top: -5px; left: -4px; right: -4px;
  height: 8px;
  background: color-mix(in srgb, var(--bcolor) 40%, #3a1000);
  border-radius: 3px;
  box-shadow: 0 -2px 5px rgba(0,0,0,0.22);
}

/* ── Floor stack (column-reverse: first child = bottom = ground) ── */
.building-floors {
  display: flex;
  flex-direction: column-reverse;
  overflow: visible;
}
/* Each floor = one cottage story: stone-brick walls with arched windows */
.building-floor {
  width: 128px;
  height: 58px;
  background:
    /* vertical mortar seams */
    repeating-linear-gradient(
      90deg,
      transparent 0px 26px,
      rgba(140,90,40,0.13) 26px 27px,
      transparent 27px 53px,
      rgba(140,90,40,0.13) 53px 54px
    ),
    /* horizontal mortar lines */
    repeating-linear-gradient(
      180deg,
      transparent 0px 14px,
      rgba(140,90,40,0.11) 14px 16px
    ),
    /* warm sandstone wall */
    linear-gradient(
      to right,
      #c0a05e 0%, #dcc08a 6%, #f8eccc 50%, #dcc08a 94%, #c0a05e 100%
    );
  border-left:  6px solid #a87838;
  border-right: 5px solid #c89850;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 12px;
  position: relative;
  animation: floorRiseGlow 0.55s cubic-bezier(0.34,1.56,0.64,1) backwards;
  transform-origin: bottom center;
}
/* Decorative cornice ledge at the top of each floor */
.building-floor::after {
  content: '';
  position: absolute;
  top: -2px; left: -6px; right: -5px;
  height: 9px;
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--bcolor) 38%, #180400) 0%,
    color-mix(in srgb, var(--bcolor) 55%, #180400) 50%,
    color-mix(in srgb, var(--bcolor) 38%, #180400) 100%
  );
  border-radius: 4px 4px 0 0;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.18), inset 0 1px 3px rgba(255,255,255,0.10);
}

/* ── Correct answer: floor rises with golden glow ── */
@keyframes floorRiseGlow {
  0%   { transform: scaleY(0); opacity: 0.15; filter: brightness(2.8) saturate(1.8); }
  38%  { transform: scaleY(1.14); filter: brightness(1.5) drop-shadow(0 -8px 16px rgba(255,210,50,0.80)); }
  62%  { transform: scaleY(0.96); filter: brightness(1.15) drop-shadow(0 -3px 7px rgba(255,210,50,0.35)); }
  83%  { transform: scaleY(1.02); }
  100% { transform: scaleY(1); opacity: 1; filter: none; }
}

/* ── Wrong answer: damaged / cracked stone floor ── */
.building-floor.floor-wrong {
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px 26px,
      rgba(70,35,5,0.18) 26px 27px,
      transparent 27px 53px,
      rgba(70,35,5,0.18) 53px 54px
    ),
    repeating-linear-gradient(
      180deg,
      transparent 0px 14px,
      rgba(70,35,5,0.16) 14px 16px
    ),
    linear-gradient(
      to right,
      #8a6840 0%, #a88456 6%, #c4a070 50%, #a88456 94%, #8a6840 100%
    );
  filter: brightness(0.76) sepia(0.22);
}
.building-floor.floor-wrong::after {
  background: color-mix(in srgb, var(--bcolor) 18%, #3a0800);
}
.building-floor.floor-wrong .floor-window {
  background: linear-gradient(165deg, rgba(170,140,70,0.50) 0%, rgba(110,80,30,0.40) 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.22);
}
/* On dark wrong floors, crack lines use screen blend so they appear as
   bright golden fractures — visible against the dark wall background */
.building-floor.floor-wrong .crack-scar {
  background:
    linear-gradient(var(--ca1),
      transparent 32.5%, rgba(255,225,140,0.22) 33.5%, rgba(255,245,190,0.34) 34.5%, transparent 35.5%,
      transparent 51.5%, rgba(245,210,120,0.16) 52.5%, rgba(255,225,140,0.26) 53.5%, transparent 54.5%
    ),
    linear-gradient(var(--ca2),
      transparent 19.5%, rgba(250,215,130,0.18) 20.5%, rgba(255,230,160,0.30) 21.5%, transparent 22.5%
    );
  mix-blend-mode: screen;
}

/* Wrong floor rises with red crash flash, then settles dark */
@keyframes floorRiseDamaged {
  0%   { transform: scaleY(0); opacity: 0.15; filter: brightness(2.5) sepia(1) hue-rotate(-40deg); }
  28%  { transform: scaleY(1.12); filter: brightness(0.55) sepia(0.9) hue-rotate(-38deg) drop-shadow(0 -7px 18px rgba(195,35,10,0.85)); }
  52%  { transform: scaleY(0.97); filter: brightness(0.65) sepia(0.65) hue-rotate(-20deg); }
  78%  { transform: scaleY(1.01); filter: brightness(0.74) sepia(0.28); }
  100% { transform: scaleY(1);    opacity: 1; filter: brightness(0.78) sepia(0.2); }
}

/* ── Wrong answer: floor cracks and crumbles dramatically ── */
@keyframes floorCrumble {
  0%   { transform: scaleX(1) scaleY(1) rotate(0) translateY(0); opacity: 1; filter: none; }
  12%  { transform: scaleX(1.08) scaleY(0.88) translateY(-4px); filter: brightness(0.72) sepia(0.7) hue-rotate(-25deg); }
  26%  { transform: scaleX(0.90) scaleY(1.08) rotate(-4deg) translateY(4px); filter: brightness(0.55) sepia(1) hue-rotate(-45deg); }
  45%  { transform: scaleX(0.80) scaleY(0.94) rotate(-8deg) translateY(18px); filter: brightness(0.42) sepia(1) hue-rotate(-55deg); opacity: 0.70; }
  100% { transform: scaleX(0.08) scaleY(0.25) rotate(-20deg) translateY(110px); filter: brightness(0.3) sepia(1); opacity: 0; }
}
.floor-collapse {
  animation: floorCrumble 0.6s cubic-bezier(0.55,0,1,0.45) forwards !important;
  pointer-events: none;
  position: relative;
  z-index: 10;
}

/* ── Arched windows — bigger warm glowing panes ── */
.floor-window {
  width: 20px; height: 32px;
  background: linear-gradient(165deg,
    rgba(255,254,200,0.99) 0%,
    rgba(255,235,65,0.92)  55%,
    rgba(255,205,20,0.78)  100%
  );
  border-radius: 9px 9px 2px 2px;
  box-shadow:
    inset 0 1px 4px rgba(0,0,0,0.07),
    0 0 11px rgba(255,228,55,0.72),
    0 0 26px rgba(255,205,20,0.38);
  border: 2px solid rgba(175,115,12,0.32);
  position: relative;
  flex-shrink: 0;
}
.floor-window::before {
  content: '';
  position: absolute;
  top: 47%; left: 2px; right: 2px;
  height: 1.5px;
  background: rgba(138,82,8,0.28);
}
.floor-window::after {
  content: '';
  position: absolute;
  top: 3px; bottom: 2px; left: 50%;
  width: 1.5px;
  transform: translateX(-0.75px);
  background: rgba(138,82,8,0.28);
}

/* ── Ground: grassy base with flower bushes ── */
.building-ground {
  width: 152px; height: 32px;
  background:
    /* grass strip cap */
    linear-gradient(to bottom, #3aaa5c 0%, #2a8844 30%, transparent 30%),
    /* stone foundation */
    linear-gradient(to bottom, #8a5c30 0%, #5a3415 100%);
  border-radius: 2px 2px 12px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  overflow: visible;
  box-shadow: 0 6px 16px rgba(0,0,0,0.30);
}
/* Left bush with pink + yellow flowers */
.building-ground::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 4px;
  width: 34px; height: 26px;
  background:
    radial-gradient(circle at 68% 18%, rgba(255,85,115,0.93) 3.5px, transparent 5px),
    radial-gradient(circle at 30% 22%, rgba(255,232,65,0.90) 3px, transparent 4.5px),
    radial-gradient(ellipse at 42% 68%, #3aaa58, #1a6030);
  border-radius: 65% 65% 38% 38%;
  box-shadow: 0 3px 7px rgba(0,0,0,0.22);
}
/* Right bush with orange flower */
.building-ground::after {
  content: '';
  position: absolute;
  bottom: -1px; right: 4px;
  width: 30px; height: 22px;
  background:
    radial-gradient(circle at 60% 20%, rgba(255,180,55,0.93) 3px, transparent 4.5px),
    radial-gradient(ellipse at 46% 66%, #46b862, #1a6030);
  border-radius: 65% 65% 38% 38%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.20);
}
/* Arched wooden door */
.building-door {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 38px;
  background: linear-gradient(to bottom, #7c3e14, #3a1800);
  border-radius: 10px 10px 0 0;
  box-shadow: inset -2px 0 5px rgba(0,0,0,0.35), inset 0 0 8px rgba(0,0,0,0.45);
}
/* Door arch inner highlight */
.building-door::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px; right: 2px;
  height: 40%;
  border-radius: 8px 8px 0 0;
  background: rgba(255,175,75,0.14);
}
/* Door knob */
.building-door::after {
  content: '';
  position: absolute;
  top: 52%; right: 3px;
  transform: translateY(-50%);
  width: 3.5px; height: 3.5px;
  border-radius: 50%;
  background: rgba(255,220,0,0.98);
  box-shadow: 0 0 5px rgba(255,205,40,0.78);
}

/* ── Score & name labels ── */
.vp-name {
  font-size: 0.76rem;
  font-weight: 800;
  color: #3a1800;
  text-align: center;
  background: rgba(255,248,228,0.92);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(80,30,0,0.20), 0 1px 0 rgba(255,255,255,0.60) inset;
  border: 1px solid rgba(200,140,60,0.30);
}
.vp-score {
  font-size: 0.73rem;
  font-weight: 800;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, #ff9a00, #e65c00);
  border-radius: 999px;
  padding: 1px 9px;
  box-shadow: 0 2px 6px rgba(200,80,0,0.35);
}

/* ─── LEADERBOARD ─── */
.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 6px var(--shadow);
  transition: all 0.3s ease;
}
.lb-row.rank-1 { background: linear-gradient(90deg, #fff8e1, #fffde7); border: 2px solid #FFD700; }
.lb-row.rank-2 { background: linear-gradient(90deg, #f5f5f5, #fafafa); border: 2px solid #C0C0C0; }
.lb-row.rank-3 { background: linear-gradient(90deg, #fbe9e7, #fff3e0); border: 2px solid #CD7F32; }
.lb-rank { font-size: 1rem; font-weight: 900; width: 28px; text-align: center; }
.lb-avatar { width: 32px; height: 32px; object-fit: contain; }
/* Override av3d padding/sizing for tight leaderboard rows */
.lb-av3d.av3d {
  padding-bottom: 0;           /* no ground reflection area in compact rows */
  overflow: visible;
  vertical-align: middle;
}
.lb-av3d.av3d::before { display: none; }  /* suppress ground shadow in lb */
.lb-av3d.av3d::after  { display: none; }
.lb-decoration { font-size: 1rem; }
.lb-name { flex: 1; font-weight: 700; font-size: 0.9rem; }
.lb-score { font-weight: 900; font-size: 1rem; color: #4CAF50; }

/* ─── QUESTION MANAGER TAB ─── */
.qmgr-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.qmgr-list {
  width: clamp(180px, 23vw, 280px);
  border-right: 1px solid rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.duration-setting {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,200,100,0.12);
  flex-shrink: 0;
}
.duration-label { font-size: 0.8rem; font-weight: 700; color: var(--text); opacity: 0.75; display: block; margin-bottom: 8px; }
.duration-controls { display: flex; align-items: center; gap: 6px; }
.dur-btn {
  padding: 4px 10px; font-size: 0.85rem; font-weight: 700;
  border: none; border-radius: 8px; cursor: pointer;
  background: var(--card-bg); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  transition: background 0.15s;
}
.dur-btn:hover { background: #e8f5e9; }
.dur-value { font-size: 1.3rem; font-weight: 900; color: var(--primary); min-width: 52px; text-align: center; }

.qmgr-list-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.qmgr-list-header h3 { font-size: 0.95rem; font-weight: 800; }
.qmgr-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qmgr-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: white;
  border: 2px solid transparent;
  transition: all 0.15s;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.qmgr-item:hover { background: #f0fff4; }
.qmgr-item.selected { border-color: #4CAF50; background: #f0fff4; }
.qmgr-item .q-idx { font-size: 0.75rem; font-weight: 900; color: var(--text-light); flex-shrink: 0; }
.qmgr-item .q-preview { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.qmgr-editor {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.qmgr-editor.empty {
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-weight: 600;
}

/* Form fields */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid #d0e8d0;
  border-radius: 10px;
  background: white;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: #4CAF50; }
.form-textarea { min-height: 80px; }

.choices-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice-form-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.choice-label {
  width: 28px; height: 28px;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.label-A { background: #e74c3c; }
.label-B { background: #3498db; }
.label-C { background: #f39c12; }
.label-D { background: #27ae60; }

.qmgr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ─── FINAL SCREEN (admin) ─── */
.final-admin {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}
.final-title {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
}
.final-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}
.podium-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.podium-avatar-wrap { position: relative; }
.podium-avatar { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15)); }
.podium-deco { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: 1.6rem; }
.podium-name { font-size: 0.85rem; font-weight: 800; text-align: center; }
.podium-score { font-size: 1rem; font-weight: 900; color: #4CAF50; }
.podium-base {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 0 0;
  font-size: 1.4rem;
  font-weight: 900;
  color: white;
  width: 90px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.podium-1st .podium-base { background: linear-gradient(135deg, #f6d365, #fda085); height: 80px; }
.podium-2nd .podium-base { background: linear-gradient(135deg, #a0a0a0, #c8c8c8); height: 60px; }
.podium-3rd .podium-base { background: linear-gradient(135deg, #cd7f32, #e8a87c); height: 44px; }

/* Responsive */
@media (max-width: 768px) {
  .lobby-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .qr-panel { border-right: none; border-bottom: 1px solid rgba(0,0,0,0.06); }
  .admin-question-layout { grid-template-columns: 1fr; }
  .answer-progress-panel { border-left: none; border-top: 1px solid rgba(0,0,0,0.06); }
  .qmgr-layout { flex-direction: column; }
  .qmgr-list { width: 100%; max-height: 200px; }
  .choices-grid-admin { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   VILLAGE-FIRST GAME LAYOUT (admin)
   ═══════════════════════════════════════════ */

/* Admin content becomes transparent so autumn sky shows through */
.admin-content.game-mode {
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  border-radius: 0;
}
/* Collapse empty tabs row so it doesn't create a gap */
#admin-tabs-row:empty { display: none; }
/* Game mode: edge-to-edge, no side gutters */
.admin-screen:has(.game-mode) {
  padding: 0;
  gap: 0;
}
.admin-screen:has(.game-mode) .admin-header {
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* Full-height flex column: village on top, dock at bottom */
.admin-game-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Village arena: the main garden stage ── */
.village-arena {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  align-content: flex-end;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 16px 28px 32px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
  background:
    /* rolling grass hill at bottom */
    radial-gradient(ellipse 120% 55% at 50% 115%, #2E7A50 0%, #3D9060 40%, transparent 68%),
    /* soft mist in mid */
    linear-gradient(180deg,
      transparent 0%,
      rgba(60,160,100,0.18) 50%,
      rgba(40,130,75,0.50) 82%,
      #2E8050 100%
    );
  position: relative;
  min-height: clamp(160px, 30vh, 9999px);
  container-type: inline-size;
  container-name: arena;
}
.village-arena::before {     /* subtle ground line */
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 26px;
  background: linear-gradient(180deg, transparent, rgba(80,150,30,0.4));
  pointer-events: none;
}
.village-arena::after {      /* flowers along the ground */
  content: '🌸 🌼 🌺 🍀 🌻 🌸 🌼 🌺 🍀 🌻 🌸 🌼';
  position: absolute;
  bottom: 5px; left: 0; right: 0;
  text-align: center;
  font-size: 1rem;
  opacity: 0.65;
  pointer-events: none;
  letter-spacing: 6px;
}
/* Scale buildings based on the arena's actual width (container queries) */
.village-arena .village-player { zoom: 0.72; }

@container arena (min-width: 420px)  { .village-player { zoom: 0.82; } }
@container arena (min-width: 560px)  { .village-player { zoom: 0.94; } }
@container arena (min-width: 720px)  { .village-player { zoom: 1.08; } }
@container arena (min-width: 900px)  { .village-player { zoom: 1.24; } }
@container arena (min-width: 1100px) { .village-player { zoom: 1.42; } }
@container arena (min-width: 1350px) { .village-player { zoom: 1.64; } }
@container arena (min-width: 1650px) { .village-player { zoom: 1.90; } }
@container arena (min-width: 2000px) { .village-player { zoom: 2.25; } }
@container arena (min-width: 2400px) { .village-player { zoom: 2.65; } }

/* ── Question dock (bottom compact panel) ── */
.question-dock {
  flex-shrink: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 22px rgba(0,0,0,0.14);
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.q-dock-inner {
  display: grid;
  grid-template-columns: 1fr clamp(200px, 18vw, 280px);
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.q-dock-left {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.q-dock-right {
  padding: 14px 12px;
  border-left: 1px solid rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.q-dock-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.q-dock-text {
  font-size: clamp(0.9rem, 1.5vw, 1.4rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
  flex-shrink: 0;
}
.q-dock-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}
.explanation-box {
  background: #e8f5e9;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2e7d32;
  flex-shrink: 0;
}
/* Final dock: same style but scrollable */
.final-dock-inner {
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}
.final-title {
  font-size: 1.4rem;
  font-weight: 900;
  text-align: center;
  color: var(--text);
}

/* ═══════════════════════════════════════════
   PLAYER VIEW WITH VILLAGE STRIP
   ═══════════════════════════════════════════ */

/* Outer wrapper used on player screens that show the village */
.player-screen-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}
/* The main content (avatar, question, etc.) fills remaining space */
.player-screen-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0 16px;
  min-height: 0;
}

/* Mini-village strip at the bottom of player screens */
.village-strip {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 60px 16px 16px;
  background:
    radial-gradient(ellipse 120% 60% at 50% 120%, #2E7A50 0%, #3D9060 45%, transparent 70%),
    linear-gradient(180deg,
      transparent 0%,
      rgba(60,150,90,0.30) 50%,
      rgba(40,120,70,0.68) 100%
    );
  min-height: 220px;
  scrollbar-width: none;
}
.village-strip::-webkit-scrollbar { display: none; }
.village-strip .village-player { zoom: 0.62; flex-shrink: 0; }
/* Highlight own building in the strip */
.village-strip .village-player.is-me .building {
  filter: drop-shadow(0 0 10px rgba(255,215,0,0.72)) drop-shadow(1px 3px 6px rgba(0,0,0,0.22));
}
.village-strip .village-player.is-me .vp-name {
  background: rgba(255,215,0,0.9);
  color: var(--text);
}

/* ── Crack-damage system ── */

/* Flash overlay — plays once then vanishes (permanent scar follows) */
.crack-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(112deg,
      transparent 34%, rgba(70,8,0,0.88) 34.7%, rgba(95,14,0,0.92) 35.4%, transparent 36.2%,
      transparent 55%, rgba(55,5,0,0.72) 55.7%, rgba(75,10,0,0.78) 56.4%, transparent 57.2%
    ),
    linear-gradient(248deg,
      transparent 22%, rgba(60,6,0,0.78) 22.8%, rgba(82,12,0,0.82) 23.5%, transparent 24.4%
    );
  animation: crackFlash 0.9s ease forwards;
  overflow: hidden;
}
@keyframes crackFlash {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  55%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Permanent crack scar — stays on the floor forever */
.crack-scar {
  --ca1: 112deg;
  --ca2: 248deg;
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(var(--ca1),
      transparent 33%, rgba(50,4,0,0.52) 33.8%, rgba(72,10,0,0.58) 34.6%, transparent 35.5%,
      transparent 52%, rgba(40,3,0,0.42) 52.8%, rgba(60,7,0,0.48) 53.6%, transparent 54.4%
    ),
    linear-gradient(var(--ca2),
      transparent 20%, rgba(45,4,0,0.46) 20.9%, rgba(65,9,0,0.52) 21.7%, transparent 22.6%
    );
  mix-blend-mode: multiply;
}

/* Floor progressively darkens with accumulated damage */
.building-floor[data-damage="1"] { filter: brightness(0.92); }
.building-floor[data-damage="2"] { filter: brightness(0.83); }
.building-floor[data-damage="3"] { filter: brightness(0.74); }
.building-floor[data-damage="4"] { filter: brightness(0.66) sepia(0.15); }

/* Shake the cracked floor during flash */
.building-floor.cracking {
  animation: floorShake 0.55s ease both !important;
}
@keyframes floorShake {
  0%   { transform: translateX(0); filter: none; }
  12%  { transform: translateX(-4px); filter: brightness(0.62) sepia(0.8) hue-rotate(-35deg); }
  26%  { transform: translateX(4px);  filter: brightness(0.58) sepia(1.0) hue-rotate(-50deg); }
  40%  { transform: translateX(-3px); filter: brightness(0.68) sepia(0.6) hue-rotate(-28deg); }
  55%  { transform: translateX(2px);  filter: brightness(0.78) sepia(0.4); }
  70%  { transform: translateX(-1px); filter: brightness(0.88) sepia(0.2); }
  100% { transform: translateX(0);    filter: none; }
}

/* ═══════════════════════════════════════
   RESPONSIVE — ADMIN SCREENS
   ═══════════════════════════════════════ */

/* ─ Phone portrait (< 520px) ─ */
@media (max-width: 520px) {
  .admin-screen { padding: 6px; gap: 6px; }
  .admin-header { padding: 6px 10px; flex-wrap: wrap; gap: 6px; }
  .admin-header h1 { font-size: 0.85rem; }
  .admin-header img { height: 22px; }
  .admin-header-right { gap: 6px; }
  .admin-header-right .btn { padding: 6px 12px; font-size: 0.8rem; }

  .lobby-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .qr-panel { border-right: none; border-bottom: 1px solid rgba(0,0,0,0.06); padding: 12px; gap: 10px; }
  .qr-box { padding: 8px; }
  .qr-box canvas, .qr-box img { width: 130px !important; height: 130px !important; }
  .player-count-badge { font-size: 1.1rem; }
  .player-count-badge .count-num { font-size: 1.5rem; }

  .q-dock-inner { grid-template-columns: 1fr; }
  .q-dock-right { border-left: none; border-top: 1px solid rgba(0,0,0,0.07); max-height: 120px; padding: 8px 10px; }
  .q-dock-choices { grid-template-columns: 1fr; gap: 5px; }
  .q-dock-left { padding: 10px 12px; gap: 7px; }
  .question-dock { max-height: 62vh; }

  .choices-grid-admin { grid-template-columns: 1fr; }
  .choice-admin { padding: 10px 14px; font-size: 0.9rem; }

  .qmgr-layout { flex-direction: column; }
  .qmgr-list { width: 100%; max-height: 170px; }
  .choices-form { grid-template-columns: 1fr; }

  .village-arena .village-player { zoom: 0.56; }
  .village-arena { min-height: 120px; padding: 8px 10px 14px; gap: 8px 10px; }

  .final-podium { gap: 6px; }
  .podium-base { width: 60px; font-size: 1.1rem; }
  .podium-1st .podium-base { height: 54px; }
  .podium-2nd .podium-base { height: 40px; }
  .podium-3rd .podium-base { height: 28px; }
  .podium-name { font-size: 0.75rem; }
}

/* ─ Phone landscape / small tablet (520px–768px) ─ */
@media (max-width: 768px) {
  .admin-header h1 { font-size: 0.95rem; }
  .admin-header-right .btn { font-size: 0.85rem; }

  .lobby-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .qr-panel { border-right: none; border-bottom: 1px solid rgba(0,0,0,0.06); }

  .admin-question-layout { grid-template-columns: 1fr; }
  .answer-progress-panel { border-left: none; border-top: 1px solid rgba(0,0,0,0.06); max-height: 160px; }

  .q-dock-inner { grid-template-columns: 1fr; }
  .q-dock-right { border-left: none; border-top: 1px solid rgba(0,0,0,0.07); max-height: 130px; }
  .q-dock-choices { grid-template-columns: 1fr; }
  .question-dock { max-height: 55vh; }

  .qmgr-layout { flex-direction: column; }
  .qmgr-list { width: 100%; max-height: 200px; }
  .choices-grid-admin { grid-template-columns: 1fr; }

  .village-arena .village-player { zoom: 0.70; }
  .village-arena { min-height: 150px; }

  .final-podium { gap: 8px; }
  .podium-base { width: 72px; }
  .podium-1st .podium-base { height: 62px; }
  .podium-2nd .podium-base { height: 48px; }
  .podium-3rd .podium-base { height: 34px; }
}

/* ─ Tablet landscape / small laptop (768px–1100px) ─ */
@media (min-width: 768px) and (max-width: 1100px) {
  .lobby-layout { grid-template-columns: clamp(200px, 26vw, 260px) 1fr; }
  .q-dock-text { font-size: clamp(0.95rem, 1.3vw, 1.15rem); }
  .admin-timer { font-size: clamp(1.8rem, 2.8vw, 2.6rem); }
  .village-arena .village-player { zoom: 0.80; }
  .village-arena { min-height: clamp(150px, 22vh, 280px); }

  /* Final: podium left, leaderboard right */
  .final-dock-inner {
    display: grid;
    grid-template-columns: clamp(220px, 32vw, 340px) 1fr;
    grid-template-rows: auto 1fr auto;
    column-gap: 16px;
    overflow-y: hidden;
  }
  .final-title   { grid-column: 1 / -1; }
  .final-podium  { grid-column: 1; grid-row: 2; align-self: center; }
  .leaderboard   { grid-column: 2; grid-row: 2 / 4; padding: 0 8px 8px; }
  .final-dock-inner > div:last-child { grid-column: 1; grid-row: 3; }

  /* QR: bigger code box */
  .qr-box canvas, .qr-box img { width: 180px !important; height: 180px !important; }
}

/* ─ Standard laptop (>= 1100px) ─ */
@media (min-width: 1100px) {
  /* Lobby: wider QR panel */
  .lobby-layout { grid-template-columns: clamp(280px, 28vw, 400px) 1fr; }
  .qr-panel { padding: 24px 20px; gap: 16px; }
  .qr-box canvas, .qr-box img { width: 220px !important; height: 220px !important; }
  .player-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .player-tile { padding: 16px 12px; }
  .player-tile .tile-avatar-wrap { width: 60px; height: 60px; }
  .player-count-badge { font-size: 1.6rem; }

  /* Final: 2-column layout */
  .question-dock { max-height: 55vh; }
  .final-dock-inner {
    display: grid;
    grid-template-columns: clamp(260px, 30vw, 380px) 1fr;
    grid-template-rows: auto 1fr auto;
    column-gap: 20px;
    overflow-y: hidden;
  }
  .final-title   { grid-column: 1 / -1; }
  .final-podium  { grid-column: 1; grid-row: 2; align-self: center; justify-content: center; }
  .leaderboard   { grid-column: 2; grid-row: 2 / 4; padding: 0 8px 8px; }
  .final-dock-inner > div:last-child { grid-column: 1; grid-row: 3; }

  /* Bigger podium */
  .podium-base    { width: 110px; }
  .podium-1st .podium-base { height: 96px; }
  .podium-2nd .podium-base { height: 74px; }
  .podium-3rd .podium-base { height: 56px; }
  .podium-name  { font-size: 0.95rem; }
  .podium-score { font-size: 1.1rem; }
  .lb-row       { padding: 10px 16px; }
  .lb-name      { font-size: 1rem; }
  .lb-score     { font-size: 1.1rem; }
}

/* ─ Large display (>= 1440px) ─ */
@media (min-width: 1440px) {
  .village-arena { gap: 16px 40px; }

  .lobby-layout { grid-template-columns: clamp(340px, 30vw, 480px) 1fr; }
  .qr-box canvas, .qr-box img { width: 260px !important; height: 260px !important; }
  .player-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
  .player-tile { padding: 18px 14px; }

  .question-dock { max-height: 58vh; }
  .final-dock-inner { grid-template-columns: clamp(320px, 32vw, 460px) 1fr; column-gap: 28px; }
  .podium-base    { width: 130px; }
  .podium-1st .podium-base { height: 112px; }
  .podium-2nd .podium-base { height: 86px; }
  .podium-3rd .podium-base { height: 64px; }
  .lb-row { padding: 12px 18px; gap: 12px; }
}

/* ─ 1080p / TV (>= 1920px) ─ */
@media (min-width: 1920px) {
  .village-arena { gap: 20px 56px; }
  .admin-timer { font-size: 4rem; }
  .q-dock-text { font-size: 1.55rem; }

  .lobby-layout { grid-template-columns: clamp(400px, 28vw, 560px) 1fr; }
  .qr-box canvas, .qr-box img { width: 300px !important; height: 300px !important; }
  .player-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .player-tile { padding: 22px 16px; }
  .player-count-badge { font-size: 2rem; }
  .player-count-badge .count-num { font-size: 2.6rem; }

  .question-dock { max-height: 60vh; }
  .final-dock-inner { grid-template-columns: clamp(380px, 30vw, 520px) 1fr; column-gap: 36px; padding: 20px 28px; }
  .final-title { font-size: 2rem; }
  .podium-base  { width: 150px; font-size: 2rem; }
  .podium-1st .podium-base { height: 136px; }
  .podium-2nd .podium-base { height: 104px; }
  .podium-3rd .podium-base { height: 76px; }
  .podium-name  { font-size: 1.1rem; }
  .podium-score { font-size: 1.3rem; }
  .lb-row { padding: 13px 20px; gap: 14px; }
  .lb-name  { font-size: 1.1rem; }
  .lb-score { font-size: 1.2rem; }
}

/* ─ 2K+ / projector (>= 2560px) ─ */
@media (min-width: 2560px) {
  .village-arena { gap: 24px 72px; }
  .q-dock-text { font-size: 1.8rem; }
  .admin-timer { font-size: 4.5rem; }

  .lobby-layout { grid-template-columns: clamp(500px, 26vw, 700px) 1fr; }
  .qr-box canvas, .qr-box img { width: 380px !important; height: 380px !important; }
  .player-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
  .player-tile { padding: 28px 20px; }

  .question-dock { max-height: 62vh; }
  .final-dock-inner { grid-template-columns: clamp(460px, 28vw, 620px) 1fr; column-gap: 48px; padding: 24px 36px; }
  .final-title { font-size: 2.4rem; }
  .podium-base  { width: 190px; font-size: 2.5rem; }
  .podium-1st .podium-base { height: 170px; }
  .podium-2nd .podium-base { height: 130px; }
  .podium-3rd .podium-base { height: 96px; }
  .lb-row { padding: 16px 24px; gap: 16px; }
  .lb-name  { font-size: 1.3rem; }
  .lb-score { font-size: 1.4rem; }
}

/* ═══════════════════════════════════════
   RESPONSIVE — PLAYER SCREENS
   ═══════════════════════════════════════ */

/* ─ Very small phones (< 380px) ─ */
@media (max-width: 380px) {
  .home-avatars { height: clamp(110px, 40vw, 160px); gap: 2px; }

  /* Join: shrink avatar cards */
  .avatar-grid { gap: 8px; max-width: 340px; }
  .avatar-card { padding: 12px 6px 10px; border-radius: 14px; }
  .avatar-card .card-av { --av-size: 76px !important; }
  .avatar-card .avatar-name { font-size: 0.8rem; margin-top: 4px; }

  /* Answer buttons: single column if very tight */
  .answers-grid { gap: 7px; padding: 8px 12px 14px; }

  /* Village strip: smaller buildings */
  .village-strip .village-player { zoom: 0.48; }
  .village-strip { min-height: 100px; padding: 6px 12px 10px; }

  /* Waiting / answered: reduce avatar size via CSS var override */
  .player-waiting, .answered-screen, .result-screen, .final-player { padding: 16px; gap: 12px; }
}

/* ─ Small phones (380px–520px) ─ */
@media (max-width: 520px) {
  .home-avatars { height: clamp(130px, 36vw, 200px); gap: 4px; }

  /* Join */
  .avatar-grid { max-width: 380px; gap: 10px; }
  .avatar-card { padding: 14px 8px 12px; }
  .avatar-card .card-av { --av-size: 84px !important; }
  .name-input { padding: 12px 16px; font-size: 1rem; }

  /* Answer buttons */
  .answers-grid { padding: 10px 14px 16px; gap: 8px; }

  /* Village strip */
  .village-strip .village-player { zoom: 0.54; }
  .village-strip { min-height: 110px; }

  /* Screens */
  .answered-screen h2 { font-size: 1.1rem; }
  .player-waiting, .answered-screen, .result-screen, .final-player { padding: 20px 16px; gap: 14px; }
}

/* ─ Large phone / small tablet (>= 520px) ─ */
@media (min-width: 520px) {
  /* Join: wider cards */
  .avatar-grid { max-width: min(100%, clamp(440px, 82vw, 600px)); gap: 18px; }
  .avatar-card { padding: 22px 14px 18px; }
  .avatar-card .card-av { --av-size: 108px !important; }

  /* Quiz: wider question + bigger buttons */
  .q-text { font-size: clamp(1rem, 2.8vw, 1.35rem); }
  .ans-btn { font-size: clamp(0.9rem, 2.5vw, 1.15rem); }

  /* Player waiting/result: more breathing room */
  .player-waiting, .answered-screen, .result-screen, .final-player { padding: 28px 24px; }
}

/* ─ Tablet portrait / large phone (>= 768px) ─ */
@media (min-width: 768px) {
  /* Join: big avatar cards, 3-col */
  .avatar-grid { max-width: min(100%, clamp(500px, 70vw, 680px)); gap: 24px; }
  .avatar-card { padding: 28px 18px 22px; border-radius: 24px; }
  .avatar-card .card-av { --av-size: 130px !important; }
  .avatar-card .avatar-name { font-size: 1rem; }

  .name-input-wrap { max-width: min(100%, clamp(360px, 60vw, 560px)); }
  .join-btn-wrap   { max-width: min(100%, clamp(360px, 60vw, 560px)); }

  /* Quiz: wider layout */
  .q-text { font-size: clamp(1.1rem, 2.5vw, 1.5rem); padding: 28px 40px; }
  .answers-grid { max-width: min(100%, clamp(500px, 80vw, 860px)); gap: 16px; }
  .ans-btn { font-size: clamp(1rem, 2.2vw, 1.2rem); border-radius: 20px; }

  /* Waiting / result: spread out */
  .player-waiting, .answered-screen, .result-screen, .final-player { padding: 36px 32px; gap: 24px; }
}

/* ─ Phone landscape (height < 500px) ─ */
@media (max-height: 500px) and (orientation: landscape) {
  /* Home: compact row layout */
  .home-screen { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; padding: 10px 20px; }
  .home-logo   { display: none; }
  .home-avatars { height: 110px; width: 220px; flex-shrink: 0; }
  .home-av-wrap-mogi { left: 0; }
  .home-av-wrap-digi { left: 50%; }
  .home-av-wrap-jiji { left: calc(100% - 70px); }
  .home-title { font-size: 1.3rem; margin: 0; }
  .home-sub   { margin: 0 0 4px; font-size: 0.8rem; }
  .home-btns  { flex-direction: column; gap: 8px; }
  .home-btn-admin, .home-btn-player { padding: 10px 20px; font-size: 0.9rem; }

  /* Join: side-by-side layout */
  .join-screen { padding: 10px 16px; gap: 8px; }
  .join-logo { margin-bottom: 0; }
  .join-title { font-size: 1rem; }
  .avatar-grid { grid-template-columns: repeat(3, 1fr); max-width: 320px; gap: 8px; }
  .avatar-card { padding: 8px 6px; }
  .avatar-card .card-av { --av-size: 64px !important; }
  .avatar-card .avatar-name { font-size: 0.75rem; margin-top: 2px; }
  .name-input-wrap { max-width: 320px; }
  .name-input { padding: 10px 14px; }

  /* Quiz: reduce heights */
  .answers-grid { padding: 6px 12px 10px; gap: 6px; }
  .q-text-wrap { padding: 0 12px; }
  .timer-bar-wrap { padding: 6px 12px 0; }

  /* Village strip: very compact in landscape */
  .village-strip { min-height: 80px; }
  .village-strip .village-player { zoom: 0.44; }

  /* Result/waiting: horizontal flex */
  .result-screen { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 12px; }
  .player-waiting { gap: 10px; padding: 12px; }
  .answered-screen { gap: 10px; padding: 12px; }
  .final-player { gap: 10px; padding: 12px; }
}
