/* The Mehdees wordmark, identical to the mehdee.com masthead: Pacifico "The"
   tilted in sunset pink, Baloo 2 "MEHDEES" in cream with a pink glow, sitting
   on the same night-violet bar. */
@font-face { font-family: 'Baloo 2'; font-weight: 800; font-display: swap; src: url('fonts/baloo2.woff2') format('woff2'); }
@font-face { font-family: 'Pacifico'; font-weight: 400; font-display: swap; src: url('fonts/pacifico.woff2') format('woff2'); }

/* Math Arena. Bright, high contrast, big targets, mobile first. */
:root {
  --ink: #17203A;
  --paper: #F7F9FF;
  --card: #FFFFFF;
  --line: #DDE4F5;
  --muted: #5A6683;
  --blue: #2563EB;
  --blue-dark: #1D4FD8;
  --green: #12885A;
  --green-soft: #DFF6EC;
  --red: #C6274B;
  --red-soft: #FDE7EC;
  --amber: #F59E0B;
  --purple: #7C3AED;
  --shadow: 0 2px 0 #C9D3EC, 0 10px 28px #17203a1f;
  --radius: 18px;
  --pad: 18px;
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
/* The page is a bright sky, not a blank sheet: soft colour pools in the corners
   and a slow drift of maths glyphs behind everything. All of it sits on fixed
   layers under the cards, so the questions themselves stay on plain white. */
body {
  background:
    radial-gradient(1100px 640px at 10% -10%, #FFE3F1 0%, transparent 62%),
    radial-gradient(980px 600px at 94% 2%, #D7EEFF 0%, transparent 64%),
    radial-gradient(900px 660px at 48% 110%, #DFFBEC 0%, transparent 62%),
    radial-gradient(700px 520px at 88% 82%, #FFF0D6 0%, transparent 62%),
    linear-gradient(180deg, #F2F6FF 0%, #F6F3FF 52%, #FFF6F1 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}
body::before {
  content: '';
  position: fixed; inset: -120px;
  z-index: -1; pointer-events: none;
  opacity: .2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150' viewBox='0 0 260 260'%3E%3Cg fill='none' stroke-width='7' stroke-linecap='round'%3E%3Cpath d='M24 46h36M42 28v36' stroke='%23FF6FB0'/%3E%3Cpath d='M170 22l28 28M198 22l-28 28' stroke='%235B8DEF'/%3E%3Ccircle cx='62' cy='182' r='17' stroke='%2334C7A0'/%3E%3Cpath d='M188 196l19-32 19 32z' stroke='%23FFB020' stroke-linejoin='round'/%3E%3Cpath d='M112 112h34M112 132h34' stroke='%23A78BFA'/%3E%3Cpath d='M228 108v26' stroke='%23FF6FB0'/%3E%3Ccircle cx='128' cy='232' r='5' fill='%235B8DEF' stroke='none'/%3E%3Ccircle cx='24' cy='114' r='5' fill='%23FFB020' stroke='none'/%3E%3C/g%3E%3C/svg%3E");
  animation: drift 90s linear infinite;
}
@keyframes drift { to { background-position: 150px 300px; } }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 8px; }

.wrap { max-width: 760px; margin: 0 auto; padding: var(--pad); }
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 11px var(--pad); background: #150F2B; border-bottom: 1px solid #37276360;
  position: sticky; top: 0; z-index: 20;
}
.wordmark { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.wordmark .the {
  font-family: 'Pacifico', 'Snell Roundhand', cursive;
  font-size: 1.05rem;
  color: #FF2D95;
  transform: rotate(-4deg) translateY(-2px);
}
.wordmark .mehdees {
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  color: #FCF2E1;
  text-shadow: 0 0 18px #ff2d9538;
}
.top .spacer { margin-left: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: #EEF3FF; color: var(--blue); border: 1px solid #CBD9FA;
  border-radius: 999px; padding: 5px 12px; font-size: .82rem; font-weight: 800;
}
.top .pill { background: #ffffff1a; color: #FCF2E1; border-color: #ffffff33; }
.top .btn--ghost { background: transparent; color: #FCF2E1; border-color: #ffffff40; box-shadow: none; }
.top .btn--ghost:hover { background: #ffffff1a; color: #fff; border-color: #FF2D95; }
.pill--green { background: var(--green-soft); color: var(--green); border-color: #B6E7D3; }
.pill--amber { background: #FEF3C7; color: #92610A; border-color: #FBD98B; }

h1, h2 { font-family: 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif; }
h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.12; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
.lede { color: var(--muted); margin-top: 8px; }
.card {
  background: var(--card); border: 1px solid #ffffff;
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--blue); color: #fff; border: 0; border-radius: 14px;
  padding: 14px 22px; font-weight: 800; box-shadow: 0 3px 0 var(--blue-dark);
  transition: transform .06s ease;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--blue-dark); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: 0 3px 0 #E4EAF8; }
.btn--ghost:hover { background: #F2F6FF; color: var(--ink); }
.btn--green { background: var(--green); box-shadow: 0 3px 0 #0B6B46; }
.btn--green:hover { background: #0F7A50; }
.btn--big { width: 100%; padding: 16px 22px; font-size: 1.05rem; }

label { display: block; font-weight: 800; margin-bottom: 6px; }
input[type="text"] {
  width: 100%; font: inherit; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
}
input[type="text"]:focus { border-color: var(--blue); outline: none; }

/* grade picker */
.grades { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.grade {
  background: #fff; border: 2px solid var(--line); border-radius: 16px;
  padding: 14px 8px; text-align: center; font-weight: 800; box-shadow: 0 3px 0 #E4EAF8;
}
.grade b { display: block; font-size: 1.6rem; line-height: 1.1; color: var(--blue); }
.grade small { display: block; color: var(--muted); font-weight: 700; font-size: .72rem; }
.grade[aria-pressed="true"] { border-color: var(--blue); background: #EEF3FF; }

/* topic list */
.topics { display: grid; gap: 10px; }
.topic {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 13px 15px;
  box-shadow: 0 3px 0 #E4EAF8;
}
.topic:hover { border-color: #B9CBF7; background: #FAFCFF; }
.topic--lock { background: #FBFCFF; cursor: not-allowed; }
.topic--lock > * { opacity: .5; }
.topic__t { font-weight: 800; }
.topic__b { color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .02em; }
.topic__stars { margin-left: auto; white-space: nowrap; font-size: 1rem; letter-spacing: 1px; }

/* play */
.hud { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.bar { height: 10px; background: #E7EDFB; border-radius: 999px; overflow: hidden; flex: 1; min-width: 120px; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width .3s ease; }
.q { font-size: clamp(1.25rem, 4.5vw, 1.7rem); font-weight: 800; line-height: 1.3; }
.qsub { color: var(--muted); margin-top: 6px; font-weight: 700; font-size: .9rem; }
.visual { margin: 14px 0; font-size: 1.3rem; line-height: 1.7; letter-spacing: 2px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
@media (max-width: 430px) { .choices { grid-template-columns: 1fr; } }
.choice {
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  padding: 16px; font-weight: 800; font-size: 1.05rem; box-shadow: 0 3px 0 #E4EAF8;
}
.choice:hover:not([disabled]) { border-color: #B9CBF7; background: #FAFCFF; }
.choice.right { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.choice.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.feedback { margin-top: 14px; border-radius: 14px; padding: 14px 16px; font-weight: 700; display: none; }
.feedback.show { display: block; }
.feedback.ok { background: var(--green-soft); color: #0B6B46; }
.feedback.no { background: var(--red-soft); color: #9B1C3B; }
.feedback b { display: block; margin-bottom: 3px; }

.hearts { font-size: 1.1rem; letter-spacing: 2px; }
.result-num { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--blue); }

/* report card */
.report { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; background: #fff; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #F0F3FB; }
.rrow:last-child { border-bottom: 0; }
.rrow .rt { font-weight: 700; }
.rrow .rs { margin-left: auto; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.hide { display: none !important; }
footer { color: var(--muted); font-size: .8rem; padding: 26px var(--pad) 40px; text-align: center; }
footer a { color: var(--blue); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- scratch paper ---------- */
.playfoot { display: flex; gap: 10px; flex-wrap: wrap; }

.pad {
  position: fixed; inset: 0; z-index: 60;
  display: none; flex-direction: column;
  background: #EEF1F9;
}
.pad.open { display: flex; }
.pad__bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #150F2B;
}
.pad__q {
  flex: 1; min-width: 0; color: #FCF2E1; font-weight: 800; font-size: 1.05rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pad__bar .btn { padding: 9px 18px; }

/* squared paper, so columns of digits line up like a workbook */
.pad__paper {
  flex: 1; position: relative; margin: 10px;
  background: #fff;
  background-image:
    repeating-linear-gradient(0deg, #E3E9F7 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, #E3E9F7 0 1px, transparent 1px 26px);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #D9E0F0;
  overflow: hidden;
}
#padCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.pad__tools {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
}
.tool {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px;
  padding: 11px 15px; font-weight: 800; font-size: .92rem;
  box-shadow: 0 3px 0 #E4EAF8;
}
.tool:hover:not([disabled]) { border-color: #B9CBF7; background: #FAFCFF; }
.tool.is-on { border-color: var(--blue); background: #EEF3FF; color: var(--blue); }
.tool[disabled] { opacity: .4; cursor: not-allowed; box-shadow: none; }
.tool--wipe { color: var(--red); }
@media (max-width: 430px) { .tool { padding: 10px 12px; font-size: .85rem; } }

/* ---------- how to do this ---------- */
.helpbtn {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 14px;
  background: #FFF7E6; color: #92610A;
  border: 2px solid #FBD98B; border-radius: 12px;
  padding: 9px 14px; font-weight: 800; font-size: .88rem;
}
.helpbtn:hover { background: #FEF0CE; }
.helpbtn[aria-expanded="true"] { background: #FEF0CE; border-color: #F0B429; }
.help {
  margin-top: 12px; padding: 16px 18px;
  background: #FFFCF4; border: 2px solid #FBD98B; border-radius: 14px;
}
.help h3 {
  font-family: 'Baloo 2', ui-rounded, system-ui, sans-serif;
  font-size: 1rem; color: #92610A; margin-bottom: 3px;
}
.help .bench {
  font-family: ui-monospace, Menlo, monospace; font-size: .7rem;
  letter-spacing: .06em; color: #A9803A; display: block; margin-bottom: 10px;
}
.help ol { margin: 0 0 12px 20px; padding: 0; }
.help li { margin-bottom: 6px; color: var(--ink); }
.help .eg {
  background: #fff; border: 1px dashed #F0B429; border-radius: 10px;
  padding: 10px 12px; font-weight: 700; color: #7A5109;
}
.help .eg b { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #A9803A; margin-bottom: 3px; }

/* ---------- parent reset ---------- */
.parentline { text-align: center; color: var(--muted); font-size: .86rem; margin-top: 4px; }
.linkbtn {
  background: none; border: 0; padding: 0;
  color: var(--muted); font: inherit; font-weight: 800; text-decoration: underline;
}
.linkbtn:hover { color: var(--red); }

.sheet { align-items: center; justify-content: center; padding: 18px; background: #17203ACC; }
.sheet.open { display: flex; }
.sheet__box {
  background: #fff; border-radius: 20px; padding: 24px 22px;
  max-width: 460px; width: 100%; box-shadow: 0 24px 60px #17203a55;
  max-height: 92vh; overflow: auto;
}
.sheet__box h2 { font-family: 'Baloo 2', ui-rounded, system-ui, sans-serif; font-size: 1.35rem; margin-bottom: 10px; }
.sheet__box p { margin-bottom: 12px; }
.sheet__list { margin: 0 0 12px 20px; color: var(--muted); }
.sheet__list li { margin-bottom: 4px; }
.sheet__warn { background: var(--red-soft); color: #9B1C3B; border-radius: 12px; padding: 12px 14px; }
.sheet__check {
  display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 18px;
  font-weight: 700; font-size: .92rem; cursor: pointer;
}
.sheet__check input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--red); }
.sheet__row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn--danger { background: var(--red); box-shadow: 0 3px 0 #9B1C3B; }
.btn--danger:hover { background: #A81F3F; }

/* Cards float above the sky rather than blending into it. */
.card, .topic, .screen { position: relative; z-index: 1; }

/* Shown only when the browser will not keep progress: a private window, or
   storage switched off. Amber, not red: nothing is broken, it just will not
   be remembered. */
.note {
  margin-top: 10px; padding: 11px 13px; border-radius: 12px;
  background: #FEF3C7; border: 1px solid #FBD98B; color: #7C4E06;
  font-size: .86rem; font-weight: 700; line-height: 1.45;
}
.note b { display: block; margin-bottom: 2px; }
