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

body {
  background: #0f0f1a;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #fff;
  user-select: none;
}

html, body {
  overflow: hidden;
  height: 100%;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform-origin: center center;
  /* scaled via JS for mobile fit */
}

#ui-top {
  display: flex;
  justify-content: space-between;
  width: 400px;
  padding: 10px 16px;
  background: #1a1a2e;
  border-radius: 8px;
  font-size: 16px;
  flex-shrink: 0;
}

#high-score { color: #ffd700; }
#current-score { color: #fff; }

#preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 400px;
  height: 70px;
  padding: 4px 16px;
  font-size: 13px;
  color: #888;
  flex-shrink: 0;
}

#preview-ball {
  width: 28px; height: 28px;
  min-width: 20px;
  border-radius: 50%;
  background: #666;
  transition: background 0.2s;
}

#game-container {
  position: relative;
  width: 400px;
  height: 600px;
  background: #1a1a2e;
  border: 2px solid #333;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#game-over-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#game-over-overlay h2 {
  font-size: 36px;
  color: #ff4444;
}

#restart-btn {
  padding: 12px 32px;
  font-size: 18px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s;
}

#restart-btn:hover { transform: scale(1.05); }
#restart-btn:active { transform: scale(0.95); }

#bottom-tip {
  font-size: 12px;
  color: #555;
  margin-top: 4px;
}

/* --- Image Manager Button --- */
#img-mgr-btn-container {
  margin-top: 8px;
}
#img-mgr-btn {
  padding: 6px 16px;
  font-size: 13px;
  background: #333;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
#img-mgr-btn:hover { background: #444; color: #fff; }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 12px;
  width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid #333;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: #666;
  line-height: 1;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 16px 20px 20px; }

/* --- Tier Grid --- */
#tier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tier-cell {
  background: #12121e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.tier-cell:hover { border-color: #666; }
.tier-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 6px;
  background-size: cover;
  background-position: center;
}
.tier-badge {
  font-size: 11px;
  color: #888;
  margin-bottom: 2px;
}
.tier-label {
  font-size: 12px;
  color: #aaa;
  word-break: keep-all;
}

/* --- Crop Editor --- */
.crop-modal { width: 460px; }
#crop-container {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}
#crop-canvas { display: block; width: 100%; height: auto; }
.crop-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
#crop-file-input { display: none; }
.btn {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #333;
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: #444; color: #fff; }
.btn-primary { background: #2d7d46; border-color: #3a9d5a; color: #fff; }
.btn-primary:hover { background: #3a9d5a; }
.btn-danger { background: #7d2d2d; border-color: #9d3a3a; color: #fff; }
.btn-danger:hover { background: #9d3a3a; }
