@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800;900&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #0f0704;
  --gold-primary: #f3c669;
  --gold-light: #ffebad;
  --gold-dark: #d49c33;
  --gold-dim: #9e7529;
  --wood-dark: #150b07;
  --wood-border: #4a2916;
  --text-main: #f9f4ea;
  --text-muted: #cbbba3;
  --shadow-wall-deep: 0 45px 95px rgba(0, 0, 0, 0.95), 0 20px 40px rgba(0, 0, 0, 0.8);
  --glow-gold: 0 0 35px rgba(243, 198, 105, 0.45);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
}

/* User Reference Room Background */
.gallery-room {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('/games/puzzle/artwork/reference_room_bg.jpg');
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: #0f0704;
}

/* Desktop Main Grid Layout */
.gallery-layout {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 210px 1fr 210px;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 90%;
  max-width: 1060px;
  height: 90vh;
  margin: 0 auto;
}

/* Desktop Framed Plaque Panels (Left & Right) */
.plaque-frame {
  position: relative;
  background: var(--wood-dark);
  border: 3px solid var(--gold-dark);
  outline: 2px solid var(--wood-border);
  border-radius: 4px;
  box-shadow: 
    0 0 0 6px #150b07,
    0 20px 50px rgba(0, 0, 0, 0.95),
    inset 0 0 20px rgba(0, 0, 0, 0.95),
    0 0 20px rgba(243, 198, 105, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
  width: 100%;
}

.plaque-crown {
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-primary) 50%, transparent 100%);
  width: 100%;
}

.plaque-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(243, 198, 105, 0.3) 50%, transparent 100%);
  width: 100%;
}

