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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #000;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app { height: 100dvh; position: relative; }

/* ── HOME SCREEN ── */
#home-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#home-header {
  padding: 40px 20px 20px;
  text-align: center;
  flex-shrink: 0;
}

#home-logo {
  display: inline-block;
  font-size: 32px;
  margin-bottom: 10px;
}

#home-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-version {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  letter-spacing: 1px;
}

#home-header p {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.4);
}

/* Topic grid — scrollable */
#topic-grid {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
  align-content: start;
}

/* Footer — sticky at bottom */
#home-footer {
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 12px);
}

#footer-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0 16px 12px;
}

/* Mode buttons */
#mode-btns {
  display: flex;
  gap: 10px;
  padding: 0 16px;
  flex-shrink: 0;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border: none;
  border-radius: 14px;
  background: rgba(255,255,255,0.07);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.mode-btn:active { transform: scale(0.96); background: rgba(255,255,255,0.14); }

.mode-icon { font-size: 24px; }
.mode-label { font-size: 13px; font-weight: 600; }

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 14px;
  border: none;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-align: left;
}
.topic-card:active { transform: scale(0.96); background: rgba(255,255,255,0.13); }

.topic-icon { font-size: 22px; }
.topic-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.topic-domain { font-size: 10px; color: rgba(255,255,255,0.35); font-weight: 500; letter-spacing: 0.3px; }
.topic-count { font-size: 10px; color: rgba(218, 165, 32, 0.8); font-weight: 600; }

/* ── QUIZ SCREEN ── */
#quiz-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, #000 0%, #0a0a0a 100%);
}

#quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  flex-shrink: 0;
}

#back-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}

#topic-badge {
  font-size: 11px;
  font-weight: 700;
  color: #e8a020;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(232,160,32,0.12);
  padding: 3px 10px;
  border-radius: 20px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#progress-text {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  letter-spacing: 1px;
}

/* Timer */
#timer-track {
  width: calc(100% - 32px);
  max-width: 500px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin: 6px auto 0;
  flex-shrink: 0;
}

#timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  background: #4dd964;
  transform-origin: left;
  transition: none;
}
@keyframes drain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Question */
#question-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 28px;
  overflow: hidden;
}

#question-text {
  font-size: 23px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  max-width: 500px;
  letter-spacing: -0.2px;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), opacity 0.2s cubic-bezier(0.4,0,0.2,1);
}
#question-text.slide-out { transform: translateY(-80px); opacity: 0; }
#question-text.slide-in  { transform: translateY(50px);  opacity: 0; }

/* Options */
#options-area {
  padding: 0 14px;
  padding-bottom: env(safe-area-inset-bottom, 10px);
  flex-shrink: 0;
}

#options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), opacity 0.2s cubic-bezier(0.4,0,0.2,1);
}
#options.slide-out { transform: translateY(-60px); opacity: 0; }
#options.slide-in  { transform: translateY(60px);  opacity: 0; }

.option-btn {
  width: 100%;
  padding: 14px 10px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: center;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
}
.option-btn:active { transform: scale(0.96); background: rgba(255,255,255,0.15); }
.option-btn.correct { background: rgba(77,217,100,0.2); box-shadow: inset 0 0 0 1.5px rgba(77,217,100,0.6); color: #4dd964; }
.option-btn.wrong   { background: rgba(255,59,48,0.2);  box-shadow: inset 0 0 0 1.5px rgba(255,59,48,0.6);  color: #ff3b30; }
.option-btn.disabled { pointer-events: none; }

#swipe-hint {
  text-align: center;
  padding: 8px 0 12px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.12);
  letter-spacing: 0.5px;
}

/* Reactions */
#heart-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
.heart {
  position: absolute;
  font-size: 28px;
  animation: floatUp 0.6s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(0.4); }
  50%  { opacity: 1; transform: translateY(-50px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-110px) scale(0.7); }
}
.reaction-label {
  position: absolute;
  top: 30%;
  left: 50%;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 2px;
  animation: labelPop 0.7s cubic-bezier(0.4,0,0.2,1) forwards;
  pointer-events: none;
}
@keyframes labelPop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.5); }
  30%  { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
  60%  { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-60%) scale(0.9); }
}

/* Summary */
#summary {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 200;
  padding: 20px;
}
#summary h1 { font-size: 28px; font-weight: 600; }
#score-circle {
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 3px solid rgba(77,217,100,0.5);
  display: flex; align-items: center; justify-content: center;
  background: rgba(77,217,100,0.08);
}
#score-value { font-size: 36px; font-weight: 700; color: #4dd964; }
#score-label { font-size: 16px; color: rgba(255,255,255,0.45); font-weight: 500; }
#summary-btns { display: flex; gap: 10px; }

#restart-btn, #home-btn {
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
#restart-btn { background: #fff; color: #000; }
#home-btn    { background: rgba(255,255,255,0.12); color: #fff; }
#restart-btn:active, #home-btn:active { transform: scale(0.96); opacity: 0.8; }

.hidden { display: none !important; }
