/* SkakScan — styles. Follows the device's light/dark setting. */
[hidden] { display: none !important; }
:root { --bg:#121417; --panel:#1c1f23; --panel2:#15181b; --line:#2c3238; --text:#e3e6ea; --muted:#8b939c; --accent:#3f9a68; --accent2:#6fdc8c;
        --light:#f0d9b5; --dark:#b58863; --warn:#f0c96a; --err:#ff8a80; color-scheme: dark; }
@media (prefers-color-scheme: light) {
  :root { --bg:#eef1f4; --panel:#fff; --panel2:#f2f4f6; --line:#d9dee3; --text:#1d2329; --muted:#66707a; --accent:#2f8a58; --accent2:#1f8a4c;
          --warn:#8a5a00; --err:#b3261e; color-scheme: light; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent2); }
.small { font-size: 13px; } .muted { color: var(--muted); }
button, .btn, select, input, textarea { font: inherit; font-size: 14px; color: var(--text); }
button, .btn { cursor: pointer; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover:not(:disabled), .btn:hover { filter: brightness(1.12); }
button:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { width: 100%; min-height: 96px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; } .row > * { flex: 1 1 auto; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand b { font-size: 20px; letter-spacing: .3px; } .brand i { font-style: normal; color: var(--accent2); }
.brand small { display: block; font-size: 12px; color: var(--muted); margin-top: -3px; }
.top nav { display: flex; gap: 6px; } .ghostbtn { background: transparent; }
main { max-width: 1180px; margin: 0 auto; padding: 18px; }

.start { max-width: 680px; margin: 4vh auto; text-align: center; }
.start h1 { font-size: clamp(22px, 4vw, 32px); margin: 0 0 10px; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 240px; margin: 22px 0;
  border: 2px dashed var(--line); border-radius: 16px; cursor: pointer; background: var(--panel); padding: 20px; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop .big { font-size: 52px; } .drop b { font-size: 18px; }

.work { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); gap: 22px; align-items: start; }
.work.nopic { grid-template-columns: minmax(0, 560px); justify-content: center; } .work.nopic .pic { display: none; }
@media (max-width: 900px) { .work { grid-template-columns: 1fr; } }
.pic, .res > div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.res h2 { margin: 0 0 10px; font-size: 18px; }
.tabs { display: flex; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 22px; padding: 3px; }
.tabs button { border: none; background: transparent; border-radius: 18px; padding: 6px 12px; flex: 1; }
.tabs button.on { background: var(--accent); color: #fff; font-weight: 700; }
.tabs #rotate { flex: 0 0 auto; }
.photo { position: relative; display: flex; justify-content: center; background: #0007; border-radius: 10px; overflow: hidden; touch-action: none; }
.photo canvas { max-width: 100%; max-height: 72vh; display: block; touch-action: none; }
.corner { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 3px solid #ffd54a; background: rgba(255,213,74,.25); cursor: grab; touch-action: none; z-index: 3; }
.photo svg { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.selrect { position: absolute; border: 2px solid #ffd54a; background: rgba(255,213,74,.12); pointer-events: none; z-index: 2; }
#status { min-height: 20px; margin-top: 8px; } #status.err { color: var(--err); } #status.ok { color: var(--accent2); }

/* editor */
.ed { display: flex; gap: 14px; flex-wrap: wrap; }
.ed-left { flex: 1 1 260px; max-width: 400px; }
.ed-right { flex: 1 1 160px; display: flex; flex-direction: column; gap: 4px; }
.ed-right > label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 4px; overflow: hidden; touch-action: none; user-select: none; }
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: crosshair; }
.sq.l { background: var(--light); } .sq.d { background: var(--dark); }
.sq img { width: 92%; height: 92%; pointer-events: none; }
.sq.unsure { box-shadow: inset 0 0 0 3px #ff5a3c; }
.sq.unsure::after { content: '?'; position: absolute; right: 2px; top: -2px; font-size: 12px; font-weight: 800; color: #ff5a3c; }
.co { position: absolute; font-size: 10px; font-weight: 700; opacity: .75; } .co.r { left: 2px; top: 1px; } .co.f { right: 3px; bottom: 0; }
.sq.l .co { color: var(--dark); } .sq.d .co { color: var(--light); }
.pal { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 6px 0; }
.pal button { aspect-ratio: 1; padding: 3px; touch-action: none; } .pal img { width: 100%; height: 100%; pointer-events: none; }
.pal button.on { background: var(--accent); }
.seg { display: flex; gap: 6px; } .seg button { flex: 1; padding: 6px 8px; } .seg button.on { background: var(--accent); color: #fff; border-color: transparent; }
.castle { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-size: 13px; } .castle .off { opacity: .4; }
.msg { min-height: 20px; font-size: 13px; margin-top: 6px; } .msg.err { color: var(--err); }
.fen { display: flex; gap: 6px; } .fen input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 50; filter: drop-shadow(0 8px 8px rgba(0,0,0,.5)); }
.fix { white-space: nowrap; } .fix.amb { color: var(--warn); }
#report { margin-top: 8px; }

dialog { max-width: 640px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 22px 26px; }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog .x { position: absolute; right: 12px; top: 12px; border-radius: 50%; width: 34px; height: 34px; padding: 0; }
@media (max-width: 560px) { .top { padding: 8px 10px; } main { padding: 10px; } .brand small { font-size: 10px; } .top nav button { padding: 6px 8px; } }
@media (max-width: 560px) { .long { display: none; } .top nav button { min-width: 40px; } }
.photo.over { outline: 3px dashed var(--accent); outline-offset: -3px; }
.photo.over::after { content: 'Drop the picture here'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 20px; font-weight: 700; z-index: 5; pointer-events: none; }
.startfrom { align-items: center; } .startfrom select { flex: 1 1 200px; }
#moveBtns select { flex: 1 1 100%; }
.photo canvas { transform-origin: 0 0; }
.zoom { position: absolute; right: 8px; top: 8px; z-index: 2; display: flex; gap: 4px; }
.zoom button { width: 34px; height: 34px; padding: 0; border-radius: 8px; font-size: 18px; line-height: 1; background: #000a; color: #fff; border: 1px solid #fff5; }
.photo.panning, .photo.panning canvas { cursor: grabbing; }

/* link back to SkakKraken, with the kraken (gently animated, with rising bubbles) */
.sklink { display: inline-flex; align-items: center; gap: 4px; color: var(--text); text-decoration: none; font-weight: 600; padding: 2px 10px 2px 2px; border-radius: 10px; border: 1px solid var(--line); }
.sklink:hover { border-color: var(--accent); }
.klogo { position: relative; width: 40px; height: 40px; display: inline-block; }
.klogo svg { width: 100%; height: 100%; display: block; overflow: visible; animation: lgFloat 6s ease-in-out infinite; }
.klogo .k-left  { transform-origin: 86px 150px;  animation: lgWaveL 3.8s ease-in-out infinite alternate; }
.klogo .k-right { transform-origin: 170px 150px; animation: lgWaveR 4.4s ease-in-out infinite alternate; }
.klogo .k-tL    { transform-origin: 104px 168px; animation: lgWiggle 3.4s ease-in-out infinite alternate; }
.klogo .k-tR    { transform-origin: 152px 168px; animation: lgWiggle 3.4s ease-in-out 1.7s infinite alternate-reverse; }
@keyframes lgFloat  { 0%, 100% { transform: translate(0, 0) rotate(0deg); } 25% { transform: translate(1px, -3px) rotate(2deg); }
                      50% { transform: translate(0, -5px) rotate(0deg); } 75% { transform: translate(-1px, -3px) rotate(-2deg); } }
@keyframes lgWaveL  { from { transform: rotate(-8deg); } to { transform: rotate(8deg); } }
@keyframes lgWaveR  { from { transform: rotate(8deg); } to { transform: rotate(-8deg); } }
@keyframes lgWiggle { from { transform: skewX(-7deg) rotate(-2deg); } to { transform: skewX(7deg) rotate(2deg); } }
.lbub { position: absolute; left: var(--x); bottom: 38%; width: var(--s); height: var(--s); border-radius: 50%; pointer-events: none;
        border: 1px solid rgba(120, 210, 170, .7); background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.5), rgba(255,255,255,0) 65%);
        opacity: 0; animation: lgBubble var(--t, 9s) ease-in var(--d) infinite; }
@keyframes lgBubble { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 8% { opacity: .8; }
                      25% { transform: translate(var(--w), -10px) scale(.85); } 50% { transform: translate(calc(var(--w) * -1), -20px) scale(1); }
                      75% { transform: translate(var(--w), -30px) scale(1.05); opacity: .5; } 100% { transform: translate(0, -42px) scale(1.15); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .klogo svg, .klogo .k-left, .klogo .k-right, .klogo .k-tL, .klogo .k-tR, .lbub { animation: none !important; } .lbub { display: none; } }
.primary-link { font-weight: 700; }
/* the help page */
.helppage { max-width: 820px; margin: 0 auto; padding: 22px 18px 60px; line-height: 1.6; }
.helppage h1 { font-size: 28px; margin: 10px 0 6px; } .helppage h2 { font-size: 20px; margin: 30px 0 8px; } .helppage h3 { font-size: 16px; margin: 18px 0 4px; }
.helppage .lead { font-size: 17px; color: var(--muted); }
.helppage .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin: 12px 0; }
.helppage ol li, .helppage ul li { margin: 4px 0; }
.helppage .toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; } .helppage .toc a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--text); font-size: 14px; }
.helppage .flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.helppage .flow div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; }
.helppage .flow b { display: block; font-size: 22px; margin-bottom: 2px; }
.top nav { align-items: center; }
.btnlink { display: inline-flex; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.sheetview { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; }
#moveBtns select#moveKind { flex: 1 1 100%; }
.corner.head { border-color: #4dabf7; background: rgba(77,171,247,.25); }
.headbtn.on { border-color: #4dabf7; box-shadow: inset 0 0 0 1px #4dabf7; }
details.head { margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; border-left: 4px solid #4dabf7; }
details.head summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.headgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 10px; margin-top: 6px; }
.headgrid label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.headgrid input, .headgrid select { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.headgrid input.auto, .headgrid select.auto { border-color: #4dabf7; background: rgba(77,171,247,.12); }
.pgnlang { align-items: center; gap: .6em; flex-wrap: wrap; font-size: .9em; }
.pgnlang select { margin-left: .4em; }
.byline { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 6px; }
details.players { margin-top: 8px; } details.players summary { cursor: pointer; font-size: .9em; } details.players textarea { width: 100%; box-sizing: border-box; margin-top: 6px; min-height: 70px; }
.sheetwrap { position: relative; }
.sheetview.clickable { cursor: pointer; }
.boxedit { position: absolute; z-index: 5; font: 600 15px system-ui, sans-serif; padding: 2px 6px; border: 2px solid #1c7ed6; border-radius: 6px; background: #fff; color: #111; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.fixbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; padding: 8px 10px; border: 1px solid #1c7ed6; border-radius: 8px; background: rgba(28,126,214,.08); }
.fixbar #fixInfo { flex: 1 1 200px; }
