@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
:root {
  font-family: "Fraunces", Georgia, serif;
  color: #eee5dc;
  background: #100e11;
  font-synthesis: none;
  color-scheme: dark;
  --paper: #111014;
  --ink: #eee5dc;
  --muted: #b6a7a8;
  --line: #403238;
  --accent: #a82b3d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input, a, summary { -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; border-radius: 0; }
button, summary { cursor: pointer; }
button { color: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible, canvas:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #ef8895; outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { appearance: none; display: inline-grid; place-content: center; width: 16px; height: 16px; flex-shrink: 0; border: 1px solid #987984; background: #0b0a0c; cursor: pointer; }
input[type="checkbox"]:checked { background: var(--accent); border-color: #d45b6d; }
input[type="checkbox"]:checked::after { content: ""; width: 8px; height: 5px; border-left: 2px solid #fff3ec; border-bottom: 2px solid #fff3ec; transform: translateY(-1px) rotate(-45deg); }
input[type="checkbox"]:disabled { opacity: .5; cursor: default; }
input[type="range"] { appearance: none; height: 18px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: #72545e; }
input[type="range"]::-moz-range-track { height: 3px; background: #72545e; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 18px; margin-top: -7.5px; border: 1px solid #d45b6d; border-radius: 0; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 16px; border: 1px solid #d45b6d; border-radius: 0; background: var(--accent); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 0; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 0; }
.app-header { position: relative; display: flex; align-items: center; gap: 18px; padding: 13px 24px; min-height: 76px; background: #0b0a0c; border-bottom: 1px solid #5f2430; z-index: 2; flex-shrink: 0; }
.brand { color: var(--ink); font: 500 34px/1 "Fraunces", Georgia, serif; letter-spacing: -1.7px; text-decoration: none; white-space: nowrap; margin-right: 5px; }
nav { display: flex; align-items: center; gap: 3px; }
.button, summary { border: 1px solid transparent; border-radius: 0; padding: 9px 11px; font-size: 14px; font-weight: 400; white-space: nowrap; line-height: 1.4; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
summary:after { content: '⌄'; margin-left: 6px; color: var(--muted); }
summary:hover, details[open] > summary, .plain:hover { background: #26191e; }
.gallery-launch { display: inline-flex; align-items: center; gap: 8px; }
.gallery-launch svg { flex-shrink: 0; }
.primary { background: var(--accent); color: #fff3ec; }
.primary:hover { background: #bf344a; }
.plain { background: transparent; }
.secondary { background: #21191e; border-color: var(--line); }
.secondary:hover { background: #33222a; }
.header-menu { position: relative; }
.menu-panel { position: absolute; top: calc(100% + 18px); left: 0; width: 300px; max-height: calc(100dvh - 100px); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 0; background: var(--paper); box-shadow: 0 10px 32px #00000066; }
h2 { font: 500 22px/1.3 "Fraunces", Georgia, serif; margin: 0 0 16px; }
.image-name { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin: 0 0 12px; }
.grid-help, .muted { color: var(--muted); }
.grid-help { font-size: 12px; line-height: 1.6; }
.upload-zone { display: flex; flex-direction: column; text-align: center; border: 1px dashed #72545e; padding: 24px 12px; border-radius: 0; cursor: pointer; gap: 7px; }
.upload-zone:hover, .upload-zone.over { background: #25171d; border-color: var(--accent); }
.upload-zone strong { font-size: 13px; font-weight: 550; }
.upload-zone small { font-size: 12px; color: var(--muted); }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; line-height: 1.5; cursor: pointer; }
.check-row input { margin: 2px 0 0; }
.grid-controls label { display: flex; justify-content: space-between; font-size: 13px; margin-top: 12px; }
.grid-controls output { font-weight: 600; }
.grid-controls input { width: 100%; margin: 14px 0 10px; }
#grid-summary { font-size: 13px; font-weight: 600; margin: 14px 0; }
.grid-controls .button { width: 100%; margin-bottom: 8px; }
.toggle-row { display: flex; align-items: center; gap: 10px; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.toggle-row input { margin-left: auto; }
.border-toggle { display: flex; align-items: center; gap: 6px; margin-left: 7px; padding-left: 10px; border-left: 1px solid var(--line); white-space: nowrap; font-size: 13px; cursor: pointer; min-height: 32px; }
.border-toggle input { margin: 0; }
.restart { width: 100%; margin-top: 20px; }
.appearance-settings { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.appearance-settings h2 { margin-bottom: 14px; }
.appearance-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; font-size: 13px; }
.appearance-row input[type="checkbox"] { margin: 0; }
.appearance-row input[type="color"] { width: 44px; height: 30px; padding: 3px; border: 1px solid #72545e; border-radius: 0; background: #0b0a0c; cursor: pointer; }
.table-swatches { display: flex; gap: 9px; margin: 9px 0 14px; }
.table-swatches button { width: 30px; height: 30px; padding: 0; border: 1px solid #72545e; border-radius: 0; background: var(--swatch-color); }
.table-swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.outline-control { margin: 12px 0; }
.outline-control output { font-variant-numeric: tabular-nums; color: var(--muted); }
.outline-control input[type="range"] { display: block; width: 100%; margin: 8px 0; }
.outline-control .grid-help { margin: 0; }
#reset-appearance { width: 100%; margin-top: 16px; }

.help-panel p { font-size: 13px; line-height: 1.65; color: #c4b6b5; }
.header-progress { font-family: Arial, sans-serif; display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.header-progress strong { font-weight: 500; }
.progress-track { width: 46px; height: 3px; background: #403238; }
.progress-track > div { width: 0; height: 100%; background: #c9475b; transition: width .4s; }
#timer { color: var(--muted); }
.zoom-controls { display: flex; align-items: center; gap: 1px; border-left: 1px solid var(--line); padding-left: 12px; }
.zoom-controls button { border: 0; background: transparent; min-width: 30px; min-height: 36px; font-size: 20px; border-radius: 0; }
.zoom-controls button:hover { background: #26191e; }
.zoom-controls #zoom-reset { font-family: Arial, sans-serif; font-size: 11px; min-width: 42px; font-variant-numeric: tabular-nums; }
.zoom-controls #gather-pieces { font-size: 12px; padding: 0 8px; }
main { position: relative; flex: 1; min-height: 0; min-width: 0; display: flex; }
.workspace { flex: 1; min-width: 0; overflow: auto; display: grid; background-color: var(--table-color, #100e11); background-image: radial-gradient(var(--grid-color, rgba(220,170,175,.14)) .8px, transparent .8px); background-size: 18px 18px; }
.workspace.grid-off { background-image: none; }
#board { display: block; margin: auto; touch-action: none; cursor: grab; }
#board:active { cursor: grabbing; }
#fireworks { position: absolute; inset: 0; display: none; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#fireworks.active { display: block; }
.celebration { position: absolute; z-index: 2; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 28px; padding: 19px 24px; border: 1px solid var(--line); border-radius: 0; background: var(--paper); box-shadow: 0 6px 24px #00000066; max-width: calc(100% - 32px); width: max-content; }
.celebration h2 { margin: 0; font: 500 27px/1.2 "Fraunces", Georgia, serif; }
.celebration p { font-size: 12px; margin: 7px 0 0; color: var(--muted); }
.celebration .button { flex-shrink: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-error { position: absolute; z-index: 2; left: 16px; bottom: 16px; margin: 0; padding: 12px 16px; max-width: min(480px, calc(100% - 32px)); background: #30131c; color: #f0b7bf; border: 1px solid #8d3e4d; border-radius: 0; font-size: 13px; }
.photo-collection { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 22px; }
.collection-actions { display: flex; gap: 8px; }
.collection-actions .button { flex: 1; padding: 9px 8px; }
.photo-collection select { width: 100%; padding: 6px; background: #0b0a0c; color: var(--ink); border: 1px solid var(--line); border-radius: 0; font-size: 12px; margin-bottom: 10px; }
.photo-collection option { padding: 7px 4px; }
.photo-collection > .button { width: 100%; margin-top: 10px; }
.difficulty-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.notice { padding: 12px; background: #26191e; border-radius: 0; font-size: 12px; line-height: 1.6; }
.app-dialog { width: min(490px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 28px; color: var(--ink); background: var(--paper); border: 1px solid #5f414b; border-radius: 0; box-shadow: 0 18px 70px #000000aa; }
.app-dialog::backdrop { background: #070609dc; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { font: 500 34px/1.2 "Fraunces", Georgia, serif; letter-spacing: -.5px; margin: 0; }
.close-button { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; background: transparent; border: 0; border-radius: 0; font-size: 25px; line-height: 1; }
.close-button:hover { background: #26191e; }
.dialog-intro { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 14px 0 24px; }
.field-label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 8px; }
.app-dialog input[type="text"], .app-dialog input[type="url"], .app-dialog input[type="search"], .app-dialog select { width: 100%; padding: 11px 12px; border: 1px solid #634b54; border-radius: 0; background: #0b0a0c; color: var(--ink); font-size: 14px; }
.share-tags-field { margin-top: 18px; }
.share-tags-field .grid-help { margin: 7px 0 0; }
.settings-summary { padding: 12px 0; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin: 4px 0 20px; }
.share-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
#share-status, #gallery-status { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
#share-status:empty, #gallery-status:empty { display: none; }
#share-copy { margin-top: 10px; }
.gallery-dialog { width: min(960px, calc(100vw - 32px)); }
.gallery-dialog .dialog-intro { margin-bottom: 0; }
.gallery-toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; border-top: 1px solid var(--line); padding: 18px 0; margin-top: 22px; }
.gallery-toolbar p { font-size: 12px; color: var(--muted); margin: 0; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 18px; }
.gallery-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 22px; }
.gallery-filter label { font-size: 12px; margin-right: 4px; }
.gallery-filter input[type="search"] { flex: 1 1 150px; width: auto; min-width: 0; padding: 9px 10px; font-size: 13px; }
.gallery-card { min-width: 0; }
.gallery-play { display: flex; flex-direction: column; width: 100%; padding: 0; text-align: left; min-width: 0; background: transparent; border: 0; border-radius: 0; }
.gallery-play img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 0; background: #251a20; }
.gallery-play:hover img { filter: brightness(1.06); }
.gallery-play span { font-size: 12px; margin-top: 8px; color: var(--muted); }
.gallery-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.gallery-tags:empty { display: none; }
.gallery-tag { max-width: 100%; padding: 5px 9px; border: 1px solid var(--line); border-radius: 0; background: #21191e; color: #c4b6b5; font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; }
.gallery-tag:hover { background: #33222a; }
#gallery-more { display: block; margin: 24px auto 0; }
@media (max-width: 1250px) {
  .app-header { gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
  .brand { font-size: 32px; }
  .progress-track { display: none; }
  .header-progress { gap: 9px; }
  .zoom-controls { padding-left: 8px; }
  .button, summary { padding: 9px; }
  .border-toggle { margin-left: 3px; padding-left: 8px; }
}
@media (max-width: 1060px) {
  .app-header { gap: 8px 16px; }
  .brand { flex: 1; order: 0; }
  .header-progress { order: 1; }
  .zoom-controls { order: 2; }
  nav { flex: 1 0 100%; order: 3; }
  .header-menu { position: static; }
  .menu-panel { top: 100%; left: 16px; max-height: calc(100dvh - 130px); }
  .border-toggle { margin-left: auto; }
}
@media (max-width: 600px) {
  .app-header { gap: 7px 10px; padding: 10px; }
  .brand { font-size: 30px; }
  .header-progress { font-size: 10px; gap: 6px; }
  .zoom-controls { padding-left: 5px; }
  .zoom-controls button { min-width: 25px; min-height: 32px; }
  .zoom-controls #gather-pieces { padding: 0 5px; font-size: 11px; }
  .zoom-controls #zoom-reset { min-width: 37px; font-size: 10px; }
  nav { flex-wrap: wrap; gap: 2px; }
  .button, summary { font-size: 13px; padding: 8px 7px; }
  .border-toggle { font-size: 12px; padding-left: 6px; gap: 4px; }
  .border-toggle input { width: 14px; height: 14px; }
  .menu-panel { left: 10px; width: min(320px, calc(100vw - 20px)); max-height: calc(100dvh - 160px); padding: 20px; }
  .celebration { padding: 16px; gap: 14px; }
  .celebration h2 { font-size: 20px; }
  .app-dialog { padding: 22px; max-height: calc(100dvh - 24px); }
  .dialog-heading h2 { font-size: 27px; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .gallery-toolbar { align-items: flex-start; }
  .gallery-filter label { flex-basis: 100%; }
}
@media (max-width: 390px) {
  .header-progress { margin-left: 0; }
  .zoom-controls { border-left: 0; padding-left: 0; }
  .border-toggle { margin-left: 0; }
  .gallery-toolbar { flex-wrap: wrap; }
}
.border-toggle:has(input:disabled) { color: var(--muted); cursor: default; }
.border-toggle input:disabled + span::after { content: ' · fixed'; font-size: 10px; }
