:root {
  --bg: #07111f;
  --panel: rgba(15, 29, 51, 0.9);
  --panel-2: #13233d;
  --text: #f8fafc;
  --muted: #9fb0c8;
  --line: rgba(255,255,255,.1);
  --cyan: #36d9f6;
  --blue: #4f7cff;
  --green: #44e3a2;
  --yellow: #ffd65a;
  --red: #ff6b7a;
  --purple: #ab7cff;
  --shadow: 0 24px 70px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(79,124,255,.18), transparent 35%),
    radial-gradient(circle at 100% 100%, rgba(54,217,246,.13), transparent 38%),
    linear-gradient(145deg, #06101d 0%, #0a1423 60%, #07111f 100%);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient { position: fixed; border-radius: 50%; filter: blur(70px); opacity: .24; pointer-events: none; }
.ambient-a { width: 360px; height: 360px; background: var(--blue); top: 10%; left: -180px; }
.ambient-b { width: 320px; height: 320px; background: var(--cyan); right: -180px; bottom: 5%; }

.app-shell { width: min(1060px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 48px; position: relative; z-index: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; font-weight: 900; background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #05101e; box-shadow: 0 10px 28px rgba(54,217,246,.22); }
.brand-text { display: flex; flex-direction: column; line-height: 1; gap: 3px; }
.brand-text strong { font-size: 18px; letter-spacing: .03em; }
.brand-text span { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: rgba(255,255,255,.05); cursor: pointer; transition: .2s ease; font-weight: 900; }
.icon-btn:hover { transform: translateY(-2px); border-color: rgba(54,217,246,.45); background: rgba(54,217,246,.08); }

.screen { display: none; }
.screen.active { display: block; animation: screenIn .38s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-card, .question-card, .result-card, .hud-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19,35,61,.96), rgba(10,23,40,.95));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.hero-card, .result-card { border-radius: 30px; padding: clamp(28px, 5vw, 58px); text-align: center; overflow: hidden; position: relative; }
.hero-card::before, .result-card::before { content: ""; position: absolute; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(54,217,246,.17), transparent 65%); top: -180px; right: -100px; pointer-events: none; }
.eyebrow { color: var(--cyan); font-size: 12px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.hero-card h1, .result-card h1 { margin: 12px 0; font-size: clamp(42px, 7vw, 76px); line-height: .96; letter-spacing: -.055em; }
.hero-card h1 span { background: linear-gradient(90deg, var(--cyan), #9ce7ff, var(--purple)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-copy { max-width: 680px; margin: 20px auto 28px; color: #c9d5e6; font-size: clamp(16px, 2vw, 20px); line-height: 1.6; }

.mission-stats { width: min(540px, 100%); margin: 0 auto 30px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: rgba(0,0,0,.14); }
.mission-stats div { display: flex; flex-direction: column; gap: 3px; }
.mission-stats div + div { border-left: 1px solid var(--line); }
.mission-stats strong { font-size: 26px; color: var(--yellow); }
.mission-stats span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 28px 0; text-align: left; }
.feature-card { padding: 18px; border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid var(--line); display: grid; gap: 7px; min-height: 138px; align-content: start; }
.feature-card > span { font-size: 25px; }
.feature-card strong { font-size: 14px; }
.feature-card small { color: var(--muted); line-height: 1.45; }

.primary-btn { border: 0; border-radius: 15px; padding: 14px 22px; min-height: 50px; font-weight: 900; color: #06101d; background: linear-gradient(90deg, var(--cyan), #76e9ff); cursor: pointer; box-shadow: 0 12px 28px rgba(54,217,246,.18); transition: transform .18s ease, filter .18s ease, opacity .18s ease; }
.primary-btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.07); }
.primary-btn:disabled { cursor: not-allowed; opacity: .38; box-shadow: none; }
.hero-btn { width: min(440px, 100%); font-size: 16px; }
.microcopy { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.hud-card { border-radius: 22px; padding: 16px 18px; margin-bottom: 14px; position: sticky; top: 10px; z-index: 10; }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mission-label { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.topic-chip { padding: 6px 10px; border-radius: 999px; font-size: 11px; letter-spacing: .08em; font-weight: 900; }
.topic-chip.ped { background: rgba(79,124,255,.18); color: #9ab3ff; border: 1px solid rgba(79,124,255,.3); }
.topic-chip.pes { background: rgba(68,227,162,.12); color: #79efbd; border: 1px solid rgba(68,227,162,.26); }
.hud-score { display: flex; align-items: baseline; gap: 7px; }
.hud-score span { color: var(--yellow); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.hud-score strong { font-size: 22px; }
.progress-track { height: 8px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; margin: 13px 0 11px; }
.progress-bar { height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .4s ease; }
.hud-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.hud-meta strong { color: var(--text); }

.question-card { border-radius: 28px; padding: clamp(22px, 4vw, 40px); min-height: 560px; }
.question-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 22px; }
.skill-tag, .difficulty-tag, .points-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 10px; font-size: 11px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.skill-tag { color: var(--cyan); background: rgba(54,217,246,.08); border: 1px solid rgba(54,217,246,.18); }
.difficulty-tag { color: #d8c7ff; background: rgba(171,124,255,.1); border: 1px solid rgba(171,124,255,.18); margin-left: 5px; }
.points-pill { color: var(--yellow); background: rgba(255,214,90,.09); border: 1px solid rgba(255,214,90,.19); }
.question-card h2 { font-size: clamp(24px, 4vw, 38px); line-height: 1.16; letter-spacing: -.025em; max-width: 900px; margin: 0 0 12px; }
.question-context { color: #b8c7da; margin: 0 0 24px; line-height: 1.65; font-size: 15px; }

.visual-zone { margin: 18px 0 24px; padding: 16px; border-radius: 20px; background: rgba(3,12,23,.58); border: 1px solid var(--line); }
.graph-shell { width: min(650px, 100%); margin: 0 auto; }
.graph-svg { width: 100%; height: auto; display: block; }
.graph-grid { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.graph-axis { stroke: rgba(255,255,255,.75); stroke-width: 2; }
.graph-curve { fill: none; stroke: #62e6ff; stroke-width: 5; stroke-linecap: round; }
.graph-curve.supply { stroke: #74efb9; }
.graph-label { fill: #cfe3f8; font-size: 14px; font-weight: 800; }
.graph-note { fill: #9fb0c8; font-size: 11px; }

.answer-zone { display: grid; gap: 12px; margin-top: 20px; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.option-btn { min-height: 72px; padding: 16px 18px; border-radius: 17px; text-align: left; color: #ecf7ff; border: 1px solid var(--line); background: rgba(255,255,255,.045); cursor: pointer; font-weight: 750; line-height: 1.35; transition: .18s ease; position: relative; }
.option-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(54,217,246,.42); background: rgba(54,217,246,.07); }
.option-btn.selected { border-color: var(--cyan); background: rgba(54,217,246,.12); box-shadow: 0 0 0 2px rgba(54,217,246,.08) inset; }
.option-btn.correct { border-color: var(--green); background: rgba(68,227,162,.11); }
.option-btn.wrong { border-color: var(--red); background: rgba(255,107,122,.1); }
.option-btn:disabled { cursor: default; }
.option-index { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 10px; border-radius: 9px; background: rgba(255,255,255,.07); color: var(--muted); font-size: 12px; }

.numeric-wrap { display: flex; gap: 10px; align-items: stretch; max-width: 560px; }
.numeric-input { flex: 1; min-width: 0; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.05); border-radius: 16px; padding: 15px 17px; outline: none; font-size: 18px; font-weight: 800; }
.numeric-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(54,217,246,.1); }
.input-unit { min-width: 76px; display: grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--muted); font-weight: 800; }
.input-hint { color: var(--muted); font-size: 12px; }

.builder-wrap { display: grid; gap: 14px; }
.builder-control { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; font-weight: 800; }
.builder-control input[type="range"] { width: 100%; accent-color: var(--cyan); }
.builder-readout { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text); text-align: center; font-weight: 900; }

.feedback-box { margin-top: 22px; padding: 16px 18px; border-radius: 18px; border: 1px solid var(--line); animation: feedbackIn .25s ease both; }
.feedback-box.correct { background: rgba(68,227,162,.08); border-color: rgba(68,227,162,.3); }
.feedback-box.wrong { background: rgba(255,107,122,.08); border-color: rgba(255,107,122,.28); }
.feedback-title-row { display: flex; align-items: center; gap: 9px; }
.feedback-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-weight: 900; background: rgba(255,255,255,.08); }
.feedback-box p { margin: 8px 0 0; color: #c8d5e5; line-height: 1.55; }
@keyframes feedbackIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }
.question-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.next-btn { min-width: 170px; }

.result-card { max-width: 900px; margin: 0 auto; }
.result-badge { width: 88px; height: 88px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 26px; font-size: 42px; background: linear-gradient(145deg, rgba(255,214,90,.18), rgba(54,217,246,.12)); border: 1px solid var(--line); }
.result-card h1 { font-size: clamp(38px, 6vw, 62px); }
.result-card > p { color: var(--muted); }
.score-ring-wrap { display: grid; place-items: center; margin: 26px 0; }
.score-ring { --score: 0%; width: 190px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--cyan) var(--score), rgba(255,255,255,.08) 0); position: relative; }
.score-ring::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: #0d1d33; border: 1px solid var(--line); }
.score-ring > div { z-index: 1; display: grid; gap: 3px; }
.score-ring strong { font-size: 31px; }
.score-ring span { color: var(--cyan); font-weight: 900; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 24px 0; }
.result-stats div { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 18px; }
.result-stats span { font-size: 22px; }
.result-stats strong { font-size: 22px; }
.result-stats small { color: var(--muted); }
.mastery-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; text-align: left; margin: 24px 0; }
.mastery-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.035); }
.mastery-card > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.mastery-card strong { color: var(--text); }
.mini-track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.07); margin-top: 11px; overflow: hidden; }
.mini-track i { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .8s ease .15s; }
.result-message { text-align: left; padding: 18px; border-radius: 18px; background: rgba(54,217,246,.06); border: 1px solid rgba(54,217,246,.14); color: #cbd9e9; line-height: 1.55; margin-bottom: 22px; }

.help-dialog { width: min(650px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 24px; color: var(--text); background: #0e1d31; box-shadow: var(--shadow); padding: 0; }
.help-dialog::backdrop { background: rgba(0,5,13,.7); backdrop-filter: blur(5px); }
.help-dialog form { padding: 26px; position: relative; }
.help-dialog h2 { margin: 0 0 18px; }
.dialog-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; }
.formula-card { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.formula-card span { color: var(--cyan); font-weight: 900; }
.formula-card strong { font-size: 14px; }
.help-dialog p { color: var(--muted); line-height: 1.55; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 24px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 13px; color: var(--text); background: #182a46; border: 1px solid var(--line); box-shadow: var(--shadow); transition: .25s ease; z-index: 50; font-weight: 800; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 100; }
.confetti { position: absolute; width: 8px; height: 14px; top: -20px; border-radius: 2px; animation: confettiFall 1.4s ease-in forwards; }
@keyframes confettiFall { to { transform: translate(var(--drift), 110vh) rotate(720deg); opacity: .2; } }

.shake { animation: shake .25s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 18px, 1060px); padding-top: 10px; }
  .topbar { margin-bottom: 12px; }
  .feature-grid { grid-template-columns: repeat(2,1fr); }
  .question-card { min-height: auto; border-radius: 22px; }
  .option-grid { grid-template-columns: 1fr; }
  .mastery-grid { grid-template-columns: 1fr; }
  .hud-meta { gap: 10px 14px; }
}

@media (max-width: 480px) {
  .hero-card, .result-card { padding: 26px 17px; border-radius: 22px; }
  .hero-card h1 { font-size: 42px; }
  .feature-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .feature-card { min-height: 125px; padding: 14px; }
  .mission-stats strong { font-size: 22px; }
  .question-head { align-items: flex-start; }
  .points-pill { white-space: nowrap; }
  .numeric-wrap { display: grid; grid-template-columns: 1fr 74px; }
  .question-actions { justify-content: stretch; }
  .question-actions button { width: 100%; }
  .result-stats { grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
  .result-stats div { padding: 12px 7px; }
  .result-stats strong { font-size: 18px; }
  .result-stats small { font-size: 10px; }
  .brand-text span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* IGCSE360 integration additions */
.quest-logo-small {
  width: 54px;
  max-height: 44px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 10px 28px rgba(54,217,246,.18);
}
.elasticity-quest-page .site-shell-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.15;
  letter-spacing: normal;
  margin: 0;
  color: #fff;
}
.elasticity-quest-intro {
  max-width: 1060px;
  width: min(1060px, calc(100% - 28px));
  margin: 22px auto 0;
}
.elasticity-intro-card {
  display: flex;
  gap: 18px;
  align-items: center;
  background: rgba(255,255,255,.96);
  color: #132033;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: 0 14px 38px rgba(0,0,0,.18);
}
.elasticity-intro-card img {
  width: 125px;
  max-width: 35vw;
  background: #fff;
  border-radius: 14px;
  padding: 6px;
  border: 1px solid #e2e8f0;
}
.elasticity-intro-card h2 {
  margin: 0 0 8px;
  color: #004d99;
  letter-spacing: normal;
}
.elasticity-intro-card p {
  margin: 0;
  color: #34445c;
  line-height: 1.55;
}
.elasticity-back-link {
  max-width: 1060px;
  width: min(1060px, calc(100% - 28px));
  margin: 14px auto 0;
}
.elasticity-back-link a {
  color: #dbeafe;
  font-weight: 800;
  text-decoration: none;
}
.elasticity-back-link a:hover { text-decoration: underline; }
.elasticity-quest-page .site-footer { position: relative; z-index: 1; }
.elasticity-quest-page .breadcrumb-nav { position: relative; z-index: 2; }
.elasticity-quest-page .global-site-nav { position: relative; z-index: 3; }
@media (max-width:700px) {
  .elasticity-intro-card { flex-direction: column; align-items: flex-start; }
}
