/* ===== CARTOON THEME - DESENHANDO ===== */
/* "Playful Canvas: Cartoon Artistry" */

/* ===== CSS VARIABLES ===== */
:root {
  /* Background & Surface — green + beige */
  --background: #4CAF50;
  --surface: #F5E6D0;
  --surface-container: #F5E6D0;
  --surface-container-low: #EDE0CC;
  --surface-container-lowest: #E8D8C0;
  --surface-container-high: #FFF3E6;
  --surface-container-highest: #FFF8F0;

  /* Primary — orange */
  --primary: #FF5722;
  --primary-container: #FF7043;
  --primary-dim: #E64A19;
  --on-primary: #fff;

  /* Secondary — teal */
  --secondary: #00897B;
  --secondary-container: #4DB6AC;
  --secondary-dim: #00796B;
  --on-secondary: #fff;

  /* Tertiary — purple */
  --tertiary: #AB47BC;
  --tertiary-container: #CE93D8;
  --on-tertiary: #fff;

  /* On-Surface & Outlines */
  --on-background: #3E2723;
  --on-surface: #3E2723;
  --on-surface-variant: #6D4C41;
  --outline: #8D6E63;
  --outline-variant: #8D6E63;

  /* Status */
  --error: #E53935;
  --success: #43A047;
  --warning: #FFB300;

  /* Shadows — cartoon 3D */
  --shadow-hard: 0 4px 0 #5D4037;
  --shadow-soft: 0 4px 0 #5D4037, 0 6px 12px rgba(93, 64, 55, 0.18);

  /* Glass Effect — cartoon style */
  --glass-bg: rgba(255, 248, 240, 0.96);
  --glass-border: #8D6E63;
  --glass-blur: 12px;

  /* Canvas */
  --canvas-bg: #ffffff;
  --canvas-border: #8D6E63;

  /* Fonts */
  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

/* ===== BASE RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-weight: 700;
  background: var(--background);
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  color: var(--on-background);
  user-select: none;
  position: relative;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-container);
  border-bottom: 3px solid var(--outline);
  z-index: 100;
  flex-shrink: 0;
}

.btn-back {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--on-surface-variant);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 12px;
  border: 3px solid var(--outline);
  background: var(--surface-container-high);
  box-shadow: 0 3px 0 #5D4037;
  transition: all 0.15s;
}
.btn-back:hover {
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #5D4037;
}
.btn-back:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5D4037;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  text-shadow: 2px 2px 0 #5D4037;
  letter-spacing: 0.5px;
}

.stats {
  display: flex;
  gap: 12px;
}

.score-box {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--surface-container-high);
  border-radius: 12px;
  border: 3px solid var(--outline);
  box-shadow: 0 3px 0 #5D4037;
}
.score-box.best { border-color: var(--primary); }

.score-icon { font-size: 1rem; }

.score-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--on-surface);
}

.neon-text {
  color: var(--primary);
  text-shadow: 1px 1px 0 #5D4037;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 8px;
  gap: 8px;
}

/* ===== GAME INFO BAR ===== */
.game-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 620px;
  padding: 8px 16px;
  background: var(--surface-container);
  border-radius: 16px;
  border: 3px solid var(--outline);
  box-shadow: var(--shadow-hard);
  flex-shrink: 0;
}

.round-info {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--secondary);
}

.timer-container {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.timer-svg {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: #D7CCC8;
  stroke-width: 3;
}

.timer-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 125.66;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-fg.warning { stroke: var(--warning); }
.timer-fg.danger { stroke: var(--error); }

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--on-surface);
}

.hint-info {
  text-align: right;
}

.hint-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--on-surface);
  letter-spacing: 3px;
}

.hint-category {
  display: block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--secondary);
  margin-top: 2px;
}

/* ===== CANVAS ===== */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1;
  flex-shrink: 1;
  min-height: 0;
}

#draw-canvas {
  width: 100%;
  height: 100%;
  background: var(--canvas-bg);
  border-radius: 16px;
  border: 3px solid var(--canvas-border);
  box-shadow: var(--shadow-soft);
  cursor: crosshair;
  touch-action: none;
}

#draw-canvas.no-draw {
  cursor: default;
  pointer-events: none;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 620px;
  padding: 8px 12px;
  background: var(--surface-container);
  border-radius: 16px;
  border: 3px solid var(--outline);
  box-shadow: var(--shadow-hard);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.toolbar::-webkit-scrollbar { height: 4px; }
.toolbar::-webkit-scrollbar-thumb { background: #BCAAA4; border-radius: 4px; }

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tool-group.colors {
  flex-wrap: wrap;
  gap: 4px;
}

.tool-group + .tool-group {
  padding-left: 8px;
  border-left: 3px solid #D7CCC8;
}

/* Color buttons */
.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.color-btn:hover { transform: scale(1.15); }
.color-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.3);
  transform: scale(1.15);
}

/* Tool buttons */
.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 3px solid var(--outline);
  background: var(--surface-container-high);
  color: var(--on-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: 0 3px 0 #5D4037;
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #5D4037; }
.tool-btn.active {
  background: #FFE0B2;
  border-color: var(--primary);
  color: var(--primary);
}

/* Size buttons */
.size-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 3px solid var(--outline);
  background: var(--surface-container-high);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: 0 3px 0 #5D4037;
}
.size-btn:hover { border-color: var(--primary); }
.size-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #5D4037; }
.size-btn.active {
  background: #FFE0B2;
  border-color: var(--primary);
}

