/* ─── Reset ─────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; overflow: hidden; font-family: 'Segoe UI', Arial, sans-serif; color: #fff; }

/* ─── Canvas ─────────────────────────────────────────────── */
#game-canvas {
  position: fixed; inset: 0; z-index: 0;
  display: none;
}

/* ─── Shared glass panel ─────────────────────────────────── */
.glass {
  background: rgba(2, 10, 28, 0.92);
  border: 1px solid rgba(80, 150, 255, 0.2);
  border-radius: 14px;
  backdrop-filter: blur(16px);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 10px 22px;
  background: rgba(0, 25, 65, 0.95);
  color: #88aadd;
  border: 1px solid rgba(80, 140, 210, 0.4);
  border-radius: 9px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover {
  background: rgba(0, 45, 100, 0.95);
  border-color: rgba(100, 180, 255, 0.7);
  color: #cceeff;
  box-shadow: 0 0 16px rgba(70, 150, 255, 0.22);
}
.btn.secondary {
  background: rgba(0, 15, 35, 0.9);
  color: #4a6680;
  border-color: rgba(50, 80, 120, 0.4);
}
.btn.secondary:hover {
  color: #88aacc; border-color: rgba(80, 130, 180, 0.6);
}

/* ─── SELECT SCREEN ──────────────────────────────────────── */
#screen-select {
  position: fixed; inset: 0; z-index: 20;
  background: #030a1a;
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto;
}

#select-header {
  text-align: center;
  padding: 32px 20px 20px;
  width: 100%;
  max-width: 860px;
}
#select-title { font-size: 26px; font-weight: 800; color: #66aaff; letter-spacing: 2px; }
#select-sub { font-size: 13px; color: #2a4560; margin-top: 6px; }

