/* ── Canvas wrapper ────────────────────────────────────── */

.canvas-wrap {
  position: relative;
  /* width/height set by JS fitCanvas() */
}

#color-layer {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: cell;
}

.line-art-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* ── Color toolbar ─────────────────────────────────────── */

.color-toolbar {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: #fff8f0;
  border-top: 1px solid #e8d8c4;
  flex-shrink: 0;
  gap: 0;
}

/* Scrollable tools area (left side) */

.tools-scroll {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-right: 0.4rem;
}

.tools-scroll::-webkit-scrollbar { display: none; }

/* Mode / action buttons */

.tool-btn {
  padding: 0 0.75rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 2px solid #e0c9b0;
  background: #fff;
  color: #5a3e28;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.8rem;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.tool-btn:hover {
  border-color: #d4601a;
  background: #fdeee4;
}

.tool-btn.active {
  border-color: #d4601a;
  background: #d4601a;
  color: #fff;
}

.tool-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Swatches */

.swatches {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.swatch {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: none;
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: 0;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: outline-color 0.1s, transform 0.1s;
}

.swatch:hover {
  transform: scale(1.12);
  outline-color: rgba(0,0,0,.45);
}

.swatch.selected {
  outline: 3px solid #222;
  outline-offset: 2px;
  transform: scale(1.12);
}

/* ── Color picker trigger button ───────────────────────── */

/* The button itself: bare, no browser default styling */
.color-pick-wrap {
  cursor: pointer;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* Rainbow ring (conic-gradient hue wheel) */
.color-wheel-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(
    hsl(0,100%,52%),
    hsl(36,100%,52%),
    hsl(72,100%,42%),
    hsl(108,100%,42%),
    hsl(144,100%,42%),
    hsl(180,100%,45%),
    hsl(216,100%,55%),
    hsl(252,100%,58%),
    hsl(288,100%,52%),
    hsl(324,100%,52%),
    hsl(360,100%,52%)
  );
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.color-pick-wrap:hover  .color-wheel-ring { transform: rotate(20deg) scale(1.1); }
.color-pick-wrap:active .color-wheel-ring { transform: rotate(40deg) scale(0.96); }

/* Inner circle — filled with the currently active color */
#current-color-dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #e63946;
}

/* ── Color picker popup ────────────────────────────────── */

/* Invisible fullscreen tap-to-close layer */
.cp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 7900;
  background: rgba(0,0,0,.12);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}

/* Popup panel — always centered in viewport */
.cp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 8000;
  background: #fff8f0;
  border: 1px solid #e0c9b0;
  border-radius: 16px;
  padding: 0.8rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

/* Hidden state — both backdrop and popup */
.cp-off { display: none !important; }

/* Header row */
.cp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.cp-title {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  font-weight: bold;
  color: #5a3e28;
}
.cp-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: #9a7a58;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
}
.cp-close:hover { color: #d4601a; background: #fdeee4; }

/* Canvas wheel */
.cp-wheel {
  border-radius: 50%;
  cursor: crosshair;
  touch-action: none;
  display: block;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  flex-shrink: 0;
}

/* Lightness slider row */
.cp-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}
.cp-lbl {
  font-family: Georgia, serif;
  font-size: 0.68rem;
  color: #9a7a58;
  flex-shrink: 0;
}
.cp-slider {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  outline: none;
  border: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, hsl(356,78%,10%), hsl(356,78%,50%), hsl(356,78%,90%));
}
.cp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,.3);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.cp-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,.3);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

/* Color preview */
.cp-preview {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
}
.cp-swatch {
  display: block;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.18);
  flex-shrink: 0;
  background: #e63946;
}
.cp-hex {
  font-family: monospace;
  font-size: 0.82rem;
  color: #5a3e28;
  letter-spacing: .04em;
}

/* Dividers */

.tool-divider {
  width: 1px;
  height: 1.6rem;
  background: #e0c9b0;
  flex-shrink: 0;
}

/* ── Reward zone (pinned right, never scrolls) ─────────── */

.reward-zone {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding-left: 0.55rem;
  border-left: 1px solid #e0c9b0;
  margin-left: 0.3rem;
}

.reward-hint-text {
  font-size: 0.6rem;
  color: #9a7a58;
  line-height: 1.35;
  max-width: 5rem;
  font-style: italic;
  text-align: right;
}

.mandala-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.35s ease;
  -webkit-tap-highlight-color: transparent;
}

.mandala-btn svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mandala-btn:hover  { transform: rotate(40deg) scale(1.1); }
.mandala-btn:active { transform: rotate(80deg) scale(0.95); }

/* ── Floating reward mandalas ──────────────────────────── */

.reward-mandala {
  position: fixed;
  bottom: -80px;
  z-index: 9000;
  pointer-events: none;
  animation-name: mandala-float;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}

.reward-mandala svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes mandala-float {
  0%   { transform: translateY(0)       rotate(0deg);               opacity: 0; }
  8%   { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateY(-115vh)  rotate(var(--spin, 360deg)); opacity: 0; }
}

/* ── Landscape / compact screens ───────────────────────── */

@media (orientation: landscape) and (max-height: 520px) {
  .color-toolbar   { padding: 0.25rem 0.5rem; }
  .tools-scroll    { gap: 0.25rem; }
  .tool-btn        { height: 1.9rem; font-size: 0.72rem; padding: 0 0.55rem; }
  .swatch          { width: 1.8rem; height: 1.8rem; }
  .color-wheel-ring  { width: 2.1rem; height: 2.1rem; padding: 3px; }
  .cp-popup          { gap: 0.35rem; padding: 0.55rem; }
  .reward-hint-text  { font-size: 0.54rem; max-width: 3.8rem; }
  .mandala-btn       { width: 2rem; height: 2rem; }
}
