/* ===== MTN Digital Puzzle — Image Reveal Edition ===== */
:root {
  --mtn-yellow: #ffcb05;
  --mtn-yellow-dark: #e6b400;
  --mtn-black: #000000;
  --mtn-graphite: #1a1a1a;
  --mtn-gray: #2a2a2a;
  --mtn-light: #f5f5f5;
  --mtn-muted: #9a9a9a;
  --board-size: 360px;
  --gap: 4px;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --transition: 180ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(ellipse at top right, rgba(255, 203, 5, 0.12), transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(255, 203, 5, 0.08), transparent 60%),
    var(--mtn-black);
  color: var(--mtn-light);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 24px;
  border-bottom: 1px solid rgba(255, 203, 5, 0.2);
  margin-bottom: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  background: var(--mtn-yellow);
  color: var(--mtn-black);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 1px;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(255, 203, 5, 0.35);
}
.brand-tag { display: flex; flex-direction: column; line-height: 1.2; }
.tag-line { font-size: 15px; font-weight: 700; color: var(--mtn-yellow); }
.tag-sub  { font-size: 12px; color: var(--mtn-muted); margin-top: 2px; }

.icon-btn {
  background: var(--mtn-gray);
  border: 1px solid rgba(255, 203, 5, 0.3);
  color: var(--mtn-yellow);
  width: 42px; height: 42px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition);
}
.icon-btn:hover { background: var(--mtn-yellow); color: var(--mtn-black); }

/* ===== Stats ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat {
  background: var(--mtn-graphite);
  border: 1px solid rgba(255, 203, 5, 0.15);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.stat-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--mtn-muted); }
.stat-value { display: block; font-size: 22px; font-weight: 800; color: var(--mtn-yellow); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ===== Board ===== */
.board-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.board {
  display: grid;
  gap: var(--gap);
  padding: var(--gap);
  background: var(--mtn-graphite);
  border: 2px solid var(--mtn-yellow);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: var(--board-size);
  height: var(--board-size);
}
.tile {
  position: relative;
  background-image: url('logo.jpg');
  background-repeat: no-repeat;
  background-color: var(--mtn-yellow);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.tile:hover { transform: scale(0.97); box-shadow: 0 4px 12px rgba(255, 203, 5, 0.5); }
.tile.empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}
.tile.solved {
  animation: solvedPulse 0.6s ease;
  border-radius: 0;
  box-shadow: none;
}
.tile.solved::after { display: none; }

/* Number overlay on each tile */
.tile::after {
  content: attr(data-num);
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--mtn-yellow);
  font-weight: 800;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
body.numbers-off .tile::after { display: none; }
.tile.empty::after { display: none; }

@keyframes solvedPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); filter: brightness(1.2); }
}

/* When the puzzle is solved, remove gaps to show the full image */
.board.solved {
  gap: 0;
  padding: 0;
  border-color: var(--mtn-yellow);
}

/* ===== Win overlay ===== */
.win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  z-index: 10;
}
.win-overlay.hidden { display: none; }
.win-card {
  background: var(--mtn-graphite);
  border: 2px solid var(--mtn-yellow);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 320px;
  text-align: center;
}
.win-card h2 { color: var(--mtn-yellow); font-size: 26px; margin-bottom: 12px; }
.win-card p  { color: var(--mtn-light); margin-bottom: 16px; }
#playerName {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--mtn-muted);
  background: var(--mtn-black);
  color: var(--mtn-light);
  font-size: 14px;
  margin-bottom: 12px;
}
#playerName:focus { outline: 2px solid var(--mtn-yellow); border-color: var(--mtn-yellow); }
.win-actions { display: flex; gap: 8px; justify-content: center; }

/* ===== Preview modal ===== */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.preview-modal.hidden { display: none; }
.preview-card {
  background: var(--mtn-graphite);
  border: 2px solid var(--mtn-yellow);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.preview-card h3 { color: var(--mtn-yellow); margin-bottom: 12px; font-size: 16px; }
.preview-img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 16px;
  display: block;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.size-picker {
  display: flex;
  background: var(--mtn-graphite);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid rgba(255, 203, 5, 0.2);
}
.size-btn {
  background: transparent;
  border: none;
  color: var(--mtn-muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.size-btn.active { background: var(--mtn-yellow); color: var(--mtn-black); }
.size-btn:not(.active):hover { color: var(--mtn-yellow); }

.control-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.btn.primary { background: var(--mtn-yellow); color: var(--mtn-black); }
.btn.primary:hover { background: var(--mtn-yellow-dark); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--mtn-light); border: 1px solid var(--mtn-muted); }
.btn.ghost:hover { border-color: var(--mtn-yellow); color: var(--mtn-yellow); }

/* ===== Leaderboard ===== */
.leaderboard {
  background: var(--mtn-graphite);
  border: 1px solid rgba(255, 203, 5, 0.15);
  border-radius: var(--radius);
  padding: 16px;
}
.lb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.lb-head h3 { color: var(--mtn-yellow); font-size: 16px; }
.btn-link { background: none; border: none; color: var(--mtn-muted); cursor: pointer; font-size: 12px; }
.btn-link:hover { color: var(--mtn-yellow); }

.lb-list { list-style: none; counter-reset: rank; }
.lb-list li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}
.lb-list li:last-child { border-bottom: none; }
.lb-list li::before {
  content: counter(rank);
  background: var(--mtn-yellow);
  color: var(--mtn-black);
  font-weight: 800;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.lb-name { font-weight: 600; }
.lb-meta { color: var(--mtn-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lb-empty { color: var(--mtn-muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* ===== Footer ===== */
.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--mtn-muted);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  :root { --board-size: 320px; }
  .stat-value { font-size: 18px; }
  .brand-mark { font-size: 18px; padding: 8px 12px; }
  .tag-line { font-size: 13px; }
  .controls { justify-content: center; }
  .tile::after { font-size: 11px; padding: 1px 4px; }
}
@media (max-width: 360px) {
  :root { --board-size: 280px; }
}
