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

:root {
  --motion: #4C97FF;
  --looks: #9966FF;
  --sound: #CF63CF;
  --events: #FFBF00;
  --control: #FFAB19;
  --sensing: #5CB1D6;
  --operators: #59C059;
  --variables: #FF8C1A;
  --bg-dark: #1a1a2e;
  --bg-panel: #252547;
  --bg-workspace: #f0f2f8;
  --text-light: #e8e8e8;
  --accent-green: #4ade80;
  --accent-red: #ef4444;
}

body {
  font-family: 'Fredoka', sans-serif;
  overflow: hidden;
  background: var(--bg-dark);
}

.dark-mode {
  --bg-workspace: #1e1e3a;
}

/* Block styles */
.block-item {
  position: relative;
  border-radius: 8px;
  padding: 8px 14px;
  margin: 3px 0;
  font-size: 13px;
  font-weight: 500;
  color: white;
  cursor: grab;
  user-select: none;
  box-shadow: 0 3px 0 rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.block-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(0,0,0,0.25);
}

.block-item:active {
  cursor: grabbing;
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.block-item::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 15px;
  width: 16px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: inherit;
}

.block-item::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 15px;
  width: 16px;
  height: 4px;
  border-radius: 0 0 2px 2px;
  background: inherit;
}

.block-item.hat-block::before {
  display: none;
}

.block-item.hat-block {
  border-radius: 16px 16px 8px 8px;
  padding-top: 10px;
}

.block-item.cap-block::after {
  display: none;
}

.block-input {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 12px;
  padding: 2px 8px;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 12px;
  font-weight: 600;
  width: 50px;
  text-align: center;
  outline: none;
}

.block-input:focus {
  background: rgba(255,255,255,0.4);
}

.block-input-wide {
  width: 100px;
}

.block-select {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 12px;
  padding: 2px 8px;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* Workspace grid */
.workspace-grid {
  background-image: radial-gradient(circle, #d0d4e0 1px, transparent 1px);
  background-size: 20px 20px;
}

.dark-mode .workspace-grid {
  background-image: radial-gradient(circle, #333366 1px, transparent 1px);
}

/* Stage canvas */
.stage-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  overflow: hidden;
  position: relative;
}

/* Speech bubble */
.speech-bubble {
  position: absolute;
  background: white;
  border: 2px solid #333;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  max-width: 180px;
  word-wrap: break-word;
  z-index: 10;
  pointer-events: none;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid white;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 19px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid #333;
}

/* Category buttons */
.category-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
  text-align: left;
}

.category-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.category-btn.active {
  outline: 2px solid white;
  outline-offset: -1px;
  filter: brightness(1.15);
}

/* Variable monitor */
.var-monitor {
  position: absolute;
  background: rgba(0,0,0,0.75);
  color: #FFAB19;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 5;
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
}

/* Dragging overlay */
.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.85;
  transform: rotate(2deg);
}

/* Nav buttons */
.nav-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  font-family: 'Fredoka', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

/* Tutorial overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.tutorial-card {
  background: linear-gradient(135deg, #252547, #1a1a2e);
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  color: white;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Workspace block on canvas */
.workspace-block-stack {
  position: absolute;
  cursor: grab;
}

.workspace-block-stack:active {
  cursor: grabbing;
}

/* Context menu */
.context-menu {
  position: fixed;
  z-index: 10001;
  background: #252547;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 160px;
}

.context-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: none;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: rgba(255,255,255,0.1);
}

/* File dropdown */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background: #252547;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 180px;
  margin-top: 4px;
}

@keyframes snapIn {
  0% { transform: scale(1.05); }
  50% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.snap-anim {
  animation: snapIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Mobile warning */
@media (max-width: 1023px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-warning {
    display: flex !important;
  }
}

@media (min-width: 1024px) {
  .mobile-warning {
    display: none !important;
  }
}