:root {
  --bg-mobile: #0a161f;
  --card-bg: rgba(16, 33, 44, 0.95);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --primary: #ff9f1c;
  --text-main: #f6efe3;
  --text-muted: #a9b7b3;
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --opt-red: #ff5d5d;
  --opt-blue: #2ec4e6;
  --opt-yellow: #ff9f1c;
  --opt-green: #1fcf99;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: radial-gradient(circle at 50% 10%, #0f3140 0%, #0a161f 100%);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.mobile-app-wrapper {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 1.2rem;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.2rem;
}

.header-logos {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  backdrop-filter: blur(8px);
}

.brand-text-main {
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #2ee6a8 0%, #2ee6a8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text-sep {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 700;
  font-size: 0.75rem;
}

.brand-text-sub {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #ff5d5d 0%, #ff9f1c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-user-tag {
  background: rgba(255, 159, 28, 0.2);
  border: 1px solid rgba(255, 159, 28, 0.4);
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffd18a;
}

/* Screen Sections */
.mobile-screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn 0.3s ease forwards;
}

.mobile-screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.pause-banner {
  background: linear-gradient(135deg, #ff9f1c, #e07a1f);
  color: white;
  text-align: center;
  font-weight: 800;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 14px rgba(255, 159, 28, 0.4);
  animation: pulse 1.5s infinite;
}

/* Photo Capture Section */
.photo-capture-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.photo-preview-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(19, 40, 58, 0.8);
  border: 3px dashed rgba(255, 159, 28, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  position: relative;
}

#photoPlaceholderIcon {
  font-size: 2.2rem;
  opacity: 0.8;
}

.photo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-btn {
  background: rgba(255, 159, 28, 0.2);
  border: 1px solid rgba(255, 159, 28, 0.5);
  color: #ffe0b5;
  padding: 0.5rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.photo-btn:hover {
  background: rgba(255, 159, 28, 0.35);
}

.photo-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lobby-timer-badge {
  background: rgba(255, 159, 28, 0.15);
  border: 1px solid rgba(255, 159, 28, 0.4);
  color: #ffcf5c;
  padding: 0.5rem 1.2rem;
  border-radius: 9999px;
  font-size: 1.05rem;
}

.lobby-user-photo-box {
  display: flex;
  justify-content: center;
}

.lobby-photo-frame {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--primary);
  box-shadow: 0 0 30px rgba(255, 159, 28, 0.5);
}

.lobby-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =========================================
   1. REGISTRATION / JOIN SCREEN
   ========================================= */
.join-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 1.8rem 1.4rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  margin-top: auto;
  margin-bottom: auto;
}

.join-title {
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
  background: linear-gradient(135deg, #ffffff, #ffe0b5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.join-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: -0.8rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #d9d2c5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  background: rgba(10, 22, 31, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  font-family: inherit;
  font-size: 1.05rem;
  color: white;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.3);
}

.join-submit-btn {
  background: linear-gradient(135deg, #1fcf99 0%, #14b384 100%);
  color: white;
  border: none;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  padding: 1rem;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(31, 207, 153, 0.4);
  margin-top: 0.5rem;
  transition: transform 0.15s ease;
}

.join-submit-btn:active {
  transform: scale(0.98);
}

/* =========================================
   2. WAITING LOBBY SCREEN
   ========================================= */
.lobby-screen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.5rem;
}

.lobby-pulse-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9f1c, #ff5d5d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  box-shadow: 0 0 40px rgba(255, 159, 28, 0.6);
  animation: floatAvatar 3s ease-in-out infinite;
}

@keyframes floatAvatar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.lobby-status-title {
  font-size: 2rem;
  font-weight: 900;
}

.lobby-instruction {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 320px;
}

.lobby-tip-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  padding: 1rem 1.2rem;
  border-radius: 14px;
  font-size: 0.9rem;
  color: #ffd18a;
}

/* =========================================
   3. QUESTION SCREEN
   ========================================= */
.q-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.q-badge {
  font-size: 0.95rem;
  font-weight: 800;
  color: #2ee6a8;
  background: rgba(46, 230, 168, 0.15);
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
}

.q-timer-badge {
  font-size: 1.15rem;
  font-weight: 900;
  background: rgba(255, 93, 93, 0.15);
  border: 1px solid rgba(255, 93, 93, 0.4);
  color: #ff8a8a;
  padding: 0.35rem 0.9rem;
  border-radius: 9999px;
}

.mobile-q-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 1.3rem 1.2rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.mobile-q-text {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.35;
  color: white;
}

/* Mobile 4 Options Buttons */
.mobile-options-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  flex: 1;
}

.mobile-option-btn {
  border: none;
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, filter 0.15s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  position: relative;
}

.mobile-option-btn:active {
  transform: scale(0.97);
}

