* { box-sizing: border-box; }
.resource-toggle { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 16px 0 22px; border: 1px solid #b3c0ca; border-radius: 10px; background: #fff; }
.resource-toggle button { padding: 10px 18px; border: 0; border-radius: 7px; font: inherit; font-weight: 600; background: transparent; color: #18264e; cursor: pointer; }
.resource-toggle button[aria-pressed="true"] { background: #28644f; color: #fff; }
.resource-toggle button:focus-visible { outline: 3px solid #2873ae; outline-offset: 2px; }
#game-guide-dialog { width: min(820px, calc(100% - 24px)); }
.game-guide-body { flex: 1; min-height: 0; overflow: auto; padding: 20px; background: #edf1f3; }
#game-guide-preview { display: block; width: 100%; max-width: 660px; height: auto; margin: auto; box-shadow: 0 2px 10px #14274725; }
#download-game-guide { text-decoration: none; text-align: center; }
#game-guide-status { flex: 1; margin: 0; font-size: 14px; }
@media(max-width:540px) { #game-guide-dialog .dialog-footer { flex-wrap: wrap; } #game-guide-status { flex-basis: 100%; } .game-guide-body { padding: 10px; } }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; color: #18264e; background: #dce5eb url('site/teacher-resources-page-background.webp') center/cover fixed; }
main { width: calc(100% - 32px); max-width: 1200px; margin: 28px auto; padding: 28px; background: rgba(255,253,246,.98); border: 2px solid #d3b465; border-radius: 20px; box-shadow: 0 12px 40px #14274725; }
h1 { font-size: 38px; line-height: 1.2; margin: 22px 0 8px; }
p { color: #526178; margin: 0 0 24px; }
a { color: #253a8d; text-underline-offset: 3px; }
a:focus-visible, input:focus-visible + .choice { outline: 3px solid #2873ae; outline-offset: 3px; }
.options { display: grid; gap: 22px; padding: 22px; margin: 24px 0 16px; border: 1px solid #d7dfe8; border-radius: 14px; background: #fff; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-size: 18px; font-weight: 700; }
.choices { display: grid; gap: 10px; }
.content-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.option { position: relative; cursor: pointer; }
.option input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.choice { display: flex; height: 100%; gap: 10px; flex-direction: column; padding: 14px; border: 2px solid #d7dfe8; border-radius: 10px; }
.choice strong { font-size: 16px; }
.choice small { display: block; color: #526178; font-size: 14px; }
.option:hover .choice { border-color: #357b68; background: #f4faf7; }
input:checked + .choice { border-color: #357b68; background: #edf5f3; box-shadow: inset 0 0 0 1px #357b68; }
input:disabled + .choice { opacity: .6; cursor: wait; }
.layout-choices .choice { flex-direction: row; align-items: center; gap: 14px; }
.choice svg { width: 42px; height: 54px; flex-shrink: 0; fill: #fff; stroke: #357b68; stroke-width: 1.5; }
.choice svg .paper { stroke: #a7b6bf; }
.selection-summary { padding: 12px 0; margin: 0; color: #33465b; }
.print-note { font-size: 14px; margin: 0 0 20px; }
.games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.game { display: flex; flex-direction: column; overflow: hidden; background: #fff; border: 1px solid #d7dfe8; border-radius: 12px; text-decoration: none; color: #18264e; padding: 0; font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.game:focus-visible { outline: 3px solid #2873ae; outline-offset: 3px; }
.game:disabled { cursor: wait; opacity: .65; }
.game-caption > span:first-child { min-width: 0; }
.board-preview { display: block; width: 100%; height: auto; aspect-ratio: 1.414 / 1; object-fit: contain; padding: 8px; background: #fff; }
.games[data-layout="two"] .board-preview, .games[data-layout="four"] .board-preview { aspect-ratio: 1 / 1.414; }
.game-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid #e0e6e9; background: #edf5f3; flex: 1; }
.game strong { display: block; font-size: 17px; }
.game small { display: block; font-size: 14px; color: #526178; }
.pdf { flex-shrink: 0; color: #28644f; font-size: 14px; font-weight: 600; }
.game:hover .game-caption { background: #deeee7; }
#load-error { padding: 14px; background: #fff1de; border: 1px solid #d3b465; border-radius: 10px; color: #594316; }
[hidden] { display: none !important; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.dialog-open { overflow: hidden; }
.flashcard-print-frame { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; border: 0; pointer-events: none; }
dialog { width: min(1180px, calc(100% - 24px)); height: min(860px, calc(100dvh - 24px)); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 1px solid #d3b465; border-radius: 16px; background: #fffdf6; color: #18264e; box-shadow: 0 20px 80px #14274755; }
dialog::backdrop { background: #14274799; }
dialog[open] { display: flex; flex-direction: column; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: #fffdf6; flex-shrink: 0; }
.dialog-header { border-bottom: 1px solid #d7dfe8; }
.dialog-header h2 { font-size: 22px; margin: 0; }
.dialog-footer { border-top: 1px solid #d7dfe8; justify-content: flex-end; }
.dialog-footer #download-status { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; margin: 0; }
.dialog-body { flex: 1; min-height: 0; padding: 16px; display: grid; grid-template-columns: minmax(300px,360px) minmax(0,1fr); grid-template-rows: minmax(0,1fr); gap: 18px; overflow: hidden; }
.dialog-body > section:first-child { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
dialog .options { margin: 0; padding: 14px; gap: 16px; }
dialog legend { font-size: 16px; margin-bottom: 8px; }
dialog .choices { gap: 8px; }
dialog .content-choices { grid-template-columns: repeat(2,minmax(0,1fr)); }
dialog .choice { align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 10px 6px; }
dialog .choice strong { font-size: 14px; line-height: 1.3; }
dialog .content-icon { width: 84px; height: 50px; color: #357b68; fill: none; stroke: currentColor; stroke-width: 1.5; }
dialog .layout-choices { grid-template-columns: repeat(3,minmax(0,1fr)); }
dialog .layout-choices .choice { flex-direction: column; gap: 4px; padding: 8px 4px; }
dialog .layout-choices svg { width: 42px; height: 36px; }
dialog .selection-summary { padding: 0; margin: 0; font-size: 14px; line-height: 1.4; }
dialog .print-note { padding: 0; margin: 0; font-size: 14px; line-height: 1.4; }
.scramble-option { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 14px; line-height: 1.3; cursor: pointer; }
.scramble-option input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; accent-color: #357b68; }
.scramble-option input:focus-visible { outline: 3px solid #2873ae; outline-offset: 3px; }
.scramble-option span { color: #526178; }
.scramble-option:has(input:disabled) { opacity: .55; cursor: default; }
.preview-panel { min-width: 0; min-height: 0; padding: 12px; border: 1px solid #d7dfe8; border-radius: 12px; background: #edf1f3; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; }
.preview-heading h3 { margin: 0; font-size: 16px; }
#page-count { color: #526178; font-size: 14px; white-space: nowrap; }
.preview-viewport { flex: 1; min-height: 0; min-width: 0; position: relative; }
#dialog-preview { display: block; width: 100%; height: 100%; object-fit: contain; }
#preview-status { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 14px; }
#preview-status:empty, #download-status:empty { display: none; }
.page-controls { display: flex; align-items: center; gap: 6px; }
.primary, .secondary { font: inherit; border-radius: 8px; padding: 9px 14px; cursor: pointer; }
.primary { background: #28644f; color: #fff; border: 2px solid #28644f; font-weight: 600; }
.secondary { background: #fff; color: #18264e; border: 1px solid #b3c0ca; }
.icon-button { padding: 6px; width: 34px; height: 34px; display: grid; place-items: center; }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.primary:focus-visible, .secondary:focus-visible { outline: 3px solid #2873ae; outline-offset: 3px; }
.primary:disabled, .secondary:disabled { opacity: .5; cursor: default; }
@media (max-width: 900px) { .games { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 800px) {
  .dialog-body { grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); gap: 12px; padding: 12px; }
  .dialog-body > section:first-child { gap: 6px; }
  dialog .options { padding: 10px; gap: 8px; }
  dialog legend { margin-bottom: 4px; }
  dialog .content-choices { grid-template-columns: repeat(4,minmax(0,1fr)); }
  dialog .content-choices .choice { padding: 6px 3px; gap: 3px; }
  dialog .content-icon { width: 64px; height: 38px; max-width: 100%; }
  dialog .layout-choices .choice { flex-direction: row; padding: 5px; gap: 6px; }
  dialog .layout-choices svg { width: 30px; height: 30px; }
  .dialog-header h2 { font-size: 20px; }
  .dialog-header, .dialog-footer { padding: 10px 14px; }
}
@media (max-width: 540px) {
  main { padding: 20px 16px; width: calc(100% - 20px); margin: 10px auto; }
  h1 { font-size: 32px; }
  .games { grid-template-columns: 1fr; }
  dialog { width: calc(100% - 12px); height: calc(100dvh - 12px); }
  dialog .choices { gap: 5px; }
  .preview-panel { padding: 8px; }
}
@media (max-height: 650px) and (min-width: 801px) {
  .dialog-body { gap: 12px; padding: 12px; }
  dialog .options { padding: 10px; gap: 10px; }
  dialog .choice { padding: 6px; gap: 3px; }
  dialog .content-icon { height: 34px; }
  dialog .layout-choices svg { height: 30px; }
  .dialog-body > section:first-child { gap: 8px; }
}
@media (max-height: 650px) and (min-width: 600px) {
  .dialog-body { grid-template-columns: minmax(270px,300px) minmax(0,1fr); grid-template-rows: minmax(0,1fr); gap: 12px; padding: 10px; }
  .dialog-header, .dialog-footer { padding: 8px 12px; }
  .dialog-body > section:first-child { gap: 6px; }
  dialog .options { padding: 8px; gap: 8px; }
  dialog legend { margin-bottom: 4px; }
  dialog .content-choices { grid-template-columns: repeat(2,minmax(0,1fr)); }
  dialog .content-choices .choice { flex-direction: row; padding: 5px; gap: 4px; }
  dialog .content-icon { width: 46px; height: 30px; }
  dialog .layout-choices .choice { flex-direction: column; padding: 4px; gap: 2px; }
  dialog .layout-choices svg { width: 24px; height: 24px; }
  .preview-heading { flex-wrap: wrap; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .dialog-header, .dialog-footer { padding: 6px 10px; }
  .dialog-body { padding: 8px; }
  dialog .options { padding: 6px; gap: 6px; }
  dialog legend { font-size: 14px; margin-bottom: 2px; }
  dialog .content-choices .choice { padding: 3px; gap: 3px; }
  dialog .content-icon { width: 40px; height: 26px; }
  dialog .choice strong { line-height: 1.15; }
  dialog .layout-choices .choice { flex-direction: row; padding: 4px 2px; }
  dialog .layout-choices svg { width: 20px; height: 24px; }
}
