@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/kalam-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/kalam-latin-700-normal.woff2") format("woff2");
}

:root {
  --swm-ink: #183820;
  --swm-copy: #405a47;
  --swm-green: #4d925d;
  --swm-green-dark: #285f3b;
  --swm-pale: #eaf6e6;
  --swm-cream: #fffdf7;
  --swm-line: rgba(35, 82, 47, 0.2);
  --swm-shadow: 0 12px 32px rgba(24, 59, 32, 0.14);
  --swm-radius: 18px;
}

.swm-app,
.swm-app *,
.swm-app *::before,
.swm-app *::after {
  box-sizing: border-box;
}

.swm-app {
  position: relative;
  left: 50%;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin-left: -50vw;
  overflow: hidden;
  color: var(--swm-ink);
  background: linear-gradient(145deg, #edf7e9, #f8f9ef 46%, #eaf6fb);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
  isolation: isolate;
}

.swm-app:fullscreen,
.swm-app:-webkit-full-screen {
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
}

.swm-app button,
.swm-app textarea,
.swm-app input {
  font: inherit;
}

.swm-app h1,
.swm-app h2,
.swm-app .swm-writing-toolbar label,
.swm-app .swm-review-heading h2,
.swm-app .swm-checklist h3,
.swm-app .swm-story-preview h3 {
  font-family: "Kalam", "Comic Sans MS", cursive;
  font-weight: 700;
}

.swm-app button:focus-visible,
.swm-app textarea:focus-visible,
.swm-app summary:focus-visible,
.swm-app input:focus-visible {
  outline: 3px solid rgba(67, 145, 89, 0.42);
  outline-offset: 2px;
}

.swm-welcome[hidden],
.swm-game[aria-hidden="true"] {
  display: none !important;
}

/* Welcome */
.swm-welcome {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: clamp(16px, 4vw, 50px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(15, 45, 23, 0.78), rgba(19, 55, 30, 0.34) 58%, rgba(19, 55, 30, 0.08)),
    url("scene-1-arrival.jpg") center / cover no-repeat;
}

.swm-welcome-card {
  width: min(720px, 100%);
  margin-right: auto;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 80px rgba(10, 35, 18, 0.3);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.swm-welcome h1 {
  max-width: 15ch;
  margin: 0;
  font-size: clamp(2.8rem, 6.5vw, 5.8rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.swm-welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(24px, 4vw, 40px);
}

/* One-viewport activity */
.swm-game {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(6px, 0.65vw, 10px);
  width: min(100%, 1760px);
  height: 100%;
  margin-inline: auto;
  padding: clamp(6px, 0.7vw, 11px);
  overflow: hidden;
}

.swm-utility-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 6px 13px;
  border: 1px solid var(--swm-line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 20px rgba(24, 59, 32, 0.08);
}

.swm-brand h1 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.45rem, 2.1vw, 2rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swm-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--swm-copy);
  font-size: clamp(0.76rem, 0.85vw, 0.9rem);
  white-space: nowrap;
}

.swm-status strong {
  color: var(--swm-green-dark);
}

.swm-status span + span::before,
.swm-status strong + span::before {
  content: "•";
  margin-right: 9px;
  color: #8bac91;
}

.swm-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid rgba(47, 107, 67, 0.22);
  border-radius: 11px;
  color: #fff;
  background: var(--swm-green-dark);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 800;
}

.swm-fullscreen-icon {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.swm-scene-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(4px, 0.5vw, 8px);
  min-height: 62px;
}

.swm-scene-tab {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 62px;
  padding: 7px 10px;
  border: 1px solid var(--swm-line);
  border-radius: 14px;
  color: var(--swm-ink);
  background: rgba(255, 255, 255, 0.84);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.swm-scene-tab:hover {
  border-color: rgba(52, 116, 68, 0.4);
  transform: translateY(-1px);
}

.swm-scene-tab.is-active {
  border-color: rgba(52, 116, 68, 0.48);
  background: linear-gradient(135deg, #e6f6e2, #e5f5f3);
  box-shadow: inset 0 -5px 0 #59a868;
}

.swm-tab-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--swm-green-dark);
  background: #e3f2df;
  font-size: 0.95rem;
  font-weight: 900;
}

.swm-tab-label {
  min-width: 0;
  font-size: clamp(0.74rem, 0.92vw, 0.93rem);
  font-weight: 800;
  line-height: 1.15;
}

.swm-tab-tick {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--swm-green);
  font-size: 0.72rem;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 150ms ease, transform 150ms ease;
}

