@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/geist-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/geist-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --red: #FF383C;
  --green: #34C759;
  --indigo: #6155F5;
  --gray-500: #8E8E93;
  --gray-400: #AEAEB2;
  --gray-300: #C7C7CC;
  --gray-200: #D1D1D6;
  --gray-100: #E5E5EA;
  --gray-50: #F2F2F7;
  --primary: #ffffff;
  --secondary: #8d8d93;
  --background: var(--gray-50);
  --text: #121213;
  --on-accent: #ffffff;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --red: #FF4245;
    --green: #30D158;
    --indigo: #6B5FFF;
    --gray-400: #636366;
    --gray-300: #48484A;
    --gray-200: #3A3A3C;
    --gray-100: #2C2C2E;
    --gray-50: #1C1C1E;
    --primary: #000000;
    --secondary: #8a8a8e;
    --text: #eeeeee;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: "Geist", sans-serif;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--indigo); }

.icon { width: 1.2em; height: 1.2em; vertical-align: -0.22em; flex: none; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: 0;
  border-radius: 8px;
  background: var(--indigo);
  color: var(--on-accent);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { background: var(--gray-200); color: var(--secondary); cursor: default; filter: none; }
.btn.big { width: 100%; padding: 0.9rem; font-size: 1.1rem; }
.btn.small { padding: 0.35rem 0.8rem; font-size: 0.9rem; color: var(--on-accent); }
.btn.danger { background: var(--red); }

.link {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--indigo);
  cursor: pointer;
  text-decoration: underline;
}
.link.danger { color: var(--red); }

.small { font-size: 0.875rem; color: var(--secondary); }
.mono { font-family: ui-monospace, monospace; font-size: 0.9em; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.logo .icon { color: var(--indigo); }
.logo a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 0.4em; }

.welcome { max-width: 560px; margin: 0 auto; padding: 4rem 16px 2rem; }
.welcome h1.logo { font-size: 2.4rem; margin: 0 0 0.6rem; }
.welcome .lead { font-size: 1.1rem; margin: 0 0 2rem; }
.welcome h2 { margin: 2rem 0 0.5rem; font-size: 1.2rem; }
.welcome.text p { margin: 0 0 0.9rem; }
.empty { padding: 1rem 0; }
.foot { margin-top: 2.5rem; font-size: 0.9rem; }

fieldset { border: 0; margin: 0 0 1.6rem; padding: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: 0.5rem; padding: 0; }

.opt {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--primary);
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.opt:has(input:checked) { border-color: var(--indigo); box-shadow: inset 0 0 0 1px var(--indigo); }
.opt input { margin: 0.25rem 0 0; accent-color: var(--indigo); }
.opt b { display: block; }
.opt small, .seg small { display: block; color: var(--secondary); font-size: 0.85rem; }

.seg { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.seg label { flex: 1 1 0; min-width: 7rem; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  text-align: center;
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--primary);
  font-weight: 600;
}
.seg input:checked + span { border-color: var(--indigo); box-shadow: inset 0 0 0 1px var(--indigo); color: var(--indigo); }
.seg input:focus-visible + span { outline: 2px solid var(--indigo); outline-offset: 2px; }
.seg input:disabled + span { opacity: 0.45; cursor: not-allowed; }

body.game { display: flex; height: 100vh; overflow: hidden; }

.side {
  width: 30vw;
  min-width: 280px;
  max-width: 70vw;
  display: flex;
  flex-direction: column;
  background: var(--primary);
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
}

.bar { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.bar .logo { font-size: 1.25rem; margin-right: auto; }
.stat { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--secondary); }
.stat + .stat { color: var(--text); }

.shot { position: relative; cursor: none; flex: none; }
.shot img { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; border-radius: 8px; background: var(--gray-100); user-select: none; }
.lens {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 1px var(--gray-400), 0 4px 16px rgba(0, 0, 0, 0.35);
  background-repeat: no-repeat;
  background-color: var(--gray-100);
  pointer-events: none;
  z-index: 5;
}

.hint { margin: 0; color: var(--secondary); }
.res p { margin: 0 0 0.3rem; }
.res .pts { font-size: 2rem; font-weight: 700; color: var(--indigo); font-variant-numeric: tabular-nums; }
.res .err { color: var(--red); }

.actions { margin-top: auto; display: flex; flex-direction: column; gap: 0.6rem; align-items: center; }
.actions .btn { width: 100%; padding: 0.85rem; font-size: 1.05rem; }

.grip { width: 6px; cursor: col-resize; background: var(--gray-200); flex: none; touch-action: none; }
.grip:hover { background: var(--indigo); }

.mapwrap { position: relative; flex: 1; min-width: 0; background: var(--gray-100); overflow: hidden; }

