:root {
  color-scheme: light;
  --ink: #35665f;
  --muted: #6c8c84;
  --paper: #fffefa;
  --background: #f5fcf7;
  --line: #cbe4db;
  --grid-line: rgba(93, 169, 142, .12);
  --primary: #398d75;
  --primary-dark: #286f5c;
  --accent: #72c6a7;
  --correct: #2f8b69;
  --wrong: #b66b70;
  --shadow: 0 13px 34px rgba(61, 122, 103, .1);
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "ヒラギノ丸ゴ ProN W4", "Yu Gothic", YuGothic, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 22px 22px,
    radial-gradient(circle at 5% 0%, rgba(123, 209, 174, .15), transparent 30rem),
    var(--background);
  background-attachment: fixed;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: transparent; }
.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; }

.app-header {
  width: min(100%, 680px);
  min-height: 58px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 13px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand { color: var(--ink); font-size: 1.08rem; font-weight: 900; letter-spacing: -.03em; text-decoration: none; }
.media-controls, .quiz-actions { display: flex; align-items: center; gap: 5px; }
.media-controls { margin-left: auto; }
.media-toggle, .top-action, .home-button {
  min-width: 40px;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .85);
  color: var(--primary-dark);
  font-size: .7rem;
  font-weight: 850;
  cursor: pointer;
}
.media-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
.media-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.media-toggle svg path:first-child { fill: currentColor; stroke: none; }
.media-toggle[data-sound-level="off"] { color: var(--muted); background: rgba(255,255,255,.48); }
.sound-wave { display: none; }
.media-toggle[data-sound-level="medium"] .sound-wave-inner,
.media-toggle[data-sound-level="high"] .sound-wave { display: block; }
.top-action { min-width: 0; padding-inline: 9px; color: var(--ink); }
.top-action:disabled { opacity: .42; }
.home-button { display: grid; place-items: center; padding: 0; border: 1px solid var(--line); background: rgba(255,255,255,.85); color: var(--primary-dark); }
.home-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { width: min(100%, 680px); margin: 0 auto; padding: 7px 13px calc(16px + env(safe-area-inset-bottom)); }
.screen[hidden], [hidden] { display: none !important; }
.setup-form { display: grid; gap: 12px; margin-top: 4px; }
.choice-section { margin: 0; padding: 0; border: 0; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mode-grid-two .mode-card { min-height: 105px; }
.compound-options { padding: 11px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); }
.compound-options legend { padding: 0 4px; color: var(--primary-dark); font-size: .82rem; font-weight: 850; }
.compound-option-row { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 7px; }
.compound-option-row + .compound-option-row { margin-top: 7px; }
.compound-option-title { color: var(--muted); font-size: .76rem; font-weight: 800; }
.option-toggles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.answer-toggles { grid-template-columns: repeat(3, 1fr); }
.option-toggle { min-width: 0; min-height: 34px; padding: 0 4px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--muted); font-size: .77rem; font-weight: 800; }
.option-toggle.is-on { border-color: #a7d6c5; background: #dff5ea; color: var(--primary-dark); }
.compound-option-message { min-height: 1em; margin: 7px 0 0 45px; color: var(--wrong); font-size: .7rem; font-weight: 700; }
.mode-card {
  position: relative; min-height: 96px; padding: 11px 10px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.84);
  box-shadow: 0 7px 18px rgba(28,82,74,.045); cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card:has(input:checked) { border-color: var(--primary); background: rgba(226, 247, 238, .95); box-shadow: 0 8px 22px rgba(57,141,117,.14), inset 0 0 0 2px rgba(57,141,117,.08); transform: translateY(-1px); }
.mode-card:has(input:focus-visible) { outline: 3px solid rgba(57,141,117,.25); outline-offset: 2px; }
.mode-icon { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--primary-dark); font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; font-size: clamp(1.15rem, 5.3vw, 1.42rem); font-weight: 700; text-align: center; white-space: nowrap; }
.mode-formula { display: block; line-height: 1; }
.mode-label { display: block; font-family: inherit; font-size: .73em; letter-spacing: .07em; line-height: 1; }
.mode-icon.name-icon { font-family: inherit; font-size: 1rem; letter-spacing: .04em; }
.mode-icon sup, .mode-icon sub, .question-prompt sup, .question-prompt sub, .feedback-answer sup, .feedback-answer sub { font-size: .62em; line-height: 0; }
.mode-icon sub { position: relative; top: .32em; line-height: 1; vertical-align: baseline; }

