:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0e0e0e;
  background-color: #070707;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: radial-gradient(circle at top, #3a2f27 0%, #1f1a16 65%, #0e0b09 100%);
}

#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.board-shell {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.board-viewport {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top, #655b4e 0%, #211d19 60%, #151515 100%);
  cursor: grab;
  touch-action: none;
  position: relative;
}

.torch-light-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.65;
  background-image: url('../img/torch-light.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 100; /* Above board content but below solution bar (1000) and help (2000+) */
  mix-blend-mode: multiply;
}

.board-viewport:active {
  cursor: grabbing;
}

.board {
  width: 2200px;
  height: 1400px;
  position: relative;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('../img/cork-background.jpg');
  background-repeat: repeat;
  background-position: 0 0;
  background-size: 512px 512px;
  touch-action: none;
}

.board-card {
  user-select: none;
  pointer-events: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  transform-origin: center center;
}

.board-item {
  position: absolute;
  pointer-events: auto;
  transition: filter 0.15s ease-out, box-shadow 0.15s ease-out, opacity 0.25s ease-out;
  opacity: 1;
}

.board-item--faded {
  opacity: 0.3;
}

.board-item--hover .board-card {
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.9)) 
          drop-shadow(0 0 24px rgba(255, 255, 255, 0.6));
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
}

.pin {
  /* Zero-size anchor: absolute position marks the thread attachment point */
  width: 0;
  height: 0;
  position: absolute;
  z-index: 40; /* Above threads */
  pointer-events: none;
}

.pin-hit-area {
  position: absolute;
  left: 0;
  top: 0;
  width: 110px;
  height: 110px;
  transform: translate(-50%, -85%); /* hover/click area lives above the anchor point */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: none;
  appearance: none;
  border: none;
  padding: 0;
  cursor: grab;
  user-select: none;
  pointer-events: auto;
}

.pin-hit-area--dragging,
.pin-hit-area:active {
  cursor: grabbing;
}

.pin-img {
  width: 32px;
  height: auto;
  user-select: none;
  transition: transform 0.15s ease-out;
  pointer-events: none;
}

.pin-hit-area:hover .pin-img,
.pin-hit-area:focus-visible .pin-img {
  transform: scale(1.35);
}

.pin-hit-area:active .pin-img,
.pin-hit-area--dragging .pin-img {
  transform: scale(1.5);
}

.threads-container {
  pointer-events: none;
}

.thread-group {
  pointer-events: auto;
  cursor: pointer;
}

.thread-hit-area {
  stroke: transparent;
  stroke-width: 16;
  fill: none;
  pointer-events: auto;
}

.thread-glow {
  stroke: #d32f2f;
  stroke-width: 8;
  fill: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.thread-group:hover .thread-glow {
  opacity: 0.6;
}

.thread-glow--active {
  opacity: 0.6;
}

.thread {
  stroke: #8d0000;
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}

.thread-temp {
  stroke: #d32f2f;
  stroke-width: 2;
  stroke-dasharray: 5, 5;
  opacity: 0.7;
  pointer-events: none;
}

.solution-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #000000;
  padding: 16px 20px 46px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
}

.solution-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 800px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.solution-url-prefix {
  color: #f5f0e8;
  font-size: 0.9rem;
  font-family: monospace;
  white-space: nowrap;
  line-height: 1;
  vertical-align: baseline;
}

.solution-inputs {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.solution-input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.solution-input {
  width: 34px;
  height: 36px;
  background-color: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #f5f0e8;
  font-size: 0.9rem;
  font-family: monospace;
  text-align: left;
  padding: 0;
  padding-left: 7px;
  line-height: 1;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.solution-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
  background-color: #252525;
}

.solution-input::placeholder {
  color: rgba(245, 240, 232, 0.4);
}

.solution-input-label {
  position: absolute;
  top: 100%;
  margin-top: 4px;
  color: #ff8c00;
  font-size: 1.125rem;
  font-weight: bold;
  font-family: monospace;
  line-height: 1;
}

.solution-separator {
  color: #f5f0e8;
  font-size: 0.9rem;
  font-family: monospace;
  padding: 0 1px;
  line-height: 1;
  vertical-align: baseline;
}

.solution-go {
  width: 36px;
  height: 36px;
  background-color: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #f5f0e8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
  padding: 0;
  margin-left: 6px;
  margin-top: 0;
  align-self: baseline;
}

/* When button wraps to new line, add top margin to avoid overlapping labels */
.solution-container > .solution-go {
  margin-top: 0;
}

@media (max-width: 600px) {
  .solution-go {
    margin-top: 28px;
  }
}

.solution-go:hover:not(:disabled) {
  background-color: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.3);
}

.solution-go:active:not(:disabled) {
  background-color: #333333;
}

.solution-go:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.help-button {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: #f5f0e8;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  padding: 0;
  user-select: none;
}

.help-button:hover {
  background-color: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}

.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.help-overlay--visible {
  opacity: 1;
  visibility: visible;
}

.help-content {
  background-color: #000000;
  border: none;
  border-radius: 20px;
  padding: 32px;
  max-width: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  transform: translateY(50px);
  transition: transform 0.3s ease-out;
}

.help-overlay--visible .help-content {
  transform: translateY(0);
}

.help-text {
  color: #f5f0e8;
  font-size: 1rem;
  line-height: 1.6;
  text-align: center;
}

.help-text p {
  margin: 0;
  padding-bottom: 12px;
}

.help-okay {
  width: 100%;
  padding: 12px 24px;
  background-color: #ff8c00;
  border: 2px solid #ff8c00;
  border-radius: 10px;
  color: #0e0e0e;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  align-self: center;
  max-width: 200px;
  font-weight: 600;
}

.help-okay:hover {
  background-color: #ff9f1a;
  border-color: #ff9f1a;
}

.help-okay:active {
  background-color: #e67e00;
  border-color: #e67e00;
}

/* Mobile styles */
@media (max-width: 768px) {
  .help-content {
    max-width: 90%;
    padding: 24px;
    margin: 20px;
  }

  .help-text {
    font-size: 0.95rem;
  }

  .help-button {
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
}


