:root {
  --bg: #080808;
  --panel: #111111;
  --panel-alt: #161616;
  --border: #f5f5f5;
  --text: #f6f6f6;
  --muted: #b3b3b3;
  --accent: #f6f6f6;
  --accent-contrast: #080808;
  --shadow: rgba(0, 0, 0, 0.45);
  --bg: #0b0f14;
  --panel: #111827;
  --border: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Special Elite", "Courier New", Courier, monospace;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0.01em;
}

.wrap {
  max-width: min(100%, 1100px);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 48px;
}

.wrap.spine-mode {
  max-width: min(100%, 3200px);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.header {
  margin-bottom: 24px;
}

.controls {
  gap: 8px;
}

.btn {
  border: 2px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  box-shadow: 0 2px 0 var(--shadow);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn.primary:hover {
  background: #e6e6e6;
  color: #050505;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn.review {
  border-color: var(--border);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn.primary {
  background: #0369a1;
  border-color: #0ea5e9;
}

.btn.review {
  border-color: #fbbf24;
  color: #fbbf24;
}

.input {
  min-width: 240px;
}

.menu {
  position: relative;
}

.menu-list {
  position: absolute;
  right: 0;
  top: 40px;
  width: 200px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 24px var(--shadow);
  width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  background: #1f2937;
}

.bar {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
  box-shadow: 0 12px 32px var(--shadow);
}

#prompt {
  flex: 1 1 240px;
  text-align: center;
}

.imgbox {
  position: relative;
  user-select: none;
  background: var(--panel-alt);
  border: 2px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  width: 100%;
  min-height: 300px;
  box-shadow: 0 16px 40px var(--shadow);
}

.imgbox.drag-mode {
  cursor: crosshair;
}

.imgbox.multi {
  aspect-ratio: 49 / 27;
  max-height: min(85vh, 1200px);
  background: linear-gradient(90deg, #0f0f0f 0%, #181818 100%);
}

.bg-strip {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 0;
  align-items: stretch;
  justify-content: stretch;
  background: transparent;
  z-index: 0;
}

.bg-strip.single {
  padding: 0;
}

.bg-image {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f0f0f;
  pointer-events: none;
}

.bg-image:first-child {
  border-left: none;
}

.bg-image:last-child {
  border-right: none;
}

.bg-strip.single .bg-image {
  border: none;
  background: #0f0f0f;
}

.bg-image.active {
  outline: 3px solid var(--border);
  outline-offset: -3px;
  min-height: 300px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.imgbox img {
  width: 100%;
  display: block;
}

.dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--panel);
  transform: translate(-50%, -50%);
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  z-index: 1;
  box-shadow: 0 0 0 2px var(--panel);
}

.dot.correct {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--panel);
}

.dot.wrong {
  background: #d22b2b;
  box-shadow: 0 0 0 2px rgba(210, 43, 43, 0.4);
}

@keyframes dotMonoPulse {
  0%,
  100% {
    background: var(--text);
    border-color: var(--text);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35),
      0 0 0 6px rgba(255, 255, 255, 0.08);
  }
  50% {
    background: var(--bg);
    border-color: var(--bg);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.65), 0 0 0 6px rgba(255, 255, 255, 0.02);
  }
}

.dot.active {
  animation: dotMonoPulse 1.3s ease-in-out infinite;
  transform: translate(-50%, -50%) scale(1.08);
}

.dot.draggable {
  cursor: grab;
}

.dot.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.5);
  background: #38bdf8;
  transform: translate(-50%, -50%);
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.dot.correct {
  background: #22c55e;
}

.dot.wrong {
  background: #ef4444;
}

.dot.active {
  outline: 3px solid #34d399;
  outline-offset: 2px;
}

.badge {
  position: absolute;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  transform: translate(-50%, -140%);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin: 16px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 32px var(--shadow);
}

.panel-head {
  align-items: baseline;
}

.panel-title {
  margin: 0;
  font-size: 1.125rem;
}

.coord-output {
  background: var(--panel-alt);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 12px;
  min-height: 180px;
  font-family: "Fira Code", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9rem;
  resize: vertical;
}

.panel-actions {
  justify-content: flex-start;
  gap: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #c7d2fe;
  transform: translate(-50%, -120%);
  font-size: 13px;
}

details {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 32px var(--shadow);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}

summary {
  cursor: pointer;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.celebration {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(6px);
  z-index: 40;
}

.celebration[hidden] {
  display: none;
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -120px;
  left: var(--left);
  width: 10px;
  height: 14px;
  background: hsl(var(--hue), 100%, 82%);
  opacity: 0;
  transform: translate3d(0, 0, 0);
  animation: confettiFall var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.celebration-card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 16px 48px var(--shadow);
  max-width: min(90vw, 420px);
}

.celebration-card h2 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.celebration-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1.05rem;
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -40vh, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate3d(0, 120vh, 0) rotate(540deg);
    opacity: 0;
  }
}