.segment-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.72); }
.segment-control.two { grid-template-columns: repeat(2, 1fr); }
.segment-control.three { grid-template-columns: repeat(3, 1fr); }
.segment-control label { position: relative; cursor: pointer; }
.segment-control input { position: absolute; opacity: 0; }
.segment-control span { min-height: 41px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); font-size: .86rem; font-weight: 750; }
.segment-control input:checked + span { background: #ccefe0; color: var(--primary-dark); box-shadow: 0 4px 12px rgba(57,141,117,.13); }
.segment-control input:focus-visible + span { outline: 3px solid rgba(57,141,117,.25); }
.primary-button, .secondary-button, .text-button { min-height: 48px; border-radius: 13px; padding: 0 18px; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; background: var(--primary); color: white; box-shadow: 0 8px 18px rgba(8,124,109,.2); }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:disabled { opacity: .52; cursor: default; box-shadow: none; }
.secondary-button { border: 1px solid var(--primary); background: white; color: var(--primary); }
.text-button { border: 0; background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }
.start-actions { display: grid; grid-template-columns: minmax(0, 1fr) 50px; gap: 8px; }
.start-button { width: 100%; font-size: 1rem; }
.weak-review-button {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 48px; padding: 0;
  border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.9); color: var(--primary-dark);
  box-shadow: 0 6px 14px rgba(57,141,117,.09); cursor: pointer;
}
.weak-review-button svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.weak-review-button:active { transform: translateY(1px); }
.weak-review-button:focus-visible, .modal-close:focus-visible { outline: 3px solid rgba(57,141,117,.25); outline-offset: 2px; }
.weak-review-count {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center;
  border: 2px solid var(--background); border-radius: 999px; background: #e79077; color: white; font-size: .61rem; font-weight: 900;
}
.question-card {
  position: relative; min-height: 134px; padding: 25px 18px 16px;
  display: flex; flex-direction: column; justify-content: center;
  border: 1px solid rgba(217,232,227,.9); border-radius: 21px; background: rgba(255,255,255,.9);
  box-shadow: var(--shadow); text-align: center; overflow: hidden;
}
.question-number { position: absolute; top: 10px; right: 13px; color: var(--muted); font-size: .76rem; font-weight: 800; }
.question-prompt { font-size: clamp(1.55rem, 8.5vw, 2.6rem); font-weight: 800; line-height: 1.32; overflow-wrap: anywhere; }
.question-prompt.formula { font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; letter-spacing: .02em; }
.ion-pair { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 3vw, 16px); white-space: nowrap; }
.ion-pair.names { width: max-content; max-width: 100%; margin-inline: auto; font-family: inherit; font-size: clamp(1.12rem, 5.4vw, 1.55rem); line-height: 1.45; }
.ion-pair.names.is-two-lines { display: grid; width: 100%; gap: 2px; white-space: normal; }
.ion-pair-first, .ion-pair-second { display: block; }
.ion-separator { margin-left: .32em; color: var(--muted); font-family: inherit; font-size: .72em; font-weight: 700; }
.formula-token { font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; letter-spacing: .02em; }
.ion-formula-name { display: inline-flex; align-items: baseline; gap: .28em; white-space: nowrap; }
.ion-formula-name .ion-name { color: var(--primary-dark); font-size: .76em; }
.streak { position: absolute; right: 13px; bottom: 8px; min-height: 1em; margin: 0; color: #bd741a; font-size: .69rem; font-weight: 800; }

.answer-area { position: relative; margin-top: 11px; }
.both-answer-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 0 3px 6px; }
.both-answer-tabs button { min-height: 32px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--muted); font-size: .77rem; font-weight: 800; }
.both-answer-tabs button.is-active { border-color: #9ad2bd; background: #e7f8ef; color: var(--primary-dark); }
.both-answer-tabs button.is-complete { background: #f1fbf5; color: var(--primary); }
.both-answer-tabs button:disabled { opacity: 1; }
.answer-composer { position: relative; --answer-submit-space: 90px; }
#answer-input {
  width: 100%; height: 57px; padding: 0 var(--answer-submit-space) 0 14px; border: 2px solid var(--line); border-radius: 15px;
  background: var(--paper); color: var(--ink); font-size: clamp(1.28rem, 5.3vw, 1.52rem); font-weight: 700; outline: none;
  text-align: center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#answer-input::placeholder { color: #a5b2af; font-weight: 650; }
#answer-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(57,141,117,.1); }
#answer-input[aria-invalid="true"] { border-color: var(--wrong); }
.answer-composer.formula-mode #answer-input { color: transparent; caret-color: transparent; }
.formula-render { position: absolute; inset: 0 var(--answer-submit-space) 0 14px; display: flex; align-items: center; justify-content: center; gap: 0; overflow: hidden; color: var(--ink); font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; font-size: clamp(1.5rem, 6.7vw, 1.75rem); font-weight: 750; pointer-events: none; white-space: nowrap; }
.formula-render sub, .formula-render sup { position: relative; font-size: .62em; line-height: 1; vertical-align: baseline; }
.formula-render sub { top: .34em; }
.formula-render sup { top: -.52em; }
.formula-render .formula-charge { position: relative; top: -.58em; display: inline-flex; align-items: flex-start; margin-left: 2px; padding: 1px 3px 2px; border-radius: 5px; background: #d8f2ed; color: #197b6d; font-family: inherit; font-size: .68em; font-weight: 900; line-height: 1; vertical-align: baseline; }
.formula-render .formula-caret { width: 1.5px; height: 1.1em; margin: 0 1px; border-radius: 1px; background: var(--primary-dark); animation: formula-caret .9s steps(1) infinite; }
@keyframes formula-caret { 50% { opacity: 0; } }
.answer-submit {
  position: absolute; top: 6px; right: 6px; min-width: 82px; max-width: 55%; height: 45px; padding: 0 10px;
  overflow: hidden; border: 1px solid #b6d9cf; border-radius: 10px; background: #eaf7f2; color: var(--primary-dark);
  font-family: inherit; font-size: .78rem; font-weight: 850; white-space: nowrap; cursor: pointer;
}
.answer-submit:disabled { opacity: .55; }
.input-message { min-height: 0; margin: 0; color: var(--wrong); font-size: .72rem; }
.input-message:not(:empty) { min-height: 1em; margin: 3px 3px 0; }

.name-shortcuts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(48px, 1.3fr); gap: 4px; margin-top: 7px; }
.name-shortcuts.compound-name-entry { grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(52px, 1.35fr); }
.name-shortcuts.ion-name-entry { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(53px, 1.35fr) minmax(40px, 1fr) minmax(48px, 1.2fr); }
.name-shortcuts button { min-width: 0; min-height: 38px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.88); color: var(--primary-dark); font-size: .85rem; font-weight: 800; box-shadow: 0 2px 0 #c8ddd5; }
.name-shortcuts button[data-key="イオン"], .name-shortcuts .name-backspace, .name-shortcuts .name-clear { white-space: nowrap; }
.name-shortcuts button:active { transform: translateY(2px); box-shadow: none; }
.name-shortcuts .name-backspace { font-size: 1rem; }
.name-shortcuts .name-clear { color: var(--muted); font-size: .72rem; }

.formula-keyboard { margin-top: 0; padding: 6px; border: 0; border-radius: 16px; background: rgba(231,245,238,.94); box-shadow: 0 8px 22px rgba(61,122,103,.08); user-select: none; }
.formula-keyboard button { min-width: 0; min-height: 42px; padding: 0; border: 1px solid #d1e0db; border-radius: 8px; background: white; color: var(--ink); font-weight: 760; box-shadow: 0 2px 0 #bfd1cb; cursor: pointer; }
.formula-keyboard button:active { transform: translateY(2px); box-shadow: none; }
.letter-keys button[data-key] { touch-action: pan-x pinch-zoom; }
.letter-keys button.is-case-flick-ready { border-color: #73bca7; background: #dff4ea; color: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 3px 0 #a7d6c5; }
.formula-keyboard .case-key { display: grid; place-items: center; }
.formula-keyboard .case-key svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.formula-keyboard .case-key[aria-pressed="true"] { border-color: #a7d6c5; background: #ccefe0; color: var(--primary-dark); }
.key-row { display: grid; gap: 3px; margin: 3px auto; }
.number-keys { grid-template-columns: repeat(10, 1fr); }
.letter-keys .key-row:nth-child(1) { grid-template-columns: repeat(10, 1fr); }
.letter-keys .key-row:nth-child(2) { width: 90%; grid-template-columns: repeat(9, 1fr); }
.letter-keys .key-row:last-child { width: 100%; grid-template-columns: 40px repeat(7, 1fr) 40px; }
.keyboard-controls { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 3px; margin-top: 5px; }
.formula-keyboard.ion-entry .keyboard-controls { grid-template-columns: repeat(8, 1fr) 1.35fr; }
.charge-keys { display: contents; }
.charge-keys button { border-color: #a8d8cb; background: #e2f7f1; color: #197b6d; }
.formula-keyboard.ion-entry .keyboard-controls > button { font-size: .72rem; }

.feedback { margin-top: 9px; padding: 13px; border-radius: 16px; border: 1px solid var(--line); background: white; text-align: center; }
.feedback.correct { border-color: #a9d9c7; background: #f0fbf6; }
.feedback.wrong { border-color: #e5c1c3; background: #fff7f7; }
.feedback-title { font-weight: 900; font-size: 1.05rem; }
.feedback-answer { margin-top: 6px; font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; font-size: 1.52rem; font-weight: 800; }
.feedback-detail { margin: 7px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.55; white-space: pre-line; }
.feedback-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 11px; }
.support-action { min-height: 39px; border: 1px solid var(--line); border-radius: 11px; background: #f7fcf9; color: var(--primary-dark); font-weight: 850; }
.support-action:last-child { background: white; color: var(--muted); }
.support-action.is-used { visibility: hidden; pointer-events: none; }
.feedback .primary-button { width: 100%; margin-top: 10px; }
.question-card.shake { animation: shake .28s ease; }
.question-card.pop { animation: pop .32s ease; }
.question-card.milestone { animation: milestone .48s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
@keyframes pop { 50% { transform: scale(1.018); box-shadow: 0 19px 52px rgba(22,128,95,.17); } }
@keyframes milestone { 45% { transform: scale(1.035); box-shadow: 0 20px 56px rgba(114,198,167,.34); } }
.spark-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.spark { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: sparkle .65s ease-out forwards; }
@keyframes sparkle { from { transform: translate(0,0) scale(1); opacity: 1; } to { transform: translate(var(--spark-x), var(--spark-y)) scale(0); opacity: 0; } }

.result-hero { padding: 16px 0 14px; text-align: center; }
.result-mark { width: 50px; height: 50px; margin: 0 auto 8px; display: grid; place-items: center; border-radius: 50%; background: #dff3ec; color: var(--correct); font-size: 1.55rem; font-weight: 900; }
h1 { margin: 0; font-size: 1.65rem; letter-spacing: -.03em; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.result-grid div { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.88); }
.result-grid dt { color: var(--muted); font-size: .74rem; font-weight: 700; }
.result-grid dd { margin: 4px 0 0; font-size: 1.55rem; font-weight: 900; }
.result-grid dd::after { content: "問"; margin-left: 3px; color: var(--muted); font-size: .67rem; }
.result-review { margin-top: 11px; }
.result-review h2 { margin: 0 0 7px; color: var(--ink); font-size: .9rem; }
.result-review-list { display: grid; gap: 7px; }
.review-item { position: relative; padding: 10px 72px 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.82); }
.review-prompt { min-height: 1.2em; color: var(--ink); font-size: .86rem; font-weight: 750; }
.review-prompt .ion-pair.names { display: block; font-size: inherit; line-height: 1.35; text-align: left; }
.review-prompt .ion-pair-first, .review-prompt .ion-pair-second { display: inline; }
.review-prompt .ion-pair-second::before { content: " "; }
.review-answer { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.review-status { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); padding: 4px 7px; border-radius: 999px; background: #e4f5ed; color: var(--primary-dark); font-size: .68rem; font-weight: 850; }
.result-actions { display: grid; gap: 8px; margin-top: 12px; }

.weak-review-dialog { width: min(calc(100% - 26px), 520px); max-height: min(78dvh, 680px); margin: auto; padding: 0; border: 0; border-radius: 19px; background: transparent; color: var(--ink); box-shadow: 0 20px 64px rgba(38,89,73,.25); }
.weak-review-dialog::backdrop { background: rgba(41, 83, 71, .28); backdrop-filter: blur(2px); }
.weak-review-sheet { max-height: min(78dvh, 680px); padding: 17px; overflow: auto; border: 1px solid var(--line); border-radius: inherit; background: #fbfffc; }
.weak-review-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.weak-review-kicker { margin: 0 0 2px; color: var(--muted); font-size: .69rem; font-weight: 800; letter-spacing: .08em; }
.weak-review-heading h2 { margin: 0; font-size: 1.28rem; }
.modal-close { width: 35px; height: 35px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--primary-dark); font-size: 1.35rem; line-height: 1; cursor: pointer; }
.weak-review-description, .weak-review-empty { margin: 10px 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.weak-review-empty { padding: 13px; border: 1px dashed var(--line); border-radius: 12px; background: rgba(239,250,245,.7); text-align: center; }
.weak-review-list { display: grid; gap: 7px; }
.weak-item { position: relative; padding: 10px 57px 10px 11px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.92); }
.weak-item-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font-size: .92rem; font-weight: 850; }
.weak-item-formula { font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; color: var(--primary-dark); }
.weak-item-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 6px; color: var(--muted); font-size: .7rem; font-weight: 750; }
.weak-skill { padding: 3px 6px; border-radius: 999px; background: #e5f5ee; color: var(--primary-dark); font-size: .65rem; font-weight: 850; }
.weak-item-delete { position: absolute; top: 50%; right: 8px; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; transform: translateY(-50%); border: 1px solid #e5bdc2; border-radius: 11px; background: #fff; color: #a84752; cursor: pointer; }
.weak-item-delete svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.weak-item-delete:focus-visible, .weak-review-clear:focus-visible { outline: 3px solid rgba(168,71,82,.24); outline-offset: 2px; }
.weak-review-sheet > .primary-button { width: 100%; margin-top: 12px; }
.weak-review-clear { width: 100%; min-height: 44px; margin-top: 8px; border: 1px solid #e0aeb5; border-radius: 12px; background: #fff; color: #a84752; font: inherit; font-size: .84rem; font-weight: 850; cursor: pointer; }

@media (min-width: 680px) {
  .app-shell { padding-top: 18px; }
  .setup-form { max-width: 490px; margin-inline: auto; }
  .question-card { min-height: 168px; }
}
@media (max-width: 365px) {
  .app-header, .app-shell { padding-inline: 9px; }
  .top-action { padding-inline: 6px; }
  .media-toggle { min-width: 37px; padding-inline: 6px; }
  .mode-card { min-height: 90px; }
  .formula-keyboard button { min-height: 40px; font-size: .78rem; }
  .letter-keys .key-row:last-child { grid-template-columns: 36px repeat(7, 1fr) 36px; }
  .name-shortcuts { grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(44px, 1.2fr); gap: 3px; }
  .name-shortcuts.compound-name-entry { grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(48px, 1.3fr); }
  .name-shortcuts.ion-name-entry { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(49px, 1.3fr) minmax(37px, .95fr) minmax(44px, 1.14fr); }
}
@media (max-width: 680px) {
  .formula-keyboard { width: calc(100% + 22px); margin-left: -11px; margin-right: -11px; padding-inline: 3px; }
}
@media (orientation: portrait) and (max-height: 600px) {
  .app-current .question-card { min-height: 98px; padding-top: 19px; padding-bottom: 11px; }
  .app-current .question-progress { margin-top: 5px; }
  .app-current .answer-area { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* current published interface keeps the original page's visual system untouched. */
.app-current {
  --ink: #174b43;
  --muted: #4c7069;
  --paper: #fffefa;
  --background: #f3fbf7;
  --line: #acd6c8;
  --primary: #08765f;
  --primary-dark: #075548;
  --accent: #5bb99a;
  --correct: #087356;
  --wrong: #a84752;
  --shadow: 0 14px 34px rgba(22, 91, 75, .12);
}
.app-current .app-header { min-height: 64px; padding-top: max(10px, env(safe-area-inset-top)); }
.app-current .brand { font-size: 1.14rem; }
.app-current .media-toggle, .app-current .home-button { min-width: 44px; height: 44px; }
.app-current .quiz-actions { flex: 1; min-width: 0; }
.app-current .active-game-description { min-width: 0; margin: 0 0 0 7px; color: var(--primary-dark); font-size: .71rem; font-weight: 850; line-height: 1.25; }
.app-current .active-game-difficulty { display: block; color: var(--primary); font-size: .9em; letter-spacing: .04em; }
.app-current .active-game-route { display: block; }
.app-current .setup-form { gap: 14px; }
.app-current .compound-options { padding: 13px; border-color: #9bcdbd; background: rgba(255,255,255,.88); }
.app-current .compound-options legend { color: var(--primary-dark); font-size: .9rem; }
.app-current .compound-option-row { grid-template-columns: 38px minmax(0, 1fr); }
.app-current .compound-option-row + .compound-option-row { margin-top: 9px; }
.app-current .compound-option-title { color: var(--ink); font-size: .84rem; }
.app-current .compound-option-row:has(.answer-toggles) .compound-option-title { align-self: start; min-height: 44px; display: flex; align-items: center; }
.app-current .option-toggles { gap: 6px; }
.app-current .answer-toggles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.app-current .ion-answer-toggles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app-current .option-toggle {
  min-height: 44px; border: 1px solid #a7d1c4; border-radius: 11px; background: #fff;
  color: #3c655d; font-size: .83rem; font-weight: 850; cursor: pointer;
}
.app-current .option-toggle.is-on {
  border-color: var(--primary); background: #d9f3e8; color: var(--primary-dark); box-shadow: inset 0 0 0 1px rgba(8,118,95,.08);
}
.app-current .option-toggle:focus-visible, .app-current .companion-toggle:focus-visible, .app-current .companion-reveal:focus-visible {
  outline: 3px solid rgba(8,118,95,.25); outline-offset: 2px;
}
.app-current .compound-option-message { margin-left: 0; font-size: .74rem; }
.app-current .segment-control span { min-height: 44px; color: #416a62; font-weight: 800; }
.app-current .mode-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 8px 22px rgba(8,118,95,.16), inset 0 0 0 2px rgba(8,118,95,.1); }
.app-current .question-card { border-color: #b9ddd1; background: rgba(255,255,255,.94); }
.app-current .question-progress { height: 7px; margin: 9px 4px 0; overflow: hidden; border-radius: 999px; background: #d7ebe4; }
.app-current .question-progress-bar { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1b9b7a, #69c4a5); transition: width .22s ease; }
.app-current .both-answer-tabs button { min-height: 44px; color: #416a62; }
.app-current #quiz-screen.is-both-complete #answer-form,
.app-current #quiz-screen.is-both-complete #name-shortcuts,
.app-current #quiz-screen.is-both-complete #formula-keyboard { display: none; }
.app-current .support-action { min-height: 44px; }
.app-current .name-shortcuts button { min-height: 44px; }
.app-current .feedback { border-color: #b9ddd1; }
.app-current .feedback-answer { color: var(--ink); }
.app-current .feedback-companion-row { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 10px; overflow-x: auto; white-space: nowrap; }
.app-current .companion-reveal { flex: 0 0 auto; min-height: 40px; padding: 0 10px; border: 1px solid #9fcdbd; border-radius: 11px; background: #fff; color: var(--primary-dark); font-size: .78rem; font-weight: 850; cursor: pointer; }
.app-current .companion-reveal:disabled { border-color: #9fcdbd; background: #e6f6ef; color: var(--primary-dark); opacity: 1; }
.app-current .feedback-companion { flex: 0 0 auto; color: var(--primary-dark); }
.app-current .feedback-companion-value { font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; font-size: 1.02rem; font-weight: 850; }
.app-current .companion-toggle { min-height: 44px; margin-top: 8px; padding: 0 10px; border: 1px solid #9fcdbd; border-radius: 11px; background: #fff; color: var(--primary-dark); font-size: .78rem; font-weight: 850; cursor: pointer; }
.app-current .companion-toggle[aria-pressed="false"] { border-color: #bdd8cf; color: #58776f; }
.app-current .result-hero { padding-bottom: 10px; }
.app-current .result-game-mode { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; color: var(--primary-dark); font-size: .78rem; font-weight: 850; }
.app-current .result-game-difficulty { padding: 4px 8px; border-radius: 999px; background: #d9f3e8; color: var(--primary-dark); letter-spacing: .04em; }
.app-current .result-game-route { overflow-wrap: anywhere; }
.app-current .result-first-rate { margin: 9px 0 0; color: var(--primary-dark); font-size: 1.12rem; font-weight: 900; }
.app-current .result-comparison { min-height: 1.3em; margin: 4px 0 0; color: var(--muted); font-size: .8rem; font-weight: 750; }
.app-current .result-count-note { margin: 9px 2px 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.app-current .result-review-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.app-current .result-review-heading h2 { margin-bottom: 0; }
.app-current .result-review-heading .companion-toggle { min-height: 38px; margin-top: 0; white-space: nowrap; }
.app-current .review-companion { margin-top: 5px; color: var(--primary-dark); font-size: .76rem; }
.app-current .review-companion strong { font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; font-size: 1.06em; }

@media (max-width: 365px) {
  .app-current .formula-keyboard { width: calc(100% + 18px); margin-left: -9px; margin-right: -9px; }
  .app-current .formula-keyboard button { min-height: 40px; }
  .app-current .result-review-heading { align-items: flex-start; }
  .app-current .result-review-heading .companion-toggle { min-height: 44px; font-size: .71rem; }
}

.difficulty-with-complex .complex-toggle { margin-left: auto; white-space: nowrap; }
.complex-toggle-state { margin-left: 6px; font-size: .72em; }
.number-keys button[data-bracket-key] { touch-action: pan-x pinch-zoom; position: relative; }
.app-current #quiz-screen.is-both-complete #complex-name-shortcuts { display: none; }

.difficulty-with-complex { display: flex; align-items: stretch; gap: 8px; }
.difficulty-with-complex .segment-control { flex: 1; min-width: 0; }
.formula-keyboard.ion-entry .keyboard-controls { grid-template-columns: repeat(9,minmax(0,1fr)) 1.35fr; }


.name-shortcuts.complex-name-shortcuts { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
.name-shortcuts.complex-name-shortcuts button { white-space: nowrap; padding: 0 2px; }
.name-shortcuts.complex-name-shortcuts button[data-key="ヒドロキシド"] { font-size: clamp(.65rem,2.7vw,.85rem); }

/* The tooltip floats above the existing difficulty row without taking space. */
.complex-only-option { position: relative; }
.complex-only-tooltip { position: absolute; bottom: calc(100% + 10px); right: 0; width: min(200px, 60vw); padding: 10px 12px; border-radius: 10px; background: var(--primary-dark, #183b56); color: white; font-size: .8rem; line-height: 1.5; font-weight: 400; pointer-events: none; visibility: hidden; opacity: 0; z-index: 20; }
.complex-only-option:hover .complex-only-tooltip, .complex-only-option:focus-within .complex-only-tooltip { visibility: visible; opacity: 1; transition: opacity .15s .65s, visibility 0s .65s; }
.difficulty-with-complex .segment-control > label > span { white-space: nowrap; }
