:root {
  --primary-color: #1565c0;
  --secondary-color: #ff8f00;
  --premium-color: #8e44ad;
  --bg-light: #f4f7f6;
  --text-dark: #2c3e50;
  --success-green: #27ae60;
  --error-red: #e74c3c;
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --font-sinhala: "Abhaya Libre", serif;
  --font-english: "Roboto", sans-serif;
  --glass: rgba(255, 255, 255, 0.9);
  --blur: blur(20px);
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #f4f7f6 100%);
  min-height: 100vh; display: flex; flex-direction: column;
  color: var(--text-dark); font-family: var(--font-sinhala); overflow-x: hidden;
}

/* Progress Bar */
.progress-container {
  width: 100%; height: 8px; background-color: #e0e0e0;
  position: fixed; top: 0; left: 0; z-index: 1000;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, #ff8f00, #ff6f00);
  width: 100%; transition: width 1s linear;
}

/* Toast Notification for Premium Levels */
#level-toast {
    position: fixed; top: 100px; left: 50%; transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.95); color: white; padding: 15px 25px;
    border-radius: 50px; z-index: 5000; display: none; text-align: center;
    box-shadow: 0 10px 30px rgba(142, 68, 173, 0.4); border: 2px solid var(--premium-color);
    animation: slideDown 0.5s ease;
}
@keyframes slideDown { from { top: -50px; opacity: 0; } to { top: 100px; opacity: 1; } }

/* --- Login Overlay Refined --- */
#login-overlay {
  position: fixed; 
  inset: 0; 
  z-index: 10000;
  /* වඩාත් Premium පෙනුමක් සඳහා Gradient එක update කළා */
  background: radial-gradient(circle at top right, #1e3a8a, #0f172a);
  display: flex; 
  justify-content: center; 
  align-items: center;
  padding: 20px;
}

.login-box {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 40px 30px;
  border-radius: var(--radius-xl);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 400px; 
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-box h1 { 
  color: white; 
  font-family: var(--font-english); 
  font-size: 2.5rem;
  margin-bottom: 5px;
  letter-spacing: -1px;
}

.login-box p { 
  color: rgba(255, 255, 255, 0.7); 
  margin-bottom: 35px; 
  font-size: 1.1rem;
}

/* Input Group Styling */
.input-group {
  position: relative;
  margin-bottom: 20px;
}

.input-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-size: 1.2rem;
  z-index: 1;
}

input[type="tel"] {
  width: 100%; 
  padding: 15px 15px 15px 45px; /* Icon එකට ඉඩ තැබුවා */
  border-radius: var(--radius-md); 
  border: 2px solid transparent;
  font-family: var(--font-english); 
  font-size: 1.1rem; 
  background: white;
  color: var(--text-dark);
  transition: all 0.3s ease;
  outline: none;
}

input[type="tel"]:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 15px rgba(255, 143, 0, 0.3);
  transform: translateY(-2px);
}

/* Login Button Styling */
.login-btn {
  width: 100%; 
  padding: 16px;
  background: linear-gradient(135deg, var(--secondary-color) 0%, #f57c00 100%);
  color: white; 
  border: none; 
  border-radius: var(--radius-md);
  font-size: 1.1rem; 
  font-weight: 800; 
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 20px rgba(255, 143, 0, 0.2);
}

.login-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 15px 25px rgba(255, 143, 0, 0.3);
}

.login-btn:active { 
  transform: scale(0.98); 
}

/* Error Message styling */
.error-msg {
  color: #ff9999;
  font-size: 0.9rem;
  margin-top: 15px;
  min-height: 20px;
  font-weight: 500;
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .login-box {
    padding: 30px 20px;
  }
  .login-box h1 {
    font-size: 2rem;
  }
}



/* Main Content */
#content-container { display: none; flex-direction: column; height: 100vh; padding-top: 10px; }

/* Header */
.main-header {
  background: var(--glass); backdrop-filter: var(--blur);
  padding: 10px 20px; display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05); z-index: 100; margin-top: 10px;
}
.user-level-badge {
    background: var(--primary-color); color: white; padding: 5px 12px;
    border-radius: 15px; font-size: 0.8rem; font-weight: bold; margin-top: 2px; display: inline-block;
}

/* Layout */
.main-layout { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 280px; background: white; padding: 20px; overflow-y: auto;
  border-right: 1px solid #eee; display: flex; flex-direction: column;
}