.view { position: absolute; inset: 0; overflow: hidden; cursor: crosshair; touch-action: none; user-select: none; }
.view.drag { cursor: grabbing; }
.view.empty::after {
  content: "This layer has no image yet.";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--secondary);
}
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; pointer-events: none; }
.tl { position: absolute; inset: 0; }
.tl img { position: absolute; max-width: none; user-select: none; }
.line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.line line { stroke: var(--text); stroke-width: 2; stroke-dasharray: 6 5; }

.pin { position: absolute; left: 0; top: 0; pointer-events: none; }
.pin .icon { display: block; width: 32px; height: 32px; }
.pin.guess .icon { margin: -30px 0 0 -16px; color: var(--red); fill: var(--primary); }
.pin.answer .icon {
  margin: -18px 0 0 -18px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.tools { position: absolute; z-index: 3; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.tools > * { pointer-events: auto; }
.pills { display: flex; flex-wrap: wrap; background: var(--primary); border: 1px solid var(--gray-200); border-radius: 8px; padding: 3px; gap: 2px; }
.pills[hidden] { display: none; }
#views { margin-left: auto; }
#layers button:not(.on) { color: var(--secondary); text-decoration: line-through; }
.pills button, .zoom button {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: 0;
  background: none;
  color: var(--text);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}
.pills button:hover { background: var(--gray-100); }
.pills button.on { background: var(--indigo); color: var(--on-accent); }
.pills button:disabled { opacity: 0.4; cursor: default; background: none; }
.pills button.on:disabled { opacity: 1; background: var(--indigo); }

.zoom { position: absolute; z-index: 3; right: 12px; bottom: 12px; display: flex; flex-direction: column; background: var(--primary); border: 1px solid var(--gray-200); border-radius: 8px; padding: 3px; gap: 2px; }
.zoom button { padding: 0.4rem; display: grid; place-items: center; }
.zoom button:hover { background: var(--gray-100); }

.over { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); padding: 16px; }
.over[hidden] { display: none; }
.over .card { background: var(--primary); border-radius: 12px; padding: 1.75rem 2rem; width: min(440px, 100%); max-height: 100%; overflow: auto; }
.over h2 { margin: 0 0 0.4rem; }
.over .big { font-size: 1.6rem; font-weight: 700; margin: 0 0 0.8rem; color: var(--indigo); }
.over form { display: flex; align-items: center; gap: 1rem; margin-top: 1.2rem; }
.scores { margin: 0; padding-left: 1.4rem; font-variant-numeric: tabular-nums; }

.nojs { position: fixed; inset: auto 0 0 0; margin: 0; padding: 1rem; background: var(--red); color: #fff; text-align: center; }

.abar { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: 12px 16px; background: var(--primary); border-bottom: 1px solid var(--gray-200); }
.abar .logo { font-size: 1.15rem; }
.abar nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.abar nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.abar nav a:hover { color: var(--indigo); }
.amain { max-width: 1400px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.amain h1 { margin: 0 0 1rem; font-size: 1.6rem; }
.amain h2 { margin: 2rem 0 0.75rem; font-size: 1.2rem; }
.notice { background: var(--primary); border-left: 3px solid var(--indigo); padding: 0.6rem 0.9rem; border-radius: 0 8px 8px 0; }
.tag { font-size: 0.75rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: var(--gray-200); color: var(--secondary); vertical-align: 0.1em; }

input:not([type]), input[type=file], select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--primary);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  max-width: 100%;
}
input[type=file] { padding: 0.3rem; }

.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.5rem 0; }
.inline label { display: flex; align-items: center; gap: 0.4rem; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; max-width: 520px; }
.stack > label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 500; }
.stack > label.check { flex-direction: row; align-items: center; }
.stack p { margin: 0; }
.stack .btn { align-self: flex-start; }
.stack fieldset { margin: 0; }

.tbl { border-collapse: collapse; width: 100%; background: var(--primary); border-radius: 8px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--gray-100); }
.tbl th { font-size: 0.85rem; color: var(--secondary); font-weight: 600; }
.tbl .right { text-align: right; }

