/**
 * HIMALAYAN JIGSAW PUZZLE — STYLESHEET
 * Himalayan Terracotta, Saffron Gold & Lapis Azure Palette
 */

:root {
  --hp-bg-dark: #070d18;
  --hp-sidebar-bg: rgba(14, 22, 36, 0.94);
  --hp-terracotta: #c2410c;
  --hp-terracotta-light: #ea580c;
  --hp-saffron: #f59e0b;
  --hp-gold: #f5a425;
  --hp-gold-light: #ffd166;
  --hp-turquoise: #2dd4bf;
  --hp-turquoise-glow: rgba(45, 212, 191, 0.4);
  --hp-lapis: #1e3a8a;
  --hp-crimson: #991b1b;
  --hp-border: rgba(245, 164, 37, 0.28);
  --hp-card-bg: rgba(255, 255, 255, 0.04);
  --hp-text: #e2e8f0;
  --hp-text-muted: #94a3b8;
  --font-serif: 'Cinzel', serif, Georgia;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--hp-bg-dark);
  font-family: var(--font-sans);
  color: var(--hp-text);
  overflow: hidden;
  touch-action: none;
  display: flex;
  flex-direction: column;
}

/* ── Main Responsive Layout ── */
.hp-layout {
  display: flex;
  width: 100vw;
  flex: 1;
  height: calc(100vh - 68px);
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ── Left Himalayan Sidebar ── */
.hp-sidebar {
  width: 250px;
  flex-shrink: 0;
  height: 100%;
  background: var(--hp-sidebar-bg);
  border-right: 1.5px solid var(--hp-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 10px;
  z-index: 10;
  backdrop-filter: blur(12px);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
}

.hp-sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Open Gallery Button */
.hp-btn-gallery {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: linear-gradient(135deg, rgba(245, 164, 37, 0.22) 0%, rgba(194, 65, 12, 0.35) 100%);
  border: 1.5px solid var(--hp-gold);
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(245, 164, 37, 0.2);
}

.hp-btn-gallery:hover {
  background: linear-gradient(135deg, rgba(245, 164, 37, 0.38) 0%, rgba(194, 65, 12, 0.5) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(245, 164, 37, 0.35);
}

/* Active Image Card */
.hp-card-active-image {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
}

.active-image-preview {
  width: 52px;
  height: 42px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.active-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.active-image-meta h4 {
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 155px;
}

.active-image-meta span {
  font-size: 0.7rem;
  color: var(--hp-turquoise);
  display: block;
}

/* Section label */
.hp-section-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--hp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 2px;
}

/* Difficulty Buttons Pills */
.hp-difficulty-pills {
  display: flex;
  gap: 5px;
  width: 100%;
}

.hp-diff-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--hp-text);
}

.hp-diff-btn .diff-title {
  font-size: 0.82rem;
  font-weight: 800;
}

.hp-diff-btn .diff-count {
  font-size: 0.65rem;
  color: var(--hp-text-muted);
}

.hp-diff-btn:hover {
  background: rgba(245, 164, 37, 0.15);
  border-color: rgba(245, 164, 37, 0.4);
}

.hp-diff-btn.active {
  background: linear-gradient(135deg, rgba(245, 164, 37, 0.3) 0%, rgba(194, 65, 12, 0.4) 100%);
  border-color: var(--hp-gold);
  color: #fff;
  box-shadow: 0 0 12px rgba(245, 164, 37, 0.3);
}

.hp-diff-btn.active .diff-count {
  color: var(--hp-gold-light);
}

/* Stats Box (Timer, Moves, Progress) */
.hp-stats-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(10, 16, 26, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
}

.hp-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-stat-item .stat-icon {
  font-size: 1rem;
}

.hp-stat-item .stat-data {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.hp-stat-item .stat-label {
  font-size: 0.74rem;
  color: var(--hp-text-muted);
}

.hp-stat-item .stat-value {
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
}

/* Sidebar Bottom Action Buttons */
.hp-sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hp-action-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.hp-btn-peek {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18) 0%, rgba(13, 148, 136, 0.3) 100%);
  border: 1.5px solid var(--hp-turquoise);
  color: #fff;
}

.hp-btn-peek:hover,
.hp-btn-peek.active {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.4) 0%, rgba(13, 148, 136, 0.55) 100%);
  box-shadow: 0 0 14px var(--hp-turquoise-glow);
  transform: translateY(-1px);
}

.hp-btn-shuffle {
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

.hp-btn-shuffle:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: #fff;
  transform: translateY(-1px);
}

.hp-btn-help {
  background: rgba(245, 164, 37, 0.08);
  border: 1.5px solid rgba(245, 164, 37, 0.35);
  color: var(--hp-gold-light);
}

.hp-btn-help:hover {
  background: rgba(245, 164, 37, 0.2);
  border-color: var(--hp-gold);
  transform: translateY(-1px);
}

