/* style.css — Doodle Pop */
:root {
  --bg: #0e0f1a;
  --panel: rgba(22, 24, 38, 0.85);
  --panel-solid: #16182a;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f4ff;
  --text-dim: #9aa3b2;
  --accent: #ff5a8a;
  --accent-2: #4aa8ff;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  color-scheme: dark;
}

html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #eef1f8;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --stroke: rgba(0, 0, 0, 0.08);
  --stroke-strong: rgba(0, 0, 0, 0.16);
  --text: #16182a;
  --text-dim: #5a6275;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #eef1f8;
    --panel: rgba(255, 255, 255, 0.9);
    --panel-solid: #ffffff;
    --stroke: rgba(0, 0, 0, 0.08);
    --stroke-strong: rgba(0, 0, 0, 0.16);
    --text: #16182a;
    --text-dim: #5a6275;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* Canvas fills behind everything */
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  background: var(--bg);
  z-index: 0;
}

/* Top bar */
#topbar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--panel) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 17px;
}
.logo {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  box-shadow: 0 4px 14px rgba(255, 90, 138, 0.4);
}
.title { background: transparent; }

.top-actions {
  display: flex;
  gap: 6px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 5px;
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 38px; height: 38px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.1s, color 0.15s;
}
.icon-btn:hover { background: var(--stroke); color: var(--accent); }
.icon-btn:active { transform: scale(0.92); }

/* Palette */
.palette {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: calc(100% - 28px);
  padding: 6px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.swatch {
  width: 26px; height: 26px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.15s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.swatch:hover { transform: scale(1.12); }
.swatch.active {
  border-color: var(--text);
  transform: scale(1.18);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent), inset 0 0 0 1px rgba(0,0,0,0.25);
}

/* Hint */
.hint {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim);
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.hint.show { opacity: 0.7; }

/* Bottom toolbar */
#toolbar {
  position: relative;
  z-index: 3;
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, var(--panel) 0%, rgba(0,0,0,0) 100%);
}

.brushes {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  padding: 4px 2px;
  scrollbar-width: none;
}
.brushes::-webkit-scrollbar { display: none; }

.brush-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 54px;
  height: 50px;
  padding: 4px 8px;
  border: 1px solid var(--stroke);
  background: var(--panel-solid);
  color: var(--text-dim);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, color 0.15s, background 0.15s;
}
.brush-btn:hover { color: var(--text); border-color: var(--stroke-strong); }
.brush-btn:active { transform: scale(0.94); }
.brush-btn.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(255, 90, 138, 0.35);
}
.brush-icon { font-size: 18px; line-height: 1; }
.brush-name { font-size: 9px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }

.size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-solid);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: var(--shadow);
}
.size-dot {
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.12s, height 0.12s, background 0.2s;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}
.size-range {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 999px;
  background: var(--stroke-strong);
  outline: none;
}
.size-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  border: 2px solid var(--panel-solid);
}
.size-range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--text);
  cursor: pointer;
  border: 2px solid var(--panel-solid);
}
.size-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rainbow-toggle {
  width: 50px; height: 50px;
  border: 1px solid var(--stroke);
  background: var(--panel-solid);
  border-radius: 14px;
  font-size: 22px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.2s;
  filter: grayscale(0.6);
}
.rainbow-toggle:hover { filter: grayscale(0.2); }
.rainbow-toggle:active { transform: scale(0.94); }
.rainbow-toggle.active {
  filter: grayscale(0);
  border-color: transparent;
  box-shadow: 0 0 0 2px #fff, 0 6px 18px rgba(155, 107, 255, 0.5);
  background: conic-gradient(from 0deg, #ff5a8a, #ffd23d, #7af060, #3df0d8, #4aa8ff, #9b6bff, #ff5a8a);
}

/* Responsive */
@media (max-width: 480px) {
  .brand .title { display: none; }
  .brush-btn { min-width: 48px; height: 46px; }
  .brush-name { font-size: 8px; }
  .size-range { width: 64px; }
  .hint { font-size: 16px; padding: 0 20px; }
}

@media (min-width: 720px) {
  .brushes { justify-content: center; }
  #toolbar { justify-content: center; }
}
