.grammar-game { width: min(1800px, calc(100% - 40px)); padding-top: 12px; }
.grammar-game [hidden] { display: none !important; }
.game-small-label { display: none; }
.game-heading { margin-bottom: 12px; }
.game-heading h2 { margin: 0; }
.game-layout { display: grid; grid-template-columns: clamp(270px, 23vw, 330px) minmax(0, 1fr); gap: 16px; height: calc(100dvh - var(--game-heading-height, 50px) - 64px); min-height: 480px; }
.game-targets, .game-editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid #d6e0e7; border-radius: 14px; overflow: hidden; }
.game-targets { background: #fff; }
.game-editor { background: #122b3a; color: #f5f9fc; border-color: #304c60; }
.game-panel-heading { flex-shrink: 0; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-panel-heading h3 { margin: 0; font-size: 23px; }
.game-panel-heading p { margin: 0; font-size: 17px; line-height: 1.4; }
.game-targets .game-panel-heading { flex-wrap: wrap; }
.game-stage { color: #42617a; font-size: 16px !important; margin-bottom: 4px !important; }
.game-score { white-space: nowrap; font-size: 22px; font-weight: 700; color: #24506d; background: #eaf3fa; border-radius: 24px; padding: 6px 12px; }
.game-score.is-complete { color: #126248; background: #e4f6ed; }
.game-size { color: #bed1df; white-space: nowrap; font-size: 15px; }
.game-progress { height: 4px; flex-shrink: 0; background: #e7eef2; }
.game-progress span { display: block; height: 100%; background: #258568; transition: width 180ms ease; }
.game-mission { padding: 12px 14px 4px; margin: 0; font-size: 18px; line-height: 1.5; color: #39566c; }
.game-filters { display: flex; flex-shrink: 0; padding: 8px 10px 4px; gap: 3px; }
.game-filters button { flex: 1; padding: 5px; color: #426078; font-size: 16px; border: 1px solid transparent; border-radius: 6px; background: #fff; }
.game-filters button[aria-pressed="true"] { color: #174f78; background: #eaf3fa; border-color: #cbdde9; }
.game-filters button span { margin-left: 3px; font-weight: 700; }
.game-filters button:disabled { opacity: .5; cursor: default; }
.game-target-list { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 14px; scrollbar-width: thin; overscroll-behavior: contain; }
.game-target-list h4 { font-size: 16px; color: #526b7c; font-weight: 600; margin: 16px 4px 6px; }
.game-target { display: block; width: 100%; padding: 12px; margin: 6px 0; text-align: left; color: #122a3c; border: 1px solid #dce5eb; border-left: 4px solid #b5c7d5; background: #fff; border-radius: 8px; line-height: 1.45; }
.game-target:hover, .game-target:focus-visible { background: #f2f8fc; border-color: #78a7c6; }
.game-target.covered { border-left-color: #278566; }
.game-target.missed { border-left-color: #b86335; }
.game-target-top { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; font-size: 20px; font-weight: 650; }
.game-target-status { font-size: 16px; color: #5a7183; }
.covered .game-target-status { color: #147253; }
.missed .game-target-status { color: #9f4d23; }
.game-formula { display: block; font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 28px; line-height: 1.65; margin-top: 4px; overflow-wrap: anywhere; }
.game-formula sub { font-size: .68em; }
.game-target-kind { display: inline-block; margin-top: 4px; color: #766237; font-size: 15px; }
.game-empty { font-size: 18px; color: #526477; }
.game-hidden-targets { padding: 16px; border-top: 1px dashed #c7d6e0; background: #f4f8fb; font-size: 19px; color: #426078; }
.game-reward { flex-shrink: 0; padding: 14px; background: #edf9f2; border-top: 1px solid #bcdccc; color: #154c39; font-size: 18px; }
.game-celebration { display: inline-block; font-size: 30px; animation: game-celebrate .5s ease-in-out 2 alternate; }
.game-reward strong { display: block; font-size: 22px; }
.game-reward p { margin: 6px 0 12px; line-height: 1.4; }
.game-reward button { width: 100%; padding: 10px; border-radius: 7px; border: 0; background: #17684e; color: #fff; font-size: 18px; font-weight: 650; }
.game-instructions { flex: 1; color: #d1e0eb; }
.game-palette { flex-shrink: 0; padding: 0 12px 10px; }
.game-palette-row + .game-palette-row { margin-top: 6px; }
.game-palette-row > div { display: flex; flex-wrap: wrap; gap: 6px; }
.game-palette button { display: flex; gap: 6px; align-items: center; padding: 6px 9px; border: 1px solid #779eb9; border-radius: 7px; background: #fff; color: #000; cursor: grab; font-size: 18px; line-height: 1.2; }
.game-palette button strong { min-width: 22px; font-family: Georgia, serif; font-size: 30px; font-weight: 600; line-height: 1; color: #000; }
.game-palette button:hover { background: #fff; border-color: #aad7f4; box-shadow: 0 0 0 2px #aad7f4; }
.game-canvas-tools { display: flex; flex-shrink: 0; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 12px; border-top: 1px solid #365265; }
.game-tool-group { display: flex; align-items: center; gap: 4px; }
.game-tool-group button { border: 1px solid #587488; background: #1c3a4e; color: #ecf5fb; font-size: 17px; padding: 4px 9px; border-radius: 5px; }
.game-tool-group button:disabled { opacity: .4; cursor: default; }
#game-zoom-label { min-width: 44px; text-align: center; font-size: 16px; color: #d2e1ec; }
.game-workspace { flex: 1; min-height: 0; position: relative; display: flex; }
.game-viewport { flex: 1; min-height: 0; overflow: auto; position: relative; background-color: #0b202e; background-image: radial-gradient(#294453 1px, transparent 1px); background-size: 20px 20px; border-block: 1px solid #365265; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #56748a #0b202e; }
.game-canvas { position: relative; transform-origin: top left; }
#game-canvas-size { position: relative; overflow: hidden; }
#game-edges { position: absolute; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#game-edge-paths path { stroke: #a3cde7; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; fill: none; }
#game-edge-paths .game-missing-edge { stroke-dasharray: 7 5; }
#game-arrow path { fill: #a3cde7; }
#game-connection-preview { stroke: #ffe0a0; stroke-width: 3; stroke-dasharray: 6 4; fill: none; }
.game-node { width: 216px; min-height: 76px; position: absolute; border: 2px solid #779eb9; background: #fff; border-radius: 10px; padding: 0 10px 28px; color: #000; box-shadow: 0 4px 12px #0003; }
.game-node:focus-visible, .game-node.is-selected { outline: 3px solid #b4ddfa; outline-offset: 4px; }
.game-node-root { border-color: #b0defa; }
.game-node-signal { min-height: 60px; padding-bottom: 4px; }
.game-node-handle { cursor: grab; touch-action: none; min-height: 46px; display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 0; user-select: none; }
.game-node-handle:active { cursor: grabbing; }
.game-node-handle strong { font-family: Georgia, serif; font-size: 34px; line-height: 1; font-weight: 500; color: #000; }
.game-node-handle span { font-size: 21px; font-weight: 650; line-height: 1.25; }
.game-node-delete { position: absolute; top: 0; right: 1px; border: 0; background: transparent; color: #000; width: 26px; height: 28px; padding: 0; font-size: 23px; border-radius: 5px; }
.game-node-delete:hover { background: #f4ddd5; }
.game-output, .game-input { position: absolute; border: 2px solid #779eb9; background: #fff; border-radius: 50%; width: 24px; height: 24px; padding: 0; touch-action: none; z-index: 2; }
.game-output::after, .game-input::after { content: ""; position: absolute; inset: -7px; }
.game-input { top: -12px; left: calc(50% - 12px); }
.game-output { bottom: -12px; transform: translateX(-50%); }
.game-output span { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 17px; line-height: 1; color: #000; font-weight: 500; }
.game-output.is-pending { background: #e8b85e; box-shadow: 0 0 0 4px #e8b85e40; }
.game-gap { position: absolute; display: flex; align-items: center; gap: 12px; width: 216px; min-height: 88px; padding: 12px 16px; border: 2px dashed #d7ba7c; border-radius: 10px; color: #000; background: #fff; font-size: 21px; text-align: left; }
.game-gap strong { font-family: Georgia, serif; font-size: 38px; }
.game-gap:hover, .game-gap.is-pending { border-style: solid; outline: 3px solid #ffe3a8; outline-offset: 3px; }
.game-scope { display: block; margin-bottom: 7px; }
.game-scope select { width: 100%; font: inherit; font-size: 18px; color: #000; border: 1px solid #779eb9; padding: 5px; border-radius: 4px; background: #fff; }
.game-help-dock { display: flex; flex-shrink: 0; flex-wrap: wrap; gap: 6px; padding: 9px 12px; border-bottom: 1px solid #365265; }
.game-help-dock button { padding: 7px 10px; border: 1px solid #587488; border-radius: 6px; background: #1c3a4e; color: #f1f8fc; font-size: 17px; line-height: 1.25; }
.game-help-dock button:hover, .game-help-dock button[aria-expanded="true"] { background: #f7f3e9; color: #203548; border-color: #f7f3e9; }
.game-help-dock [data-solution] { border-color: #8ab4cc; }
.game-help-dock [data-solution="flexible"] { margin-left: auto; }
.game-note { position: absolute; z-index: 6; left: 12px; right: 12px; bottom: 12px; max-height: calc(100% - 24px); overflow: auto; padding: 20px 24px; border: 1px solid #decfae; border-radius: 10px; background: #fffbf2; box-shadow: 0 8px 32px #0005; color: #193347; font-size: 19px; line-height: 1.5; overscroll-behavior: contain; }
.game-note h3 { font-size: 24px; margin: 0 40px 14px 0; }
.game-note p { margin: 12px 0 0; }
.game-note-close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 1px solid #d7c9ad; border-radius: 6px; background: #fff; color: #193347; font-size: 28px; line-height: 1; }
.game-symbols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin: 0; }
.game-symbols > div { display: flex; align-items: baseline; gap: 10px; }
.game-symbols dt { font-family: Georgia, serif; flex: 0 0 48px; font-size: 29px; color: #1b577a; }
.game-symbols dd { margin: 0; font-size: 18px; line-height: 1.4; }
.game-palette [data-kind="zero"] strong, .game-node[data-node-kind="zero"] strong, .game-symbols [data-symbol="zero"] { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: slashed-zero; }
.game-actions { display: flex; flex-shrink: 0; align-items: center; gap: 12px; padding: 9px 12px; min-height: 68px; }
.game-check { padding: 10px 18px; border: 1px solid #c4e6fb; border-radius: 7px; background: #b5def7; color: #112f43; font-size: 22px; font-weight: 700; white-space: nowrap; }
.game-check:hover { background: #dbf0ff; }
.game-feedback { padding-right: 40px; margin: 0; min-width: 0; max-height: 58px; overflow: auto; color: #e5eff6; font-size: 18px; line-height: 1.4; overscroll-behavior: contain; }
.game-feedback.is-error { color: #ffccaf; }
.game-tooltip { position: fixed; z-index: 50; width: min(460px, calc(100vw - 24px)); background: #fffbf2; color: #193347; border: 1px solid #d8c9a8; border-radius: 9px; padding: 16px 18px; box-shadow: 0 6px 28px #0e293435; font-size: 19px; line-height: 1.5; }
.game-tooltip strong { font-size: 21px; }
.game-tooltip p { margin: 8px 0 0; }
.game-tooltip .game-tooltip-note { border-top: 1px solid #d8c9a8; padding-top: 9px; font-size: 17px; }
.game-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.grammar-game button:focus-visible, .grammar-game select:focus-visible, .game-viewport:focus-visible { outline: 3px solid #2a84b8; outline-offset: 3px; }
.game-editor button:focus-visible, .game-viewport:focus-visible { outline-color: #ffe3a8; }
.game-note button:focus-visible { outline-color: #2a84b8; }
@keyframes game-celebrate { from { transform: scale(1) rotate(-10deg); } to { transform: scale(1.25) rotate(10deg); } }
@media (max-width: 1350px) {
  .game-palette button span { display: none; }
  .game-palette button { min-width: 44px; justify-content: center; }
  #grammar-app[data-phase="intro"] .game-palette button span { display: inline; }
  .game-size { display: none; }
  .game-help-dock button { font-size: 16px; padding: 6px 8px; }
}
@media (max-width: 1050px) {
  .game-layout { grid-template-columns: 265px minmax(0, 1fr); gap: 12px; }
  .game-editor .game-panel-heading { flex-wrap: wrap; gap: 4px; }
  .game-instructions { flex-basis: 100%; }
  .game-help-dock { display: grid; grid-template-columns: 1fr 1fr; }
  .game-help-dock [data-solution="flexible"] { margin-left: 0; }
}
@media (max-width: 800px) {
  .grammar-game { width: calc(100% - 20px); }
  .game-heading h2 { font-size: 24px; }
  .game-layout { grid-template-columns: 1fr; grid-template-rows: 164px minmax(0, 1fr); gap: 10px; min-height: 520px; }
  .game-targets { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 42px 4px minmax(0, 1fr); border-radius: 10px; }
  .game-targets .game-panel-heading { grid-column: 1; padding: 4px 10px; flex-wrap: nowrap; }
  .game-stage, .game-mission { display: none; }
  .game-panel-heading h3 { font-size: 20px; }
  .game-score { font-size: 18px; padding: 2px 8px; }
  .game-filters { grid-column: 2; grid-row: 1; padding: 4px; }
  .game-filters button { padding: 2px; font-size: 14px; }
  .game-progress { grid-column: 1 / -1; grid-row: 2; }
  .game-target-list { grid-column: 1 / -1; display: flex; gap: 8px; padding: 6px 8px; }
  .game-target-list h4 { display: none; }
  .game-target { flex: 0 0 240px; margin: 0; padding: 5px 8px; }
  .game-target-top { gap: 1px; font-size: 17px; }
  .game-target-status { font-size: 14px; }
  .game-formula { margin: 0; font-size: 24px; line-height: 1.4; }
  .game-target-kind { display: none; }
  .game-hidden-targets { position: absolute; right: 4px; top: 41px; z-index: 1; padding: 3px 6px; font-size: 13px; border-radius: 4px; }
  .game-reward { position: absolute; inset: 0; z-index: 3; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; padding: 10px; }
  #grammar-app[data-phase="explore"] .game-reward { display: none; }
  .game-reward strong { align-self: center; }
  .game-reward p { grid-column: 1 / -1; margin: 0; font-size: 16px; }
  .game-reward button { grid-column: 1 / -1; padding: 7px; }
  .game-wide-label { display: none; }
  .game-small-label { display: inline; }
  .game-editor .game-panel-heading { padding: 7px 10px; }
  .game-editor .game-panel-heading h3 { display: none; }
  #grammar-app[data-phase="intro"] .game-target { flex-basis: calc((100% - 8px) / 2); min-width: 0; }
  #grammar-app[data-phase="intro"] .game-target-top { font-size: 14px; }
  #grammar-app[data-phase="intro"] .game-target-status { font-size: 12px; }
  #grammar-app[data-phase="intro"] .game-formula { font-size: 22px; }
  .game-node-handle span { font-size: 26px; }
  .game-node-handle strong { font-size: 38px; }
  .game-panel-heading p { font-size: 15px; }
  .game-palette { padding: 0 8px 7px; }
  .game-palette-row + .game-palette-row { margin-top: 4px; }
  .game-palette-row > div { gap: 4px; }
  .game-palette button { min-width: 37px; padding: 4px 6px; font-size: 15px; }
  .game-tool-group button { font-size: 15px; padding: 3px 6px; white-space: nowrap; }
  .game-help-dock { grid-template-columns: repeat(4, 1fr); padding: 6px 8px; gap: 4px; }
  .game-help-dock button { font-size: 14px; padding: 5px 2px; white-space: nowrap; }
  .game-actions { gap: 8px; padding: 7px 8px; min-height: 62px; }
  .game-check { font-size: 19px; padding: 8px 12px; }
  .game-feedback { font-size: 15px; max-height: 52px; }
  .game-note { padding: 16px; font-size: 17px; }
  .game-note h3 { font-size: 21px; }
  .game-symbols { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  #grammar-app[data-phase="intro"] .game-palette button span { display: none; }
  .game-canvas-tools { padding-inline: 6px; }
  .game-tool-group { gap: 3px; }
  .game-tool-group button { font-size: 14px; padding-inline: 4px; }
  #game-zoom-label { min-width: 36px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .game-progress span { transition: none; } .game-celebration { animation: none; } }
