/* stage.css — เวทีสุ่มนำเสนอและตอบคำถาม (Fullscreen Stage & Randomizer Gimmicks) */

:root {
  --stage-bg: #0f172a;
  --stage-card: #1e293b;
  --stage-border: #334155;
  --stage-accent: #38bdf8;
  --stage-gold: #f59e0b;
  --stage-success: #10b981;
  --stage-text: #f8fafc;
  --stage-muted: #94a3b8;
}

/* Fullscreen Overlay for Projector Mode */
.stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #090d16 80%);
  color: var(--stage-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Noto Sans Thai', sans-serif;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--stage-border);
}

.stage-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--stage-gold);
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-btn {
  background: var(--stage-card);
  color: var(--stage-text);
  border: 1px solid var(--stage-border);
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.stage-btn:hover {
  background: #334155;
  border-color: #64748b;
}

.stage-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.stage-btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-size: 1.25rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stage-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(16, 185, 129, 0.6);
}

.stage-btn-primary:active {
  transform: translateY(1px);
}

/* Main Arena */
.stage-arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

/* ── 3 Gimmick Displays ──────────────────────────────────────────────────── */

/* 1. Giant Spinning Wheel */
.wheel-container {
  position: relative;
  width: 580px;
  height: 580px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ctrlWheelCanvas, #wheelCanvas {
  border-radius: 50%;
  box-shadow: 0 0 50px rgba(0,0,0,0.8), 0 0 20px rgba(245, 158, 11, 0.5);
  border: 6px solid #f59e0b;
}

.wheel-pointer {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 40px solid #ef4444;
  z-index: 20;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
  transition: transform 0.08s ease-out;
}

.wheel-center-pin {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, #fef08a, #d97706);
  border: 4px solid #fff;
  z-index: 10;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

/* 2. 3D Cylinder Carousel (กับการ์ดทรงกระบอกโค้ง Curved Card) */
.cylinder-scene {
  width: 700px;
  height: 440px;
  perspective: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cylinder-carousel {
  width: 260px;
  height: 190px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.1s linear;
}

/* การ์ดแบบเดิมแต่โค้งตามทรงกระบอก */
.cylinder-card {
  position: absolute;
  width: 260px;
  height: 190px;
  border-radius: 20px;
  /* Cylindrical Curvature Gradient & Shadow */
  background: linear-gradient(90deg, #090e1a 0%, #1e293b 22%, #334155 50%, #1e293b 78%, #090e1a 100%);
  border: 2px solid rgba(56, 189, 248, 0.45);
  box-shadow: inset 20px 0 22px -10px rgba(0,0,0,0.85), inset -20px 0 22px -10px rgba(0,0,0,0.85), 0 12px 35px rgba(0,0,0,0.7);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  backface-visibility: hidden;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  box-sizing: border-box;
}

.cylinder-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 6px;
}

.cylinder-card-badge {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  padding: 2px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
}

.cylinder-card-count {
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 600;
}

.cylinder-card-title {
  font-size: 1.55rem;
  font-weight: 900;
  color: #38bdf8;
  margin: 6px 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cylinder-card-members {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.cylinder-card.winner {
  border-color: #34d399;
  background: linear-gradient(90deg, #022c22 0%, #064e3b 35%, #059669 50%, #064e3b 65%, #022c22 100%);
  box-shadow: 0 0 60px rgba(52, 211, 153, 0.9), inset 0 0 25px rgba(52, 211, 153, 0.5);
  transform: scale(1.18) !important;
}

.cylinder-card.winner .cylinder-card-title {
  color: #fef08a;
}

/* 3. Safe Thai Digit Reveal (เผยทีละหลักของเดิม ปรับภาษาไทยถูกต้อง) */
.thai-digit-wrap {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 28px 0;
}

.thai-digit-box {
  min-width: 80px;
  height: 115px;
  padding: 0 14px;
  background: #1e293b;
  border: 4px solid var(--stage-accent);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  font-weight: 900;
  color: var(--stage-accent);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.3), inset 0 0 15px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

.thai-digit-box.locked {
  background: linear-gradient(180deg, #065f46, #022c22);
  border-color: #34d399;
  color: #6ee7b7;
  transform: scale(1.1);
  box-shadow: 0 0 40px rgba(52, 211, 153, 0.65);
}

.thai-digit-spacer {
  width: 22px;
  min-width: 22px;
  height: 115px;
  display: inline-block;
}

/* Winner Banner */
.stage-winner-banner {
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.stage-winner-badge {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--stage-gold);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stage-winner-name {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fef08a, #f59e0b, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  line-height: 1.2;
}

.stage-winner-members {
  font-size: 1.25rem;
  color: #cbd5e1;
  max-width: 650px;
  margin: 0 auto 20px auto;
}

/* Winner Actions */
.stage-winner-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
}

/* Showcase Modal / Panel */
.stage-work-modal {
  position: absolute;
  inset: 40px;
  background: rgba(15, 23, 42, 0.96);
  border: 2px solid var(--stage-accent);
  border-radius: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.stage-work-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--stage-border);
}

.stage-work-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

/* Confetti Canvas */
#stageConfettiCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}


/* แผงเวทีติดมุมหน้าครู ไม่บังทั้งหน้า (ไม่เปิดหน้าใหม่) */
.stage-overlay.dock {
  inset: auto 16px 16px auto;
  width: min(580px, calc(100vw - 32px));
  max-height: 84vh;
  border-radius: 18px;
  border: 2px solid #f59e0b;
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
  overflow-y: auto;
}
.stage-overlay.dock .stage-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
.stage-overlay.dock .stage-controls { flex-wrap: wrap; gap: 6px; }
.stage-overlay.dock .stage-arena { padding: 12px; justify-content: flex-start; }
.stage-overlay.dock .stage-winner-name { font-size: 1.5rem !important; }
.stage-overlay.dock .stage-work-modal { position: static; }
@keyframes spin { to { transform: rotate(360deg); } }