.navigator-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.nav-item {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: #f1f2f6; border-radius: 8px; font-family: var(--font-english); font-weight: bold;
  color: #999; cursor: pointer; transition: 0.2s; position: relative;
}
.nav-item:hover { opacity: 0.8; }
.nav-item.active { background: var(--primary-color); color: white; border: 2px solid #0d47a1; }
.nav-item.answered { background: var(--success-green); color: white; }
.nav-item.skipped { background: #95a5a6; color: white; }

/* Premium Styling in Nav */
.nav-item.premium-q { border: 2px solid var(--premium-color); color: var(--premium-color); }
.nav-item.premium-q.answered { background: var(--premium-color); color: white; border: none; }
.nav-item.premium-q::after {
    content: '★'; position: absolute; top: -5px; right: -5px; 
    font-size: 0.7rem; color: #f1c40f; text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Question Area */
.question-area { flex: 1; padding: 30px; overflow-y: auto; display: flex; flex-direction: column; align-items: center; }
.question-card {
  background: white; padding: 40px; border-radius: var(--radius-xl);
  box-shadow: 0 10px 40px rgba(0,0,0,0.05); width: 100%; max-width: 800px;
  position: relative;
}
.question-text { font-size: 1.4rem; margin-bottom: 30px; font-weight: bold; }

.time-left-badge {
    position: absolute; top: 20px; right: 20px;
    background: #ffe0b2; color: #e65100; padding: 5px 15px;
    border-radius: 20px; font-weight: bold; font-family: var(--font-english);
}

.answers-grid { display: grid; gap: 15px; }
.answer-option {
  padding: 15px 20px; border: 2px solid #eee; border-radius: 15px;
  cursor: pointer; display: flex; align-items: center; transition: all 0.2s;
}
.answer-option:hover { background: #f9f9f9; }
.answer-option.selected {
  background: #e3f2fd; border-color: var(--primary-color); color: var(--primary-color);
}
.option-letter {
  width: 35px; height: 35px; background: #eee; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-right: 15px; font-weight: bold;
}

/* Footer Buttons */
.action-footer {
  width: 100%; max-width: 800px; margin-top: 20px;
  display: flex; justify-content: space-between;
}
.action-footer-right { display: flex; justify-content: flex-end; flex: 1; }
.btn {
  padding: 12px 30px; border-radius: 12px; font-weight: bold; border: none; cursor: pointer;
  font-size: 1.1rem;
}
.btn-primary { background: var(--secondary-color); color: white; }
.btn-finish { background: var(--success-green); color: white; }

/* Results */
#results-section {
  display: none; flex-direction: column; align-items: center;
  padding: 20px; width: 100%; min-height: 100vh;
  overflow-y: auto; background: var(--bg-light);
}

.results-card {
  background: white; padding: 30px; border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1); margin-bottom: 20px;
  width: 100%; max-width: 794px;
}
.score-big { font-size: 5rem; font-weight: 900; color: var(--primary-color); font-family: var(--font-english); }

.xp-box {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: white; padding: 15px; border-radius: 10px;
    margin-top: 15px; text-align: center;
}

/* Report Styles */
.report-question-item {
  border-bottom: 1px solid #eee; padding: 20px 0;
  page-break-inside: avoid;
}
.report-status {
  font-weight: bold; font-size: 0.9rem; margin-bottom: 5px;
  display: inline-block; padding: 2px 8px; border-radius: 4px;
}
.status-correct { color: #27ae60; background: #e8f5e9; }
.status-wrong { color: #e74c3c; background: #fce4ec; }

.explanation-box {
    margin-top: 15px; background: #fff3e0; padding: 12px;
    border-left: 4px solid #ff9800; border-radius: 4px;
    font-size: 0.95rem; color: #444;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-header { flex-direction: column; gap: 10px; align-items: flex-start; }
  .question-card { padding: 20px; }
  .question-text { font-size: 1.1rem; }
  .score-big { font-size: 3.5rem; }
  #level-toast { width: 90%; top: 80px; }
}

/* Watermark */
#watermark-parent { position: fixed; inset: 0; pointer-events: none; opacity: 0.03; overflow: hidden; z-index: 9999; }
.wm-text { position: absolute; font-weight: 900; transform: rotate(-45deg); font-family: sans-serif; white-space: nowrap; }

/* Video Modal Styling */
#videoModal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: #000;
}

.player-wrapper {
    position: relative;
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}

#yt-container { width: 100%; height: 100%; pointer-events: none; }

/* Transparent Touch Guard */
.touch-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10; background: rgba(0,0,0,0);
}

/* Close Button */
.close-player {
    position: absolute; top: 20px; right: 20px;
    z-index: 50; color: white; background: rgba(0,0,0,0.5);
    padding: 10px 15px; border-radius: 5px; cursor: pointer;
    font-weight: bold; border: 1px solid #fff;
}

/* Custom Controls (Seeker) */
.custom-controls {
    position: absolute; bottom: 0; left: 0; width: 100%;
    padding: 30px 20px 50px 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    z-index: 40; opacity: 0; transition: opacity 0.3s;
}
.custom-controls.active { opacity: 1; }

.seeker-bar { width: 100%; height: 6px; background: rgba(255,255,255,0.3); position: relative; border-radius: 3px; cursor: pointer; }
.seeker-fill { height: 100%; background: #ff0000; width: 0%; border-radius: 3px; }
.time-txt { color: white; font-size: 14px; margin-top: 10px; font-weight: bold; }

/* Play/Pause Button */
.center-play-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 70px; height: 70px; background: rgba(255, 255, 255, 0.2);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    z-index: 30; opacity: 0; transition: opacity 0.3s; pointer-events: none;
    border: 2px solid #fff;
}
.center-play-btn.visible { opacity: 1; pointer-events: all; }

/* Floating Navigation Arrows (Attached to Question Card) */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95); /* පොඩි වීදුරු ගතියක් */
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.nav-arrow:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-50%) scale(1.1); /* Hover කරද්දි පොඩ්ඩක් ලොකු වෙනවා */
}

