:root {
  --game-bg: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 40%, #ffcc80 100%);
  --easel-wood: #8d6e63;
  --easel-wood-dark: #5d4037;
  --canvas-border: #d7ccc8;
  --tile-bg: #ffffff;
  --tile-shadow: rgba(93, 64, 55, 0.18);
}

.easel-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 6px 12px 10px;
  background: var(--game-bg);
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Top/Side Studio Toolbar --- */
.easel-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  width: 100%;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  padding: 5px 10px;
  box-shadow: 0 4px 14px rgba(93, 64, 55, 0.12);
  border: 2px solid #ffffff;
  z-index: 10;
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.toolbar-divider {
  width: 1.5px;
  height: 32px;
  background: #e0e0e0;
  margin: 0 4px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 42px;
  height: 42px;
  padding: 4px 10px;
  border-radius: 14px;
  border: 2px solid #e0e0e0;
  background: #ffffff;
  color: #3e2723;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-btn:hover {
  transform: translateY(-1px);
  border-color: #ffb74d;
  background: #fff8e1;
}

.tool-btn:active {
  transform: scale(0.94);
}

.tool-btn.active {
  background: #ff9800;
  color: #ffffff;
  border-color: #f57c00;
  box-shadow: 0 3px 8px rgba(245, 124, 0, 0.35);
}

.tool-icon {
  font-size: 18px;
  line-height: 1;
}

.tool-label {
  display: inline-block;
  white-space: nowrap;
}

/* Palette swatches */
.color-palette {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  max-width: 320px;
  padding: 2px 0;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  transform: scale(1.22);
  border-color: #3e2723;
  box-shadow: 0 0 0 2px #ffffff, 0 3px 8px rgba(0, 0, 0, 0.35);
}

/* Brush Size Button */
.size-btn {
  width: 42px;
  padding: 0;
}

.size-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3e2723;
  transition: width 0.15s ease, height 0.15s ease, background 0.15s ease;
}

.action-btn {
  width: 42px;
  padding: 0;
}

.save-btn {
  background: #e8f5e9;
  border-color: #a5d6a7;
}

.save-btn:hover {
  background: #c8e6c9;
  border-color: #81c784;
}

/* --- Center Easel Canvas Board --- */
.easel-board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  padding: 6px 0;
}

.easel-canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 920px;
  height: 100%;
  max-height: 100%;
  background: #ffffff;
  border-radius: 20px;
  border: 4px solid var(--canvas-border);
  box-shadow: 0 10px 28px rgba(93, 64, 55, 0.18), inset 0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  touch-action: none;
  box-sizing: border-box;
}

.easel-canvas,
.sparkle-canvas {
  position: absolute;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.easel-canvas {
  z-index: 1;
  background: #ffffff;
  cursor: crosshair;
}

.sparkle-canvas {
  z-index: 2;
  pointer-events: none;
}

.type-cursor {
  position: absolute;
  width: 4px;
  height: 38px;
  border-radius: 2px;
  background: #ff9800;
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.6);
  pointer-events: none;
  z-index: 3;
  display: none;
  animation: cursor-blink 0.8s infinite ease-in-out;
}

.type-cursor.visible {
  display: block;
}

.tile-btn:focus-visible,
.tool-btn:focus-visible,
.dock-tab-btn:focus-visible,
.color-swatch:focus-visible {
  outline: 3px solid #ff9800;
  outline-offset: 2px;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.2; }
}

/* --- Bottom Child-Friendly Letter & Number Dock --- */
.easel-bottom-dock {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 920px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  padding: 6px 10px 8px;
  box-shadow: 0 -4px 16px rgba(93, 64, 55, 0.1);
  border: 2px solid #ffffff;
  z-index: 10;
  flex-shrink: 0;
}

.dock-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.dock-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 14px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: #f5f5f5;
  color: #5d4037;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.dock-tab-btn:hover {
  background: #fff3e0;
  color: #e65100;
}

.dock-tab-btn.active {
  background: #ffb74d;
  color: #3e2723;
  border-color: #ffa726;
  box-shadow: 0 2px 6px rgba(255, 167, 38, 0.3);
}

.tab-icon {
  font-size: 16px;
  line-height: 1;
}

.dock-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #ffcc80 transparent;
  touch-action: pan-x;
}

.dock-tray::-webkit-scrollbar {
  height: 6px;
}

.dock-tray::-webkit-scrollbar-thumb {
  background: #ffb74d;
  border-radius: 3px;
}

/* Individual Child Tiles (Letters, Numbers, Stickers) */
.tile-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 48px;
  padding: 4px 6px;
  border-radius: 14px;
  border: 2px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 3px 8px var(--tile-shadow), 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.1s ease;
}

.tile-btn:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 6px 14px rgba(245, 124, 0, 0.25);
  border-color: #ffcc80;
}

.tile-btn:active {
  transform: scale(0.92);
}

.tile-char {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  color: #e65100;
  font-family: inherit;
}

.tile-sub {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #795548;
  margin-top: 2px;
  white-space: nowrap;
}

.tile-sticker .tile-char {
  font-size: 24px;
}

.tile-sticker.active {
  background: #fff8e1;
  border-color: #ff9800;
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 4px 10px rgba(255, 152, 0, 0.4);
}

/* Pop/Burst Animation for typed items */
.typed-pop-bubble {
  position: absolute;
  pointer-events: none;
  font-weight: 900;
  transform: translate(-50%, -50%);
  animation: pop-bounce 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  z-index: 10;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}

@keyframes pop-bounce {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0.6;
  }
  60% {
    transform: translate(-50%, -50%) scale(1.25);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* --- Responsive Adjustments --- */
@media (max-width: 680px) {
  .tool-label {
    display: none;
  }
  .tool-btn {
    min-width: 38px;
    height: 38px;
    padding: 0;
  }
  .color-swatch {
    width: 26px;
    height: 26px;
  }
  .tile-btn {
    min-width: 38px;
    height: 44px;
  }
  .tile-char {
    font-size: 19px;
  }
}

@media (max-height: 600px) {
  .easel-toolbar {
    padding: 3px 6px;
    gap: 3px 5px;
  }
  .tool-btn {
    min-width: 34px;
    height: 34px;
    font-size: 12px;
  }
  .tool-icon {
    font-size: 15px;
  }
  .color-swatch {
    width: 22px;
    height: 22px;
  }
  .easel-bottom-dock {
    padding: 3px 6px 5px;
  }
  .dock-tabs {
    margin-bottom: 2px;
  }
  .dock-tab-btn {
    padding: 2px 8px;
    font-size: 11px;
  }
  .tile-btn {
    min-width: 36px;
    height: 38px;
    padding: 2px;
  }
  .tile-char {
    font-size: 17px;
  }
  .tile-sub {
    font-size: 8px;
  }
}
