:root {
  --cc-bg: #050712;
  --cc-panel: #141827;
  --cc-accent: #22e57f;
  --cc-text-main: #f5f5f7;
  --cc-text-muted: #a2a7c2;
  --cc-border-subtle: #30364c;
  --cc-shadow-soft: 0 14px 40px rgba(0, 0, 0, 0.6);
  
  /* Colors */
  --c-red: #FF4F70;
  --c-blue: #148CFF;
  --c-green: #59FF84; 
  --c-yellow: #FFE83D;
  --c-empty: #2a3044;
  --c-burnt-orange: #E95D0F;
  --c-neon-orange: #FF9F2E; /* Added for Hard Tier */
}

*, *::before, *::after { box-sizing: border-box; }

html, body { 
  margin: 0; 
  padding: 0; 
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--cc-text-main);
  background-color: #050712;
  display: flex;
  flex-direction: column;
}

.center-wrapper {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 8px;
  position: relative;
  z-index: 1;
}

/* FIXED BACKGROUND (Continuous Stars - No Nebula) */
.fixed-background {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0; 
  background-color: #020205; 
  /* REMOVED: Blue Radial Glow */
  overflow: hidden;
  pointer-events: none; 
}

.fixed-background::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 25px 5px, white 1px, transparent 1.5px),
    radial-gradient(circle at 50px 25px, rgba(255,255,255,0.8) 1px, transparent 1.5px),
    radial-gradient(circle at 125px 20px, white 1px, transparent 1.5px),
    radial-gradient(circle at 200px 65px, rgba(255,255,255,0.6) 1px, transparent 1.5px),
    radial-gradient(circle at 300px 10px, white 1px, transparent 1.5px),
    radial-gradient(circle at 360px 45px, rgba(255,255,255,0.9) 1px, transparent 1.5px);
  background-size: 400px 400px;
  opacity: 0.6; 
  /* CHANGED: Continuous Loop matching background size */
  animation: starIntro 40s linear infinite;
}

.fixed-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 75px 100px, white 1.5px, transparent 2.5px),
    radial-gradient(circle at 150px 250px, white 1px, transparent 2px),
    radial-gradient(circle at 320px 380px, white 1.5px, transparent 2.5px);
  background-size: 550px 550px; 
  opacity: 0.8; 
  /* CHANGED: Continuous Loop matching background size */
  animation: starIntroFast 30s linear infinite;
}

@keyframes starIntro {
  from { background-position: 0 0; }
  to { background-position: 0 400px; } /* Matches bg size for seamless loop */
}

@keyframes starIntroFast {
  from { background-position: 0 0; }
  to { background-position: 0 550px; } /* Matches bg size for seamless loop */
}

