@font-face {
  font-family: "Bravura";
  src: url("../assets/fonts/bravura/Bravura.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #172b3a;
  --ink-soft: #4d6270;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --surface-muted: #edf1ee;
  --line: #d5ded8;
  --accent: #a93b25;
  --accent-soft: #fff0ea;
  --teal: #1b776c;
  --teal-dark: #14554e;
  --shadow: 0 18px 44px rgba(23, 43, 58, .11);
  font-family: "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 8% 12%, #fff5dc 0, transparent 28%), linear-gradient(135deg, #f7f5ef 0%, #e7f0ed 100%);
  font-size: 16px;
}

button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid rgba(27, 119, 108, .42); outline-offset: 3px; }

.app-shell { width: min(100% - 40px, 1000px); margin: 0 auto; padding: 32px 0 48px; }
.app-header, .action-row, .results-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.app-header { margin-bottom: 40px; }
.eyebrow, .kicker { margin: 0 0 8px; color: var(--teal); font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: "Trebuchet MS", sans-serif; }
h1 { font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.05; }
h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h3 { font-size: 1.15rem; }

.progress-block { width: min(240px, 32vw); flex: 0 0 auto; }
.progress-block > span { display: block; margin-bottom: 8px; color: var(--ink-soft); font-size: .9rem; font-weight: 700; text-align: right; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: #d4dfdb; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: #a93b25; transition: width 240ms ease; }
.instruction { max-width: 790px; margin: 14px 0 24px; color: var(--ink-soft); line-height: 1.55; }

.equation { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 132px; padding: 20px clamp(12px, 3vw, 30px); border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 253, 248, .9); box-shadow: var(--shadow); }
.operand { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; }
.operator, .equals { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; min-width: 30px; color: var(--ink); font-size: 2rem; font-weight: 700; line-height: 1; }
.palette-panel { margin-top: 22px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255, 253, 248, .86); }
.answer-row { display: flex; flex: 1 1 190px; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 145px; min-height: 70px; padding: 4px 6px; border-bottom: 2px dashed #aabbb3; background: transparent; }
.answer-empty { color: var(--ink-soft); font-size: .92rem; }
.answer-note { display: inline-grid; place-items: center; width: 48px; height: 56px; padding: 0; border: 1px solid transparent; border-radius: 5px; color: var(--ink); background: transparent; cursor: pointer; }
.answer-note:hover { border-color: var(--accent); background: var(--accent-soft); }
.palette { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 10px; margin-top: 12px; }
.palette-note { display: flex; min-height: 92px; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 7px; border: 1px solid var(--line); border-bottom: 3px solid #b8c6bf; border-radius: 7px; color: var(--ink); background: var(--surface); cursor: pointer; font-weight: 700; }
.palette-note:hover { border-color: var(--teal); background: #f1f8f5; transform: translateY(-1px); }
.palette-note:active { transform: translateY(1px); }
.palette-note:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.note-symbol { display: block; width: 42px; height: 46px; overflow: visible; color: currentColor; }
.equation .note-symbol { width: 40px; height: 44px; }
.answer-note .note-symbol { width: 39px; height: 43px; }
.note-symbol path { vector-effect: non-scaling-stroke; }
.action-row { align-items: flex-start; margin-top: 22px; }
.feedback { flex: 1; min-height: 1.5em; margin: 10px 0 0; color: var(--ink-soft); line-height: 1.5; }
.feedback.is-correct { color: var(--teal-dark); font-weight: 700; }
.feedback.is-wrong { color: var(--accent); font-weight: 700; }
.primary-button, .secondary-button { min-height: 48px; padding: 0 20px; border: 0; border-radius: 7px; font-weight: 700; cursor: pointer; }
.primary-button { flex: 0 0 auto; color: #fffaf5; background: #a93b25; }
.primary-button:hover { background: #832e1d; }
.secondary-button { color: var(--teal-dark); border: 2px solid var(--teal); background: transparent; }
.secondary-button:hover { color: #fff; background: var(--teal); }
.results-view { animation: rise-in 360ms ease both; }
.score-summary { margin: 12px 0 24px; color: var(--ink-soft); font-size: 1.1rem; }
.results-list { display: grid; gap: 10px; }
.result-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid var(--teal); border-radius: 8px; background: var(--surface); }
.result-item.is-wrong { border-left-color: var(--accent); }
.result-number { color: var(--ink-soft); font-weight: 700; }
.result-solutions { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.result-solution-label { display: block; margin-bottom: 3px; color: var(--ink-soft); font-size: .8rem; font-weight: 700; }
.result-equation { display: flex; min-height: 46px; align-items: center; flex-wrap: wrap; gap: 3px; padding: 5px 7px; border-radius: 5px; background: var(--surface-muted); }
.result-equation .note-symbol { width: 26px; height: 30px; }
.result-equation .operator, .result-equation .equals { min-width: 18px; font-size: 1.2rem; }
.result-equation-answer { display: flex; min-height: 34px; align-items: center; flex-wrap: wrap; gap: 2px; border-bottom: 1px dashed #aabbb3; }
.result-equation-answer .note-symbol { width: 26px; height: 30px; }
.result-answer-empty { color: var(--ink-soft); font-size: .9rem; }
.result-points { font-weight: 700; white-space: nowrap; }
.scorm-status { max-width: 520px; color: var(--ink-soft); font-size: .88rem; line-height: 1.5; }
.app-footer { padding: 0 20px 22px; color: var(--ink-soft); font-size: .8rem; text-align: center; }
[hidden] { display: none !important; }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 700px) {
  .app-shell { width: calc(100% - 28px); padding-top: 22px; }
  .app-header { align-items: flex-start; flex-direction: column; margin-bottom: 30px; }
  .progress-block { width: 100%; }
  .progress-block > span { text-align: left; }
  .equation { gap: 7px; }
  .palette { grid-template-columns: repeat(3, minmax(82px, 1fr)); }
  .action-row, .results-actions { align-items: stretch; flex-direction: column; gap: 8px; }
  .primary-button { width: 100%; }
}

@media (max-width: 390px) {
  .equation { justify-content: center; padding: 12px 6px; }
  .equation .note-symbol { width: 33px; height: 39px; }
  .operator, .equals { font-size: 1.6rem; }
  .palette-panel { padding: 14px 12px; }
  .palette { gap: 6px; }
  .palette-note { min-height: 84px; font-size: .88rem; }
  .result-item { grid-template-columns: 24px minmax(0, 1fr); }
  .result-points { grid-column: 2; }
  .result-solutions { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
