/* ==========================================================================
   CargoLoop — Truck & Conveyor Belt Color Sorting Puzzle
   ========================================================================== */

:root {
  --bg-color: #0b1120;
  --bg-panel: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --border-color: #334155;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  --font-mono: ui-monospace, "SF Mono", monospace;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Header */
.game-header {
  width: 100%;
  max-width: 540px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-panel);
  transition: all 0.2s;
}

.back-link:hover {
  color: var(--text-main);
}

.header-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
}

.level-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-panel);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.icon-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--accent);
}

/* Instructions Banner */
.hint-banner {
  width: 100%;
  max-width: 480px;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.hint-banner strong {
  color: var(--accent);
}

/* Canvas & Stage */
.stage-container {
  flex: 1;
  width: 100%;
  max-width: 520px;
  height: calc(100vh - 100px);
  min-height: 480px;
  max-height: 640px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  touch-action: manipulation;
  padding: 0.5rem;
}

#game-canvas {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: block;
  cursor: pointer;
}

/* Modal Overlay */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

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

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.stars-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 2.2rem;
  margin-bottom: 1.5rem;
}

.modal-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #0b1120;
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal-btn:hover {
  opacity: 0.9;
}