/* ── Main Game Board Area (Velvet Table) ── */
.hp-main {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #141f33 0%, #0b1220 58%, #060a13 100%);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.75);
}

.hp-main::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.26;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='velvetGrain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.62' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23velvetGrain)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 220px 220px;
  mix-blend-mode: overlay;
}

.hp-stage-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.65;
}

.hp-stage-backdrop svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The Canvas Stage Container */
.hp-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#puzzleCanvas {
  display: block;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
}

#puzzleCanvas:active {
  cursor: grabbing;
}

/* Translucent Ghost Peek Overlay */
.hp-ghost-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.25s ease;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  border: 2px dashed rgba(245, 164, 37, 0.6);
  border-radius: 6px;
  background-size: cover;
  background-position: center;
}

.hp-ghost-overlay.active {
  opacity: 0.45;
}

/* Celebration Canvas for Side Fireworks */
.hp-celebration-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* Inspection Mode Floating Banner */
.hp-inspect-banner {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(24px);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  background: rgba(13, 20, 34, 0.94);
  border: 1.5px solid var(--hp-gold);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 24px rgba(245, 164, 37, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  user-select: none;
}

.hp-inspect-banner.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  animation: inspectPulse 2s ease-in-out infinite;
}

@keyframes inspectPulse {
  0%, 100% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 20px rgba(245, 164, 37, 0.3);
  }
  50% {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75), 0 0 32px rgba(245, 164, 37, 0.55);
  }
}

.hp-inspect-badge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0b111e;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.hp-inspect-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .hp-inspect-banner {
    bottom: 14px;
    padding: 8px 16px;
    gap: 8px;
  }
  .hp-inspect-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
  .hp-inspect-text {
    font-size: 0.78rem;
  }
}

/* ── Modals & Dialogs ── */
.hp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 11, 20, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: hpFadeIn 0.2s ease-out;
}

.hp-modal-overlay.active {
  display: flex;
}

@keyframes hpFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hp-modal-box {
  background: linear-gradient(135deg, #131d2e 0%, #0d1522 100%);
  border: 1.5px solid var(--hp-border);
  border-radius: 18px;
  padding: 22px;
  max-width: 620px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.hp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.hp-modal-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: #fff;
  letter-spacing: 1px;
}

.hp-modal-sub {
  font-size: 0.85rem;
  color: var(--hp-text-muted);
  margin-bottom: 18px;
}

.hp-modal-close {
  background: none;
  border: none;
  color: var(--hp-text-muted);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.hp-modal-close:hover {
  color: #fff;
}

/* Gallery Grid */
.hp-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
}

.hp-gallery-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.hp-gallery-card:hover {
  transform: translateY(-3px);
  border-color: var(--hp-gold);
  box-shadow: 0 8px 24px rgba(245, 164, 37, 0.3);
}

.hp-gallery-card.active {
  border-color: var(--hp-turquoise);
  box-shadow: 0 0 20px var(--hp-turquoise-glow);
}

.card-thumb-wrap {
  width: 100%;
  height: 110px;
  overflow: hidden;
  position: relative;
}

.card-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.hp-gallery-card:hover .card-thumb-wrap img {
  transform: scale(1.05);
}

.card-category-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(14, 20, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--hp-gold-light);
}

.card-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
}

.card-sub {
  font-size: 0.72rem;
  color: var(--hp-text-muted);
}

/* Win Modal Specifics */
.hp-win-box {
  text-align: center;
  max-width: 440px;
}

.win-crown {
  font-size: 3rem;
  margin-bottom: 6px;
  animation: winCrownBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winCrownBounce {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.win-preview-frame {
  width: 100%;
  height: 170px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--hp-gold);
  box-shadow: 0 8px 24px rgba(245, 164, 37, 0.3);
  margin-bottom: 16px;
}

.win-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.win-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.win-metric-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.win-metric-card .m-icon {
  font-size: 1.2rem;
  margin-bottom: 2px;
}

.win-metric-card .m-label {
  font-size: 0.7rem;
  color: var(--hp-text-muted);
}

.win-metric-card .m-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--hp-gold-light);
}

.win-buttons-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hp-btn-primary {
  padding: 12px;
  background: linear-gradient(135deg, var(--hp-gold) 0%, var(--hp-terracotta) 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(245, 164, 37, 0.35);
}

.hp-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 164, 37, 0.5);
}

.hp-btn-secondary {
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hp-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Help Modal Content */
.hp-help-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.help-item .h-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ── Mobile & Small Screen Adaptability ── */
@media (max-width: 768px) {
  .hp-layout {
    flex-direction: column;
  }

  .hp-sidebar {
    width: 100%;
    height: auto;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1.5px solid var(--hp-border);
    overflow-y: auto;
  }

  .hp-main {
    flex: 1;
  }
}

