:root {
  --bg-primary: #0b0b0d;
  --bg-gradient: radial-gradient(circle at center, #1e1911 0%, #050506 100%);
  --bg-card: rgba(26, 26, 31, 0.7);
  --border-color: rgba(212, 175, 55, 0.25);
  --accent-gold: #d4af37; /* Pure gold */
  --accent-amber: #f59e0b;
  --text-primary: #ffffff;
  --text-secondary: #c5b497;
  --font-family: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

.puzzle-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  position: relative;
  overflow: hidden;
  padding-top: 80px;
}

.puzzle-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.puzzle-screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* 1. Menu screen layouts */
.menu-header {
  text-align: center;
  margin: 20px 0 16px 0;
}

.menu-header h1 {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -1.5px;
}

.gold-text {
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

.menu-header p {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 6px;
}

.settings-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.size-selectors {
  display: flex;
  gap: 8px;
}

.size-btn {
  background: none;
  border: 1.5px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.size-btn.active {
  color: var(--bg-primary);
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.gallery-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.image-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.img-preview-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background-size: cover;
  background-position: center;
  transition: border-color 0.2s;
}

.image-card.active .img-preview-box {
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
}

.image-card span {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.custom-uploader-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 20px;
}

.upload-btn {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  color: var(--accent-gold);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.action-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-amber));
  color: #000;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.35);
}

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

/* 2. Play Board UI */
.play-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  margin-bottom: 16px;
}

.hud-back-btn {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.hud-metrics {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  gap: 16px;
  color: var(--text-secondary);
}

.hud-metrics strong {
  color: var(--accent-gold);
}

.board-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.puzzle-board-grid {
  width: 310px;
  height: 310px;
  background: #111115;
  border: 3px solid var(--accent-gold);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.15);
  display: grid;
  gap: 2px;
  padding: 2px;
  overflow: hidden;
}

.puzzle-tile {
  background-size: 310px 310px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  position: relative;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

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

.tile-number {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border-color);
  color: var(--accent-gold);
  font-size: 12px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 6px;
  left: 6px;
}

.empty-tile {
  background: #111115 !important;
  cursor: default;
  box-shadow: none;
}

.help-controls {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.action-btn-small {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  color: var(--accent-gold);
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* Hint floating card overlays */
.hint-preview-container {
  position: absolute;
  bottom: 60px;
  width: 140px;
  height: 140px;
  border: 2px solid var(--accent-gold);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.hint-preview-container.active {
  opacity: 1;
}

.hint-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
}

/* Victory Overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11,11,13,0.9);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.victory-card {
  width: 85%;
  max-width: 320px;
  background: rgba(26,26,31,0.85);
  border: 1.5px solid var(--border-color);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 0 35px rgba(212,175,55,0.25);
}

.victory-card h2 {
  font-size: 26px;
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(212,175,55,0.4);
  margin-bottom: 8px;
}

.victory-card p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.victory-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 24px;
}

.vic-stat {
  display: flex;
  flex-direction: column;
}

.vic-stat span {
  font-size: 11px;
  color: var(--text-secondary);
}

.vic-stat strong {
  font-size: 18px;
  color: #fff;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