.game-shell.cc-shell {
  width: 100%;
  max-width: 460px;
  padding: 18px 14px 22px;
  margin: 0;
  background: rgba(20, 24, 39, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 26px;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 1px rgba(20, 140, 255, 0.25), 0 0 18px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.cc-confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

.hidden { display: none !important; }

.cc-header { text-align: center; margin-bottom: 6px; }
.cc-header h1 { margin: 0 0 4px; letter-spacing: 0.22em; font-weight: 800; font-size: 1.6rem; }
.cc-tagline { margin: 0; font-size: 0.78rem; color: var(--cc-text-muted); }
.cc-howto-btn { margin-top: 6px; background: transparent; border: none; color: var(--cc-text-muted); font-size: 0.75rem; cursor: pointer; text-decoration: underline; padding: 0; }
.cc-howto-btn:hover { color: var(--cc-text-main); }
.cc-howto-tooltip { margin: 6px 0 10px; font-size: 0.75rem; background: rgba(10, 14, 26, 0.96); border-radius: 10px; padding: 8px 10px; border: 1px solid var(--cc-border-subtle); color: var(--cc-text-muted); text-align: center; line-height: 1.4; }

.cc-btn-mini {
margin-top: 10px; padding: 6px 12px; border-radius: 999px;
border: none;
background: #ffffff;
color: #000000; cursor: pointer;
font-weight: 800; font-size: 0.75rem; text-transform: uppercase;
transition: transform 0.1s;
}
.cc-btn-mini:hover { transform: scale(1.05); }

.top-bar.cc-top-bar {
display: flex; align-items: center; justify-content: space-between;
background: rgba(9, 12, 24, 0.96); border-radius: 999px;
padding: 6px 8px; 
border: 1px solid var(--cc-border-subtle);
box-shadow: var(--cc-shadow-soft); margin-bottom: 10px; font-size: 0.7rem; gap: 4px;
}
.top-item { flex: 1; display: flex; flex-direction: column; align-items: center; }
.top-label { text-transform: uppercase; letter-spacing: 0.12em; color: var(--cc-text-muted); font-size: 0.6rem; }
.top-value { margin-top: 2px; font-weight: 600; font-size: 0.8rem; }

.cc-sound-toggle {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--cc-border-subtle);
  color: var(--cc-text-muted); border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 1rem; transition: all 0.2s ease; margin-left: 2px; flex-shrink: 0;
}
.cc-sound-toggle:hover { background: rgba(255, 255, 255, 0.1); color: var(--cc-text-main); transform: scale(1.05); }
.cc-sound-toggle.muted { opacity: 0.6; color: #666; }

.mode-switch.cc-mode-switch {
display: inline-flex; background: rgba(13, 17, 30, 0.9); border-radius: 999px;
padding: 3px; border: 1px solid var(--cc-border-subtle); box-shadow: var(--cc-shadow-soft);
margin: 0 auto 10px; position: relative; left: 50%; transform: translateX(-50%);
}
.mode-btn {
border: none; background: transparent; color: var(--cc-text-muted); padding: 8px 14px;
border-radius: 999px; cursor: pointer; transition: background 0.2s ease-out, color 0.2s ease-out;
font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.mode-btn.active { 
  background: #ffffff; 
  color: #000000; 
  font-weight: 800; 
  }

.difficulty-switch {
display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; text-align: center;
}
.diff-btn {
border: 1px solid var(--cc-border-subtle); background: transparent;
color: var(--cc-text-muted); padding: 4px 10px; border-radius: 99px;
font-size: 0.65rem; cursor: pointer; text-transform: uppercase;
}
.diff-btn.active {
  background: var(--cc-text-main); color: #000; border-color: var(--cc-text-main); font-weight: 700;
}

.cc-game-area {
  margin-top: 8px;
  background: radial-gradient(circle at top, #191f3a, #141827);
  padding: 10px;
  border-radius: 20px;
  box-shadow: var(--cc-shadow-soft);
  border: 1px solid rgba(80, 88, 120, 0.6);
}

.cc-board-layout {
  display: grid;
  grid-template-columns: 0.8fr repeat(5, 1fr);
  grid-template-rows: 0.8fr repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  aspect-ratio: 6/6;
}

.cc-clue-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--cc-text-muted);
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 2px;
}
.cc-clue-row { flex-direction: row; gap: 4px; justify-content: flex-end; padding-right: 6px; }
.clue-item { display: inline-block; padding: 0 2px; }
.cc-clue-box.satisfied { background: rgba(34, 229, 127, 0.15); border: 1px solid rgba(34, 229, 127, 0.4); color: #fff; }

.cc-tile {
  background: var(--c-empty);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
  position: relative;
}
.cc-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.3); }

.cc-tile[data-col="0"] { background: var(--c-empty); }
.cc-tile[data-col="1"] { background: var(--c-red); border-color: rgba(255,255,255,0.3); }
.cc-tile[data-col="2"] { background: var(--c-blue); border-color: rgba(255,255,255,0.3); }
.cc-tile[data-col="3"] { background: var(--c-yellow); border-color: rgba(255,255,255,0.3); }
.cc-tile[data-col="4"] { background: var(--c-green); border-color: rgba(255,255,255,0.3); }

.cc-tile[data-col="X"] { background: #1a1a1a; }
.cc-tile[data-col="X"]::after {
  content: "×"; 
  position: absolute; 
  left: 50%; top: 50%;
  transform: translate(-50%, -50%); 
  color: #FF4F70; 
  font-size: 1.5rem; 
  font-weight: 800;
  z-index: 2; 
}

@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-4px); }
75% { transform: translateX(4px); }
}
.cc-tile.error-flash {
  animation: shake 0.3s ease-in-out;
  border: 2px solid var(--c-red) !important;
  filter: brightness(1.5);
}

