:root {
  color-scheme: light;
  --paper: #fffdf8;
  --ink: #20324d;
  --muted: #6e7890;
  --line: #dbe1ea;
  --coral: #ff765f;
  --coral-soft: #fff0ec;
  --mint: #48c9b0;
  --mint-soft: #e8f9f5;
  --yellow: #ffc94f;
  --yellow-soft: #fff7d9;
  --purple: #a98be8;
  --blue: #4b88e5;
  --shadow: 0 24px 70px rgba(39, 55, 86, 0.16);
  --panel-radius: 20px;
  --control-radius: 14px;
  --offset-shadow: 3px 4px 0 var(--ink);
  --tap-target: 48px;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #edf2f7; }

body {
  min-height: 100dvh;
  margin: 0;
  padding: clamp(12px, 3vw, 34px);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 201, 79, .18), transparent 25%),
    radial-gradient(circle at 88% 82%, rgba(72, 201, 176, .14), transparent 26%),
    #edf2f7;
  -webkit-tap-highlight-color: transparent;
}

button, a { font: inherit; }
button, a, [role="button"] { touch-action: manipulation; }
button { color: inherit; }

.app-frame {
  position: relative;
  isolation: isolate;
  width: min(1120px, calc(100vw - 56px));
  min-height: calc(100dvh - clamp(24px, 6vw, 68px));
  margin: 0 auto;
}

.notebook {
  position: relative;
  z-index: 1;
  min-height: inherit;
  overflow: hidden;
  border: 1px solid #d8dee8;
  border-radius: 26px;
  background:
    linear-gradient(90deg, transparent 74px, rgba(255, 118, 95, .16) 75px, transparent 76px),
    repeating-linear-gradient(0deg, rgba(70, 106, 151, .045) 0, rgba(70, 106, 151, .045) 1px, transparent 1px, transparent 30px),
    var(--paper);
  box-shadow: var(--shadow);
  padding: 24px clamp(24px, 5vw, 72px) 30px 96px;
}

.notebook::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 56px;
  background: linear-gradient(90deg, #e7ebf0, #f5f7fa 48%, #d5dbe4 50%, transparent 52%);
  border-right: 1px solid #d7dde7;
}

.binder-rings {
  position: absolute;
  z-index: 5;
  top: 12%; bottom: 12%; left: -18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.binder-rings span {
  width: 82px;
  height: 18px;
  border: 5px solid #8895a8;
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(#f9fbfd 0 35%, #b7c0cb 36% 60%, #f7f9fb 61%);
  box-shadow: 0 3px 4px rgba(44, 56, 76, .25);
}

.app-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 19px;
  border-bottom: 2px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: clamp(190px, 25vw, 270px);
  height: auto;
}

.brand-logo.compact {
  width: clamp(176px, 23vw, 248px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  border: 3px solid var(--ink);
  border-radius: 16px 11px 15px 12px;
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 24px;
  font-weight: 900;
  transform: rotate(-2deg);
}

.brand strong { display: block; font-size: 21px; letter-spacing: .06em; }
.brand small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; }

.daily-progress {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 4px 12px;
  text-align: right;
}

.daily-progress > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.daily-progress strong { grid-row: 1 / 3; grid-column: 2; font-size: 20px; }
.progress-dots { display: flex; gap: 5px; justify-content: flex-end; }
.progress-dots i { width: 22px; height: 7px; border-radius: 9px; background: #e1e5ec; }
.progress-dots i.filled { background: var(--coral); }

.game-card {
  width: min(760px, 100%);
  margin: 22px auto 18px;
  padding: clamp(17px, 2.5vw, 25px);
  border: 1px solid #dfe4ec;
  border-radius: 22px 18px 24px 19px;
  background: rgba(255, 255, 255, .93);
  box-shadow: 0 12px 30px rgba(36, 54, 84, .08);
}

.game-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--coral); font-size: 11px; font-weight: 900; letter-spacing: .14em; }

