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

body {
  background: #2d3748;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
}

/* ===== Canvas ===== */
#canvas-container {
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ===== Top bar ===== */
#top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
  padding: 8px 12px 40px;
  pointer-events: none;
}
#top-bar > * { pointer-events: auto; }

.back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.back-row a {
  color: #ccc;
  text-decoration: none;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  transition: all 0.2s;
}
.back-row a:hover {
  color: #fff;
  background: rgba(255,255,255,0.2);
}
.back-row span {
  color: #999;
  font-size: 12px;
}

/* ===== Bottom control bar ===== */
#controls-wrap {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.75);
  padding: 10px 16px;
  border-radius: 14px;
  backdrop-filter: blur(4px);
  max-width: 95vw;
}

/* Unit toggle */
#unit-selector {
  display: flex;
  gap: 4px;
}
.unit-btn {
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.unit-btn:hover {
  border-color: #667eea;
  color: #667eea;
}
.unit-btn.active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

/* Phase buttons */
#phase-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.phase-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: #444;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.phase-btn:hover:not(:disabled) {
  background: #666;
}
.phase-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.phase-btn.primary {
  background: #378ADD;
}
.phase-btn.primary:hover:not(:disabled) {
  background: #4facfe;
}
.phase-btn.primary:disabled {
  background: #444;
  opacity: 0.35;
}
.phase-btn.replay {
  background: #43e97b;
  color: #000;
}
.phase-btn.replay:hover {
  background: #5cf891;
}

/* Step info */
#step-info {
  color: #ccc;
  font-size: 12px;
  min-width: 80px;
  text-align: center;
}

/* Hint */
#hint {
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  text-align: center;
  transition: color 0.3s;
}
#controls-wrap:hover #hint {
  color: rgba(255,255,255,0.7);
}
@media (hover: none) and (pointer: coarse) {
  #hint { display: none; }
}
