/* New exercise widgets inherit the production fonts, keys, themes and buttons. */
#exercise-widget [hidden] { display: none !important; }
body { --nse-ui-font: 'Nunito', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', sans-serif; }
.nse-mixed #study-instruction, #exercise-widget #feedback, #exercise-widget #summary { font-family: var(--nse-ui-font); }
.nse-mixed #study-title, .nse-typed #game-title, #actions .game-btn, #result-action .game-btn, #summary .game-btn { font-family: 'Fredoka', var(--nse-ui-font); }
#bin-label:lang(zh-CN) { font-family: var(--nse-ui-font); }
.non-spelling-exercises button:focus-visible { outline: 3px solid #f59e0b; outline-offset: 3px; }
.non-spelling-exercises button:disabled { cursor: default; }
.nse-mixed, .nse-typed, .non-spelling-exercises { touch-action: pan-y; }
.nse-heading { padding: 0 40px; text-align: center; }
.nse-game-instruction { margin: 0 0 12px; text-align: center; font-family: var(--nse-ui-font); font-size: var(--font-md); line-height: 1.4; }
.non-spelling-exercises { width: 100%; max-width: 700px; margin: 0 auto; padding: 0 8px; --nse-green: linear-gradient(180deg, #4ade80 0%, #16a34a 100%); --nse-red: linear-gradient(180deg, #f87171 0%, #dc2626 100%); }
.nse-sentences { display: flex; flex-direction: column; gap: 12px; }
.nse-sentence { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px 7px; padding: 15px 14px; margin: 0; border: 2px solid #ffffff18; border-radius: 16px; background: #ffffff09; box-shadow: 0 3px 0 #00000012; font-family: inherit; font-size: var(--font-lg); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; text-align: center; }
.nse-fixed-word { display: inline-block; white-space: nowrap; }
#grammarGame .nse-sentence { color: #1e293b; background: #ffffffc9; border-color: #ffffffcf; box-shadow: 0 3px 0 #cbd5e144, 0 5px 12px #1e293b08; }
.nse-answer { position: relative; display: inline-flex; flex-wrap: wrap; gap: 1px; align-items: center; justify-content: center; vertical-align: middle; min-width: 105px; max-width: 100%; min-height: var(--touch-min); padding: 5px 9px; border: 2px solid #94a3b8; border-radius: 12px; background: #1e293b; color: white; font-family: inherit; font-size: var(--answer-font); font-weight: 700; line-height: 1.2; box-shadow: 0 3px 0 #0f172a; transition: border-color .15s, box-shadow .15s; }
#grammarGame .nse-answer { background: #fff; border-color: #cbd5e1; color: #1e293b; box-shadow: 0 3px 0 #cbd5e1; }
.nse-answer.active { border-color: #fbbf24 !important; box-shadow: 0 3px 0 #d97706, 0 0 0 3px #fbbf2426; }
.nse-answer.spelling-correct { background: var(--nse-green) !important; border-color: #15803d !important; box-shadow: 0 3px 0 #15803d, 0 0 12px #22c55e66 !important; animation: nse-pop .34s ease-out; }
.nse-answer.spelling-wrong { animation: nse-shake .32s ease-in-out; }
.nse-answer.all-correct::after { content: '\2713'; position: absolute; top: -9px; right: -9px; display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid #fff; border-radius: 50%; background: #15803d; color: #fff; font: 700 15px/1 Nunito,sans-serif; box-shadow: 0 2px 4px #14532d33; }
.nse-empty { display: block; width: 44px; height: 3px; border-radius: 2px; background: currentColor; opacity: .28; }
.letter { display: inline-block; min-width: .62em; line-height: 1.4; border-radius: 5px; text-align: center; }
#exercise-widget .letter.correct { background: var(--nse-green); color: #fff !important; box-shadow: inset 0 -2px 0 #15803d; }
#exercise-widget .letter.wrong { background: var(--nse-red); color: #fff !important; box-shadow: inset 0 -2px 0 #991b1b; }
#exercise-widget .nse-answer.spelling-correct .letter { min-width: 0; background: transparent; color: #fff !important; box-shadow: none; }
.nse-word { min-height: var(--touch-min); margin: 0; padding: 7px 11px; font-size: var(--font-md); touch-action: none; }
.nse-word.selected { outline: 3px solid #facc15; outline-offset: 2px; transform: translateY(-2px); }
.nse-word:disabled { opacity: 1; }
.nse-bin { display: flex; align-items: center; justify-content: center; gap: 10px; width: fit-content; min-width: 120px; max-width: 100%; min-height: 56px; margin: 16px auto 14px; padding: 6px 16px 8px; color: #475569; border: 2px solid #cbd5e1; border-bottom: 4px solid #94a3b8; border-radius: 16px; background: linear-gradient(180deg, #fff 0%, #f1f5f9 100%); box-shadow: 0 3px 8px #0f172a0d; font-family: inherit; font-size: var(--font-md); font-weight: 700; transition: background .15s, border-color .15s, transform .15s; }
.nse-bin:not(:disabled):hover { transform: translateY(-1px); }
.nse-bin:not(:disabled):active { transform: translateY(2px); }
.nse-bin-target { position: relative; z-index: 2; flex: 0 0 auto; display: inline-flex; align-items: center; }
.nse-bin-icon { flex: 0 0 auto; width: 29px; height: 34px; overflow: visible; color: #c77723; filter: drop-shadow(0 2px 0 #a85c1720); }
.nse-bin-body { fill: #ffcc80; stroke: #d98b38; stroke-width: 2; }
.nse-bin-grooves { color: #fff8e7; }
.nse-bin-lid, .nse-bin-handle { transform-origin: 20px 11px; transition: transform .2s ease; }
.nse-bin.ready, .nse-bin.drag-over { background: linear-gradient(180deg, #fff4d8 0%, #ffe2a9 100%); border-color: #f6b554; border-bottom-color: #d98b38; box-shadow: 0 3px 8px #b4530915; }
.nse-bin.ready .nse-bin-lid, .nse-bin.ready .nse-bin-handle, .nse-bin.drag-over .nse-bin-lid, .nse-bin.drag-over .nse-bin-handle { transform: translateY(-3px) rotate(-12deg); }
#bin-label { position: relative; z-index: 1; overflow-wrap: anywhere; }
.nse-bin.has-word #bin-label { padding: 4px 10px; border-radius: 8px; background: #e2e8f0; font-size: var(--font-sm); }
#bin-undo { font-size: 14px; opacity: .7; }
#bin-mark { position: absolute; top: -5px; right: -9px; z-index: 3; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #fff, 0 2px 4px #14532d22; font-size: 18px; }
#exercise-widget .nse-bin.word-correct { background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%); border-color: #86efac; border-bottom-color: #16a34a; box-shadow: 0 3px 8px #15803d1a; }
.nse-bin.word-correct .nse-bin-icon { color: #15803d; }
.nse-bin.word-correct .nse-bin-body { fill: #4ade80; stroke: #16a34a; }
.nse-bin.word-correct .nse-bin-grooves { color: #f0fdf4; }
.nse-bin.word-correct .nse-bin-lid, .nse-bin.word-correct .nse-bin-handle { animation: nse-bin-gulp .85s ease-in-out both; }
.nse-bin.word-correct .nse-bin-icon { animation: nse-bin-settle .85s ease-in-out both; }
.nse-bin.word-correct #bin-label { white-space: nowrap; text-decoration: line-through; text-decoration-color: #b91c1c; text-decoration-thickness: 2px; animation: nse-bin-swallow .85s ease-in-out both; }
#exercise-widget .nse-bin.word-wrong { background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%); border-color: #fca5a5; border-bottom-color: #dc2626; }
.nse-bin.word-wrong .nse-bin-icon { color: #b91c1c; }
.nse-bin.word-wrong .nse-bin-body { fill: #f87171; stroke: #dc2626; }
.nse-bin.word-correct #bin-mark { color: #16a34a; }
.nse-bin.word-wrong #bin-mark { color: #dc2626; }
.nse-keyboard { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--gap-sm); margin: 17px 0; padding: 14px 10px 18px; border-radius: 16px; background: #ffffff06; }
.nse-key-row { display: contents; }
#grammarGame .nse-keyboard { background: #ffffff70; border: 1px solid #ffffffaa; }
#grammarGame .letter-bubble { color: #1e293b; }
.key:disabled { opacity: 1; transform: none; }
.nse-actions { display: flex; justify-content: center; align-items: stretch; flex-wrap: wrap; gap: 12px; }
.nse-backspace { min-width: var(--touch-min); padding: 8px 14px; }
#backspace:disabled { opacity: .45; }
.nse-feedback { display: flex; align-items: center; justify-content: center; gap: 9px; width: fit-content; max-width: 100%; min-height: 34px; margin: 12px auto 0; padding: 7px 12px; border-radius: 12px; font-family: inherit; font-size: var(--font-sm); font-weight: 700; text-align: center; line-height: 1.4; }
.nse-feedback:empty { padding: 0; }
.nse-feedback-icon { flex: 0 0 auto; font-size: 21px; }
.nse-feedback.success { background: #dcfce7; border: 1px solid #86efac; box-shadow: 0 2px 0 #bbf7d0; animation: nse-pop .34s ease-out; }
.nse-feedback.error { background: #fff1f2; border: 1px solid #fecaca; box-shadow: 0 2px 0 #fee2e2; }
#exercise-widget .nse-feedback.success, #exercise-widget .nse-feedback.success .nse-feedback-text { color: #166534 !important; }
#exercise-widget .nse-feedback.error, #exercise-widget .nse-feedback.error .nse-feedback-text { color: #9f1239 !important; }
#result-action { margin-top: 22px; }
.nse-summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #94a3b844; font-size: var(--font-sm); }
body.kid-friendly .nse-sentence { background: #fffcf7; border-color: #ffdec9; box-shadow: 0 3px 0 #efbea02b, 0 6px 16px #8c451509; }
body.kid-friendly .nse-sentence.nse-active { border-color: #ffb98f; }
body.kid-friendly .nse-answer { background: #fff4e8; border-color: #edc4a6; color: #5d4037; box-shadow: 0 3px 0 #e6b58f; }
body.kid-friendly .nse-answer.active { border-color: #fb8c00 !important; box-shadow: 0 3px 0 #ef6c00, 0 0 0 3px #ffb74d24; }
body.kid-friendly .nse-keyboard { background: #fff9ef; border: 1px solid #ffe5ce; box-shadow: 0 3px 0 #efbea018; }
body.kid-friendly .nse-bin { background: linear-gradient(180deg, #fffaf2 0%, #fff0dd 100%); border-color: #efc5a7; border-bottom-color: #e4b593; color: #8c573b; }
body.kid-friendly .nse-bin.ready, body.kid-friendly .nse-bin.drag-over { background: linear-gradient(180deg, #fff4d8 0%, #ffe2a9 100%); border-color: #f6b554; border-bottom-color: #d98b38; }
body.kid-friendly .nse-bin.has-word #bin-label { background: #ffe1bf; }
body.kid-friendly .nse-word.selected { outline-color: #e65100; }
body.kid-friendly #clear, body.kid-friendly #backspace { background: #fff7ef !important; border: 2px solid #efc5a7 !important; border-bottom: 4px solid #e4b593 !important; color: #9b4d28 !important; box-shadow: none; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: #f59e0b; color: #1a1a2e; font-family: Fredoka,sans-serif; font-weight: 700; font-size: var(--font-lg); transform: translate(-50%,-70%); box-shadow: 0 5px 15px #0003; }
@keyframes nse-pop { 0% { transform: scale(.96); } 55% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes nse-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes nse-bin-gulp {
  0%,100% { transform: translateY(0) rotate(0); }
  22%,60% { transform: translateY(-7px) rotate(-18deg); }
  78% { transform: translateY(1px) rotate(5deg); }
  90% { transform: translateY(-2px) rotate(-4deg); }
}
@keyframes nse-bin-settle {
  0%,65%,100% { transform: scale(1); }
  78% { transform: scale(1.12,.88); }
  89% { transform: scale(.94,1.06); }
}
@keyframes nse-bin-swallow {
  0%,30% { transform: translate(0,0) scale(1); opacity: 1; }
  50% { transform: translate(calc(var(--swallow-x) * .55), calc(var(--swallow-y) - 14px)) rotate(-10deg) scale(.9); opacity: 1; }
  68% { transform: translate(var(--swallow-x), var(--swallow-y)) rotate(8deg) scale(.65); opacity: 1; }
  80% { transform: translate(var(--swallow-x), calc(var(--swallow-y) + 16px)) scale(0); opacity: 0; }
  0%,80% { max-width: var(--binned-width); padding-left: 10px; padding-right: 10px; margin-left: 0; visibility: visible; }
  100% { transform: translate(var(--swallow-x), calc(var(--swallow-y) + 16px)) scale(0); opacity: 0; max-width: 0; padding-left: 0; padding-right: 0; margin-left: -10px; visibility: hidden; }
}
@media (prefers-reduced-motion:reduce) {
  .nse-answer, .nse-bin, .nse-feedback { animation: none !important; transition: none !important; }
  .nse-bin-icon, .nse-bin-lid, .nse-bin-handle, #bin-label { animation: none !important; transition: none; }
  .nse-bin.word-correct #bin-label { visibility: hidden; max-width: 0; padding-left: 0; padding-right: 0; margin-left: -10px; }
}
@media (max-width:480px) {
  .non-spelling-exercises { padding: 0 2px; }
  .nse-sentence { padding: 12px 10px; gap: 4px 6px; }
  .nse-answer { min-width: 99px; }
  .nse-word { padding: 6px 9px; }
  .nse-keyboard { flex-direction: column; padding: 12px 8px 16px; gap: 10px; }
  .nse-key-row { display: flex; justify-content: center; gap: var(--gap-sm); width: 100%; }
  .nse-actions { gap: 8px; }
  .nse-actions .game-btn { padding: 10px 14px; }
}
@media (orientation:landscape) and (max-height:500px) {
  .nse-keyboard { margin: 10px 0; padding: 8px; }
  .nse-sentences { gap: 8px; }
}
@media (max-width:480px) and (max-height:650px) {
  /* Leave the same floating theme control clear of the exercise actions. */
  #studyModeOverlay.nse-mixed, #grammarGame.nse-typed { padding-bottom: 80px; }
  #grammarGame.nse-typed .minigame-container { max-height: calc(100dvh - 96px); }
  .nse-sentence { padding: 10px 8px; }
  .nse-bin { min-height: 50px; margin: 10px auto; padding: 4px 12px 6px; }
  .nse-keyboard { margin: 10px 0; padding: 10px 8px 14px; }
  .nse-keyboard[data-key-count="4"], .nse-keyboard[data-key-count="5"] { flex-direction: row; column-gap: 4px; }
  .nse-keyboard[data-key-count="4"] .nse-key-row, .nse-keyboard[data-key-count="5"] .nse-key-row { display: contents; }
  .nse-feedback { margin-top: 8px; }
  #next { font-size: 1.15rem; padding: 12px 18px; }
}

/* Keep the pronoun and its editable contraction ending together. */
.nse-contraction { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
#exercise-widget .nse-contraction .nse-answer { min-width: 64px; }
