:root { --paper:#f7f4ed; --ink:#171821; --blue:#5c66e8; --lime:#cafa70; --muted:#60616b; --line:#d9d5ca; }
* { box-sizing:border-box; }
body { margin:0; min-height:100vh; color:var(--ink); background:radial-gradient(circle at 95% 2%, #c7c9da 0 120px, transparent 122px),radial-gradient(circle at 3% 33%, #c2d4a8 0 90px, transparent 92px),#d5ddd2; font:16px/1.45 ui-rounded,"Arial Rounded MT Bold",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
button,a { -webkit-tap-highlight-color:transparent; }
button { font:inherit; cursor:pointer; }
button:disabled { cursor:default; opacity:.55; }
:focus-visible { outline:4px solid #f2b82c; outline-offset:3px; }
.topbar { min-height:68px; padding:12px clamp(16px,4vw,60px); display:flex; align-items:center; justify-content:space-between; gap:14px; border-bottom:3px solid #e7e2d5; background:#fffefaed; }
.topbar a { color:inherit; text-decoration:none; font-weight:800; }
.back { white-space:nowrap; }
.brand { display:inline-flex; align-items:center; gap:8px; font-weight:900; font-size:clamp(15px,2vw,20px); }
.brand-mark { display:grid; place-items:center; width:31px; height:31px; border-radius:8px; background:var(--lime); box-shadow:0 3px 0 #abc956; transform:rotate(-5deg); font-size:23px; }
.topbar .account-link { border:2px solid var(--blue); border-radius:999px; color:#3039a1; background:#eff0ff; padding:7px 14px; font-size:14px; white-space:nowrap; }
.page { max-width:1160px; margin:auto; padding:clamp(26px,5vw,54px) clamp(16px,4vw,40px) 80px; }
.in-game .page { padding-top:16px; }
.in-game .page { max-width:920px; padding-inline:clamp(16px,2vw,32px); padding-bottom:32px; }
.in-game .intro { margin-bottom:20px; }
.in-game .intro .lede,.in-game .intro-art { display:none; }
.intro { display:flex; justify-content:space-between; align-items:center; gap:24px; margin-bottom:30px; }
.eyebrow { margin:0 0 8px; text-transform:uppercase; letter-spacing:.13em; color:var(--muted); font-size:12px; font-weight:900; }
h1 { margin:0; font-size:clamp(40px,5.5vw,68px); line-height:1.08; letter-spacing:-.01em; word-spacing:.025em; }
h1 em { color:var(--blue); font-style:normal; }
.lede { max-width:720px; margin:16px 0 0; color:#4a4c55; font-size:clamp(16px,1.7vw,19px); }
.intro-art { flex:none; display:flex; align-items:center; gap:9px; padding:18px 22px; border:2px solid #33354d; border-radius:22px; box-shadow:0 7px 0 #dcd8ca; background:#fffefa; font-size:36px; transform:rotate(3deg); }
.intro-art img { width:52px; height:52px; object-fit:contain; }
.intro-art span:nth-child(2) { color:var(--blue); font-size:23px; font-weight:900; }
.game-panel { overflow:hidden; border:2px solid #34365c; border-radius:26px; background:#20213b; box-shadow:0 8px 0 #11121e,0 25px 55px #1718212b; }
.setup h2,.finish h2,.question-copy h2,#feedback { color:#fff; }
.game-panel .setup>p,.game-panel .finish p,.game-panel .question-copy .eyebrow { color:#d9daec; }
.panel-top { display:flex; gap:1px; background:#d9d8e5; border-bottom:2px solid #d3d4e7; }
.stat,.mode-stat { display:flex; align-items:baseline; gap:10px; flex:1; padding:15px clamp(14px,2.5vw,28px); background:#f0f0ff; }
.stat span,.mode-stat span { color:#484a64; font-size:14px; font-weight:800; }
.stat strong,.mode-stat strong { font-size:32px; line-height:1; letter-spacing:-.04em; }
.stat small { color:var(--muted); }
.mode-stat { flex:0 0 auto; background:#e8f9c9; }
.setup,.play,.finish { padding:clamp(22px,3.8vw,40px); }
.setup h2,.finish h2 { margin:0; font-size:clamp(27px,3vw,39px); line-height:1.12; letter-spacing:-.01em; word-spacing:.02em; }
.setup>p { margin:7px 0 22px; color:var(--muted); }
.factor-choices { display:grid; grid-template-columns:repeat(9,minmax(0,1fr)); gap:10px; margin-bottom:40px; }
.factor-button { min-height:68px; border:2px solid #777aa1; border-radius:15px; background:#fff; color:var(--ink); font-size:25px; font-weight:900; box-shadow:0 4px 0 #d4d3df; }
.factor-button[aria-pressed="true"] { background:var(--lime); border-color:#303347; box-shadow:0 4px 0 #afca70; }
.account-status { color:var(--muted); min-height:24px; }
.start-actions,.finish-actions { display:flex; gap:12px; flex-wrap:wrap; }
.primary,.secondary { min-height:50px; padding:10px 22px; border:2px solid #303347; border-radius:14px; font-weight:900; }
.primary { background:var(--blue); color:white; box-shadow:0 4px 0 #363e9c; }
.secondary { background:#fff; box-shadow:0 4px 0 #d6d3ca; }
.question-top { display:grid; grid-template-columns:minmax(0,3fr) minmax(230px,2fr); gap:14px; align-items:stretch; }
.number-summary { display:grid; grid-template-rows:1fr 1fr; gap:12px; min-width:0; }
.apple-count,.remaining-count { min-width:0; padding:15px 22px; border:2px solid #e1dccc; border-radius:18px; background:#fdf6e8; }
.remaining-count { background:#eaf9ce; }
.remaining-count.short { background:#ffe6de; }
.remaining-count.empty { background:#fff0e1; border-color:#a4432c; }
.overline { display:block; text-transform:uppercase; letter-spacing:.09em; color:#555663; font-size:12px; font-weight:900; }
.apple-count strong,.remaining-count strong { margin-right:7px; font-size:clamp(31px,4vw,44px); line-height:1; letter-spacing:-.05em; }
.apple-tray { min-width:0; padding:15px 18px; border:2px solid #e1dccc; border-radius:18px; background:#fff8ec; }
.tray-label { display:block; margin-bottom:8px; color:#484a64; font-size:14px; font-weight:900; }
.apple-pile { display:flex; flex-wrap:wrap; gap:2px 4px; min-height:28px; align-content:flex-start; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.apple-piece { display:block; flex:none; width:25px; height:28px; object-fit:contain; }
.basket-apples .apple-piece { width:17px; height:19px; }
.question-heading { display:flex; align-items:center; gap:20px; margin-bottom:18px; }
.question-copy { flex:1; min-width:0; }
.equation-card { flex:none; padding:14px 20px; border:2px solid #d9daf1; border-radius:18px; background:#f0f0ff; text-align:center; }
.equation { margin:0; color:#363da1; font-size:clamp(25px,3vw,34px); font-weight:900; letter-spacing:-.01em; white-space:nowrap; }
.equation-card>span { color:#565970; font-size:12px; font-weight:700; }
.equation-card.solved { background:var(--lime); border-color:#a7c867; }
.question-copy h2 { margin:0; font-size:clamp(26px,3.2vw,38px); line-height:1.12; letter-spacing:-.01em; word-spacing:.02em; }
.question-copy>p:last-child { margin:8px 0 0; color:var(--muted); }
.basket-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px; margin:16px 0; }
.basket-card { min-width:0; padding:12px; border:2px solid #dadbed; border-radius:20px; background:#f8f8ff; box-shadow:0 5px 0 #dad9e4; text-align:center; }
.basket-card h3 { margin:0 0 8px; font-size:16px; }
.basket-choices { display:grid; grid-template-columns:repeat(4,minmax(44px,56px)); justify-content:center; gap:8px; margin-bottom:14px; }
.answer-button { display:grid; place-items:center; width:100%; aspect-ratio:1; min-width:44px; min-height:44px; padding:0; border:1px solid #deddd6; border-radius:50%; background:#fff; color:#24253a; font-size:18px; font-weight:800; box-shadow:0 4px 0 #c9c8c0; transition:transform .12s ease,background .12s ease; }
.answer-button:hover:not(:disabled) { background:#f1f2ff; border-color:#969bdd; }
.answer-button:active:not(:disabled) { transform:translateY(3px); box-shadow:0 1px 0 #c9c8c0; }
.answer-button[aria-pressed="true"] { border-color:#303347; background:var(--lime); box-shadow:0 4px 0 #b2cf72; }
.answer-button:disabled:not([aria-pressed="true"]) { opacity:1; border-color:#aaa9ae; background:#e8e6e5; color:#686972; box-shadow:none; cursor:not-allowed; }
.basket { min-height:0; padding:7px; border-radius:12px; background:#fff; }
.basket.filled { background:#eff0ff; }
.basket-number { display:block; min-height:35px; font-size:27px; font-weight:900; line-height:1.25; }
.basket-scene { position:relative; width:150px; max-width:100%; height:122px; margin:auto; }
.basket-icon { display:block; width:100%; height:100%; object-fit:fill; }
.basket-apples { position:absolute; left:50%; bottom:49px; transform:translateX(-50%); display:flex; flex-wrap:wrap-reverse; justify-content:center; gap:0 1px; width:108px; max-width:90%; }
.feedback-row { display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:52px; }
#feedback { margin:0; font-weight:800; }
.clear-button { min-height:40px; padding:7px 14px; border:2px solid #8d8b90; border-radius:11px; background:#fff; color:#41434c; font-size:14px; font-weight:800; white-space:nowrap; }
.finish { text-align:center; padding-block:52px; }
.finish h2 { font-size:clamp(34px,5vw,54px); }
.finish p { color:var(--muted); }
.finish .eyebrow { color:var(--blue); }
.finish-actions { justify-content:center; margin-top:20px; }
[hidden] { display:none!important; }
@media (max-width:800px) { .factor-choices { grid-template-columns:repeat(5,minmax(0,1fr)); } .intro-art { display:none; } .stat { display:block; } .stat span,.stat small { display:block; } .mode-stat { display:block; } }
@media (max-width:620px) { .question-top { grid-template-columns:1fr; } .number-summary { grid-template-columns:1fr 1fr; grid-template-rows:auto; } }
@media (max-width:540px) { .topbar { gap:8px; } .topbar .account-link { padding:6px 10px; } .brand { font-size:0; } .brand-mark { font-size:23px; } .panel-top .stat,.panel-top .mode-stat { padding:12px; } .stat span,.mode-stat span { font-size:11px; } .stat strong,.mode-stat strong { font-size:27px; } .stat small { font-size:11px; } .factor-choices { grid-template-columns:repeat(3,minmax(0,1fr)); } .question-top { gap:8px; } .apple-count,.remaining-count { padding:10px; } .apple-count strong,.remaining-count strong { font-size:31px; } .apple-count span:last-child,.remaining-count span:last-child { font-size:12px; } .basket-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } .basket-card { padding:8px; } }

@media (max-width:800px) { .question-heading { align-items:flex-start; flex-direction:column; gap:12px; } .equation-card { padding:8px 16px; } }
@media (max-width:540px) { .basket-choices { grid-template-columns:repeat(2,44px); gap:8px; } .play { padding:16px 12px; } .basket-grid { gap:10px; } .basket-scene { width:100px; height:82px; } .basket-apples { bottom:33px; width:74px; } .basket-apples .apple-piece { width:14px; height:16px; } .feedback-row { align-items:flex-start; flex-direction:column; gap:10px; } }
@media (min-width:541px) {
  .basket-grid { grid-template-columns:repeat(auto-fit,210px); justify-content:center; }
  .basket-card { width:100%; max-width:230px; padding:6px; }
  .basket-choices { grid-template-columns:repeat(4,44px); gap:6px; margin-bottom:8px; }
  .basket { padding:5px; }
  .basket-scene { width:100px; height:82px; }
  .basket-apples { bottom:33px; width:74px; }
  .basket-apples .apple-piece { width:14px; height:16px; }
  .basket-number { min-height:30px; font-size:24px; }
}
@media (min-width:1100px) {
  .play { padding:20px 24px; }
  .question-heading { margin-bottom:12px; }
  .question-top { grid-template-columns:minmax(0,1fr) 230px; gap:12px; }
  .apple-count,.remaining-count { padding:10px 16px; }
  .apple-count strong,.remaining-count strong { font-size:32px; }
  .number-summary { gap:8px; }
  .basket-grid { gap:12px; margin:12px 0; }
  .basket-card h3 { margin-bottom:6px; }
}
@media (prefers-reduced-motion:reduce) { .answer-button { transition:none; } }

.apple-tray { display:grid; grid-template-columns:minmax(0,1fr) 170px; align-items:center; gap:16px; }
.apple-tray .apple-pile { grid-column:1; grid-row:1; }
.tray-count { grid-column:2; grid-row:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; min-height:112px; margin:0; color:var(--ink); font-weight:800; }
.tray-count strong { display:inline-block; border-radius:8px; font-size:56px; line-height:1; font-variant-numeric:tabular-nums; transform-origin:center; }
.tray-count span { font-size:14px; }
@media (max-width:540px) {
  .apple-tray { grid-template-columns:minmax(0,1fr) 112px; gap:10px; padding:16px 12px; }
  .tray-count { min-height:100px; }
  .tray-count strong { font-size:40px; }
  .tray-count span { font-size:12px; }
}

.basket-card { background:#245440; border-color:#49765e; box-shadow:0 5px 0 #15392b; }
.basket-card h3 { color:#fff; }
.basket-card .basket { background:#e7efe4; }
.basket-card .basket.filled { background:#d4e9c7; }

.basket-card .basket-choices { margin-bottom:10px; }

/* Keep desktop baskets compact in a centered five-column grid. */
@media (min-width:1000px) and (orientation:landscape) {
  .in-game .topbar { min-height:48px; padding-block:6px; }
  .in-game .page { max-width:1200px; padding:10px 16px 16px; }
  .in-game .intro { margin-bottom:10px; }
  .in-game .intro .eyebrow { display:none; }
  .in-game h1 { font-size:36px; }
  .in-game .stat,.in-game .mode-stat { padding:10px 16px; }
  .in-game .stat strong,.in-game .mode-stat strong { font-size:26px; }
  .in-game .play { padding:12px 16px; }
  .in-game .question-heading { margin-bottom:10px; gap:12px; }
  .in-game .question-copy h2 { font-size:26px; }
  .in-game .question-copy .eyebrow { margin-bottom:4px; font-size:10px; }
  .in-game .equation-card { padding:8px 14px; }
  .in-game .equation { font-size:28px; }
  .in-game .apple-tray { padding:10px 14px; grid-template-columns:minmax(0,1fr) 140px; }
  .in-game .tray-count { min-height:92px; }
  .in-game .tray-count strong { font-size:46px; }
  .in-game .apple-pile { gap:2px 3px; }
  .in-game .apple-pile .apple-piece { width:21px; height:23px; }
  .in-game .basket-grid { grid-template-columns:repeat(5,minmax(0,204px)); gap:10px; margin:10px 0; }
  .in-game .basket-card { max-width:none; padding:6px; }
  .in-game .basket-card h3 { font-size:14px; margin-bottom:5px; }
  .in-game .basket-choices { grid-template-columns:repeat(4,44px); gap:4px; margin-bottom:8px; }
  .in-game .basket { min-height:0; padding:4px; }
  .in-game .basket-scene { width:88px; height:72px; }
  .in-game .basket-apples { bottom:29px; width:66px; }
  .in-game .basket-apples .apple-piece { width:12px; height:14px; }
  .in-game .feedback-row { min-height:40px; }
}
@media (min-width:1000px) and (max-height:900px) and (orientation:landscape) {
  .in-game h1 { font-size:28px; }
  .in-game .page { padding-top:6px; padding-bottom:8px; }
  .in-game .play { padding-block:8px; }
  .in-game .tray-count { min-height:72px; }
  .in-game .apple-pile .apple-piece { width:18px; height:20px; }
  .in-game .basket-scene { width:76px; height:62px; }
  .in-game .basket-apples { bottom:25px; width:58px; }
  .in-game .basket-apples .apple-piece { width:10px; height:11px; }
  .in-game .basket-grid { gap:8px; margin-block:8px; }
}
@media (min-width:1000px) and (max-width:1100px) and (max-height:900px) and (orientation:landscape) {
  .in-game .page { padding-inline:8px; }
  .in-game .play { padding-inline:8px; }
  .in-game .basket-grid { gap:6px; }
  .in-game .basket-card { padding:4px; }
  .in-game .basket-choices { gap:2px; }
}
@media (min-width:1000px) and (max-height:760px) and (orientation:landscape) {
  .in-game .question-heading { margin-bottom:6px; }
  .in-game .apple-tray { padding-block:6px; }
  .in-game .tray-count { min-height:62px; }
  .in-game .apple-pile .apple-piece { width:15px; height:17px; }
  .in-game .basket-grid { margin-block:4px; }
  .in-game .basket-scene { width:76px; height:54px; }
  .in-game .basket-apples { bottom:21px; width:58px; }
  .in-game .basket-apples .apple-piece { width:9px; height:10px; }
}

.duration-setting { display:flex; align-items:center; flex-wrap:wrap; gap:12px; color:#fff; font-weight:800; }
.duration-choices { display:flex; flex-wrap:wrap; gap:8px; }
.duration-choice { width:48px; min-height:48px; border:2px solid #9ca2ec; border-radius:999px; background:#f0f1ff; color:#3039a1; font-size:17px; font-weight:900; }
.duration-choice[aria-pressed="true"] { border-color:#c9ceff; background:#bfc5ff; color:#202963; }
.duration-actions { display:flex; flex:1; align-items:center; gap:12px; }
.duration-actions #start { margin-left:auto; }
.duration-unit { white-space:nowrap; }
@media (max-width:540px) {
  .factor-choices { margin-bottom:32px; }
  .duration-setting { gap:8px; }
  #duration-label { flex-basis:100%; }
  .duration-choices { gap:5px; }
  .duration-actions { width:100%; justify-content:space-between; margin-left:0; }
}
@media (max-width:360px) {
  .duration-choices { gap:5px; }
}

/* Separate the sharing tray from the basket controls at every viewport size. */
.in-game .basket-grid { margin-top:32px; }
.feedback-row { justify-content:flex-end; }
.clear-button { margin-left:auto; }

/* A vertical apple tray beside the basket board, with room for touch controls. */
@media (min-width:700px) {
  .in-game .play {
    display:grid;
    grid-template-columns:clamp(130px,16vw,180px) minmax(0,1fr);
    column-gap:16px;
    row-gap:40px;
    align-items:start;
  }
  .in-game .question-heading { grid-column:1 / -1; margin-bottom:0; }
  .in-game .apple-tray {
    grid-column:1;
    grid-row:3;
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:20px;
    align-self:stretch;
    padding:18px 12px;
  }
  .in-game .tray-count { min-height:0; gap:8px; }
  .in-game .apple-pile { justify-content:center; }
  .in-game .basket-grid {
    grid-column:2;
    grid-row:3;
    grid-template-columns:repeat(auto-fit,minmax(196px,204px));
    justify-content:center;
    gap:16px 12px;
    margin:0;
  }
  .in-game .basket-card { max-width:none; }
  .in-game .feedback-row { grid-column:2; }
}

@media (max-width:699px) {
  .in-game .question-heading { margin-bottom:36px; }
}

/* Equation sizing. */
.in-game .equation-card { margin-left:auto; padding:10px 16px; }
.in-game .equation { font-size:clamp(30px,3vw,36px); }
@media (min-width:700px) {
  .in-game .basket-grid { justify-content:start; }
}



.round-hud { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:24px; color:#fff; }
.timer-badge { display:flex; align-items:center; gap:18px; padding:14px 20px; border-radius:20px; background:#30314f; }
.timer-badge span { color:#d9daec; text-transform:uppercase; letter-spacing:.1em; font-size:14px; font-weight:900; }
.timer-badge strong,.round-score strong { font-size:36px; line-height:1; font-variant-numeric:tabular-nums; }
.round-score { display:flex; align-items:center; gap:18px; font-weight:800; }
@media (min-width:700px) {
  .in-game .round-hud { grid-column:1 / -1; grid-row:1; margin-bottom:0; }
  .in-game .question-heading { grid-row:2; }
}
@media (max-width:540px) {
  .round-hud { gap:12px; }
  .timer-badge { gap:10px; padding:12px; }
  .timer-badge span { font-size:12px; }
  .timer-badge strong,.round-score strong { font-size:28px; }
  .round-score { gap:8px; font-size:14px; }
}

/* Center the equation independently of the widths of the two counters. */
.round-hud { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); }
.timer-badge { justify-self:start; }
.round-score { justify-self:end; }
.in-game .round-hud .equation-card { margin:0; }
@media (max-width:899px) {
  .round-hud { grid-template-columns:1fr 1fr; }
  .round-hud .timer-badge { grid-column:1; grid-row:1; }
  .round-hud .round-score { grid-column:2; grid-row:1; }
  .round-hud .equation-card { grid-column:1 / -1; grid-row:2; justify-self:center; }
}

.round-score { padding:14px 20px; border-radius:20px; background:#30314f; }
@media (max-width:540px) {
  .round-score { padding:12px; }
}

/* Give the game contents breathing room inside the panel border. */
.in-game .play { padding:28px; }
@media (max-width:540px) {
  .in-game .play { padding:20px 16px; }
}
