:root { --app-accent: #27aa91; --app-accent-soft: #e8f9f5; --prime: var(--app-accent); --prime-soft: var(--app-accent-soft); }
body.modal-open { overflow: hidden; }
.prime-frame { min-height: 100vh; }
.prime-brand-mark { background: var(--mint); }
.prime-header-status { display: grid; justify-items: end; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 800; }
.prime-header-status strong { color: var(--prime); font-size: 14px; letter-spacing: .08em; }
.prime-screen { padding: clamp(24px, 5vw, 52px); }
.prime-screen[hidden] { display: none; }
.prime-hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 36px; align-items: center; }
.prime-hero h1, .result-screen h1 { margin: 0; font-size: clamp(44px, 8vw, 76px); line-height: .98; letter-spacing: -.04em; }
.prime-hero h1 em { color: var(--prime); font-style: normal; }
.hero-copy { max-width: 480px; margin: 20px 0 0; color: var(--muted); line-height: 1.85; }
.factor-doodle { position: relative; display: flex; align-items: center; justify-content: center; min-height: 190px; transform: rotate(-2deg); }
.prime-mini-doodle { position: absolute; top: -45px; right: -8px; transform: rotate(5deg); }
.factor-doodle span { display: grid; place-items: center; width: 74px; height: 82px; border: 3px solid var(--ink); border-radius: 17px 14px 19px 15px; background: var(--paper); box-shadow: 4px 5px 0 var(--ink); font-size: 31px; font-weight: 900; }
.factor-doodle span:nth-of-type(2) { background: var(--mint-soft); }
.factor-doodle span:nth-of-type(3) { background: var(--yellow-soft); }
.factor-doodle i { margin: 0 -3px; padding: 6px 8px; color: var(--coral); font-size: 18px; font-style: normal; font-weight: 900; transform: translateY(-50px) rotate(4deg); }
.level-sheet { margin-top: 36px; padding: 20px; border: 2px solid var(--ink); border-radius: 19px 16px 22px 17px; background: #fff; box-shadow: 3px 4px 0 var(--ink); }
.level-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.level-option { display: grid; gap: 4px; min-height: 76px; padding: 12px; border: 2px solid #cbd3df; border-radius: 14px; background: #fff; color: var(--ink); cursor: pointer; }
.level-option strong { font-size: 15px; }
.level-option small { color: var(--muted); font-weight: 700; }
.level-option small b { margin-left: 4px; color: var(--prime); font-weight: 900; white-space: nowrap; }
.level-option[aria-checked="true"] { border-color: var(--ink); background: var(--prime-soft); box-shadow: 2px 3px 0 var(--ink); transform: translateY(-2px); }
.level-option:focus-visible, .mode-button:focus-visible, .prime-button:focus-visible, .quiet-button:focus-visible, .resume-button:focus-visible { outline: 5px solid rgba(75,136,229,.3); outline-offset: 3px; }
.mode-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 22px; }
.mode-button { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; min-height: 86px; padding: 15px 18px; border: 2px solid var(--ink); border-radius: 16px 14px 18px 15px; color: var(--ink); cursor: pointer; text-align: left; box-shadow: 3px 4px 0 var(--ink); }
.mode-button:hover { transform: translateY(-2px); box-shadow: 4px 6px 0 var(--ink); }
.single-mode { background: var(--yellow-soft); }
.ten-mode { background: var(--prime-soft); }
.mode-icon { display: grid; place-items: center; width: 47px; height: 47px; border: 2px solid var(--ink); border-radius: 50%; background: white; font-size: 17px; font-weight: 900; }
.mode-button strong { display: block; font-size: 16px; }
.mode-button small { display: block; margin-top: 4px; color: var(--muted); font-weight: 700; }
.mode-button b { font-size: 22px; }
.resume-button { grid-column: 1 / -1; padding: 13px; border: 1px dashed var(--prime); border-radius: 12px; background: white; color: #167c68; cursor: pointer; font-weight: 900; }
.lifetime-summary { margin: 20px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.prime-game-heading { align-items: start; }
.prime-game-heading h1 { margin: 0; font-size: clamp(28px, 5vw, 46px); }
.prime-game-heading h1 em { color: var(--prime); font-style: normal; }
.quiet-button { min-height: 44px; padding: 9px 15px; border: 1px solid #cbd3df; border-radius: 11px; background: white; color: var(--ink); cursor: pointer; font-weight: 900; white-space: nowrap; }
.prime-message { margin: 22px 0; }
.number-stage { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; max-width: 500px; margin: 24px auto 30px; }
.number-card-panel { display: grid; place-items: center; min-height: 128px; border: 3px solid var(--ink); border-radius: 20px 16px 23px 17px; box-shadow: 5px 6px 0 var(--ink); }
.number-card-panel small { align-self: end; color: var(--muted); font-size: 11px; font-weight: 900; }
.number-card-panel strong { align-self: start; font-size: clamp(43px, 8vw, 66px); line-height: 1; }
.original-panel { background: var(--yellow-soft); }
.current-panel { background: var(--prime-soft); }
.current-panel.changed strong { animation: prime-pop .25s ease; }
.stage-arrow { color: var(--coral); font-size: 28px; font-weight: 900; }
.prime-pad, .factor-strip { margin-top: 20px; }
.prime-buttons { display: grid; grid-template-columns: repeat(6, minmax(54px, 1fr)); gap: 11px; }
.prime-button { min-height: 66px; border: 2px solid var(--ink); border-radius: 15px 12px 17px 13px; background: var(--card-color); color: var(--ink); cursor: pointer; font-size: 25px; font-weight: 900; box-shadow: 3px 4px 0 var(--ink); }
.prime-button:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 4px 7px 0 var(--ink); }
.prime-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 1px 2px 0 var(--ink); }
.prime-button:disabled { cursor: default; opacity: .48; }
.factor-strip { padding: 16px; border: 1px dashed #aeb9c8; border-radius: 15px; background: rgba(255,255,255,.62); }
.factor-expression { min-height: 30px; margin: 6px 0 0; color: var(--prime); font-size: clamp(17px, 4vw, 24px); font-weight: 900; text-align: center; }
.prime-history { margin-top: 20px; }
.division-history { display: grid; gap: 7px; margin: 12px 0 0; padding: 0; list-style-position: inside; }
.division-history li:not(.history-empty) { padding: 9px 12px; border-radius: 10px; background: #f7f9fc; font-size: 14px; font-weight: 800; }
.prime-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.hint-button small { margin-left: 4px; opacity: .65; }
.prime-success-card { padding-top: 48px; }
.prime-success-card .success-stamp { background: var(--prime); }
.prime-success-actions { grid-template-columns: 1fr; }
.prime-success-card .next-button { min-height: 52px; padding: 11px 22px; border-radius: 12px; cursor: pointer; font-weight: 900; }
.result-screen { text-align: center; }
.result-screen h1 { font-size: clamp(40px, 7vw, 66px); }
.result-comment { color: var(--muted); font-size: 16px; font-weight: 800; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.result-stats div { display: grid; padding: 18px 10px; border: 2px solid var(--ink); border-radius: 15px; background: white; box-shadow: 3px 4px 0 var(--ink); }
.result-stats div:nth-child(1) { background: var(--prime-soft); }
.result-stats div:nth-child(2) { background: var(--yellow-soft); }
.result-stats div:nth-child(3) { background: var(--coral-soft); }
.result-stats strong { font-size: 34px; }
.result-stats small { color: var(--muted); font-weight: 900; }
.result-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; text-align: left; }
.result-list li { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.result-list .result-number { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--prime-soft); font-weight: 900; }
.result-list strong { font-size: 14px; }
.result-list small { color: var(--muted); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.compact-mode { display: block; min-height: 54px; background: var(--yellow); text-align: center; font-weight: 900; }
.large-quiet { min-height: 54px; }
@keyframes prime-pop { 50% { transform: scale(1.13) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
@media (min-width: 721px) and (max-height: 980px) {
  .prime-frame { min-height: calc(100dvh - 20px); }
  .prime-screen { padding: 18px 28px; }
  .prime-hero { gap: 24px; }
  .prime-hero h1 { font-size: clamp(38px, 5.2vw, 56px); line-height: 1; }
  .hero-copy { margin-top: 12px; line-height: 1.65; }
  .factor-doodle { min-height: 140px; }
  .prime-mini-doodle { width: 86px; top: -26px; }
  .factor-doodle span {
    width: 58px;
    height: 64px;
    font-size: 25px;
  }
  .level-sheet {
    margin-top: 18px;
    padding: 14px;
  }
  .level-option {
    min-height: 62px;
    padding: 9px 11px;
  }
  .mode-actions {
    gap: 12px;
    margin-top: 14px;
  }
  .mode-button {
    min-height: 70px;
    padding: 11px 14px;
  }
  .mode-icon {
    width: 40px;
    height: 40px;
  }
  .lifetime-summary { margin-top: 12px; }
}
@media (max-width: 680px) {
  .prime-screen { padding: 12px 12px 18px; }
  .prime-hero { display: block; }
  .prime-hero h1 { font-size: clamp(26px, 7vw, 34px); line-height: 1.08; }
  .prime-hero h1 br { display: none; }
  .hero-copy { margin-top: 7px; font-size: 12px; line-height: 1.55; }
  .factor-doodle { display: none; }
  .level-sheet { margin-top: 12px; padding: 12px; }
  .level-options { grid-template-columns: 1fr; }
  .level-option { grid-template-columns: 1fr auto; align-items: center; min-height: 48px; padding: 9px 11px; }
  .mode-actions { grid-template-columns: 1fr; }
  .mode-button { min-height: 60px; padding: 10px 12px; }
  .mode-icon { width: 38px; height: 38px; }
  .mode-button small { display: none; }
  .prime-buttons { grid-template-columns: repeat(3, 1fr); }
  .number-stage { gap: 10px; }
  .number-card-panel { min-height: 105px; }
  .prime-header-status { display: none; }
  .result-actions { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .prime-screen { padding-inline: 13px; }
  .number-stage { grid-template-columns: 1fr 24px 1fr; }
  .stage-arrow { font-size: 21px; }
}