.layer { background: var(--primary); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.lhead { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 0.8rem; }
.lhead form { margin: 0; }
.variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.variant { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.variant form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.variant img, .noimg { width: 100%; max-width: 360px; aspect-ratio: 1; object-fit: contain; background: var(--gray-100); border-radius: 6px; }
.noimg { display: grid; place-items: center; color: var(--secondary); font-size: 0.9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.thumb { display: block; background: var(--primary); border-radius: 8px; overflow: hidden; color: var(--text); text-decoration: none; }
.thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--gray-100); }
.thumb span { display: block; padding: 0.5rem 0.7rem; font-weight: 500; }
.thumb small { display: block; color: var(--secondary); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb:hover { outline: 2px solid var(--indigo); }

.shotgrid { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 1.5rem; align-items: start; }
.editor { display: flex; flex-direction: column; gap: 1rem; }
.preview img { display: block; width: 100%; border-radius: 8px; background: var(--gray-100); }
.aview { position: sticky; top: 16px; height: calc(100vh - 32px); min-height: 400px; border-radius: 8px; }
.stack .seg label { min-width: 5.5rem; }
.stack .seg span { font-size: 0.9rem; }

.touch { display: none; font-size: 0.85rem; }
.full { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; background: #000; overflow: hidden; touch-action: none; }
.full img { max-width: 100%; max-height: 100%; transform-origin: 50% 50%; user-select: none; }

@media (pointer: coarse) {
  .touch { display: block; }
  .shot { cursor: pointer; }
  .zoom button { padding: 0.6rem; }
  .pills button { padding: 0.5rem 0.8rem; }
}

@media (max-width: 760px) and (orientation: portrait), (max-width: 480px) {
  body.game { flex-direction: column; height: 100vh; height: 100dvh; }
  .side { width: auto !important; min-width: 0; max-width: none; flex: none; max-height: 58dvh; padding: 10px 12px; gap: 8px; }
  .bar { flex-wrap: nowrap; gap: 0.6rem; white-space: nowrap; }
  .bar .logo { font-size: 1.1rem; }
  .stat { font-size: 0.9rem; }
  .shot img { max-height: 27dvh; }
  .hint { font-size: 0.9rem; }
  .res .pts { font-size: 1.5rem; }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .btn { flex: 1; width: auto; padding: 0.7rem; }
  .actions .link { flex-basis: 100%; text-align: center; }
  .actions { position: sticky; bottom: -10px; background: var(--primary); padding-bottom: 10px; margin-bottom: -10px; }
  .side:has(.res:not([hidden])) .hint { display: none; }
  .grip { display: none; }
  .mapwrap { min-height: 0; }
  .tools { top: 8px; left: 8px; right: 8px; gap: 6px; }
  .pills { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .pills button { white-space: nowrap; flex: none; }
  .zoom { right: 8px; bottom: 8px; }
  .over .card { padding: 1.25rem; }
  .welcome { padding-top: 2rem; }
  .welcome h1.logo { font-size: 2rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .side { min-width: 240px; padding: 10px; gap: 8px; }
  .shot img { max-height: 55vh; }
  .bar .logo { font-size: 1.05rem; }
  .actions .btn { padding: 0.6rem; }
  .side:has(.res:not([hidden])) .hint { display: none; }
}

@media (max-width: 760px) {
  .tbl { display: block; overflow-x: auto; white-space: nowrap; }
  .shotgrid { grid-template-columns: 1fr; }
  .aview { position: relative; top: 0; height: 70vh; }
}

.btn.alt { background: var(--primary); color: var(--indigo); box-shadow: inset 0 0 0 1px var(--indigo); margin-top: 0.6rem; }
.center { text-align: center; }
.err { color: var(--red); margin: 0.4rem 0 0; min-height: 1em; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

.dot { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.5em; flex: none; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 0.25em; padding: 0.35rem 0; border-bottom: 1px solid var(--gray-100); }
.plist li:last-child { border-bottom: 0; }
.plist li.off { opacity: 0.5; }
.plist li.me { font-weight: 600; }
.plist .pr { margin-left: auto; white-space: pre; font-variant-numeric: tabular-nums; color: var(--secondary); font-weight: 400; }
.scores li.me { font-weight: 600; }
.scores li { padding: 0.15rem 0; }
.scores .dot { vertical-align: 0.05em; }

.wait { position: fixed; inset: 0; z-index: 15; background: var(--background); overflow-y: auto; padding: 3rem 16px 2rem; }
.wait .card { max-width: 560px; margin: 0 auto; }
.wait h1.logo { font-size: 2rem; margin: 0 0 1rem; }
.wait h2 { margin: 0 0 0.4rem; font-size: 1.3rem; }
.wait h3 { margin: 1.6rem 0 0.4rem; font-size: 1rem; }
.wait p { margin: 0 0 0.6rem; }
.wait label[for] { display: block; font-weight: 600; margin: 1.2rem 0 0.4rem; }
.wait .setup { margin-top: 1.6rem; }
.wait .setup input:disabled + span { cursor: default; }
.wait #start { margin-top: 0.4rem; }
.share { display: flex; gap: 0.5rem; }
.share input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--primary); border: 1px solid var(--gray-300); border-radius: 8px; padding: 0.5rem 0.7rem; }
.oacts { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1.2rem; }
.oacts .hint { flex-basis: 100%; margin: 0; }

.others { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ocur, .orect { position: absolute; left: 0; top: 0; will-change: transform; }
.ocur .icon { display: block; width: 20px; height: 20px; color: var(--c); fill: var(--c); stroke: var(--primary); stroke-width: 1.5; margin: -2px 0 0 -2px; }
.ocur span { position: absolute; left: 16px; top: 16px; white-space: nowrap; font-size: 0.75rem; font-weight: 600; color: #fff; background: var(--c); border-radius: 4px; padding: 0.05rem 0.35rem; }
.orect { border: 2px solid var(--c); border-radius: 4px; opacity: 0.6; }