.cc-corner { background: transparent; }

.cc-bottom { margin-top: 10px; padding: 8px 2px 0; }
.cc-status-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 4px 6px; text-align: center; }
.cc-status-text { font-size: 0.85rem; color: var(--cc-text-muted); transition: color 0.2s ease, text-shadow 0.2s ease; }
.cc-status-text.highlight { color: #ffffff; font-weight: 600; text-shadow: 0 0 12px rgba(255, 255, 255, 0.25); }

.cc-status-text.status-solved { color: #ffffff; font-weight: bold; }

.cc-controls { display: flex; gap: 8px; margin-top: 4px; }
.cc-bottom-actions { display: flex; gap: 6px; margin-top: 8px; }

.cc-ctrl-btn, .cc-bottom-btn, .cc-btn-std {
  flex: 1; border-radius: 999px; padding: 10px; 
  border: 1px solid rgba(255, 255, 255, 0.2); 
  background: rgba(14, 18, 35, 0.96); 
  color: var(--cc-text-main); 
  cursor: pointer; font-size: 0.75rem; 
  font-weight: 700; text-transform: uppercase; 
  letter-spacing: 0.08em; transition: all 0.15s;
  white-space: nowrap; 
}

.cc-std-btn:hover, .cc-bottom-btn:hover, .cc-ctrl-btn:hover {
  transform: translateY(-1px); border-color: rgba(255,255,255,0.4);
}
.cc-std-btn:disabled, .cc-bottom-btn:disabled { opacity: 0.4; cursor: default; }

.cc-share-btn:enabled {
  background: var(--c-red) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(255, 79, 112, 0.4);
}
.cc-share-btn:hover:enabled {
  background: #ff7892 !important;
}

.cc-modal-overlay { position: fixed; inset: 0; background: rgba(1, 3, 10, 0.85); display: flex; align-items: center; justify-content: center; z-index: 20; }
.cc-modal { position: relative; width: min(420px, 92vw); max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; background: #050712; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9); padding: 14px 16px 16px; text-align: center; }
.cc-modal-title { margin: 0 0 8px; font-size: 1.1rem; }
.cc-modal-close { border: none; background: transparent; color: var(--cc-text-muted); position: absolute; right: 18px; top: 14px; font-size: 1.1rem; cursor: pointer; }

.cc-stats-content { overflow-y: auto; padding-right: 4px; min-height: 0; }
.cc-stats-intro { font-size: 0.75rem; color: var(--cc-text-muted); margin-bottom: 12px; line-height: 1.4; text-align: center; opacity: 0.9; }

.tier-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--cc-border-subtle);
  border-radius: 12px;
  padding: 10px;
}

.tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tier-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--cc-text-muted);
}

.tier-badge { 
  background: #222; 
  border: 1px solid var(--cc-border-subtle); 
  padding: 4px 10px; 
  border-radius: 99px; 
  font-size: 0.7rem; 
  color: var(--cc-text-main); 
  font-weight: 700; 
  text-transform: uppercase; 
  white-space: nowrap; 
}
.tier-badge.tier-hard { border-color: var(--c-yellow); color: var(--c-yellow); }
.tier-badge.tier-hardest { border-color: var(--c-red); color: var(--c-red); }

.tier-next-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tier-next-label { 
  font-size: 0.65rem; 
  color: var(--cc-text-muted); 
  text-align: left; 
}

.tier-progress-bar { 
  width: 100%; 
  height: 6px; 
  background: #222; 
  border-radius: 99px; 
  overflow: hidden; 
}
.tier-progress-fill { 
  height: 100%; 
  background: var(--cc-accent); 
  width: 0%; 
  transition: width 0.3s; 
}

.cc-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.cc-stat-box { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--cc-border-subtle); border-radius: 12px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cc-stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cc-text-muted); margin-bottom: 4px; }
.cc-stat-val { font-size: 1.1rem; font-weight: 700; color: #fff; }

/* NEW: Best Time Pill Style */
.best-time-pill {
    font-size: 0.9rem;
    font-family: monospace;
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--cc-accent);
}