.swm-scene-tab.is-complete .swm-tab-tick {
  opacity: 1;
  transform: scale(1);
}

.swm-stage {
  min-height: 0;
  overflow: hidden;
}

.swm-scene,
.swm-completion,
.swm-finished {
  display: none;
  height: 100%;
  min-height: 0;
}

.swm-scene.is-active,
.swm-completion.is-active,
.swm-finished.is-active {
  display: block;
}

.swm-scene-layout {
  display: grid;
  grid-template-columns: minmax(0, 59%) minmax(300px, 41%);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "left writing"
    "support support";
  gap: 9px 12px;
  height: 100%;
  min-height: 0;
}

.swm-scene-left {
  grid-area: left;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.swm-scene-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.72fr);
  grid-template-areas:
    "heading focus"
    "prompt prompt";
  gap: 6px 12px;
  padding: 10px 13px 11px;
  border: 1px solid var(--swm-line);
  border-radius: var(--swm-radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(24, 59, 32, 0.08);
}

.swm-scene-heading {
  grid-area: heading;
  min-width: 0;
}

.swm-scene-number {
  display: block;
  margin-bottom: 1px;
  color: var(--swm-green-dark);
  font-size: clamp(0.78rem, 0.9vw, 0.94rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.swm-scene-heading h2,
.swm-review-heading h2 {
  margin: 0;
  font-size: clamp(1.75rem, 2.6vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.swm-focus {
  grid-area: focus;
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid rgba(54, 126, 73, 0.28);
  border-radius: 14px;
  color: #245e38;
  background: linear-gradient(135deg, #e9f7e5, #f3faee);
}

.swm-focus span {
  font-size: clamp(0.78rem, 0.9vw, 0.95rem);
  font-weight: 950;
  letter-spacing: 0.14em;
}

.swm-focus strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 1.4vw, 1.42rem);
  line-height: 1.18;
}

.swm-prompt-panel {
  grid-area: prompt;
  min-width: 0;
  padding-top: 3px;
  border-top: 1px solid rgba(47, 100, 59, 0.12);
}

.swm-prompt-panel h3 {
  margin: 4px 0 1px;
  color: var(--swm-green-dark);
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(0.8rem, 0.92vw, 0.98rem);
  font-weight: 950;
  letter-spacing: 0.12em;
}

.swm-prompt-copy {
  color: #263d2c;
  font-size: clamp(1.02rem, 1.27vw, 1.32rem);
  line-height: 1.38;
}

.swm-prompt-copy p {
  display: inline;
  margin: 0;
}

.swm-prompt-copy p + p::before {
  content: " ";
}

.swm-visual-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  margin: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--swm-line);
  border-radius: var(--swm-radius);
  background: #1c3825;
  box-shadow: var(--swm-shadow);
}

.swm-visual-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #1c3825;
}

.swm-scene-video,
.swm-completion-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1c3825;
}

.swm-writing-panel {
  grid-area: writing;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(47, 100, 59, 0.2);
  border-radius: var(--swm-radius);
  background: #fffefb;
  box-shadow: var(--swm-shadow);
}

.swm-writing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding: 10px 15px 8px;
  border-bottom: 1px solid rgba(47, 100, 59, 0.14);
  color: var(--swm-copy);
  background: #f5faf2;
}

.swm-writing-toolbar label {
  color: var(--swm-ink);
  font-size: clamp(1.45rem, 2vw, 2.15rem);
  line-height: 1.05;
}

.swm-word-count {
  flex: 0 0 auto;
  font-size: 0.9rem;
  white-space: nowrap;
}

.swm-story-text {
  display: block;
  width: 100%;
  min-height: 0;
  resize: none;
  padding: clamp(14px, 1.5vw, 21px);
  border: 0;
  outline: 0;
  color: #203727;
  background: #fffefb;
  font-size: clamp(1.05rem, 1.25vw, 1.28rem);
  line-height: 1.62;
}

.swm-story-text::placeholder {
  color: #8fa096;
}

.swm-writing-message {
  min-height: 1.4em;
  margin: 0;
  padding: 3px 14px 7px;
  color: #9b3c35;
  background: #fffaf7;
  font-size: 0.9rem;
  font-weight: 800;
}

/* STUCK support sits beneath both scene columns. */
.swm-support {
  position: relative;
  z-index: 40;
  grid-area: support;
  min-width: 0;
}

