/* ============================================================
   style.css — ระบบเกม "โกงหรือไม่โกง?"
   โทนสี: น้ำเงินเข้ม #1E3A8A, ฟ้า #38BDF8, เหลือง #FACC15,
          เขียว #22C55E, แดง #EF4444
   ============================================================ */
:root {
  --c-navy:   #1E3A8A;
  --c-sky:    #38BDF8;
  --c-yellow: #FACC15;
  --c-green:  #22C55E;
  --c-red:    #EF4444;
  --c-ink:    #0f172a;
}

* { box-sizing: border-box; }

body {
  font-family: "Sarabun", "Prompt", -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563eb 45%, #38BDF8 100%);
  background-attachment: fixed;
  color: var(--c-ink);
  min-height: 100vh;
  margin: 0;
}

.brand-title {
  font-weight: 800;
  letter-spacing: .5px;
}
.text-yellow { color: var(--c-yellow) !important; }

/* การ์ดแก้วใส */
.glass-card {
  background: rgba(255, 255, 255, 0.97);
  border: none;
  border-radius: 1.25rem;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

/* ปุ่มหลักของระบบ */
.btn-game {
  border: none;
  border-radius: 1rem;
  font-weight: 700;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  box-shadow: 0 6px 0 rgba(0,0,0,.15);
}
.btn-game:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.btn-game:hover  { filter: brightness(1.05); }

.btn-navy   { background: var(--c-navy);   color: #fff; }
.btn-sky    { background: var(--c-sky);    color: #062a3a; }
.btn-yellow { background: var(--c-yellow); color: #4a3a00; }
.btn-green  { background: var(--c-green);  color: #fff; }
.btn-red    { background: var(--c-red);    color: #fff; }

/* ===================== หน้าตอบคำถาม (play.php) ===================== */
.answer-btn {
  width: 100%;
  border: 3px solid transparent;
  border-radius: 1.1rem;
  padding: 1.4rem 1rem;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: #fff;
  color: var(--c-ink);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  transition: transform .12s ease, border-color .12s, background .2s;
  cursor: pointer;
}
.answer-btn:hover:not(:disabled) { transform: translateY(-3px); }
.answer-btn:disabled { opacity: .75; cursor: not-allowed; }

.answer-btn.selected { border-color: var(--c-navy); background: #e0f2fe; }
.answer-btn.correct  { border-color: var(--c-green); background: #dcfce7; color: #14532d; }
.answer-btn.wrong    { border-color: var(--c-red);   background: #fee2e2; color: #7f1d1d; }

/* ไอคอนผลของตัวเลือก */
.answer-btn .badge-result { float: right; font-size: 1.4rem; }

/* แถบคะแนนด้านบน */
.score-pill {
  background: var(--c-yellow);
  color: #4a3a00;
  font-weight: 800;
  border-radius: 999px;
  padding: .4rem 1rem;
  font-size: 1.1rem;
}

/* สถานะรอ */
.status-box {
  border-radius: 1rem;
  padding: 2rem 1rem;
  text-align: center;
}

/* นาฬิกา + วงกลมวาบๆ กระจายออก (ripple/pulse) */
.clock-pulse {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 1rem auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clock-pulse .clock-icon {
  position: relative;
  z-index: 2;
  font-size: 3.6rem;
  line-height: 1;
  animation: clockGlow 1.6s ease-in-out infinite;
}
.clock-pulse .pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border: 4px solid var(--c-sky);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
  animation: pulseRing 2.1s cubic-bezier(0, .55, .45, 1) infinite;
}
.clock-pulse .pulse-ring:nth-child(2) { animation-delay: .7s; border-color: var(--c-navy); }
.clock-pulse .pulse-ring:nth-child(3) { animation-delay: 1.4s; border-color: var(--c-yellow); }

@keyframes pulseRing {
  0%   { transform: scale(0.4); opacity: .85; }
  70%  { opacity: .25; }
  100% { transform: scale(2.6); opacity: 0; }
}
@keyframes clockGlow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(56,189,248,0)); }
  50%      { transform: scale(1.12); filter: drop-shadow(0 0 10px rgba(56,189,248,.7)); }
}

/* ===================== หน้าจอแสดงผล (screen.php) ===================== */
.screen-wrap { color: #fff; }
.screen-question {
  font-size: clamp(1.8rem, 4.5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.25;
  text-shadow: 0 3px 12px rgba(0,0,0,.35);
}
.screen-qnum {
  font-size: clamp(1rem, 2vw, 1.5rem);
  font-weight: 700;
  color: var(--c-yellow);
}

/* กราฟแท่งผลโหวต */
.vote-row { margin-bottom: 1.1rem; }
.vote-label {
  font-size: clamp(1.1rem, 2.2vw, 1.8rem);
  font-weight: 800;
  margin-bottom: .25rem;
  display: flex; justify-content: space-between; align-items: center;
}
.vote-bar-track {
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  height: clamp(28px, 4vw, 46px);
  overflow: hidden;
}
.vote-bar-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width .8s cubic-bezier(.22,1,.36,1);
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: .75rem;
  color: #fff; font-weight: 800;
  font-size: clamp(.9rem, 1.8vw, 1.4rem);
}
.vote-bar-fill.is-correct { background: var(--c-green); }
.vote-bar-fill.is-normal  { background: var(--c-sky); }

.vote-row.correct .vote-label { color: var(--c-yellow); }

/* leaderboard */
.leader-item {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(255,255,255,.12);
  border-radius: .9rem;
  padding: .6rem 1rem;
  margin-bottom: .6rem;
  font-weight: 700;
}
.leader-rank {
  width: 2.4rem; height: 2.4rem; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  background: var(--c-yellow); color: #4a3a00;
}
.leader-rank.r1 { background: #FACC15; }
.leader-rank.r2 { background: #cbd5e1; }
.leader-rank.r3 { background: #f59e0b; color:#fff; }
.leader-score { margin-left: auto; color: var(--c-yellow); font-size: 1.2rem; }

/* QR / join box */
.join-code {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--c-yellow);
}

/* ===================== แอนิเมชัน ===================== */
@keyframes pop {
  0%   { transform: scale(.85); opacity: 0; }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
.animate-pop { animation: pop .4s ease both; }

@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.05); }
}
.animate-pulse-soft { animation: pulse 1.6s ease-in-out infinite; }

/* ===================== admin ===================== */
.admin-stat {
  background: rgba(255,255,255,.97);
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
}
.admin-stat .num { font-size: 2rem; font-weight: 800; color: var(--c-navy); }
.admin-stat .lbl { color: #475569; font-weight: 600; }

/* รายการคำถามแบบการ์ด */
.q-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: .25rem;
}
.q-list-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .65rem;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: .9rem;
  padding: .6rem .75rem;
  transition: background .15s, border-color .15s, transform .1s;
}
.q-list-item:hover { background: #eff6ff; border-color: var(--c-sky); transform: translateY(-1px); }
.q-list-item.active {
  border-color: var(--c-green);
  background: #dcfce7;
}
.q-list-item .q-num {
  flex: 0 0 auto;
  width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--c-navy); color: #fff;
  font-weight: 800; font-size: .95rem;
}
.q-list-item.active .q-num { background: var(--c-green); }
.q-list-item .q-text {
  flex: 1 1 auto;
  font-size: .95rem;
  line-height: 1.3;
  color: #1e293b;
}
.q-list-item .q-start {
  flex: 0 0 auto;
  border: none;
  border-radius: .6rem;
  font-weight: 700;
  padding: .35rem .7rem;
  font-size: .9rem;
  background: var(--c-green);
  color: #fff;
  white-space: nowrap;
}
.q-list-item.active .q-start { background: var(--c-navy); }

/* รายการผู้เล่น (จัดการ/ลบ) */
.player-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: .25rem;
}
.player-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: .8rem;
  padding: .5rem .65rem;
  transition: background .15s, border-color .15s;
}
.player-item:hover { background: #eff6ff; border-color: var(--c-sky); }
.player-item .player-check { flex: 0 0 auto; margin: 0; width: 1.15rem; height: 1.15rem; }
.player-item .player-info { flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.player-item .player-name { font-weight: 700; color: #1e293b; font-size: .95rem; }
.player-item .player-meta { font-size: .8rem; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-item .player-del {
  flex: 0 0 auto;
  border: none;
  border-radius: .55rem;
  background: #fee2e2;
  padding: .3rem .5rem;
  font-size: .9rem;
  line-height: 1;
}
.player-item .player-del:hover { background: var(--c-red); }

/* ตัวจับเวลา */
.countdown-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--c-navy);
  line-height: 1;
}
.countdown-num.low { color: var(--c-red); animation: pulse 1s ease-in-out infinite; }

.status-badge { font-size: .95rem; padding: .5rem .9rem; border-radius: 999px; font-weight: 700; }
