* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: 'Fredoka', sans-serif;
  background: #FFF8F0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

#header {
  background: linear-gradient(135deg, #FF6B35, #FFD23F, #FF6B35);
  background-size: 200% 200%;
  animation: headerShimmer 4s ease infinite;
  padding: 10px 16px;
  text-align: center;
  z-index: 10;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(255, 107, 53, 0.3);
}

@keyframes headerShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

#header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.9);
  font-weight: 400;
  margin-top: 2px;
}

#toast-area {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: rgba(0,0,0,0.82);
  color: #FFD23F;
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 700;
  animation: toastPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), toastFade 2s ease forwards;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

@keyframes toastPop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes toastFade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-20px); }
}

#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  touch-action: none;
}

#stats-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  display: flex;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #555;
}

#stats-bar span {
  background: rgba(255,255,255,0.85);
  padding: 4px 10px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  backdrop-filter: blur(4px);
}

footer {
  position: absolute;
  bottom: 6px;
  right: 8px;
  z-index: 5;
}

footer a {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.6rem;
  color: rgba(0,0,0,0.2);
  text-decoration: none;
}

footer a:hover {
  color: rgba(0,0,0,0.5);
}

#toolbar {
  background: linear-gradient(0deg, #2D1B4E, #3D2560);
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 -3px 12px rgba(0,0,0,0.25);
}

#spawner-panel {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#spawner-panel::-webkit-scrollbar { display: none; }

.spawn-btn {
  min-width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow: 0 3px 0 rgba(0,0,0,0.3), 0 4px 8px rgba(0,0,0,0.15);
  transition: transform 0.1s, box-shadow 0.1s;
  flex-shrink: 0;
}

.spawn-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.3);
}

#toolbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#toolbar-actions button {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

#toolbar-actions button:hover {
  background: rgba(255,255,255,0.2);
}

/* Empty state hint */
#canvas-wrap .empty-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 2;
  opacity: 0.5;
  transition: opacity 0.3s;
}

.empty-hint h2 {
  font-size: 1.3rem;
  color: #C4960C;
  margin-bottom: 4px;
}

.empty-hint p {
  font-size: 0.85rem;
  color: #999;
}

@media (max-width: 480px) {
  #header { padding: 8px 12px; }
  #header h1 { font-size: 1.1rem; }
  .subtitle { font-size: 0.7rem; }
  .spawn-btn { min-width: 40px; height: 40px; font-size: 1rem; }
  #toolbar-actions button { width: 40px; height: 40px; font-size: 1.1rem; }
  #toolbar { padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); gap: 6px; }
  .toast { font-size: 1rem; padding: 8px 18px; }
  #stats-bar { font-size: 0.65rem; }
  #stats-bar span { padding: 3px 8px; }
}

@media (max-width: 360px) {
  #header h1 { font-size: 0.95rem; }
  .spawn-btn { min-width: 36px; height: 36px; font-size: 0.9rem; }
  #toolbar-actions button { width: 36px; height: 36px; }
}