.swm-support summary {
  display: flex;
  width: 50%;
  min-height: 52px;
  margin-left: 50%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 15px;
  border: 2px solid rgba(55, 119, 71, 0.26);
  border-radius: 14px;
  color: #285f3b;
  background: #edf8e9;
  cursor: pointer;
  font-size: clamp(1.13rem, 1.5vw, 1.52rem);
  font-weight: 900;
  list-style: none;
}

.swm-support summary::-webkit-details-marker {
  display: none;
}

.swm-support summary::after {
  content: "+";
  font-size: 1.5em;
  line-height: 1;
}

.swm-support[open] summary::after {
  content: "–";
}

.swm-support-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 100;
  width: min(920px, 67%);
  max-height: min(440px, 54vh);
  padding: 13px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--swm-line);
  border-radius: 15px;
  background: #fffefa;
  box-shadow: 0 20px 54px rgba(22, 54, 29, 0.28);
}

.swm-choice-list,
.swm-starter-list {
  display: grid;
  gap: 7px;
}

.swm-opening-choice,
.swm-insert-starter {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(55, 105, 66, 0.2);
  border-radius: 11px;
  color: var(--swm-ink);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: clamp(0.94rem, 1.04vw, 1.08rem);
}

.swm-opening-choice:hover,
.swm-insert-starter:hover,
.swm-opening-choice.is-selected {
  border-color: rgba(67, 139, 84, 0.5);
  background: #f0f8ed;
}

.swm-opening-choice.is-best {
  border-color: #52a765;
  background: #e8f6e4;
}

.swm-opening-choice strong {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  background: #e6f3e2;
}

.swm-insert-starter {
  grid-template-columns: minmax(0, 1fr) auto;
}

.swm-insert-starter small {
  color: var(--swm-green-dark);
  font-size: 0.82em;
  font-weight: 900;
}

.swm-choice-feedback {
  min-height: 1.5em;
  margin: 9px 2px;
  color: var(--swm-green-dark);
  font-size: 0.98rem;
  font-weight: 800;
}

.swm-insert-choice {
  margin-left: auto;
}

/* Actions */
.swm-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
}

.swm-review-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.swm-review-actions[hidden] {
  display: none;
}

.swm-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 850;
  text-align: center;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.swm-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.swm-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.swm-button-primary {
  color: #fff;
  background: linear-gradient(135deg, #347849, #59a768);
  box-shadow: 0 7px 18px rgba(47, 107, 67, 0.2);
}

.swm-button-secondary {
  border-color: var(--swm-line);
  color: var(--swm-ink);
  background: rgba(255, 255, 255, 0.94);
}

.swm-button-quiet {
  border-color: rgba(47, 100, 59, 0.17);
  color: #315d3c;
  background: rgba(255, 255, 255, 0.82);
}

.swm-button-danger {
  border-color: rgba(144, 61, 57, 0.22);
  color: #873e3a;
  background: #fff5f3;
}

/* Completion video */
.swm-completion-card {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--swm-line);
  border-radius: var(--swm-radius);
  background: #1c3825;
  box-shadow: var(--swm-shadow);
}

.swm-completion-video {
  position: absolute;
  inset: 0;
}

#swm-completion-continue {
  position: relative;
  z-index: 2;
  align-self: end;
  margin-bottom: 20px;
}

/* Finished-story review */
.swm-finished {
  padding: clamp(14px, 1.6vw, 23px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--swm-line);
  border-radius: var(--swm-radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--swm-shadow);
}

.swm-review-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 13px;
}

.swm-review-heading > p {
  max-width: 52ch;
  margin: 0;
  color: var(--swm-copy);
  font-size: 0.95rem;
}

.swm-review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 29%);
  gap: 13px;
  align-items: start;
}

.swm-story-preview {
  display: grid;
  gap: 9px;
}

.swm-story-preview article {
  padding: 11px 13px;
  border: 1px solid rgba(47, 100, 59, 0.14);
  border-radius: 11px;
  background: #fffefa;
}

.swm-story-preview article header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.swm-story-preview h3 {
  margin: 0;
  color: var(--swm-green-dark);
  font-size: 1.2rem;
}

