/* RESET */
* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden; /* 🔥 kills sideways scroll */
  background: #f5f7fb;
}

body, html {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  height: 100%;
  overflow: hidden;
}

/* APP SHELL */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* HEADER */
#topbar {
  display: flex;
  align-items: center;
  background: #222;
  color: white;
  padding: 10px;
}

#menuBtn {
  font-size: 20px;
  margin-right: 10px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

/* WELCOME */
#welcome {
  background: #fffff;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  overflow-y: auto; /* 🔥 allow scrolling */

  padding: 24px 16px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.welcome-inner {
  width: 100%;
  max-width: 600px;
}

#welcome input {
  margin-top: 20px;
  padding: 10px;
  font-size: 16px;
}

#app {
  display: none; /* hide initially */
}

/* CONTENT */
#title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#content {
  flex: 1;
  overflow: hidden;
}

#viewer {
  width: 100%;
  height: 100%;
  border: none;
}

/* SIDEBAR MENU */
#menu {
  position: fixed;
  top: 0;
  left: -260px;
  width: 260px;
  height: 100%;
  background: #f4f4f4;
  overflow-y: auto;
  transition: left 0.3s ease;
  z-index: 1000;
  padding: 10px;
}

/* OVERLAY */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: none;
  z-index: 900;
}

/* SHOW MENU STATE */
#menu.open {
  left: 0;
}

#overlay.show {
  display: block;
}

/* MODAL (FULLSCREEN PAGE) */
#quizModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 2000;
  display: none;
  overflow-y: auto;
  padding: 16px;
}

#closeBtn {
  font-size: 18px;
  margin-bottom: 10px;
}

/* TOUCH FRIENDLY */
button, .menu-item {
  padding: 12px;
  font-size: 16px;
}

.card {
  border: none;
  border-radius: 14px;
  background: #f9fafc;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  padding: 16px;
  margin: 10px 0 10px 0;
}

h1 {
  margin-bottom: 0;
}

p {
  margin-top: 0;
  line-height: 1.5;
}

.menu-item {
  padding: 14px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
}

.menu-item:active {
  background: #ddd;
}

#quizContent {
  max-width: 600px;
  margin: 0 auto;
}

#quizContent h2 {
  margin-top: 0;
}

#quizContent div {
  line-height: 1.5;
  padding: 8px 0;
}

.score-card {
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
}

.score-card:active {
  background: #f0f0f0;
}

button {
  background: #777;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

button:active {
  transform: scale(0.95);
  box-shadow: 0 3px 8px rgba(0,0,0,0.2) inset;
}

#closeBtn {
  font-size: 18px;
  margin-bottom: 16px;
}

.menu-item,
.score-card {
  transition: transform 0.08s ease, background 0.1s ease;
}

.menu-item:active,
.score-card:active {
  transform: scale(0.98);
  background: #eaeaea;
}

#viewer {
  opacity: 1;
  transition: opacity 0.2s ease;
}

#viewer.fade-out {
  opacity: 0;
}

#quizModal {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

#quizModal.show {
  opacity: 1;
  transform: translateY(0);
}

#app {
  opacity: 1;
  transition: opacity 0.2s ease;
}

#app.fade-out {
  opacity: 0;
}

#welcome {
  opacity: 1;
  transition: opacity 0.5s ease;
}

#welcome.fade-in {
  opacity: 1;
}

#welcome {
  opacity: 0;
}

a {
  background: #f5f7fb;
  color: #777;
  text-decoration: none;
}

#readerControls {
  position: fixed;
  top: 3px;
  right: 12px;
  z-index: 1500;

  display: flex;
  gap: 8px;
  
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(6px);
  padding: 6px;
  border-radius: 12px;
}

#readerControls button {
  background: #ffffff;
  color: #333;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 16px;
}

#readerControls {
  background: rgba(0,0,0,0.1);
  padding: 6px;
  border-radius: 12px;
}

.quiz-option {
  width: 100%;
  padding: 14px;
  margin-bottom: 10px;

  border-radius: 12px;
  border: none;

  background: #f1f1f1 !important;
  color: #000;

  text-align: left;

  transition: all 0.15s ease;
}

/* tap feel */
.quiz-option:active {
  transform: scale(0.97);
}

/* selected */
.quiz-option.selected {
  background: #777 !important;
  color: white;
}

/* WRONG answer */
.quiz-option.wrong {
  background: #f44336 !important;
  color: white;
}

.quiz-option.pop {
  animation: pop 0.2s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.quiz-header h2 {
  letter-spacing: 1px;
  font-size: 18px;
}

.book-item {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #f1f1f1;
  cursor: pointer;
  transition: 0.1s;
}

.book-item {
  transition: transform 0.08s ease;
}

.book-item:active {
  transform: scale(0.97);
}

#bookList {
  max-height: 260px;   /* ~5 items */
  overflow-y: auto;
  scrollbar-width: thin;
}

#splash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  background: #f5e9d8; /* your cream */
  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 9999;
}

#splash {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.splash-content {
  text-align: center;
}

.splash-content img {
  width: 120px;
  margin-bottom: 16px;
}

.splash-content h1 {
  margin: 0;
  font-size: 28px;
}

.splash-content p {
  margin-top: 8px;
  font-size: 14px;
  opacity: 0.7;
}
