/* The page stays inside the device viewport; dialogs and galleries scroll inside it. */
html { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { height:100vh; height:100dvh; height:var(--layout-height,100dvh); min-height: 0; overflow: hidden; overscroll-behavior: none; }
/* The shell always fills the usable viewport. Legacy browser fallbacks must not impose a canvas ratio. */
.stage { width:100%; height:100%; max-width:none; max-height:none; aspect-ratio:auto; }
.orientation-tip { position: absolute; bottom: 5%; left: 0; right: 0; pointer-events: none; }
.forest-playing .level-screen { touch-action: manipulation; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
.level-screen .level-world.is-input-error { animation: none; box-shadow: none; }
.level-screen .level-world.is-input-error::after { display: none; }

.level-world {
  --forest-dock-height: clamp(96px, 10cqw, 132px);
  --forest-dock-bottom: max(2%, env(safe-area-inset-bottom));
}
.level-world .forest-answer-dock {
  left: 14%; width: 72%; bottom: var(--forest-dock-bottom); height: var(--forest-dock-height);
  min-height: 0; max-height: none; border-radius: clamp(12px, 1.6cqw, 22px);
  padding: .4cqw .8cqw .65cqw; gap: .35cqw;
  background: transparent; border: 1px solid transparent; box-shadow: none;
}
.forest-answer-dock .writing-tools { flex: 0 0 auto; min-height: 24px; gap: max(8px, .5cqw); font-size: clamp(12px, 1.1cqw, 16px); }
.forest-answer-dock .writing-tools label { white-space: nowrap; }
.forest-answer-dock .writing-tools label { color: #183c2d; background: #f1f6e8; border-radius: 8px; padding: 3px 8px; }
.forest-answer-dock .writing-tools button { min-width: 44px; min-height: 44px; padding: 0 .85em; }
.forest-answer-dock .writing-row { min-height: 44px; gap: max(8px, .7cqw); }
.forest-answer-dock .writing-surface { min-height: 44px; }
.forest-word-choices { height: 100%; min-height: 44px; display: grid; grid-template-columns: repeat(4, minmax(44px, 1fr)); gap: max(8px, .8cqw); }
.forest-word-choice {
  position: relative; min-width: 44px; min-height: 44px; padding: .2em .3em;
  border: 1px solid #b6cfb2; border-radius: clamp(7px, 1cqw, 14px);
  background: #f1f6e8; color: #244d37;
  font-family: "Trebuchet MS", Arial, sans-serif; font-weight: 700;
  font-size: clamp(14px, 1.9cqw, 28px); line-height: 1.15;
  overflow-wrap: anywhere; text-align: center;
}
.forest-word-choice:hover:not(:disabled) { background: #e3eed6; border-color: #69965b; }
.forest-word-choice:active:not(:disabled) { background: #d2e5c5; }
.forest-word-choice.is-wrong { opacity: 1; border-color: #b85b45; background: #fff0e7; color: #86432e; }
.forest-choice-mark { position: absolute; right: .2em; top: 0; font: 700 12px/1.1 Arial, sans-serif; }
.forest-choice-idle { grid-column: 1 / -1; align-self: center; text-align: center; color: #65735b; font-size: clamp(12px, 1.25cqw, 18px); }
.forest-answer-dock .check-word { min-width: 44px; min-height: 44px; height: 100%; font-size: clamp(12px, 1.35cqw, 19px); padding: 0 .9em; box-shadow: none; border-radius: 9px; }
/* Keep the ordinary input surface usable if a lesson mounts tools instead of choices. */
.forest-answer-dock:not([data-input-mode="choice"]) { height: auto; min-height: 116px; }
.forest-answer-dock:not([data-input-mode="choice"]) .writing-row,
.forest-answer-dock:not([data-input-mode="choice"]) .writing-surface { min-height: 56px; }
.level-world .word-prompt { bottom: calc(var(--forest-dock-height) + var(--forest-dock-bottom) + 8px); padding: .25em .8em; font-size: clamp(12px, 1.15cqw, 17px); }
/* Feedback remains available to screen readers without covering the artwork. */
.level-world .forest-feedback { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-height: 520px) and (orientation: landscape) {
  .level-world .topbar { top:max(2%,env(safe-area-inset-top)); left:max(2%,env(safe-area-inset-left)); right:max(2%,env(safe-area-inset-right)); gap:4px; }
  .level-world .topbar > button, .level-world .topbar > details { flex-shrink: 0; }
  .level-world .topbar .quiet-button { min-height:44px; padding:4px 7px; font-size:11px; white-space: nowrap; }
  .level-world .page-heading { flex: 0 1 26%; width: 26%; min-width: 0; max-width: 26%; padding: 5px 6px; }
  .level-world .page-heading span { display: none; }
  .level-world .page-heading h1 { font-size: 11px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .level-world .progress-pill { margin-left: 0; padding: 5px 7px; gap: 2px; font-size: 9px; white-space: nowrap; }
  .level-world .progress-pill strong { font-size: 1.4em; }
  .level-world .audio-settings summary { display: flex; align-items: center; min-height:44px; padding:4px 7px; font-size:11px; }
  .level-world { --forest-dock-height: 84px; }
  .level-world .forest-answer-dock { padding: 2px 6px 5px; gap: 2px; left: max(7%, env(safe-area-inset-left)); right: max(7%, env(safe-area-inset-right)); width: auto; }
  .forest-answer-dock .writing-tools { min-height: 24px; font-size: 12px; }
  .forest-word-choice { font-size: clamp(14px, 1.9cqw, 17px); }
  .level-world .word-prompt { font-size: 12px; }
  .level-world .word-prompt strong { font-size: 1.2em; }
}
@supports not (width: 1cqw) {
  .level-world { --forest-dock-height:clamp(88px,14vh,110px); }
  .level-world .forest-answer-dock { padding:3px 6px 5px; gap:3px; }
  .forest-word-choices { gap:8px; }
  .forest-word-choice { font-size:clamp(13px,2.5vh,20px); }
  .forest-answer-dock .writing-row { gap:8px; }
  .level-world .word-orb { min-width:44px; min-height:44px; }
}