.swm-story-preview p {
  margin: 5px 0 0;
  color: #2b4030;
  font-size: 1rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.swm-story-preview p.is-empty {
  color: #8b9c90;
  font-style: italic;
}

.swm-edit-scene {
  padding: 5px 9px;
  border: 1px solid rgba(47, 100, 59, 0.2);
  border-radius: 8px;
  color: var(--swm-green-dark);
  background: #edf7e9;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
}

.swm-checklist {
  position: sticky;
  top: 0;
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid rgba(47, 100, 59, 0.18);
  border-radius: 13px;
  background: #eff8ec;
}

.swm-checklist h3 {
  margin: 0 0 2px;
  font-size: 1.45rem;
}

.swm-checklist label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #334a38;
  font-size: 0.9rem;
}

.swm-checklist input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--swm-green-dark);
}

.swm-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 999999;
  max-width: min(92vw, 560px);
  padding: 11px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(22, 53, 29, 0.95);
  box-shadow: 0 12px 30px rgba(10, 28, 14, 0.28);
  font-size: 0.9rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.swm-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Short desktop and tablet landscape */
@media (min-width: 641px) and (max-height: 760px) {
  .swm-game { gap: 5px; padding: 5px; }
  .swm-utility-bar { min-height: 43px; padding-block: 4px; }
  .swm-brand h1 { font-size: 1.42rem; }
  .swm-scene-nav { min-height: 49px; gap: 5px; }
  .swm-scene-tab { min-height: 49px; padding: 4px 7px; }
  .swm-tab-number { width: 27px; height: 27px; }
  .swm-scene-layout { gap: 5px 8px; }
  .swm-scene-left { gap: 5px; }
  .swm-scene-brief { gap: 3px 8px; padding: 6px 9px 7px; }
  .swm-scene-heading h2 { font-size: clamp(1.5rem, 2.2vw, 2.15rem); }
  .swm-focus { padding: 5px 8px; }
  .swm-focus strong { font-size: clamp(0.94rem, 1.18vw, 1.12rem); }
  .swm-prompt-copy { font-size: clamp(0.91rem, 1.08vw, 1.08rem); line-height: 1.3; }
  .swm-writing-toolbar { min-height: 52px; padding: 7px 11px 5px; }
  .swm-writing-toolbar label { font-size: clamp(1.25rem, 1.7vw, 1.75rem); }
  .swm-story-text { padding: 11px 14px; font-size: 1rem; }
  .swm-writing-message { font-size: 0.78rem; }
  .swm-support summary { min-height: 44px; padding-block: 6px; font-size: clamp(1rem, 1.25vw, 1.2rem); }
  .swm-actions { min-height: 42px; }
  .swm-button { min-height: 36px; padding-block: 6px; }
}

