body {
  margin: 0;
  padding: 0;
  font-family: 'Fira Mono', 'Consolas', 'Courier New', monospace;
  background: var(--bg);
  color: var(--fg);
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-x: hidden;
}
html {
  box-sizing: border-box;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}
*, *:before, *:after {
  box-sizing: inherit;
}
:root {
  --bg: #f7fafc;
  --fg: #1a2233;
  --accent: #1e88e5;
  --accent2: #43a047;
  --btn-bg: #fff;
  --btn-fg: #1a2233;
  --btn-hover: #e3f2fd;
  --card-bg: #fff;
  --shadow: 0 8px 32px 0 rgba(30,136,229,0.08);
  --correct: #43a047;
  --incorrect: #e53935;
  --chem-dot: #b3e5fc;
}
body.light {
  --bg: #fff;
  --fg: #1a2233;
  --accent: #1565c0;
  --accent2: #388e3c;
  --btn-bg: #fff;
  --btn-fg: #1a2233;
  --btn-hover: #e3f2fd;
  --card-bg: #fff;
  --shadow: 0 8px 32px 0 rgba(30,136,229,0.08);
  --correct: #43a047;
  --incorrect: #e53935;
  --chem-dot: #b3e5fc;
}
body:not(.light) {
  --bg: #101624;
  --fg: #f7fafc;
  --accent: #90caf9;
  --accent2: #66bb6a;
  --btn-bg: #181e2e;
  --btn-fg: #f7fafc;
  --btn-hover: #22304a;
  --card-bg: #181e2e;
  --shadow: 0 8px 32px 0 rgba(9,30,66,0.18);
  --correct: #43e68f;
  --incorrect: #ff6f6f;
  --chem-dot: #1976d2;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 3.5rem 2rem 2.5rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  border-radius: 18px;
  background: var(--card-bg);
  margin-top: 2.5vh;
  margin-bottom: 2.5vh;
  position: relative;
  width: 100%;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  width: 100%;
  min-height: 3.5rem;
}
.typewriter {
  font-family: inherit;
  letter-spacing: 0.04em;
  border-right: 2px solid var(--accent);
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow: visible;
  animation: blink-caret 0.8s step-end infinite;
  font-size: 2.5rem;
  max-width: 100vw;
  text-overflow: ellipsis;
}
@keyframes blink-caret {
  0%, 100% { border-color: transparent; }
  50% { border-color: var(--accent); }
}
#mode-toggle {
  background: none;
  border: none;
  font-size: 2.2rem;
  color: var(--accent);
  cursor: pointer;
  transition: color 0.3s, transform 0.2s;
}
#mode-toggle:hover {
  color: var(--accent2);
  transform: scale(1.2) rotate(-10deg);
}
#start-btn {
  font-size: 1.5rem;
  padding: 1.2em 2.5em;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 2px solid var(--accent);
  border-radius: 12px;
  cursor: pointer;
  margin: 3rem auto 2rem auto;
  display: block;
  box-shadow: 0 2px 12px rgba(30,136,229,0.07);
  transition: background 0.2s, color 0.2s, transform 0.15s, border 0.2s;
  font-weight: bold;
  letter-spacing: 0.05em;
  outline: none;
}
#start-btn:hover {
  background: var(--btn-hover);
  color: var(--accent);
  border-color: var(--accent2);
  transform: scale(1.05);
}
#quiz {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 1.5rem;
}
#timer {
  font-size: 1.5rem;
  margin-bottom: 1.8rem;
  color: var(--accent);
  font-weight: bold;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(30,136,229,0.08);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
#question-img-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 2.5rem;
  position: relative;
}
#question-img {
  max-width: 100%;
  max-height: 480px;
  min-height: 220px;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(30,136,229,0.10);
  background: #e3f2fd;
  object-fit: contain;
  transition: transform 0.3s, box-shadow 0.3s;
  border: 3px solid var(--accent);
}
.chem-dots {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
}
.chem-dot {
  width: 14px;
  height: 14px;
  background: var(--chem-dot);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(30,136,229,0.10);
}
#options {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 600px;
  margin-top: 2.2rem;
  gap: 1.2em;
}
.option-btn {
  flex: 1 1 0;
  margin: 0;
  padding: 1.3em 0;
  font-size: 1.3rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 2px solid var(--accent);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s, border 0.2s;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(30,136,229,0.07);
  outline: none;
  position: relative;
  z-index: 1;
}
.option-btn:hover, .option-btn:focus {
  background: var(--btn-hover);
  color: var(--accent);
  transform: scale(1.04);
  border-color: var(--accent2);
}
.option-btn.selected {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent);
  animation: popIn 0.3s;
}
.option-btn.correct {
  background: var(--correct) !important;
  color: #fff !important;
  border-color: var(--correct) !important;
  animation: correctPop 0.5s;
}
@keyframes correctPop {
  0% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.option-btn.incorrect {
  background: var(--incorrect) !important;
  color: #fff !important;
  border-color: var(--incorrect) !important;
  animation: incorrectShake 0.4s;
}
@keyframes incorrectShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
#result {
  margin-top: 3rem;
  font-size: 1.7rem;
  text-align: center;
  animation: fadeIn 1s cubic-bezier(.4,0,.2,1);
}
#review {
  margin-top: 3rem;
  animation: fadeIn 1.2s cubic-bezier(.4,0,.2,1);
}
.review-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(30,136,229,0.10);
  margin-bottom: 2rem;
  padding: 1.5rem 1.2rem 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow 0.2s;
  border: 2px solid transparent;
}
.review-card.correct {
  border-color: var(--correct);
}
.review-card.incorrect {
  border-color: var(--incorrect);
}
.review-img {
  max-width: 95%;
  max-height: 260px;
  border-radius: 10px;
  margin-bottom: 0.7rem;
  box-shadow: 0 2px 8px rgba(30,136,229,0.08);
  border: 2px solid var(--accent2);
  background: #e3f2fd;
}
.review-answers {
  display: flex;
  gap: 1.2em;
  margin-top: 0.5em;
  font-size: 1.2rem;
}
.review-answers span {
  padding: 0.2em 0.7em;
  border-radius: 6px;
  font-weight: 500;
}
.review-answers .your {
  background: var(--incorrect);
  color: #fff;
}
.review-answers .correct {
  background: var(--correct);
  color: #fff;
}
.hidden {
  display: none !important;
}
@media (max-width: 900px) {
  .container {
    max-width: 100vw;
    padding: 1.2rem 0.2rem;
    border-radius: 0;
    min-height: 100vh;
    box-shadow: none;
  }
  header {
    padding: 0 0.5rem;
    min-height: 2.5rem;
  }
  .typewriter {
    font-size: 1.5rem;
    padding-right: 0.2em;
    max-width: 90vw;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: visible;
  }
  #question-img {
    max-height: 160px;
    min-height: 80px;
  }
  #options {
    flex-direction: column;
    max-width: 100%;
    gap: 0.7em;
  }
  .option-btn {
    margin: 0.2em 0;
    font-size: 1.1rem;
    padding: 1em 0;
  }
  .review-img {
    max-height: 80px;
  }
}
@media (max-width: 600px) {
  .container {
    padding: 0.5rem 0.1rem;
    min-height: 100vh;
  }
  header {
    min-height: 2rem;
  }
  .typewriter {
    font-size: 1.1rem;
    max-width: 80vw;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: visible;
  }
  #question-img {
    max-height: 100px;
    min-height: 50px;
  }
}