.cc-heatmap-container { margin-top: 0; text-align: center; }
.cc-heatmap-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--cc-text-muted); margin-bottom: 6px; }
.cc-heatmap-row { display: flex; justify-content: center; gap: 6px; }
.cc-heatmap-cell { width: 20px; height: 20px; border-radius: 4px; background: #1a1e2e; border: 1px solid rgba(255,255,255,0.05); }

/* Heatmap Colors (Updated to Green/Orange/Red) */
.hm-green { background: var(--c-green); box-shadow: 0 0 6px rgba(89, 255, 132, 0.4); border-color: rgba(255,255,255,0.3); }
.hm-orange { background: var(--c-neon-orange); box-shadow: 0 0 6px rgba(255, 159, 46, 0.4); border-color: rgba(255,255,255,0.3); }
.hm-red { background: var(--c-red); box-shadow: 0 0 6px rgba(255, 79, 112, 0.4); border-color: rgba(255,255,255,0.3); }
.hm-grey { background: #2a3044; opacity: 0.3; }

/* Duel Flash Animation */
@keyframes duel-flash-anim {
  0% { transform: scale(1); background-color: rgba(255, 255, 255, 0.1); }
  50% { transform: scale(1.1); background-color: rgba(255, 255, 255, 0.3); border-color: #fff; box-shadow: 0 0 15px rgba(255,255,255,0.5); }
  100% { transform: scale(1); background-color: rgba(255, 255, 255, 0.1); }
}
.duel-flash { animation: duel-flash-anim 0.4s ease-out; }

.content-section {
  width: 100%;
  max-width: 600px;
  margin-top: 20px;
  padding: 0 14px;
  color: var(--cc-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  z-index: 5;
  text-align: left;
}

.content-section h2 {
  color: var(--cc-text-main);
  font-size: 1.3rem;
  margin-bottom: 16px;
  margin-top: 10px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--cc-border-subtle);
  padding-bottom: 8px;
  text-align: center;
}

.content-section h3 {
  color: var(--c-blue);
  font-size: 1.1rem;
  margin-bottom: 10px;
  margin-top: 24px;
}

/* ADDED: Color for Step headings (h4) */
.content-section h4 {
  color: #ffffff;
  margin-top: 18px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 700;
}

.content-section p {
  margin-bottom: 16px;
}

.content-section ul {
  margin-bottom: 16px;
  padding-left: 0;
  list-style: none;
}

.content-section li {
  margin-bottom: 8px;
}

.content-section strong {
  color: var(--cc-text-main);
}

.cc-footer { 
  margin-top: 40px; 
  padding-top: 20px; 
  border-top: 1px solid var(--cc-border-subtle);
  text-align: center; 
  font-size: 0.8rem; 
  color: var(--cc-text-muted); 
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 10;
}
.cc-footer-links { display: flex; justify-content: center; gap: 12px; margin-bottom: 6px; }
.cc-footer-link { color: var(--c-blue); text-decoration: none; font-size: 0.8rem; }
.cc-footer-link:hover { text-decoration: underline; color: var(--c-red); }
.cc-footer-copy { margin: 6px 0 0; font-size: 0.75rem; }

@media (max-width: 480px) {
.game-shell.cc-shell { padding: 16px 10px 18px; }
.cc-header h1 { font-size: 1.4rem; }
}

@media (max-width: 400px) {
  .cc-ctrl-btn {
    font-size: 0.65rem;
    padding: 10px 8px;
  }
}

.arcade-return-nav {
  width: 100%;
  max-width: 460px;
  margin: 20px auto 10px;
  display: flex;
  justify-content: center;
  z-index: 5;
  position: relative;
}

.return-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  background: rgba(13, 17, 30, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 28px;
  border-radius: 999px;
  color: var(--cc-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.return-link:hover {
  background: rgba(20, 140, 255, 0.12);
  border-color: var(--c-blue);
  color: #ffffff;
  box-shadow: 0 0 25px rgba(20, 140, 255, 0.25);
  transform: translateY(-2px);
}

.return-icon {
  font-size: 1.1em;
  transition: transform 0.3s ease;
}

.return-link:hover .return-icon {
  transform: translateX(-4px);
}

.return-link:active {
  transform: translateY(0) scale(0.98);
  opacity: 0.8;
}