/* Font Imports & Design Tokens */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Prompt:wght@400;500;600;700&display=swap');

:root {
  --primary-gold: #d4af37;
  --gold-glow: rgba(212, 175, 55, 0.4);
  --primary-amber: #e67e22;
  --bg-dark-overlay: rgba(15, 23, 42, 0.75);
  --glass-bg: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.4);
  --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  --text-main: #2c3e50;
  --text-muted: #64748b;
  --accent-green: #27ae60;
  --accent-red: #e74c3c;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-title: 'Prompt', sans-serif;
  --font-body: 'Sarabun', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-body);
  color: var(--text-main);
  background-color: #0f172a;
  overflow-x: hidden;
  min-height: 100vh;
}

/* App Container */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-size: cover;
  background-position: center;
  transition: background-image 0.8s ease-in-out;
}

/* Header & Navigation */
header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(15,23,42,0.85), transparent);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--primary-gold));
}

.logo-text h1 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.logo-text p {
  font-size: 12px;
  color: var(--primary-gold);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-badge {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

/* Screens Management */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Landing Screen */
#screen-landing {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.5) 0%, rgba(15, 23, 42, 0.85) 100%),
              url('assets/images/bg_lumbini.jpg') center/cover;
  padding: 20px;
}

.landing-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(15px);
  border: 2px solid var(--primary-gold);
  border-radius: var(--radius-lg);
  padding: 40px 50px;
  max-width: 650px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: fadeIn 1s ease-out;
}

.landing-title {
  font-family: var(--font-title);
  font-size: 32px;
  color: #1e293b;
  margin-bottom: 10px;
}

.landing-subtitle {
  font-size: 18px;
  color: #475569;
  margin-bottom: 25px;
}

.player-input-group {
  margin-bottom: 25px;
}

.player-input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #334155;
}

.input-field {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 2px solid #cbd5e1;
  font-size: 16px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
}

.input-field:focus {
  border-color: var(--primary-gold);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-gold), var(--primary-amber));
  color: #fff;
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
  padding: 14px 36px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(230, 126, 34, 0.4);
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(230, 126, 34, 0.5);
}

/* Chapter Selection Screen */
#screen-chapters {
  justify-content: center;
  align-items: center;
  padding: 80px 20px 40px;
  background: rgba(15, 23, 42, 0.85);
  overflow-y: auto;
}

.section-title {
  font-family: var(--font-title);
  color: #fff;
  font-size: 28px;
  text-align: center;
  margin-bottom: 30px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  max-width: 1100px;
  width: 100%;
}

.chapter-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.chapter-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 35px rgba(212, 175, 55, 0.3);
}

.chapter-card.locked {
  opacity: 0.6;
  filter: grayscale(0.8);
  cursor: not-allowed;
}

.chapter-img {
  height: 130px;
  background-size: cover;
  background-position: center;
  position: relative;
}

.chapter-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--primary-amber);
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.chapter-content {
  padding: 15px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chapter-title {
  font-family: var(--font-title);
  font-size: 16px;
  color: #1e293b;
  margin-bottom: 6px;
}

.chapter-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Visual Novel Gameplay Screen */
#screen-game {
  justify-content: flex-end;
  padding: 20px;
  position: relative;
}

.vn-container {
  width: 100%;
  max-width: 950px;
  margin: 0 auto;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Dialogue Box */
.dialogue-box {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 2px solid var(--primary-gold);
  border-radius: var(--radius-lg);
  padding: 25px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  min-height: 160px;
  cursor: pointer;
  position: relative;
}

.speaker-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary-gold), var(--primary-amber));
  color: #fff;
  font-family: var(--font-title);
  font-weight: 700;
  padding: 4px 16px;
  border-radius: 15px;
  font-size: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.dialogue-text {
  font-size: 18px;
  line-height: 1.6;
  letter-spacing: 0.3px;
  color: #f8fafc;
}

.next-indicator {
  position: absolute;
  bottom: 15px;
  right: 20px;
  font-size: 14px;
  color: var(--primary-gold);
  animation: bounce 1s infinite alternate;
}

/* Choice Buttons Container */
.choices-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.choice-btn {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--primary-gold);
  color: #1e293b;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.choice-btn:hover {
  background: var(--primary-gold);
  color: #fff;
  transform: translateX(5px);
}

/* Modal Popup */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 35px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  position: relative;
  animation: scaleUp 0.3s ease-out;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 24px;
  color: #1e293b;
  margin-bottom: 15px;
}

/* Mini Game & Quiz Component */
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.quiz-btn {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 15px;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-btn:hover {
  border-color: var(--primary-gold);
  background: #f8fafc;
}

.quiz-btn.correct {
  background: #dcfce7;
  border-color: var(--accent-green);
  color: #166534;
}

.quiz-btn.incorrect {
  background: #fee2e2;
  border-color: var(--accent-red);
  color: #991b1b;
}

/* Certificate Screen */
#screen-certificate {
  justify-content: center;
  align-items: center;
  padding: 70px 20px 30px;
  background: rgba(15, 23, 42, 0.9);
  overflow-y: auto;
}

.cert-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#certCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
  border: 4px solid var(--primary-gold);
}

.cert-actions {
  display: flex;
  gap: 15px;
}

/* Summary Sheet Screen */
#screen-summary {
  justify-content: flex-start;
  align-items: center;
  padding: 90px 20px 40px;
  background: rgba(15, 23, 42, 0.92);
  overflow-y: auto;
}

.summary-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 30px;
  max-width: 850px;
  width: 100%;
  box-shadow: var(--card-shadow);
  color: #334155;
}

.summary-section {
  margin-bottom: 25px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 15px;
}

.summary-section h3 {
  font-family: var(--font-title);
  color: var(--primary-amber);
  margin-bottom: 10px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-5px); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  header { padding: 10px 15px; }
  .logo-text h1 { font-size: 16px; }
  .landing-card { padding: 25px 20px; }
  .dialogue-text { font-size: 15px; }
  .quiz-options { grid-template-columns: 1fr; }
}