.mobile-option-btn.opt-0 { background: linear-gradient(135deg, #ff5d5d, #e04848); }
.mobile-option-btn.opt-1 { background: linear-gradient(135deg, #2ec4e6, #1aa3c2); }
.mobile-option-btn.opt-2 { background: linear-gradient(135deg, #ff9f1c, #e07a1f); }
.mobile-option-btn.opt-3 { background: linear-gradient(135deg, #1fcf99, #14b384); }

.m-opt-symbol {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  flex-shrink: 0;
}

.m-opt-text {
  flex: 1;
  line-height: 1.25;
}

/* Submitted State */
.mobile-option-btn.selected {
  outline: 4px solid #ffffff;
  filter: brightness(1.2);
}

.mobile-option-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.mobile-option-btn.selected:disabled {
  opacity: 1;
}

.answer-locked-banner {
  background: rgba(31, 207, 153, 0.2);
  border: 1px solid rgba(31, 207, 153, 0.5);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  text-align: center;
  color: #9ff5d5;
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 0.8rem;
  display: none;
}

/* =========================================
   4. ROUND RESULT SCREEN
   ========================================= */
.round-result-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem 1.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  margin-top: auto;
  margin-bottom: auto;
}

.result-icon {
  font-size: 4rem;
}

.result-heading {
  font-size: 2.2rem;
  font-weight: 900;
}

.result-heading.correct { color: #1fcf99; }
.result-heading.wrong { color: #ff5d5d; }

.points-pill {
  font-size: 1.4rem;
  font-weight: 900;
  color: #2ee6a8;
  background: rgba(46, 230, 168, 0.15);
  padding: 0.5rem 1.4rem;
  border-radius: 9999px;
}

.streak-pill {
  font-size: 1rem;
  font-weight: 700;
  color: #f97316;
}

.mobile-explanation {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.92rem;
  color: #d9d2c5;
  text-align: left;
  line-height: 1.45;
  width: 100%;
}

/* =========================================
   5. FINAL PODIUM & CERTIFICATE
   ========================================= */
.final-screen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.2rem;
  padding-bottom: 2rem;
}

.final-trophy {
  font-size: 4.5rem;
  margin-top: 1rem;
  animation: bounce 2s infinite ease-in-out;
}

.final-rank-tag {
  font-size: 2.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ffcf5c, #ff9f1c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Certificate Preview Canvas */
.cert-preview-card {
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  margin-top: 0.5rem;
}

#certCanvas {
  width: 100%;
  height: auto;
  display: block;
}

.download-cert-btn {
  background: linear-gradient(135deg, #ff9f1c, #f77f00);
  color: white;
  border: none;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 0.95rem 1.6rem;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 159, 28, 0.4);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-decoration: none;
}

/* Anti-Cheating Warning Banner */
.cheat-warning-banner {
  background: linear-gradient(135deg, #ff5d5d, #c0392b);
  color: white;
  padding: 0.85rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  animation: slideDown 0.3s ease;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(255, 93, 93, 0.5);
  line-height: 1.4;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===================== v2 additions ===================== */
.join-error { color: #ffb3b3; text-align: center; font-weight: 700; font-size: 0.9rem; }

.q-progress-track { height: 6px; background: rgba(255,255,255,0.1); border-radius: 9999px; overflow: hidden; margin-bottom: 1rem; }
.q-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ff9f1c, #2ee6a8); transition: width 0.4s ease; }
.q-timer-badge.urgent { animation: pulse 0.6s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.mobile-option-btn.is-correct { outline: 4px solid #ffffff; filter: brightness(1.15); opacity: 1; }
.mobile-option-btn.is-correct::after { content: '✓'; position: absolute; right: 1rem; font-size: 1.5rem; font-weight: 900; }
.mobile-option-btn.is-wrong { outline: 4px solid #ffd0d0; opacity: 1; }
.mobile-option-btn.is-wrong::after { content: '✕'; position: absolute; right: 1rem; font-size: 1.5rem; font-weight: 900; }
.mobile-option-btn.dim:disabled { opacity: 0.35; }

.answer-feedback {
  margin-top: 1rem; border-radius: 16px; padding: 1rem 1.1rem;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border-subtle);
  animation: fadeIn 0.3s ease;
}
.answer-feedback.correct { border-color: rgba(31,207,153,0.6); background: rgba(31,207,153,0.12); }
.answer-feedback.wrong { border-color: rgba(255,93,93,0.6); background: rgba(255,93,93,0.12); }
.feedback-head { display: flex; align-items: center; gap: 0.6rem; font-size: 1.35rem; font-weight: 900; }
.feedback-pts { margin-left: auto; color: #2ee6a8; }
.feedback-explain { font-size: 0.9rem; color: #d9d2c5; line-height: 1.45; margin-top: 0.5rem; }
.feedback-score { margin-top: 0.6rem; font-size: 0.9rem; color: var(--text-muted); }
.feedback-score strong { color: #fff; }

.next-q-btn {
  margin-top: 1rem; width: 100%;
  background: linear-gradient(135deg, #ff9f1c, #f77f00); color: #fff; border: none;
  font-family: inherit; font-size: 1.2rem; font-weight: 800; padding: 1rem; border-radius: 14px;
  cursor: pointer; box-shadow: 0 8px 24px rgba(255,159,28,0.4); animation: fadeIn 0.3s ease;
}
.next-q-btn:active { transform: scale(0.98); }
.feedback-rank { margin-top: 0.6rem; font-weight: 800; font-size: 0.95rem; color: #ffe0b5; background: rgba(255,159,28,0.15); padding: 0.45rem 0.8rem; border-radius: 10px; text-align: center; }
.feedback-rank.top { color: #ffe3a3; background: rgba(255,209,102,0.18); }
.lobby-joined-pill { background: rgba(255,255,255,0.06); border: 1px solid var(--border-subtle); padding: 0.45rem 1rem; border-radius: 9999px; font-size: 0.95rem; color: #d9d2c5; }
.lobby-joined-pill strong { color: #fff; }