/* Difficulty tabs */
#diff-tabs {
  display: flex; gap: 6px;
  justify-content: center;
  margin-top: 20px;
}
.diff-tab {
  padding: 8px 28px;
  background: rgba(0, 15, 35, 0.9);
  color: #3a5a7a;
  border: 1px solid rgba(50, 80, 130, 0.35);
  border-radius: 8px;
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; transition: all 0.15s;
}
.diff-tab:hover { color: #88aacc; border-color: rgba(80, 130, 200, 0.6); }
.diff-tab.active.easy   { color: #44ccff; border-color: rgba(50, 180, 255, 0.7); background: rgba(0,40,80,0.9); box-shadow: 0 0 18px rgba(40,160,255,0.2); }
.diff-tab.active.normal { color: #bb88ff; border-color: rgba(160, 100, 255, 0.7); background: rgba(20,0,60,0.9); box-shadow: 0 0 18px rgba(130,80,255,0.2); }
.diff-tab.active.hard   { color: #ff8855; border-color: rgba(255, 110, 60, 0.7); background: rgba(50,10,0,0.9); box-shadow: 0 0 18px rgba(255,80,30,0.2); }

/* Stage grid */
#stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 20px 32px;
  width: 100%; max-width: 860px;
}

.stage-card {
  background: rgba(4, 14, 34, 0.96);
  border: 1px solid rgba(50, 90, 150, 0.3);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
  overflow: hidden;
}
.stage-card:hover {
  border-color: rgba(90, 160, 255, 0.55);
  box-shadow: 0 0 20px rgba(60, 130, 255, 0.15);
  transform: translateY(-2px);
}
.stage-card.all-solved {
  border-color: rgba(40, 180, 120, 0.5);
  background: rgba(0, 20, 14, 0.96);
}
.stage-card.all-solved:hover { box-shadow: 0 0 20px rgba(30, 200, 130, 0.18); }

.card-stage-num { font-size: 10px; font-weight: 700; color: #2a4a6a; letter-spacing: 1.5px; text-transform: uppercase; }
.card-stage-name { font-size: 15px; font-weight: 700; color: #88aace; margin: 4px 0 10px; }
.card-progress-dots { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.prog-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(40, 70, 110, 0.6);
  border: 1px solid rgba(50, 90, 140, 0.5);
  transition: all 0.2s;
}
.prog-dot.solved { background: #3aaa66; border-color: #5acc88; box-shadow: 0 0 5px rgba(50, 200, 120, 0.5); }
.card-count { font-size: 11px; color: #2a4a6a; text-align: right; }
.card-count.complete { color: #3aaa66; }

/* ─── GAME SCREEN (HUD overlay) ──────────────────────────── */
#screen-game {
  position: fixed; inset: 0; z-index: 10;
  pointer-events: none;
  display: none;
}
#screen-game.active { display: block; }

/* Top HUD bar */
#hud-bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(to bottom, rgba(2,8,20,0.96) 60%, transparent);
  pointer-events: auto;
}
#btn-back-game {
  padding: 7px 14px;
  background: rgba(0,12,30,0.9);
  color: #4a6888;
  border: 1px solid rgba(50,80,130,0.4);
  border-radius: 8px;
  font-size: 13px; cursor: pointer; flex-shrink: 0;
  transition: all 0.15s;
}
#btn-back-game:hover { color: #88aacc; border-color: rgba(80,130,200,0.6); }

#hud-stage-info { flex: 1; }
#hud-stage-name { font-size: 15px; font-weight: 700; color: #66aaff; }
#hud-diff-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 4px; margin-left: 8px;
  vertical-align: middle;
}
.badge-easy   { background: rgba(0,80,160,0.7); color: #44ccff; border: 1px solid rgba(40,160,255,0.4); }
.badge-normal { background: rgba(50,0,110,0.7); color: #bb88ff; border: 1px solid rgba(150,80,255,0.4); }
.badge-hard   { background: rgba(90,20,0,0.7);  color: #ff8855; border: 1px solid rgba(255,100,40,0.4); }

#hud-stats { display: flex; gap: 16px; align-items: center; flex-shrink: 0; }
.hud-stat { text-align: right; }
.hud-stat-label { font-size: 9px; color: #2a4060; text-transform: uppercase; letter-spacing: 1px; }
.hud-stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
#hud-cubes-val { color: #ff5533; }
#hud-moves-val { color: #ffcc44; font-size: 18px; }

/* Puzzle dots row */
#puzzle-dots-bar {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
  pointer-events: auto;
}
.puzzle-dot {
  width: 28px; height: 8px; border-radius: 4px;
  background: rgba(20, 50, 90, 0.7);
  border: 1px solid rgba(40, 80, 150, 0.4);
  cursor: pointer; transition: all 0.15s;
}
.puzzle-dot:hover { border-color: rgba(80, 150, 255, 0.7); background: rgba(30,70,120,0.8); }
.puzzle-dot.current { background: rgba(50, 130, 255, 0.7); border-color: rgba(100, 180, 255, 0.9); box-shadow: 0 0 8px rgba(70,150,255,0.5); }
.puzzle-dot.solved  { background: rgba(30, 160, 90, 0.7);  border-color: rgba(50, 200, 120, 0.7); }
.puzzle-dot.solved.current { background: rgba(30, 180, 100, 0.8); }

/* Hint */
#hint {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  color: #1a2a3a; font-size: 11px; pointer-events: none; z-index: 5;
  white-space: nowrap;
}

/* Legend */
#legend {
  position: fixed; left: 16px; bottom: 14px;
  pointer-events: none; z-index: 5;
}
.leg { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; font-size: 11px; color: #2a4060; }
.leg-ico { width: 12px; height: 12px; flex-shrink: 0; }

/* ─── WIN OVERLAY ────────────────────────────────────────── */
#win-overlay {
  position: fixed; inset: 0; z-index: 30;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,4,14,0.6); backdrop-filter: blur(4px);
}
#win-overlay.visible { display: flex; }

#win-box {
  text-align: center; padding: 48px 64px;
  max-width: 400px; width: 90%;
}
#win-emoji { font-size: 52px; margin-bottom: 12px; }
#win-title { font-size: 28px; font-weight: 800; color: #88ddff; margin-bottom: 6px; }
#win-sub { color: #2a4a60; font-size: 14px; margin-bottom: 24px; }
#win-btns { display: flex; gap: 10px; justify-content: center; }

/* ─── STAGE CLEAR OVERLAY ────────────────────────────────── */
#stage-clear-overlay {
  position: fixed; inset: 0; z-index: 35;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,4,14,0.75); backdrop-filter: blur(6px);
}
#stage-clear-overlay.visible { display: flex; }

#stage-clear-box {
  text-align: center; padding: 52px 72px;
  max-width: 440px; width: 90%;
}
#sc-emoji { font-size: 60px; margin-bottom: 16px; }
#sc-title { font-size: 30px; font-weight: 800; color: #ffdd77; margin-bottom: 8px; }
#sc-sub { color: #3a4a20; font-size: 14px; margin-bottom: 28px; }

/* ─── Loading ─────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; z-index: 50;
  background: #030a1a;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #3a5a7a; letter-spacing: 2px;
}
