.photo-entry {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; max-width: calc(100vw - 24px); margin: 6px auto;
}
.photo-entry-note { flex: 1 1 175px; min-width: 0; margin: 0; color: #435b74; font-size: 13px; line-height: 1.4; }
.photo-quick-help {
  box-sizing: border-box; max-width: 390px; margin: 8px auto 0; padding: 8px 10px 10px;
  border: 1px solid #d5e0ed; border-radius: 6px; background: #f7faff;
  color: #233c59; font: 13px/1.4 system-ui, sans-serif; text-align: left;
}
.photo-quick-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.photo-quick-heading a { color: #23517e; text-underline-offset: 2px; }
.photo-quick-steps {
  display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px;
  margin: 0; padding: 0; list-style: none; text-align: center;
}
.photo-quick-steps li {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 3px;
  padding: 4px 2px; border: 1px solid #dce6f1; border-radius: 4px; background: #fff;
}
.photo-quick-steps li + li::before {
  content: ""; position: absolute; top: 23px; left: -11px; width: 5px; height: 5px;
  border-top: 1px solid #466281; border-right: 1px solid #466281; transform: rotate(45deg);
}
.photo-quick-visual {
  position: relative; display: grid; place-items: center;
  width: 34px; height: 32px; color: #245483; font-size: 23px;
}
.photo-quick-grid {
  width: 24px; height: 24px; border: 1px solid currentColor; box-sizing: border-box;
  background-image: linear-gradient(to right, transparent 90%, currentColor 90%),
                    linear-gradient(to bottom, transparent 90%, currentColor 90%);
  background-size: 33.333% 33.333%;
}
.photo-quick-check {
  position: absolute; right: 0; bottom: 1px; padding: 2px;
  border-radius: 50%; background: #e4f2ff; color: #245483; font-size: 11px;
}
#solver-photo-guide { scroll-margin-top: 64px; }
@media (prefers-reduced-motion: no-preference) {
  .photo-quick-playing li { animation: photo-quick-highlight 1.6s both; }
  .photo-quick-playing li:nth-child(2) { animation-delay: 1.6s; }
  .photo-quick-playing li:nth-child(3) { animation-delay: 3.2s; }
  @keyframes photo-quick-highlight {
    0%, 100% { border-color: #dce6f1; background: #fff; transform: none; }
    16%, 82% { border-color: #729dcb; background: #e8f2ff; transform: translateY(-2px); }
  }
}
.photo-entry button, #puzzle-photo button {
  min-height: 36px; padding: 4px 10px;
  border: 1px solid #b9cce0; border-radius: 5px;
  background: #fff; color: #23517e; font: inherit; cursor: pointer;
}
.photo-entry button { background: #edf5ff; }
#puzzle-photo {
  box-sizing: border-box; width: min(710px, calc(100% - 20px)); max-height: calc(100% - 24px);
  padding: 16px; border: 1px solid #b9cce0; border-radius: 8px;
  background: #fff; color: #233c59; overflow: auto; overscroll-behavior: contain;
  text-align: left; font: 14px/1.5 system-ui, sans-serif;
}
#puzzle-photo::backdrop { background: #13283e80; }
.photo-heading, .photo-actions { display: flex; align-items: center; gap: 8px; }
.photo-heading { justify-content: space-between; }
.photo-heading h2 { margin: 0; font-size: 18px; }
.photo-heading > button, .photo-heading > form { flex-shrink: 0; white-space: nowrap; }
.photo-heading form, .photo-actions form { margin: 0; }
.photo-actions { flex-wrap: wrap; }
#puzzle-photo:has(#photo-review:not([hidden])) .photo-intro { display: none; }
#puzzle-photo:has(#photo-review:not([hidden])) #photo-drop { margin-top: 8px; }
#photo-drop { padding: 10px; border: 1px dashed #8ba7c6; border-radius: 6px; }
#photo-drop p { margin: 0 0 8px; color: #435b74; }
#photo-drop.photo-dragging { border-color: #21578b; background: #edf5ff; }
#photo-paste-fallback { margin-top: 8px; }
#photo-paste-target {
  min-height: 36px; margin-top: 4px; padding: 6px 8px; box-sizing: border-box;
  border: 1px solid #b9cce0; border-radius: 5px; font-size: 16px;
}
#photo-paste-target:empty::before { content: "ここに画像を貼り付け"; color: #435b74; pointer-events: none; }
#photo-paste-target:focus { outline: 2px solid #1462a9; outline-offset: 1px; }
#photo-progress:empty, #photo-warning:empty { display: none; }
#photo-progress-row { margin-block: 8px; }
#photo-progress-row:has(#photo-progress:empty) { margin: 0; }
#photo-progress { margin: 0; }
#puzzle-photo [hidden] { display: none; }
#photo-corner-editor p { margin: 8px 0 12px; }
#photo-corner-stage {
  position: relative; width: min(100%, 600px, calc(53vh * var(--photo-ratio, 1)));
  margin: 0 auto; touch-action: none;
}
#photo-original { display: block; width: 100%; height: auto; }
#photo-corner-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#puzzle-photo .photo-corner {
  position: absolute; transform: translate(-50%, -50%); width: 40px; height: 40px;
  border: 0; padding: 0; border-radius: 50%; background: transparent;
  display: grid; place-items: center; cursor: grab; touch-action: none;
}
#puzzle-photo .photo-corner::before {
  content: ""; width: 13px; height: 13px; box-sizing: border-box;
  border: 2px solid white; border-radius: 50%; background: #1462a9;
  box-shadow: 0 0 0 1px #163c5d;
}
#puzzle-photo .photo-corner:focus-visible { outline: 2px solid #1462a9; }
#puzzle-photo #photo-adjust-read { background: #244d7b; color: #fff; }
#puzzle-photo #photo-adjust-read:disabled { opacity: .55; cursor: default; }
#puzzle-photo:has(#photo-corner-editor:not([hidden])) :is(.photo-intro, #photo-drop) { display: none; }
.photo-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
#photo-preview { display: block; width: 100%; height: auto; }
#photo-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); border: 2px solid #233c59; }
#puzzle-photo .photo-cell {
  aspect-ratio: 1; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0;
  border-right: 1px solid #a6b6c8; border-bottom: 1px solid #a6b6c8;
  color: #142d47; font-size: clamp(13px, 4vw, 20px); font-weight: 600;
}
#puzzle-photo .photo-cell:nth-child(3n):not(:nth-child(9n)) { border-right: 2px solid #233c59; }
#puzzle-photo .photo-cell:is(:nth-child(n+19):nth-child(-n+27), :nth-child(n+46):nth-child(-n+54)) { border-bottom: 2px solid #233c59; }
#puzzle-photo .photo-cell:nth-child(9n) { border-right: 0; }
#puzzle-photo .photo-cell:nth-child(n+73) { border-bottom: 0; }
#puzzle-photo .photo-uncertain { background: #fff2bc; }
#puzzle-photo .photo-conflict { background: #fce0e0; color: #912929; }
#puzzle-photo .photo-cell[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #1765b4; }
#photo-pad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
#photo-pad button { padding-inline: 0; }
#photo-warning { color: #912929; }
.photo-confirm { justify-content: flex-end; margin-top: 14px; }
#photo-apply:not(:disabled) { background: #244d7b; color: #fff; }
#photo-apply:disabled { opacity: .55; cursor: default; }
@media (hover: hover) and (pointer: fine) { #photo-camera-button { display: none; } }
@media (max-width: 540px) {
  .photo-comparison { grid-template-columns: minmax(0, 1fr); }
  #photo-preview { max-width: 148px; margin-inline: auto; }
  #photo-drop p { display: none; }
}
@media print { .photo-entry, .photo-quick-help, #puzzle-photo { display: none; } }

.solver-feedback-entry { margin: 6px 0; text-align: center; }
.solver-feedback-entry button {
  min-height: 32px; padding: 0 8px; border: 0; background: none;
  color: #23517e; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.solver-feedback-entry button:focus-visible { outline: 2px solid #2468aa; outline-offset: 2px; }
#solver-feedback button {
  min-height: 38px; padding: 4px 10px; border: 1px solid #b9cce0; border-radius: 5px;
  background: #fff; color: #23517e; font: inherit; cursor: pointer;
}
#solver-feedback {
  box-sizing: border-box; width: min(420px, calc(100% - 20px)); max-height: calc(100% - 24px);
  padding: 16px; border: 1px solid #b9cce0; border-radius: 8px; overflow: auto;
  background: #fff; color: #233c59; text-align: left; font: 14px/1.5 system-ui, sans-serif;
}
#solver-feedback::backdrop { background: #13283e80; }
#solver-feedback h2 { margin: 0; font-size: 18px; }
#solver-feedback-origin { margin: 4px 0 12px; color: #435b74; }
#solver-feedback fieldset { display: grid; gap: 5px; min-width: 0; margin: 0 0 8px; padding: 0; border: 0; }
#solver-feedback label:not(:first-child) { margin-top: 4px; }
#solver-feedback :is(input, textarea, select) {
  box-sizing: border-box; width: 100%; min-width: 0; padding: 6px 8px;
  border: 1px solid #b9cce0; border-radius: 4px; color: #233c59; font: inherit; font-size: 16px;
}
#solver-feedback textarea { resize: vertical; }
#solver-feedback-status:empty { display: none; }
.solver-feedback-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
#solver-feedback button[type="submit"] { background: #244d7b; color: #fff; }
#solver-feedback button:disabled { opacity: .55; cursor: default; }
@media print { .solver-feedback-entry, #solver-feedback { display: none; } }