/* Compact widths retain one viewport with stacked scene and writing areas. */
@media (max-width: 640px) {
  .swm-welcome {
    align-items: end;
    padding: 12px;
  }

  .swm-welcome-card {
    margin: 0;
    padding: 24px;
    border-radius: 22px;
  }

  .swm-welcome h1 {
    font-size: clamp(2.55rem, 14vw, 4rem);
  }

  .swm-welcome-actions {
    display: grid;
  }

  .swm-welcome-actions .swm-button {
    width: 100%;
  }

  .swm-game {
    gap: 4px;
    padding: 4px;
  }

  .swm-utility-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
    min-height: 45px;
    padding: 4px 7px;
  }

  .swm-brand h1 {
    font-size: 1.1rem;
  }

  .swm-status {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
    width: 100%;
    font-size: 0.68rem;
  }

  .swm-status #swm-save-state-global {
    display: none;
  }

  .swm-status span + span::before,
  .swm-status strong + span::before {
    display: none;
  }

  .swm-icon-button {
    grid-column: 2;
    grid-row: 1;
    min-height: 31px;
    padding: 4px 7px;
  }

  .swm-fullscreen-label {
    display: none;
  }

  .swm-scene-nav {
    gap: 3px;
    min-height: 42px;
  }

  .swm-scene-tab {
    display: grid;
    min-height: 42px;
    place-items: center;
    padding: 2px;
  }

  .swm-tab-number {
    width: 28px;
    height: 28px;
    font-size: 0.82rem;
  }

  .swm-tab-label {
    display: none;
  }

  .swm-tab-tick {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    font-size: 0.52rem;
  }

  .swm-scene-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 3fr) minmax(0, 2fr) auto;
    grid-template-areas:
      "left"
      "writing"
      "support";
    gap: 4px;
  }

  .swm-scene-left {
    gap: 4px;
  }

  .swm-scene-brief {
    grid-template-columns: minmax(0, 1fr) minmax(118px, 0.72fr);
    gap: 3px 6px;
    padding: 5px 7px 6px;
    border-radius: 12px;
  }

  .swm-scene-number {
    font-size: 0.62rem;
  }

  .swm-scene-heading h2 {
    font-size: clamp(1.35rem, 6vw, 1.72rem);
  }

  .swm-focus {
    padding: 4px 6px;
    border-width: 1px;
    border-radius: 9px;
  }

  .swm-focus span {
    font-size: 0.58rem;
  }

  .swm-focus strong {
    font-size: clamp(0.76rem, 3.2vw, 0.91rem);
  }

  .swm-prompt-panel h3 {
    margin-top: 2px;
    font-size: 0.62rem;
  }

  .swm-prompt-copy {
    font-size: clamp(0.78rem, 3.25vw, 0.94rem);
    line-height: 1.25;
  }

  .swm-visual-panel,
  .swm-writing-panel {
    border-radius: 12px;
  }

  .swm-writing-toolbar {
    min-height: 42px;
    padding: 5px 8px 3px;
  }

  .swm-writing-toolbar label {
    font-size: clamp(1.1rem, 5vw, 1.4rem);
  }

  .swm-word-count {
    font-size: 0.68rem;
  }

  .swm-story-text {
    padding: 8px 10px;
    font-size: 0.9rem;
    line-height: 1.42;
  }

  .swm-writing-message {
    padding: 1px 9px 3px;
    font-size: 0.7rem;
  }

  .swm-support summary {
    width: 100%;
    min-height: 42px;
    margin-left: 0;
    padding: 6px 9px;
    border-radius: 11px;
    font-size: clamp(0.92rem, 4.2vw, 1.1rem);
  }

  .swm-support-popover {
    position: fixed;
    right: 6px;
    bottom: 54px;
    left: 6px;
    width: auto;
    max-height: 54vh;
    padding: 9px;
  }

  .swm-opening-choice,
  .swm-insert-starter {
    padding: 8px 9px;
    font-size: 0.86rem;
  }

  .swm-actions {
    gap: 5px;
    min-height: 42px;
  }

  .swm-button {
    min-height: 37px;
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .swm-app.is-reviewing .swm-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  }

  .swm-app.is-reviewing .swm-review-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .swm-app.is-reviewing #swm-prev {
    grid-column: 1;
    grid-row: 2;
  }

  .swm-app.is-reviewing #swm-next {
    grid-column: 2;
    grid-row: 2;
  }

  .swm-review-heading {
    display: block;
  }

  .swm-review-heading > p {
    margin-top: 6px;
  }

  .swm-review-grid {
    grid-template-columns: 1fr;
  }

  .swm-checklist {
    position: static;
  }
}

@media (max-width: 640px) and (max-height: 700px) and (orientation: portrait) {
  .swm-utility-bar {
    min-height: 39px;
  }

  .swm-status {
    display: none;
  }

  .swm-scene-layout {
    grid-template-rows: minmax(0, 7fr) minmax(0, 3fr) auto;
  }

  .swm-writing-toolbar {
    min-height: 37px;
  }

  .swm-writing-toolbar label {
    font-size: 1.05rem;
  }

  .swm-story-text {
    padding-block: 6px;
  }
}

/* Very short phone landscape returns to two columns. */
@media (max-width: 640px) and (orientation: landscape) {
  .swm-scene-layout {
    grid-template-columns: minmax(0, 58%) minmax(0, 42%);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "left writing"
      "support support";
  }

  .swm-scene-brief {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 0.62fr);
  }

  .swm-writing-toolbar label {
    font-size: 1.05rem;
  }

  .swm-support summary {
    width: 50%;
    margin-left: 50%;
  }
}

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

@media print {
  body.swm-printing > *:not(.swm-app),
  body.swm-printing .swm-welcome,
  body.swm-printing .swm-utility-bar,
  body.swm-printing .swm-scene-nav,
  body.swm-printing .swm-scene,
  body.swm-printing .swm-completion,
  body.swm-printing .swm-actions,
  body.swm-printing .swm-checklist,
  body.swm-printing .swm-toast {
    display: none !important;
  }

  body.swm-printing .swm-app,
  body.swm-printing .swm-game,
  body.swm-printing .swm-stage,
  body.swm-printing .swm-finished {
    position: static !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  body.swm-printing .swm-review-grid {
    display: block;
  }

  body.swm-printing .swm-story-preview article {
    break-inside: avoid;
    border: 0;
    padding: 8px 0;
  }

  body.swm-printing .swm-edit-scene {
    display: none;
  }
}
