.puzzles-panel { min-width: 0; }
.puzzles-header, .puzzle-activity-header, .puzzles-library, .puzzle-status-line, .puzzles-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.puzzles-header h1 { font: 24px Georgia, serif; margin: 8px 0 20px; }
.puzzles-library { justify-content: flex-start; margin: 12px 0; }
.puzzles-library label { flex: 1; min-width: 140px; font-size: 11px; }
.puzzles-library select { display: block; width: 100%; margin-top: 5px; }
.puzzles-panel select, .puzzle-create select, .puzzle-create input { border: 1px solid var(--border); background: var(--input-background); color: var(--text); border-radius: 6px; padding: 9px 10px; font: 12px inherit; }
.puzzle-activity-header { margin: 22px 0 12px; align-items: flex-start; }
.puzzle-activity-header h2 { font: 22px Georgia, serif; margin: 0; }
.puzzle-activity-header .switch-setting { margin: 0; gap: 12px; font-size: 12px; }
.puzzle-status-line { font-size: 12px; color: var(--muted); align-items: flex-start; }
#puzzles-state[data-status="submitted"] { color: #e5bd77; }
#puzzles-state[data-status="accepted"] { color: #9ed89f; }
.puzzle-hint { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 12px 0; }
#puzzles-workspace { max-width: 100%; container-type: inline-size; }
.puzzle-plate { min-width: 0; }
.puzzle-placement-rule { padding: 10px 12px; margin: 0; border-left: 3px solid #c6a56a; background: var(--input-background); color: var(--text); font-size: 12px; line-height: 1.5; }
#puzzles-rules { padding: 16px; margin: 18px 0; background: var(--input-background); border: 1px solid var(--border); border-radius: 10px; }
#puzzles-rules h3 { font: 20px Georgia, serif; margin: 0 0 14px; }
#puzzles-rules dl { margin: 0; font-size: 12px; line-height: 1.55; }
#puzzles-rules dt { margin: 12px 0 3px; font-weight: 700; color: var(--text); }
#puzzles-rules dd { margin: 0; color: var(--muted); }
.puzzle-directions { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.puzzle-directions h2, #puzzles-rules .puzzle-directions h3 { font: 18px/1.3 Georgia, serif; margin: 0 0 12px; }
.puzzle-directions p { margin: 10px 0; }
.puzzle-directions ol { padding-left: 23px; margin: 14px 0; }
.puzzle-directions li { margin: 12px 0; padding-left: 3px; }
@container (min-width: 830px) { .puzzle-layout:has(#puzzles-rules:not([hidden])) { display: grid; grid-template-columns: minmax(0, 560px) minmax(210px, 1fr); gap: 24px; align-items: start; } }
#puzzles-stage { position: relative; width: 100%; max-width: 560px; margin: 18px auto 0; border: 5px double #9c885b; border-radius: 14px; padding: 12px; box-sizing: border-box; background: linear-gradient(135deg, #30392f, #19231f 55%, #3c4131); }
#puzzles-surface { width: 100%; }
#puzzles-surface > img { display: block; width: 100%; height: auto; max-height: 75dvh; object-fit: contain; border-radius: 4px; }
#puzzles-stage:has(img) { border: 1px solid var(--border); background: var(--surface); }
#puzzles-surface .runeboard-grid { width: 100%; }
#puzzles-surface .runeboard-grid .runeboard-cell { height: auto; aspect-ratio: 1; }
#puzzles-surface .runeboard-grid .runeboard-coordinate { height: 22px; }
#puzzles-surface .runeboard-cell > button { width: 100%; min-width: 0; height: auto; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 2px; border: 0; border-radius: 0; background: transparent; color: #14251f; cursor: pointer; position: relative; z-index: 1; }
#puzzles-surface .runeboard-cell > button:disabled { opacity: 1; cursor: default; }
#puzzles-surface .runeboard-cell > button:hover:not(:disabled) { background: #ffffef40; outline: 2px solid #f3cf83; outline-offset: -2px; }
#puzzles-surface .runeboard-cell > button:focus-visible { outline: 3px solid #ffeaaf; outline-offset: -3px; }
#puzzles-surface .runeboard-cell .runeboard-engraving { position: absolute; inset: 0; pointer-events: none; }
#puzzles-surface .runeboard-cell:has(.runeboard-token) .runeboard-engraving { inset: auto auto 2px 2px; }
#puzzles-surface .runeboard-token { border: 1px solid #867548; border-radius: 5px; background: #fffbeb; padding: 3px; box-shadow: 0 2px 4px #14251f40; pointer-events: none; max-width: 85%; }
#puzzles-surface .runeboard-rune-shape { width: clamp(20px, 4vw, 38px); height: clamp(20px, 4vw, 38px); }
#puzzles-surface [data-rune] { touch-action: none; }
#puzzles-surface [aria-pressed="true"] { outline: 3px solid #f3cf83; outline-offset: -3px; }
#puzzles-legend { justify-content: center; }
#puzzles-legend span { padding: 4px 10px; border-radius: 4px; color: #18221c; font: 11px system-ui, sans-serif; }
.puzzle-symbols { margin: 14px 0; }
.puzzle-symbols h3 { margin: 0 0 8px; font: 600 11px/1.5 system-ui, sans-serif; color: var(--muted); text-align: center; }
.puzzle-symbols .runeboard-mark-key { justify-content: center; gap: 8px 16px; }
#puzzles-tray { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; max-width: 650px; margin: 18px auto; }
.puzzle-rune { min-width: 0; min-height: 64px; display: flex; align-items: center; justify-content: center; padding: 6px 2px; border: 1px solid #9c885b; border-radius: 8px; background: #faf3df; touch-action: none; }
.puzzle-rune.is-placed { background: #d6d1c2; opacity: .55; }
.puzzle-rune[aria-pressed="true"] { outline: 3px solid #e9be69; outline-offset: 2px; opacity: 1; }
.puzzle-rune:disabled { cursor: default; }
.puzzles-actions { justify-content: flex-start; padding: 12px 0 22px; }
.puzzles-actions button { font-size: 12px; }
#puzzles-cursors { pointer-events: none; position: absolute; inset: 0; overflow: hidden; border-radius: inherit; z-index: 5; }
.puzzle-cursor { position: absolute; display: flex; gap: 3px; align-items: flex-start; transition: left .65s linear, top .65s linear; color: var(--cursor-colour); }
.puzzle-pointer { display: inline-block; transform: rotate(-120deg); font-size: 24px; line-height: 1; text-shadow: 0 1px 2px #000; }
.puzzle-cursor-name { font: 600 10px/1.4 system-ui, sans-serif; background: var(--cursor-colour); color: #18221c; border: 1px solid #18221c55; padding: 2px 5px; border-radius: 4px; white-space: nowrap; margin-top: 14px; }
.puzzle-create { width: min(430px, calc(100vw - 40px)); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 22px; }
.puzzle-create::backdrop { background: #0008; }
.puzzle-create h2 { margin: 0 0 16px; font: 24px Georgia, serif; }
.puzzle-create label { display: block; margin: 12px 0; font-size: 12px; }
.puzzle-create input, .puzzle-create select { display: block; width: 100%; margin-top: 6px; }
.puzzles-popout .app-shell { display: block; overflow: auto; background: var(--surface); }
.puzzles-popout .puzzles-panel { max-width: 1080px; padding: 24px 36px; margin: auto; }
.puzzles-popout .puzzles-header h1 { font-size: 30px; }
@media (max-width: 550px) {
  .puzzles-popout .puzzles-panel { padding: 16px 12px; }
  #puzzles-stage { padding: 5px; border-width: 3px; }
  #puzzles-surface .runeboard-grid tr > :first-child { width: 20px; }
  #puzzles-surface .runeboard-token { padding: 2px; }
  #puzzles-surface .runeboard-rune-name { font-size: 8px; }
  #puzzles-tray { gap: 5px; }
  .puzzle-rune { min-height: 58px; }
  .puzzle-rune .runeboard-rune-shape { width: 26px; height: 26px; }
  .puzzle-rune .runeboard-rune-name { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) { .puzzle-cursor { transition: none; } }