.series-doodle {
  width: clamp(86px, 10vw, 122px);
  height: auto;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(4px 5px 0 rgba(32, 50, 77, .14));
}
.series-doodle .doodle-ink {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.series-doodle .doodle-paper { fill: var(--paper); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.series-doodle .doodle-coral { fill: var(--coral); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.series-doodle .doodle-mint { fill: var(--mint); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.series-doodle .doodle-yellow { fill: var(--yellow); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.series-doodle .doodle-purple { fill: var(--purple); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
h1 { margin: 0; font-size: clamp(23px, 4vw, 34px); letter-spacing: .02em; }
h1 em { color: var(--coral); font-size: 1.18em; font-style: normal; }

.target-card {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 92px; height: 84px;
  border: 3px solid var(--ink);
  border-radius: 18px 14px 20px 15px;
  background: var(--coral);
  color: white;
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(1.5deg);
}
.target-card span { margin-bottom: -8px; font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.target-card strong { font-size: 42px; line-height: 1; }

.guide-line { display: flex; align-items: center; gap: 10px; margin: 18px 0 9px; }
.guide-line.compact { margin: 14px 0 8px; }
.guide-line p { margin: 0; font-size: 14px; font-weight: 800; }
.step-number {
  display: grid; place-items: center;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: var(--ink); color: white;
  font-size: 12px; font-weight: 900;
}

.tray-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 8px; }
.tray-heading span { color: var(--ink); font-size: 12px; font-weight: 900; }
.tray-heading small { color: var(--muted); font-size: 10px; }
.number-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(9px, 2vw, 16px); }
.number-card {
  position: relative;
  min-height: clamp(74px, 10vw, 96px);
  border: 2px solid var(--ink);
  border-radius: 16px 13px 18px 14px;
  background: var(--card-color, var(--coral-soft));
  box-shadow: 3px 4px 0 var(--ink);
  cursor: pointer;
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 900;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.number-card:nth-child(4n+1) { --card-color: #ffd8d0; }
.number-card:nth-child(4n+2) { --card-color: #c8f2e8; }
.number-card:nth-child(4n+3) { --card-color: #fff0ad; }
.number-card:nth-child(4n+4) { --card-color: #ddd2f7; }
.number-card:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: 4px 7px 0 var(--ink); }
.number-card:active { transform: translateY(2px); box-shadow: 1px 2px 0 var(--ink); }
.number-card.selected { transform: translateY(-7px); outline: 5px solid rgba(75, 136, 229, .22); box-shadow: 4px 9px 0 var(--blue); }
.number-card.used {
  opacity: .42;
  cursor: default;
  filter: none;
  box-shadow: 1px 2px 0 #8b96a8;
}
.number-card.used::after {
  content: "使用ずみ";
  position: absolute;
  inset: 50% auto auto 50%;
  padding: 3px 7px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: var(--ink);
  font-size: 9px;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-5deg);
}
.number-card.used:hover { transform: none; box-shadow: 1px 2px 0 #8b96a8; }

.math-doodles { flex: 0 0 auto; width: 154px; height: 76px; transform: rotate(1deg); }
.math-doodles svg { display: block; width: 100%; height: 100%; overflow: visible; }
.math-doodles path { stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.5; }
.doodle-mint { fill: #9ee3d4; }
.doodle-paper { fill: var(--paper); }
.doodle-pencil { fill: var(--yellow); stroke: var(--ink); stroke-width: 2.5; }
.doodle-pencil path { stroke: var(--ink); }
.doodle-pencil .pencil-tip { fill: #ffd8c9; }
.doodle-pencil .pencil-line { fill: none; }
.doodle-star { fill: #ff8f79; }
.doodle-spark { fill: none; stroke: var(--blue) !important; }
.number-card .pick-order {
  position: absolute; top: -9px; right: -8px;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border: 2px solid white; border-radius: 50%;
  background: var(--blue); color: white;
  font-size: 13px;
}
.number-card .mini-expression { position: absolute; inset: auto 4px 7px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.result-bank {
  margin-top: 12px;
  padding: 10px 12px 12px;
  border: 2px solid #9bdccb;
  border-radius: 14px;
  background: var(--mint-soft);
}
.result-bank .tray-heading { margin-bottom: 7px; }
.result-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-height: 50px; }
.result-cards .number-card { min-height: 55px; background: var(--card-color); font-size: 29px; box-shadow: 2px 3px 0 var(--ink); }
.result-cards .number-card.selected { transform: translateY(-4px); box-shadow: 3px 6px 0 var(--blue); }
.result-empty { display: grid; place-items: center; min-height: 50px; border: 1px dashed #83cdbc; border-radius: 10px; color: #578b80; font-size: 11px; font-weight: 700; }

.workbench {
  position: relative;
  margin-top: 16px;
  padding: 16px 20px 17px;
  border: 2px dashed #bac4d3;
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(75, 136, 229, .045) 1px, transparent 1px),
    linear-gradient(rgba(75, 136, 229, .045) 1px, transparent 1px), #fbfcfe;
  background-size: 18px 18px;
}
.binder-clip { position: absolute; top: -10px; left: 50%; width: 55px; height: 18px; border: 3px solid #9099a8; border-radius: 5px; background: #e9edf2; transform: translateX(-50%); }
.workbench-label { margin: 0 0 13px; color: var(--muted); font-size: 11px; font-weight: 900; text-align: center; }
.equation-preview { display: flex; align-items: center; justify-content: center; gap: clamp(7px, 2vw, 15px); }
.equation-slot {
  display: grid; place-items: center;
  width: clamp(54px, 11vw, 82px); height: clamp(54px, 9vw, 70px);
  border: 2px solid #aeb9ca; border-radius: 12px;
  background: white; color: var(--ink);
  font-size: 28px; font-weight: 900;
}
.equation-slot span { color: #a7b0bf; font-size: 15px; }
.equation-slot.filled { border-color: var(--blue); background: #edf4ff; }
.result-slot { border-style: dashed; }
.operator-slot { width: 30px; color: var(--coral); font-size: 25px; font-weight: 900; text-align: center; }
.arrow { color: var(--muted); font-size: 23px; }

.operators { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.operator {
  min-height: 58px;
  border: 2px solid var(--ink); border-radius: 13px 11px 14px 12px;
  box-shadow: 2px 3px 0 var(--ink);
  cursor: pointer;
  font-size: 30px; font-weight: 900;
  transition: transform .12s ease, opacity .12s ease;
}
.operator.add { background: #ff9b88; }
.operator.subtract { background: #7bdbc8; }
.operator.multiply { background: #ffd56f; }
.operator.divide { background: #c3afea; }
.operator:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(.3); }
.operator:not(:disabled):hover { transform: translateY(-2px); }
.operator:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.operator.active { outline: 5px solid rgba(75, 136, 229, .24); transform: translateY(-3px); box-shadow: 3px 6px 0 var(--blue); }

.message-box {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; margin-top: 14px; padding: 9px 12px;
  border-radius: 13px; background: var(--yellow-soft);
}
.message-box.success { background: var(--mint-soft); }
.message-box.error { background: var(--coral-soft); }
.message-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: white; font-size: 20px; }
.message-box p { margin: 0; }
.message-box strong, .message-box small { display: block; }
.message-box strong { font-size: 14px; }
.message-box small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.message-box + .tray-heading { margin-top: 16px; }
.operator-area { margin-top: 10px; }

.hint-history-panel {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #efce73;
  border-radius: 13px;
  background: #fffaf0;
}
.hint-history-panel[hidden] { display: none; }
.hint-history-panel h2 { margin: 0 0 7px; color: #725913; font-size: 11px; }
.hint-history-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hint-history-list li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline; color: var(--ink); font-size: 11px; line-height: 1.5; }
.hint-history-list strong { color: #9b7412; white-space: nowrap; }

.calculation-history {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #dfe4ec;
  border-radius: 13px;
  background: #fbfcfe;
}
.history-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.history-heading h2 { margin: 0; font-size: 12px; }
.history-heading small { color: var(--muted); font-size: 9px; }
.history-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 31px; margin: 8px 0 0; padding: 0; list-style: none; }
.history-list li { padding: 6px 10px; border-radius: 9px; background: white; box-shadow: inset 0 0 0 1px #d8dee8; font-size: 12px; font-weight: 900; }
.history-empty { color: var(--muted); font-size: 10px; font-weight: 500; }
.history-summary {
  flex-basis: 100%;
  border: 2px solid #8bd5c4 !important;
  background: var(--mint-soft) !important;
  color: var(--ink);
  font-size: 13px !important;
}

.game-actions { display: grid; grid-template-columns: 1fr 1fr 1.05fr; align-items: stretch; gap: 10px; margin-top: 14px; }
.action-button, .hint-button, .next-button, .retry-button {
  min-height: 44px; border-radius: 12px; cursor: pointer; font-weight: 900;
}
.action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 54px;
  border: 2px solid var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
  font-size: 13px;
}
.action-button:active, .hint-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.action-button:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(.3); }
.undo-action { background: #e7f0ff; }
.reset-action { background: var(--coral-soft); }
.action-icon { font-size: 21px; line-height: 1; }
.hint-button { padding: 0 18px; border: 2px solid var(--ink); background: var(--yellow); box-shadow: 2px 3px 0 var(--ink); }

.puzzle-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #cfd6e1;
}
.puzzle-nav-button {
  min-height: 48px;
  border: 1px solid #c8d0dc;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}
.puzzle-nav-button:hover { border-color: var(--ink); background: #f7f9fc; }
.puzzle-nav-button:disabled { opacity: .35; cursor: not-allowed; }
.next-puzzle-button { border: 2px solid var(--ink); background: #edf4ff; }
.give-up-label { color: var(--muted); font-size: 10px; font-weight: 700; }
.give-up-label[hidden] { display: none; }

.note-footer {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 24px;
  width: min(760px, 100%); margin: 0 auto;
}
.note-footer > div { display: flex; align-items: center; gap: 10px; }
.footer-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: white; font-weight: 900; }
.footer-icon.coral { background: var(--coral); }
.footer-icon.mint { background: var(--mint); }
.note-footer p { margin: 0; }
.note-footer small, .note-footer strong { display: block; }
.note-footer small { color: var(--muted); font-size: 10px; }
.note-footer strong { font-size: 15px; }
.footer-tip { justify-self: end; color: var(--muted); font-size: 11px; line-height: 1.6; text-align: right; }

.binder-tabs { position: absolute; z-index: 0; top: 120px; right: -48px; display: grid; gap: 7px; }
.tab {
  width: 78px; height: 70px; padding-left: 30px;
  border: 1px solid rgba(32, 50, 77, .16); border-radius: 0 14px 14px 0;
  cursor: pointer; color: var(--ink); font-size: 12px; font-weight: 900;
  writing-mode: vertical-rl;
}
.tab.coral { background: #ff9c89; }
.tab.mint { background: #82dfcd; }
.tab.yellow { background: #ffdc79; }
.tab.purple { background: #c9b8ef; }
.tab.active { transform: translateX(7px); }

.success-overlay {
  position: fixed; z-index: 20; inset: 0;
  display: grid; place-items: center; padding: 24px;
  background: rgba(24, 37, 57, .52); backdrop-filter: blur(5px);
}
.success-overlay[hidden] { display: none; }
.success-card {
  position: relative; width: min(420px, 100%); padding: 44px 32px 30px;
  border: 3px solid var(--ink); border-radius: 24px 19px 25px 20px;
  background: var(--paper); box-shadow: 8px 9px 0 var(--ink); text-align: center;
  animation: pop .3s ease-out;
}
.close-success-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #cfd6e1;
  border-radius: 50%;
  background: white;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  font-weight: 700;
}
.close-success-button:hover { background: #f2f5f8; color: var(--ink); }
.success-stamp {
  position: absolute; top: -42px; left: 50%; display: grid; place-items: center;
  width: 84px; height: 84px; border: 4px solid white; border-radius: 50%;
  background: var(--coral); color: white; box-shadow: 0 5px 0 var(--ink);
  font-size: 28px; font-weight: 900; transform: translateX(-50%) rotate(-7deg);
}
.success-card h2 { margin: 4px 0 10px; font-size: 34px; }
.success-expression { margin: 0; padding: 15px; border-radius: 12px; background: var(--mint-soft); font-size: 18px; font-weight: 900; }
.success-comment { color: var(--muted); font-size: 13px; }
.success-actions { display: grid; grid-template-columns: 1fr 1.15fr; gap: 10px; }
.next-button { border: 2px solid var(--ink); background: var(--yellow); box-shadow: 3px 4px 0 var(--ink); }
.retry-button { border: 1px solid #c9d1dc; background: white; color: var(--ink); }

@keyframes pop { from { opacity: 0; transform: scale(.84) rotate(-2deg); } to { opacity: 1; transform: scale(1); } }

button:focus-visible, a:focus-visible { outline: 4px solid rgba(75, 136, 229, .28); outline-offset: 3px; }

@media (max-width: 720px) {
  body { padding: 0; background: var(--paper); }
  .app-frame { width: 100%; min-height: 100dvh; }
  .notebook { border: 0; border-radius: 0; box-shadow: none; padding: 12px 14px 22px 24px; background-position-x: -44px, 0, 0; }
  .notebook::before, .binder-rings { display: none; }
  .binder-tabs { display: none; }
  .app-header { align-items: center; gap: 10px; padding-bottom: 8px; }
  .brand-logo { width: min(172px, 48vw); }
  .brand-logo.compact { width: min(154px, 43vw); }
  .brand-mark { width: 42px; height: 42px; font-size: 20px; }
  .brand strong { font-size: 17px; }
  .daily-progress > span { display: none; }
  .daily-progress { display: block; }
  .daily-progress strong { font-size: 13px; }
  .progress-dots { display: none; }
  .progress-dots i { width: 12px; }
  .game-card { margin-top: 8px; padding: 12px; }
  .game-heading { gap: 10px; }
  .eyebrow { margin-bottom: 3px; font-size: 10px; }
  .math-doodles { display: none; }
  .game-heading h1 { max-width: none; font-size: 20px; line-height: 1.18; }
  .message-box { min-height: 48px; margin-top: 9px; padding: 8px 10px; }
  .message-icon { width: 32px; height: 32px; font-size: 17px; }
  .tray-heading { margin-top: 10px; }
  .number-cards { gap: 8px; }
  .result-bank { margin-top: 10px; }
  .operator-area { margin-top: 8px; }
  .operator-grid { gap: 8px; }
  .history-panel,
  .calculation-history { margin-top: 10px; }
  .target-card { width: 72px; height: 68px; }
  .target-card strong { font-size: 33px; }
  .note-footer { grid-template-columns: 1fr 1fr; gap: 14px; }
  .footer-tip { display: none; }
  .math-doodles { width: 112px; height: 62px; }
}

@media (min-width: 721px) and (max-height: 980px) {
  body { padding: 10px 18px; }
  .app-frame {
    width: min(1120px, calc(100vw - 36px));
    min-height: calc(100dvh - 20px);
  }
  .notebook {
    padding: 12px clamp(18px, 4vw, 56px) 14px 82px;
  }
  .notebook::before { width: 48px; }
  .binder-rings { top: 10%; bottom: 10%; left: -16px; }
  .binder-rings span { width: 76px; height: 16px; border-width: 4px; }
  .app-header {
    gap: 16px;
    padding-bottom: 10px;
  }
  .brand-logo { width: clamp(158px, 16vw, 194px); }
  .brand-logo.compact { width: clamp(150px, 15vw, 184px); }
  .daily-progress > span { font-size: 10px; }
  .daily-progress strong { font-size: 18px; }
  .progress-dots i { width: 18px; height: 6px; }
  .game-card {
    width: min(820px, 100%);
    margin: 12px auto 6px;
    padding: 13px 20px;
  }
  .game-heading { gap: 14px; }
  .game-heading h1 { font-size: 27px; line-height: 1.12; }
  .eyebrow { margin-bottom: 3px; font-size: 10px; }
  .math-doodles { display: none; }
  .message-box {
    min-height: 40px;
    margin-top: 8px;
    padding: 6px 10px;
  }
  .message-icon { width: 30px; height: 30px; font-size: 16px; }
  .message-box strong { font-size: 13px; }
  .message-box small { font-size: 10px; }
  .message-box + .tray-heading { margin-top: 10px; }
  .tray-heading { margin: 7px 2px 5px; }
  .number-cards { gap: 10px; }
  .number-card {
    min-height: 68px;
    font-size: 38px;
    border-radius: 14px 12px 16px 13px;
  }
  .operator-area { margin-top: 7px; }
  .operators { gap: 10px; }
  .operator {
    min-height: 42px;
    font-size: 25px;
  }
  .result-bank {
    margin-top: 8px;
    padding: 7px 10px 8px;
  }
  .result-bank .tray-heading { margin-bottom: 5px; }
  .result-cards {
    gap: 8px;
    min-height: 38px;
  }
  .result-cards .number-card {
    min-height: 44px;
    font-size: 24px;
  }
  .result-empty {
    min-height: 34px;
    font-size: 10px;
  }
  .workbench {
    margin-top: 9px;
    padding: 10px 14px 11px;
  }
  .binder-clip { display: none; }
  .workbench-label {
    margin-bottom: 7px;
    font-size: 10px;
  }
  .equation-slot {
    width: 52px;
    height: 48px;
    font-size: 23px;
  }
  .operator-slot { width: 24px; font-size: 22px; }
  .arrow { font-size: 18px; }
  .calculation-history {
    margin-top: 8px;
    padding: 7px 10px;
  }
  .history-heading h2 { font-size: 11px; }
  .history-heading small { font-size: 8px; }
  .history-list {
    min-height: 22px;
    margin-top: 5px;
    gap: 5px;
  }
  .history-list li {
    padding: 4px 8px;
    font-size: 11px;
  }
  .game-actions {
    gap: 8px;
    margin-top: 9px;
  }
  .action-button {
    min-height: 42px;
    font-size: 12px;
  }
  .action-icon { font-size: 18px; }
  .hint-button {
    min-height: 42px;
    padding: 0 12px;
  }
  .puzzle-navigation {
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
  }
  .puzzle-nav-button {
    min-height: 40px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .notebook { padding-left: 14px; padding-right: 14px; }
  .game-card { padding: 10px; }
  .game-heading { align-items: flex-start; }
  h1 { max-width: 100%; font-size: 20px; }
  .math-doodles { width: 84px; height: 52px; }
  .target-card { width: 64px; height: 62px; }
  .message-box { min-height: 40px; margin-top: 7px; padding: 6px 8px; gap: 8px; }
  .message-icon { width: 28px; height: 28px; font-size: 15px; }
  .message-box strong { font-size: 12px; }
  .message-box small { margin-top: 1px; font-size: 10px; }
  .message-box + .tray-heading { margin-top: 9px; }
  .tray-heading { margin: 7px 2px 5px; }
  .tray-heading small { display: none; }
  .number-card { min-height: 66px; font-size: 27px; }
  .operator-area { margin-top: 6px; }
  .operator { min-height: 44px; font-size: 27px; }
  .result-bank { margin-top: 8px; padding: 7px 8px 8px; }
  .result-bank .tray-heading { margin-bottom: 5px; }
  .result-cards { gap: 7px; min-height: 38px; }
  .result-cards .number-card { min-height: 48px; }
  .result-empty { min-height: 34px; font-size: 10px; }
  .workbench { margin-top: 9px; padding: 11px 10px 12px; }
  .binder-clip { display: none; }
  .workbench-label { margin-bottom: 8px; font-size: 10px; }
  .equation-preview { gap: 5px; }
  .equation-slot { width: 49px; height: 52px; }
  .operator-slot { width: 22px; }
  .arrow { font-size: 18px; }
  .calculation-history { margin-top: 8px; padding: 7px 8px; }
  .history-heading small { display: none; }
  .history-list { min-height: 22px; margin-top: 5px; gap: 5px; }
  .history-list li { padding: 4px 7px; font-size: 11px; }
  .game-actions { grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 9px; }
  .action-button, .hint-button { min-height: 44px; padding-inline: 6px; font-size: 12px; }
  .action-icon { font-size: 17px; }
  .puzzle-navigation { gap: 7px; margin-top: 8px; padding-top: 8px; }
  .puzzle-nav-button { min-height: 42px; font-size: 12px; }
  .success-actions { grid-template-columns: 1fr; }
}

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