.prev-arrow {
    left: -50px; /* කාඩ් එකෙන් බාගයක් එළියට පනින විදියට */
}

.next-arrow {
    right: -50px; /* කාඩ් එකෙන් බාගයක් එළියට පනින විදියට */
}

/* Finish Button Styling */
.btn-finish-large {
    background: var(--success-green);
    color: white;
    font-size: 1.2rem;
    padding: 15px 40px;
    border-radius: 30px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
    transition: all 0.2s;
}
.btn-finish-large:hover {
    background: #219653;
    transform: scale(1.05);
}

/* ෆෝන් එකෙන් බලද්දී ඊතල එළියට පනින එක නවත්තන්න */
@media (max-width: 768px) {
    .prev-arrow { left: 5px; }
    .next-arrow { right: 5px; }
}

/* ==========================================
   SUPER VIDEO MODAL STYLES (PORTRAIT/LANDSCAPE)
   ========================================== */

.super-video-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000000; z-index: 100000; display: none; flex-direction: column;
    align-items: center; justify-content: center; overflow: hidden;
}

.vid-close-btn {
    position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.15); 
    border: none; color: white; font-size: 1.8rem; width: 45px; height: 45px; 
    border-radius: 50%; cursor: pointer; z-index: 100001; backdrop-filter: blur(4px);
    transition: background 0.3s; display: flex; align-items: center; justify-content: center;
}
.vid-close-btn:hover { background: rgba(255, 71, 87, 0.8); }

.portrait-decor {
    width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: white; padding: 20px; box-sizing: border-box; text-align: center;
}

.pt-top { flex: 1; justify-content: flex-end; padding-bottom: 30px; background: linear-gradient(to bottom, rgba(15,20,30,1) 0%, rgba(0,0,0,1) 100%); }
.pt-bottom { flex: 1; justify-content: flex-start; padding-top: 30px; background: linear-gradient(to top, rgba(15,20,30,1) 0%, rgba(0,0,0,1) 100%); }

.rotate-icon { font-size: 3rem; color: #bdc3c7; margin-bottom: 15px; animation: tiltPhone 2.5s infinite ease-in-out; }
@keyframes tiltPhone { 
    0%, 100% { transform: rotate(0deg); color: #bdc3c7; } 
    50% { transform: rotate(-90deg); color: #f1c40f; } 
}

.video-wrapper {
    width: 100%; max-width: 1000px; aspect-ratio: 16/9; background: #111; 
    position: relative; box-shadow: 0 0 30px rgba(0,0,0,0.8); z-index: 10;
}
/* YT Iframe එක 100% Fit වීම */
.video-wrapper iframe, .video-wrapper #yt-container { width: 100%; height: 100%; border: none; }

/* === LANDSCAPE MODE (ෆෝන් එක හරහට හැරවූ විට) === */
@media (orientation: landscape) {
    .portrait-decor { display: none !important; }
    .video-wrapper { 
        width: 100vw !important; height: 100vh !important; 
        max-width: none; aspect-ratio: auto;
    }
}