/* Buttons inside Plaque */
.plaque-btn {
  background: transparent;
  border: none;
  color: var(--gold-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 14px 10px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.plaque-btn:hover {
  background: rgba(243, 198, 105, 0.14);
  color: #ffffff;
  text-shadow: 0 0 10px rgba(243, 198, 105, 0.6);
}

.plaque-btn:active {
  transform: scale(0.98);
}

.plaque-icon {
  font-size: 1.05rem;
}

/* Info Sections inside Plaque */
.plaque-block {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.plaque-label {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gold-dim);
  margin-bottom: 4px;
}

.plaque-value-large {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.plaque-label-sub {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--gold-primary);
  margin-top: 4px;
}

.plaque-value-title {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1.2px;
  line-height: 1.3;
  max-width: 170px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.plaque-sub-icon {
  color: var(--gold-primary);
  font-size: 1.05rem;
  margin-top: 2px;
}

/* Right Plaque Timer Row */
.plaque-timer-row {
  padding: 14px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.plaque-value-timer {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* Center Main Ornate Gold Painting Frame */
.main-painting-mount {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.ornate-gold-frame {
  position: relative;
  padding: 20px;
  background: 
    linear-gradient(135deg, #442614 0%, #1e0f07 50%, #4a2916 100%);
  border-radius: 10px;
  border: 5px solid #d49c33;
  outline: 3px solid #4a2916;
  box-shadow:
    0 0 0 6px #150b07,
    0 0 0 10px #3d2214,
    var(--shadow-wall-deep),
    0 0 50px rgba(243, 198, 105, 0.25);
  transition: box-shadow 0.4s ease;
}

.ornate-gold-frame.completed-glow {
  box-shadow:
    0 0 0 3px #ffe599,
    0 0 0 8px #f3c669,
    0 0 0 13px #7d4d29,
    0 0 90px rgba(243, 198, 105, 0.95),
    var(--shadow-wall-deep);
}

/* Brass Frame Corner Accents */
.frame-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--gold-primary);
  pointer-events: none;
}
.corner-tl { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.corner-tr { top: 6px; right: 6px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 6px; left: 6px; border-right: none; border-top: none; }
.corner-br { bottom: 6px; right: 6px; border-left: none; border-top: none; }

/* Puzzle Board Canvas */
.puzzle-board {
  position: relative;
  width: min(60vw, 470px);
  height: min(60vw, 470px);
  max-width: 470px;
  max-height: 470px;
  background: #090402;
  border-radius: 4px;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.95);
  overflow: hidden;
}

/* Tactile Tiles */
.puzzle-tile {
  position: absolute;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s ease, filter 0.2s ease;
  border-radius: 3px;
  box-shadow: 
    inset 0 0 0 1px rgba(255, 225, 150, 0.35),
    0 4px 10px rgba(0, 0, 0, 0.5);
  background-repeat: no-repeat;
  will-change: transform;
}

.puzzle-tile:hover {
  filter: brightness(1.15);
  box-shadow: 
    inset 0 0 0 2px var(--gold-primary),
    0 0 18px rgba(243, 198, 105, 0.7);
  z-index: 2;
}

.puzzle-tile:active {
  transform: scale(0.97);
}

.puzzle-tile.hint-highlight {
  animation: hintPulse 1.2s infinite alternate ease-in-out;
  z-index: 3;
}

@keyframes hintPulse {
  0% { box-shadow: inset 0 0 0 3px #ffffff, 0 0 10px #f3c669; }
  100% { box-shadow: inset 0 0 0 4px #f3c669, 0 0 30px #ffffff; }
}

.puzzle-tile.blank-tile {
  opacity: 0;
  pointer-events: none;
}

.puzzle-tile.blank-tile.reveal-final {
  opacity: 1;
  animation: revealFadeIn 0.6s ease forwards;
}

@keyframes revealFadeIn {
  0% { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

.tile-number {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(18, 10, 6, 0.85);
  color: var(--gold-primary);
  border: 1px solid var(--gold-dark);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Modals Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 2, 1, 0.9);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--wood-dark);
  border: 2px solid var(--gold-primary);
  border-radius: 18px;
  padding: 28px;
  width: 90%;
  max-width: 540px;
  box-shadow: var(--shadow-wall-deep), 0 0 40px rgba(243, 198, 105, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  color: var(--gold-primary);
  text-shadow: 0 2px 10px rgba(243, 198, 105, 0.4);
}

.btn-gold-action {
  background: linear-gradient(180deg, #f3c669 0%, #b88628 100%);
  color: #1a0d06;
  border: 1px solid #ffe599;
  font-weight: 800;
  padding: 10px 24px;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
  transition: all 0.2s ease;
  box-shadow: 0 6px 20px rgba(243, 198, 105, 0.35);
}

.btn-gold-action:hover {
  background: linear-gradient(180deg, #ffe599 0%, #d49c33 100%);
  box-shadow: 0 8px 25px rgba(243, 198, 105, 0.55);
  transform: translateY(-2px);
}

.preview-img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  border: 3px solid var(--wood-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
}

.gallery-modal-card {
  max-width: 800px;
  max-height: 88vh;
  width: 94%;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  width: 100%;
  max-height: 55vh;
  overflow-y: auto;
  padding: 10px 6px;
}

.gallery-item {
  position: relative;
  background: #1a0e08;
  border: 2px solid var(--wood-border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.gallery-item:hover:not(.locked) {
  border-color: var(--gold-primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(243, 198, 105, 0.3);
}

.gallery-item.locked {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.gallery-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
}

.gallery-item-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.gallery-stars {
  color: var(--gold-primary);
  font-size: 0.75rem;
  letter-spacing: 2px;
}

.victory-painting-view {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid var(--gold-primary);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8), 0 0 25px rgba(243, 198, 105, 0.4);
}

.stars-container {
  display: flex;
  gap: 12px;
  font-size: 2.2rem;
  color: #554428;
}

.star-filled {
  color: var(--gold-primary);
  text-shadow: 0 0 15px rgba(243, 198, 105, 0.8);
  animation: starPop 0.4s ease forwards;
}

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

.victory-stats-row {
  display: flex;
  gap: 30px;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 24px;
  border-radius: 10px;
  border: 1px solid rgba(243, 198, 105, 0.2);
}

.stat-block-val {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
}

.stat-block-lbl {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* High-Quality Mobile & Tablet Responsive Design */
@media (max-width: 920px) {
  .gallery-room {
    background-position: center top;
  }

  .gallery-layout {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100vh;
    padding: 10px 8px;
    gap: 8px;
    max-width: 100%;
    overflow-y: auto;
  }

  /* Top Mobile HUD Strip */
  .plaque-left {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    padding: 6px 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    border: 2px solid var(--gold-dark);
  }

  .plaque-left .plaque-crown,
  .plaque-left .plaque-divider {
    display: none;
  }

  .plaque-left .plaque-btn {
    width: auto;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .plaque-left .plaque-block {
    padding: 2px 6px;
  }

  .plaque-value-large {
    font-size: 1.1rem;
  }

  .plaque-value-title {
    font-size: 0.78rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Center Main Painting Frame on Mobile */
  .main-painting-mount {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .ornate-gold-frame {
    padding: 10px;
    border-width: 4px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9);
  }

  .puzzle-board {
    width: min(84vw, 360px);
    height: min(84vw, 360px);
  }

  /* Bottom Mobile Tool Buttons Strip */
  .plaque-right {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    max-width: 500px;
    padding: 6px 8px;
    gap: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    border: 2px solid var(--gold-dark);
  }

  .plaque-right .plaque-crown,
  .plaque-right .plaque-divider {
    display: none;
  }

  .plaque-timer-row {
    padding: 4px 8px;
  }

  .plaque-value-timer {
    font-size: 1.1rem;
  }

  .plaque-right .plaque-btn {
    width: auto;
    padding: 6px 8px;
    font-size: 0.75rem;
    background: rgba(243, 198, 105, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(243, 198, 105, 0.25);
  }
}