@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=IM+Fell+English:ital@0;1&display=swap');

:root {
  --gold: #F5D061;
  --gold-dim: rgba(245, 208, 97, 0.4);
  --ink: #050301;
  --ink-overlay: rgba(10, 6, 2, 0.85);
  --parchment: #f0e6c8;
  --crimson: #C0392B;
  --sage: #5D8A6A;
  --sky: #4A90C4;
  --rose: #D4607A;
  --white: #FFFFFF;
  --eraser: #FF6B6B;
}

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

body {
  background: var(--ink);
  overflow: hidden;
  font-family: 'IM Fell English', serif;
  user-select: none;
}

video { display: none; }

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  z-index: 1;
  cursor: crosshair;
}

/* ── Toolbar ── */
#toolbar {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(5, 3, 1, 0.82);
  border: 1px solid rgba(245, 208, 97, 0.35);
  border-radius: 60px;
  padding: 10px 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 40px rgba(245, 208, 97, 0.08), inset 0 1px 0 rgba(245, 208, 97, 0.1);
  transition: opacity 0.3s;
}

#toolbar:hover { opacity: 1 !important; }

.tool-sep {
  width: 1px;
  height: 28px;
  background: rgba(245, 208, 97, 0.2);
  margin: 0 4px;
}

/* Color swatches */
.color-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.color-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px currentColor;
}

.color-btn.active {
  border-color: #fff;
  transform: scale(1.25);
  box-shadow: 0 0 14px currentColor;
}

/* Tool buttons */
.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(245, 208, 97, 0.25);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.tool-btn:hover {
  background: rgba(245, 208, 97, 0.12);
  box-shadow: 0 0 12px rgba(245, 208, 97, 0.25);
  transform: translateY(-1px);
}

.tool-btn.active {
  background: rgba(245, 208, 97, 0.2);
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(245, 208, 97, 0.35);
}

.tool-btn.eraser-active {
  color: var(--eraser);
  border-color: var(--eraser);
  background: rgba(255, 107, 107, 0.15);
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.3);
}

.tool-btn.save-btn { color: #7EC8A4; border-color: rgba(126, 200, 164, 0.3); }
.tool-btn.save-btn:hover { background: rgba(126, 200, 164, 0.12); box-shadow: 0 0 12px rgba(126, 200, 164, 0.25); }
.tool-btn.clear-btn { color: var(--eraser); border-color: rgba(255, 107, 107, 0.3); }
.tool-btn.clear-btn:hover { background: rgba(255, 107, 107, 0.1); }

/* Brush size */
.size-track {
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-track label {
  color: rgba(245, 208, 97, 0.5);
  font-size: 10px;
  letter-spacing: 0.08em;
  font-family: 'Cinzel', serif;
  text-transform: uppercase;
}

#sizeSlider {
  -webkit-appearance: none;
  width: 70px;
  height: 4px;
  border-radius: 2px;
  background: rgba(245, 208, 97, 0.2);
  outline: none;
  cursor: pointer;
}

#sizeSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(245, 208, 97, 0.6);
  transition: transform 0.15s;
}
#sizeSlider::-webkit-slider-thumb:hover { transform: scale(1.3); }

/* ── Status badge ── */
#status {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(245, 208, 97, 0.5);
  background: rgba(5, 3, 1, 0.7);
  border: 1px solid rgba(245, 208, 97, 0.15);
  padding: 6px 18px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: color 0.3s, border-color 0.3s;
}

#status.drawing {
  color: var(--gold);
  border-color: rgba(245, 208, 97, 0.4);
  text-shadow: 0 0 10px rgba(245, 208, 97, 0.5);
}

/* ── Hint overlay ── */
#hint {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 13px;
  color: rgba(245, 208, 97, 0.35);
  pointer-events: none;
  text-align: center;
  transition: opacity 1s;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 20;
  background: rgba(5, 3, 1, 0.9);
  border: 1px solid rgba(126, 200, 164, 0.4);
  color: #7EC8A4;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  padding: 10px 24px;
  border-radius: 30px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Loading screen ── */
#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 0.8s;
}

#loading.hidden { opacity: 0; pointer-events: none; }

.loading-title {
  font-family: 'Cinzel', serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-shadow: 0 0 30px rgba(245, 208, 97, 0.4);
}

.loading-sub {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  color: rgba(245, 208, 97, 0.45);
  font-size: 15px;
  letter-spacing: 0.1em;
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: rgba(245, 208, 97, 0.1);
  border-radius: 1px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ── Cursor mode indicator ── */
#modeTag {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 10;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 208, 97, 0.2);
  color: rgba(245, 208, 97, 0.5);
  background: rgba(5, 3, 1, 0.6);
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: all 0.25s;
}

#modeTag.eraser {
  color: var(--eraser);
  border-color: rgba(255, 107, 107, 0.4);
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
}
