@media screen {
  .world-tool {
    --tool-accent: #24654f;
    --tool-wash: #e1eee2;
    --tool-edge: #c5d4c6;
  }
  .world-tool[data-world='dino'] {
    --tool-accent: #815123;
    --tool-wash: #f4e8d5;
    --tool-edge: #ddcdb5;
  }
  .world-tool[data-world='space'] {
    --tool-accent: #484586;
    --tool-wash: #eae9f6;
    --tool-edge: #cecee0;
  }
  .world-tool .page-head { padding: clamp(24px, 4vw, 52px) 0 24px; }
  .world-tool .page-head h1 { font-size: clamp(2.25rem, 5.5vw, 4.35rem); margin: 0; }
  .world-tool .page-head p { max-width: 57ch; margin: 12px 0 0; }
  .world-tool .tool-grid,
  .world-tool .print-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(276px, 1fr);
    align-items: start;
    gap: clamp(16px, 2.4vw, 28px);
  }
  .world-tool .scan-panel,
  .world-tool .print-tools {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(20px, 3vw, 32px);
    border-radius: 20px;
  }
  .world-tool .scan-panel h2,
  .world-tool .print-tools label { margin: 0 0 12px; font-size: 1.4rem; line-height: 1.25; }
  .world-tool .pill { min-height: 46px; font-size: 1rem; }
  .world-tool .pill.dark {
    color: #fff;
    background: var(--tool-accent);
    border-color: var(--tool-accent);
  }
  .world-tool .pill.dark:hover { filter: brightness(.91); }
  .world-tool .capture-actions,
  .world-tool .camera-actions { gap: 8px; }
  .world-tool .camera-actions:has(> [hidden]:only-child),
  .world-tool .camera-actions:not(:has(> :not([hidden]))) { display: none; }
  .scanner-window {
    display: grid;
    place-items: center;
    overflow: hidden;
    min-height: 160px;
    margin-top: 18px;
    border: 1px solid var(--tool-edge);
    border-radius: 13px;
    background-color: var(--tool-wash);
  }
  #sheet-guide { padding: 18px; width: min(246px, 66%); transform: rotate(-4deg); }
  #sheet-guide > svg {
    display: block;
    width: 100%;
    height: auto;
    box-shadow: 0 5px 14px #26312e29;
  }
  .world-tool #camera-view { margin: 0; border-radius: 0; width: 100%; background: #111815; }
  .world-tool .tool-message { font-weight: 600; font-size: .95rem; color: var(--ink); }
  .world-tool .tool-message:empty { display: none; }
  .world-tool .tool-message[data-state='error'],
  .world-tool #code-error { color: #923621; }
  .world-tool .tool-message[data-state='success'] { color: #276043; }
  .world-tool #result { margin-top: 16px; }
  .world-tool #result h3 { margin: 0; font-size: 1.2rem; }
  .world-tool #result canvas { background: var(--tool-wash); }
  .world-tool .room-card { background: #fffcf5; }
  .world-tool .room-card details {
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .world-tool summary { font-weight: 700; cursor: pointer; }
  .world-tool #join-form { display: block; margin: 16px 0 2px; }
  .world-tool #join-form label { font-weight: 700; }
  .world-tool .field-hint { margin: 2px 0 8px; color: #4b5952; font-size: .9rem; }
  .join-row { display: flex; flex-wrap: wrap; gap: 8px; }
  .join-row .code-input { flex: 1 1 7.8em; min-width: 0; letter-spacing: .07em; font-family: monospace; }
  .code-input[aria-invalid='true'] { border-color: #923621; }
  .world-tool .room-tools { gap: 8px; }
  .room-tools #room-link { flex-basis: 100%; width: fit-content; margin-bottom: 5px; }
  .text-action { padding: 8px 0; border: 0; background: none; text-decoration: underline; text-underline-offset: 4px; }
  .world-tool .print-tools { grid-column: 2; grid-row: 1; }
  .print-tools #kind { display: block; width: 100%; min-height: 48px; font-weight: 650; }
  .print-tools #print { width: 100%; margin-top: 12px; }
  .file-links { display: grid; justify-items: start; margin: 13px 0; }
  .file-links a { display: inline-flex; align-items: center; min-height: 42px; }
  .print-tools .next-step { padding-top: 16px; border-top: 1px solid var(--line); margin: 0; }
  .world-tool .sheet { grid-column: 1; grid-row: 1; width: 100%; margin: 0; border: 1px solid var(--line); }
  /* Keep the nested artwork in the print SVG at its authored 640 × 420 size. */
  .world-tool .sheet svg svg { width: 640px; height: 420px; }
  @media (max-width: 720px) {
    .world-tool .tool-grid,
    .world-tool .print-layout { grid-template-columns: minmax(0, 1fr); }
    .world-tool .print-tools,
    .world-tool .sheet { grid-column: auto; grid-row: auto; }
    .world-tool .mast nav { gap: 12px; }
    .world-tool .mast nav a { font-size: .9rem; }
  }
  @media (max-width: 420px) {
    .world-tool .wrap { width: calc(100% - 28px); }
    .world-tool .scan-panel, .world-tool .print-tools { padding: 16px; }
    .world-tool .capture-actions .pill { flex: 1 1 8rem; padding-inline: 8px; }
    .world-tool .scanner-window { min-height: 126px; }
    #sheet-guide { width: min(180px, 68%); padding: 12px; }
  }
}
@media print {
  .world-tool .print-layout { display: block; }
  .world-tool .sheet svg svg { width: 640px; height: 420px; max-height: none; }
}