.size-dot {
  border-radius: 50%;
  background: var(--on-surface);
}
.size-s { width: 6px; height: 6px; }
.size-m { width: 10px; height: 10px; }
.size-l { width: 16px; height: 16px; }

/* ===== GUESS AREA ===== */
.guess-area {
  width: 100%;
  max-width: 620px;
  flex-shrink: 0;
}

.guess-input-wrapper {
  display: flex;
  gap: 8px;
}

.guess-input {
  flex: 1;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 16px;
  color: var(--on-surface);
  outline: none;
  box-shadow: inset 0 2px 4px rgba(93, 64, 55, 0.1);
  transition: border-color 0.2s;
}
.guess-input:focus { border-color: var(--primary); }
.guess-input::placeholder { color: #BCAAA4; }

.btn-guess {
  padding: 10px 20px;
  font-size: 0.95rem;
  border-radius: 16px;
  flex-shrink: 0;
}

.guess-feedback {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  padding: 4px 0;
  min-height: 28px;
  color: var(--warning);
  transition: color 0.2s;
}
.guess-feedback.correct { color: var(--success); }
.guess-feedback.wrong { color: var(--error); }

/* ===== MODAL / OVERLAYS ===== */
.modal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.glass-overlay {
  background: rgba(56, 142, 60, 0.75);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.glass-modal {
  background: var(--glass-bg);
  border: 3px solid var(--glass-border);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-soft);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
  text-shadow: 2px 2px 0 rgba(93, 64, 55, 0.25);
}

.modal-subtitle {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--on-surface-variant);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-hint {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--secondary);
  margin-top: -12px;
  margin-bottom: 16px;
}

.word-reveal {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--secondary);
  text-shadow: 2px 2px 0 rgba(0, 137, 123, 0.2);
}

.overlay-score {
  margin-bottom: 16px;
}

.neon-score {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  text-shadow: 2px 2px 0 rgba(93, 64, 55, 0.25);
}

/* ===== BUTTONS ===== */
.btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1rem;
  padding: 12px 28px;
  border: 3px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: #BF360C;
  box-shadow: 0 4px 0 #BF360C;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #BF360C;
}
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #BF360C;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--on-secondary);
  border-color: #004D40;
  box-shadow: 0 4px 0 #004D40;
}
.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #004D40;
}
.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #004D40;
}

.btn-tertiary {
  background: var(--tertiary);
  color: var(--on-tertiary);
  border-color: #6A1B9A;
  box-shadow: 0 4px 0 #6A1B9A;
}
.btn-tertiary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #6A1B9A;
}
.btn-tertiary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #6A1B9A;
}

.btn-whatsapp {
  background: #25D366;
  color: #fff;
  border-color: #128C3E;
  box-shadow: 0 4px 0 #128C3E;
}
.btn-whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #128C3E;
}
.btn-whatsapp:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #128C3E;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-mode {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px 24px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .topbar { padding: 8px 10px; }
  .game-title { font-size: 1.2rem; }
  .score-value { font-size: 1.1rem; }
  .score-box { padding: 3px 7px; gap: 3px; }

  .game-container { padding: 4px; gap: 4px; }

  .canvas-wrapper {
    max-width: 100%;
    max-height: calc(100dvh - 260px);
    aspect-ratio: 1;
  }

  .toolbar { padding: 6px 8px; gap: 6px; }
  .color-btn { width: 24px; height: 24px; }
  .tool-btn, .size-btn { width: 32px; height: 32px; }

  .game-info-bar { padding: 6px 10px; }
  .round-info { font-size: 1rem; }
  .hint-text { font-size: 1.1rem; letter-spacing: 2px; }

  .glass-modal { padding: 24px 20px; }
  .modal-title { font-size: 1.6rem; }
  .btn-mode { font-size: 0.95rem; padding: 12px 20px; }
}

@media (min-width: 900px) {
  .game-container {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    gap: 16px;
  }

  .game-info-bar {
    width: 100%;
    max-width: 800px;
  }

  .canvas-wrapper {
    max-width: 550px;
    max-height: calc(100dvh - 200px);
  }

  .toolbar {
    flex-direction: column;
    width: auto;
    max-width: none;
    padding: 12px;
    align-self: stretch;
    overflow-x: visible;
    overflow-y: auto;
  }

  .tool-group { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .tool-group.colors { max-width: 130px; }
  .tool-group + .tool-group { padding-left: 0; border-left: none; padding-top: 8px; border-top: 3px solid #D7CCC8; }

  .guess-area { max-width: 800px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.glass-modal { animation: fadeIn 0.3s ease-out; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 0 #5D4037, 0 6px 12px rgba(93, 64, 55, 0.18); }
  50% { box-shadow: 0 4px 0 #5D4037, 0 6px 20px rgba(255, 87, 34, 0.25); }
}

#draw-canvas.drawing { animation: pulse-glow 2s ease-in-out infinite; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

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