/* ==========================================================================
   Linus LetterPro - Tracing Screen & Precision Canvas Styles
   ========================================================================== */

#tracing-screen {
  background: radial-gradient(circle at center, #1E293B 0%, #0F172A 100%);
  position: relative;
}

.tracing-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

.tracing-center-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tracing-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}

.tracing-word-subtitle {
  font-size: 14px;
  color: #38BDF8;
  font-weight: 600;
}

.stage-badge {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid #3B82F6;
  color: #93C5FD;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Canvas Tracing Arena */
.tracing-arena {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.canvas-wrapper {
  position: relative;
  width: min(92vw, 92vh * 1.3);
  height: min(80vh, 80vw * 0.75);
  max-width: 960px;
  max-height: 720px;
  background: rgba(15, 23, 42, 0.65);
  border-radius: 32px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6), 0 12px 30px rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

#trace-canvas,
#trace-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#trace-canvas {
  z-index: 10;
}

#trace-overlay {
  z-index: 15;
  cursor: crosshair;
}

/* Guideline Label Tabs on sides */
.guideline-labels {
  position: absolute;
  left: 10px;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10% 0 10% 0;
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
}

.gl-sky { color: #38BDF8; }
.gl-fence { color: #FBBF24; }
.gl-grass { color: #34D399; }

/* Tracing Floating Controls (Left / Right Toolbar) */
.tracing-side-tools {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
}

/* Invert layout for left-handed toddlers */
body.left-handed .tracing-side-tools {
  left: auto;
  right: 20px;
}

/* Apple Pencil Mode enhancements */
body.pencil-mode .canvas-wrapper {
  border-color: #38BDF8;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.25);
}

/* Off-track pulse warning alert */
.canvas-wrapper.off-track-warning {
  border-color: #EF4444;
  animation: warningPulse 0.3s ease infinite alternate;
}

@keyframes warningPulse {
  from { box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }
  to { box-shadow: 0 0 35px rgba(239, 68, 68, 0.8); }
}

/* 52 Styles Modal Layout */
.styles-card {
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.styles-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.styles-grid-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 16px 4px;
}

.style-item-card {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.style-item-card:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.style-item-card.active {
  border-color: #F59E0B;
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.style-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(0, 0, 0, 0.3);
}

.style-info {
  display: flex;
  flex-direction: column;
}

.style-num {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.style-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

/* Victory Modal */
.victory-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: victoryBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-mascot {
  font-size: 64px;
}

.victory-stars-row {
  display: flex;
  gap: 12px;
  font-size: 48px;
}

.victory-star.earned {
  color: #FBBF24;
  filter: drop-shadow(0 0 10px #F59E0B);
  animation: starPop 0.5s ease-out;
}

.victory-star.empty {
  color: #475569;
}

.victory-metrics {
  display: flex;
  gap: 20px;
}

.metric-pill {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.metric-pill .label {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-pill .val {
  font-size: 18px;
  font-weight: 800;
  color: #10B981;
}

.victory-actions {
  display: flex;
  gap: 14px;
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

@keyframes victoryBounce {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes starPop {
  0% { transform: scale(0); }
  80% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
