/* ── Threaded — game-specific styles ── */

#canvas-wrap {
  background: #0b1420;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: 0;
}

.th-hide { display: none !important; }

/* ── Game wrapper ── */
#th-game {
  position: relative;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ── HUD ── */
#th-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: #c8b880;
  letter-spacing: 0.03em;
}

/* ── Play area ── */
#th-play-area {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #0d1828;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.55);
}

/* Fine horizontal fabric texture */
#th-play-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent       0px,
    transparent       5px,
    rgba(255,255,255,0.012) 5px,
    rgba(255,255,255,0.012) 6px
  );
  pointer-events: none;
  z-index: 0;
}

/* Subtle radial light source at top-center */
#th-play-area::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 35% at 50% 0%, rgba(140, 180, 255, 0.07) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ── Thread lines ── */
.th-thread {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  /* Fades to transparent at the edges like thread tautly stretched across */
  background: linear-gradient(
    90deg,
    transparent 0%,
    #b8a86a 5%,
    #d4c080 20%,
    #c8b478 50%,
    #d4c080 80%,
    #b8a86a 95%,
    transparent 100%
  );
  box-shadow: 0 0 6px rgba(200, 176, 120, 0.28);
  z-index: 1;
}

/* ── Eye circles ── */
.th-eye {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #f0c040;
  background: rgba(240, 192, 64, 0.09);
  box-shadow:
    0 0 10px rgba(240, 192, 64, 0.50),
    0 0 22px rgba(240, 192, 64, 0.18),
    inset 0 0 8px rgba(240, 192, 64, 0.10);
  z-index: 2;
}

/* ── Needle ── */
#th-needle {
  position: absolute;
  width: 4px;
  /* height and top set by JS */
  background: linear-gradient(to bottom, #ecf0fa 0%, #b8c8e0 35%, #7888a8 100%);
  clip-path: polygon(50% 0%, 100% 11%, 100% 100%, 0% 100%, 0% 11%);
  filter: drop-shadow(0 0 5px rgba(170, 200, 255, 0.50));
  z-index: 3;
}

/* ── Hit flash ── */
#th-hit-flash {
  position: absolute;
  inset: 0;
  background: rgba(240, 192, 64, 0.38);
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

/* ── String SVG ── */
#th-string-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 4;
}

#th-string-line {
  stroke: #c83030;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ── Outcome overlay (fail / success) ── */
#th-outcome-screen {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 26, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 18;
  pointer-events: auto;
}

.th-outcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 32px 28px;
}

.th-outcome-msg {
  font-family: 'DM Sans', sans-serif;
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #f0c040;
  margin: 0;
  text-shadow: 0 0 24px rgba(240, 192, 64, 0.45);
}

.th-outcome-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 14px 40px;
  border-radius: 13px;
  border: none;
  background: #f0c040;
  color: #0b1420;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity 0.1s;
}

.th-outcome-btn:active { opacity: 0.78; }

@keyframes th-flash-anim {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

#th-hit-flash.th-flashing {
  animation: th-flash-anim 0.5s ease-out forwards;
}

#th-hit-flash.th-miss {
  background: rgba(220, 60, 60, 0.42);
}

/* ── Controls ── */
#th-controls {
  padding: 18px 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.th-nav-btn {
  width: 52px;
  height: 52px;
  background: #1a3a58;
  color: #e8d898;
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
  border: 2px solid rgba(200, 184, 128, 0.30);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 #0d2234, 0 5px 12px rgba(0, 0, 0, 0.45);
  transition: transform 0.07s, box-shadow 0.07s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  flex-shrink: 0;
}

.th-nav-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0d2234, 0 2px 6px rgba(0, 0, 0, 0.40);
}

/* Needle positioning track — subtle rail at play-area bottom */
#th-needle-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(200, 184, 128, 0.20) 8%,
    rgba(200, 184, 128, 0.20) 92%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

#th-launch-btn {
  background: #1a3a58;
  color: #e8d898;
  font-family: 'DM Sans', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 16px 64px;
  border: 2px solid rgba(200, 184, 128, 0.30);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 #0d2234, 0 6px 16px rgba(0, 0, 0, 0.50);
  transition: transform 0.07s, box-shadow 0.07s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

#th-launch-btn:hover:not(:disabled) {
  background: #1f4a6e;
}

#th-launch-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0d2234, 0 2px 8px rgba(0, 0, 0, 0.45);
}

#th-launch-btn:disabled {
  background: #0f2030;
  border-color: rgba(200, 184, 128, 0.12);
  color: rgba(232, 216, 152, 0.35);
  box-shadow: 0 2px 0 #060f18, 0 4px 10px rgba(0, 0, 0, 0.35);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ── Resume / restart overlay ── */
#th-resume-screen {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 26, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
  padding: 32px 28px;
}

.th-resume-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 300px;
}

.th-resume-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #c8b880;
  margin: 0 0 6px;
}

.th-resume-btn {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 16px 20px;
  border-radius: 13px;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity 0.1s;
}

.th-resume-btn:active { opacity: 0.80; }

.th-resume-continue {
  background: #f0c040;
  color: #0b1420;
}

.th-resume-restart {
  background: transparent;
  color: rgba(200, 184, 128, 0.65);
  border: 1.5px solid rgba(200, 184, 128, 0.22);
}

/* ── Win screen ── */
#th-win-screen {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 26, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 32px 28px;
}

.th-win-trophy {
  font-size: 3.2rem;
  margin: 0 0 4px;
  line-height: 1;
}

.th-win-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(200, 184, 128, 0.65);
  margin: 0 0 20px;
  text-align: center;
}

/* ── Round transition overlay ── */
#th-round-screen {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 26, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.th-round-inner { text-align: center; }

.th-round-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #c8b880;
  margin: 0 0 6px;
}

.th-round-num {
  font-family: 'DM Sans', sans-serif;
  font-size: 6rem;
  font-weight: 900;
  line-height: 1;
  color: #f0c040;
  margin: 0;
  text-shadow: 0 0 30px rgba(240, 192, 64, 0.45);
}
