:root {
  --bg: #121212;
  --surface: #1b1b1b;
  --surface-2: #232323;
  --text: #f6f6f6;
  --muted: #b6b6b6;
  --brand: #4caf50;
  --brand-2: #82e283;
  --danger: #ff5252;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --maxw: 960px;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  padding: 16px;
  color: var(--text);
  background: radial-gradient(
    1200px 600px at 30% -10%,
    #1e1e1e 0,
    var(--bg) 60%
  );
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
}
h1 {
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: 0.3px;
}
.sub {
  color: var(--muted);
  margin: 0 0 12px;
}
.gallery {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px 16px 4px;
  margin: 6px 0;
  scroll-snap-type: x mandatory;
  position: relative;
  border-radius: 18px; /* Added to contain the glow nicely */
  animation: pulse-glow 1.1s ease-out 0.5s 2;
}
.gallery::-webkit-scrollbar {
  height: 8px;
}
.gallery::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 4px;
}
@media (max-width: 768px) {
  .gallery::after {
    content: "Scroll →";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--brand);
    color: #fff;
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    animation: fade-in-out 3s 0.5s forwards;
  }
}
@keyframes fade-in-out {
  0%,
  50%,
  100% {
    opacity: 0;
  }
  25%,
  75% {
    opacity: 1;
  }
}
.card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid #2a2a2a;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    border-color 0.12s ease;
  isolation: isolate;
  min-width: 240px;
  width: 240px;
  scroll-snap-align: start;
}
@media (max-width: 768px) {
  .card {
    min-width: 240px;
    width: 240px;
  }
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  border-color: #3a3a3a;
}
.card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.35) inset,
    0 14px 34px rgba(0, 0, 0, 0.5);
}
.card .label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.4;
}
.card .label small {
  display: block;
  font-weight: normal;
  color: var(--muted);
  font-size: 11px;
}
.thumb {
  width: 100%;
  aspect-ratio: 4/3;
  display: block;
  object-fit: cover;
  background: #222;
}
.cassette {
  display: grid;
  place-items: center;
  aspect-ratio: 4/3;
  background: linear-gradient(#2b2b2b, #272727);
  border: 2px dashed #3c3c3c;
  color: #ddd;
}
.cassette .plus {
  font-size: 42px;
  line-height: 1;
}
.cassette small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}
.controls {
  display: grid;
  gap: 10px;
  align-items: start;
  overflow: hidden;
  transition: max-height 0.35s ease-out, margin-bottom 0.35s ease-out;
  max-height: 500px;
  margin-bottom: 10px;
}
.controls.is-collapsed {
  max-height: 42px;
}
.controls > *:not(.segmented) {
  transition: opacity 0.2s ease-out;
}
.controls.is-collapsed > *:not(.segmented) {
  opacity: 0;
  pointer-events: none;
}
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 2px;
  gap: 2px;
}
.segmented__btn {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented__btn.active {
  background: var(--brand);
  color: #0c220c;
}
.segmented__btn:not(.active):hover {
  background: rgba(255, 255, 255, 0.05);
}
button {
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  border: 1px solid #2e2e2e;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
button:hover {
  background: #2a2a2a;
}
button.active {
  background: var(--brand);
  border-color: var(--brand-2);
}
:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}
.btn-ghost {
  background: transparent;
  border-color: #2a2a2a;
  color: var(--muted);
}
.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  max-height: calc(2 * 1.2em);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  color: var(--muted);
  font-size: 14px;
}
.status strong {
  color: var(--brand-2);
}
.pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid #2e2e2e;
}
.stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0e0e0e;
  border: 2px solid #2a2a2a;
  box-shadow: var(--shadow);
}
.stage.solve {
  border-style: solid;
  border-color: rgba(130, 226, 131, 0.55);
}
.stage.draw {
  border: 2px dashed #3c3c3c;
}
canvas {
  display: none;
  background: #fff;
  image-rendering: pixelated;
  width: 100%;
  height: auto;
}
canvas.visible {
  display: block;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #000000;
  font-weight: 1000;
  font-size: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.overlay.show {
  opacity: 1;
}
.skeleton {
  position: relative;
  overflow: hidden;
  background: #222;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.06),
    transparent
  );
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.initial-prompt {
  text-align: center;
  padding: 40px 20px;
}
.initial-prompt h2 {
  margin: 0 0 8px;
  font-weight: 750;

  color: var(--brand-2);
}
#start-drawing-btn {
  background: var(--brand);
  border-color: var(--brand-2);
  margin-top: 16px;
  font-weight: 600;
  color: #0c220c;
}
.drawing-tool-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  width: 100%;
}

.drawing-tools-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.drawing-tools-row button {
  width: 100%;
}

.size-control {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: var(--muted);
}

.size-control label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.size-control input[type="range"] {
  flex: 1 1 auto;
}

.size-control.is-disabled {
  opacity: 0.4;
}

.size-control.is-disabled input[type="range"] {
  pointer-events: none;
}

.floating-message {
  position: absolute;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 14px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  animation: float-up-and-fade 1.8s ease-out forwards;
}

.floating-message--wall {
  background: rgba(255, 82, 82, 0.95);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.floating-message--nopath {
  background: #ffb300;
  color: #121212;
  border: 1px solid #ffe082;
}

@keyframes float-up-and-fade {
  from {
    transform: translate(-50%, -120%);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -220%);
    opacity: 0;
  }
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(76, 175, 80, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}
