* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px; line-height: 1.6; color: #233; background: #eef7ff;
}
header { background: #2b7de9; color: #fff; padding: 10px 16px; text-align: center; }
header h1 { margin: 0; font-size: 1.5rem; }
header p { margin: 0; font-size: .95rem; }
rt { font-size: .55em; }

main {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 16px; max-width: 1100px; margin: 0 auto; padding: 16px;
}
@media (max-width: 800px) { main { grid-template-columns: 1fr; padding: 10px; } }

.stage-wrap { position: sticky; top: 8px; align-self: start; }
@media (max-width: 800px) { .stage-wrap { position: static; } }
#stage {
  display: block; width: 100%; max-height: 78vh; aspect-ratio: 1;
  background: #fff; border: 4px solid #2b7de9; border-radius: 16px;
  touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none;
}
#gridNote { margin: 2px 6px 0; font-size: .8rem; color: #678; text-align: right; }
#msg {
  margin-top: 6px; padding: 10px 14px; border-radius: 12px; min-height: 3em;
  background: #fff8d6; border: 2px solid #f2c94c; font-weight: bold;
}
#msg.bad { background: #ffe6e6; border-color: #ef6b6b; }
#msg.good { background: #e3f9e5; border-color: #53b96a; }

.shape { fill: #ffd76a; fill-opacity: .85; stroke: #c0392b; stroke-width: 1; stroke-linejoin: round; }
#live { fill: none; stroke: #c0392b; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
#closer { stroke: #c0392b; stroke-width: .6; stroke-dasharray: 2 2; }
.hole { fill: #fff; stroke: #c0392b; stroke-width: .6; }
.cross { stroke: #1b3fd6; stroke-width: .8; fill: none; }
.guessDot { fill: #8e44ad; stroke: #fff; stroke-width: .5; }
.guessLabel, .numLabel { fill: #8e44ad; font-weight: bold; pointer-events: none; }
.pivot { fill: #111; }

.panel { display: flex; flex-direction: column; gap: 12px; }
.step { background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 1px 4px rgba(0, 40, 90, .12); }
.step h2 { margin: 0 0 6px; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.num {
  display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%;
  background: #ff8a3d; color: #fff; font-size: .95rem; flex: none;
}
.hint { margin: 4px 0 8px; font-size: .9rem; color: #456; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.label { font-size: .9rem; }
.field { margin: 8px 0; }
.field > label { display: block; font-weight: bold; font-size: .92rem; }
.check { display: block; margin-top: 6px; font-size: .92rem; }

.btn {
  font: inherit; font-weight: bold; padding: 10px 14px; min-height: 44px;
  border: 2px solid #2b7de9; border-radius: 12px; background: #fff; color: #1d5fb8; cursor: pointer;
}
.btn.small { padding: 6px 10px; min-height: 38px; font-size: .9rem; }
.btn.primary { background: #2b7de9; color: #fff; width: 100%; font-size: 1.05rem; }
.btn:hover:not(:disabled) { filter: brightness(.95); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #ff8a3d; outline-offset: 2px; }

input[type=range] { flex: 1; min-width: 120px; }
input[type=number] { font: inherit; width: 5em; padding: 6px; border: 2px solid #9bb; border-radius: 8px; }
select { font: inherit; padding: 8px; border: 2px solid #9bb; border-radius: 8px; max-width: 100%; }

#result { margin: 8px 0 0; font-weight: bold; }
#warn { margin: 8px 0 0; color: #c0392b; font-weight: bold; font-size: .92rem; }
details { background: #fff; border-radius: 14px; padding: 10px 14px; font-size: .88rem; }
details ul { margin: 6px 0; padding-left: 1.2em; }
summary { cursor: pointer; font-weight: bold; }

#svgHost { position: absolute; left: -99999px; top: 0; visibility: hidden; }

.numLabel { fill: #1b3fd6; }

dialog {
  width: min(560px, 94vw); max-height: 94vh; overflow: auto; padding: 14px 16px;
  border: 4px solid #2b7de9; border-radius: 16px; color: inherit;
}
dialog::backdrop { background: rgba(10, 30, 60, .55); }
dialog h2 { margin: 0 0 4px; font-size: 1.1rem; }
dialog .hint { margin: 0 0 6px; }
/* まわりの余白でも、かどのつまみをつかめるようにする */
#imgWrap { padding: 14px; margin: -8px -14px; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#imgCanvas { display: block; max-width: 100%; max-height: 50vh; margin: 0 auto; background: #eee; }
#imgInfo { margin: 6px 0; font-weight: bold; }
dialog input[type=range] { width: 100%; }
dialog .btn.primary { width: auto; flex: 1; }

.pdfBox { margin-top: 12px; padding-top: 10px; border-top: 2px dashed #cfe3f5; }
.pdfBox .btn { margin-top: 6px; }
#pdfInfo { margin: 6px 0 0; font-weight: bold; }

[hidden] { display: none !important; }
