/* ============================================================
   BASE & RESET
   ============================================================ */


:root {
  --bg: #0d1117;
  --bg-panel: #151b27;
  --bg-selection: #1a2535;
  --surface: #ffffff;
  --surface-dark: #1e2a3a;
  --border: #e5e7eb;
  --border-dark: #2a3a50;
  --text-primary: #ffffff;
  --text-secondary: #8b9ab0;
  --text-dark: #111827;
  --accent: #ffb802;
  --accent-hover: #e6a500;
  --success: #22c55e;
  --error: #ef4444;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow-card: 0 10px 30px rgba(0,0,0,.06);
  --font: 'Inter', sans-serif;
  --transition: 0.2s ease;
}






/* ============================================================
   CONFETTI CANVAS
   ============================================================ */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  width: 100%;
  height: 100%;
}

/* ============================================================
   APP WRAPPER
   ============================================================ */
#app {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

/* ============================================================
   HEADER
   ============================================================ */
#header {
  padding: 32px 0 8px;
  text-align: center;
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: black;
}

.brand-tagline {
  font-size: 2.2rem;
  font-weight: 800;
  color: black;
  letter-spacing: -0.02em;
}

/* ============================================================
   NAV BAR
   ============================================================ */
#nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-toggle {
  display: flex;
  background: #1e2d40;
  border-radius: 40px;
  padding: 4px;
  gap: 2px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 7px 22px;
  border-radius: 36px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.mode-btn.active {
  background: var(--surface);
  color: var(--text-dark);
}

.mode-btn:not(.active):hover {
  color: var(--text-primary);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-hint {
  font-size: 0.78rem;
  color: #505357;
  white-space: nowrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background var(--transition), transform 0.1s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 7px 16px;
  font-size: 0.8rem;
}

.btn-ghost {
  background: rgba(255,255,255,0.85);
  color: #374151;
  border: 1.5px solid rgba(0,0,0,0.1);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background var(--transition), border-color var(--transition);
}

.btn-ghost:hover {
  background: #fff;
  border-color: rgba(0,0,0,0.2);
}

.btn-next {
  background: var(--surface);
  color: var(--text-dark);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  margin-top: 8px;
  transition: background var(--transition), transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-next:hover {
  background: var(--accent);
  transform: translateX(3px);
}

.btn-action-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-dark);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 13px 20px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  transition: border-color var(--transition), background var(--transition);
}

.btn-action-outline:hover {
  border-color: var(--accent);
  background: rgba(255,184,2,0.06);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 14px 20px;
  font-size: 0.95rem;
  border-radius: 14px;
}

/* ============================================================
   PROGRESS SECTION
   ============================================================ */
#progress-section {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.progress-left {
  flex: 1;
}

.progress-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: black;
  margin-bottom: 4px;
}

.progress-round-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.progress-round-row h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: black;
}

.hsb-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: #1e2d40;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.progress-bar-track {
  margin-top: 10px;
  height: 5px;
  background: #1e2d40;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff8c00);
  border-radius: 10px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
  width: 10%;
}

.progress-right {
  text-align: right;
  flex-shrink: 0;
}

.score-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: black;
  margin-bottom: 2px;
}

.score-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: #7c7e81e3;
  line-height: 1;
  transition: color 0.3s ease;
}

/* ============================================================
   GAME AREA
   ============================================================ */
#game-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

/* ============================================================
   GAME PANELS
   ============================================================ */
.game-panel.color-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 440px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: background-color 200ms ease;
}

#target-panel {
  background: hsl(200, 55%, 70%);
  justify-content: flex-start;
}

#selection-panel {
  background: hsl(180, 50%, 70%);
}

/* Auto-contrast text classes (toggled via JS) */
.color-card.dark-text .panel-badge,
.color-card.dark-text .round-badge-small,
.color-card.dark-text .hsb-badge-top,
.color-card.dark-text .target-bottom-text h3 {
  color: rgba(0,0,0,0.72);
  background: rgba(255,255,255,0.35);
}

.color-card.light-text .panel-badge,
.color-card.light-text .round-badge-small,
.color-card.light-text .hsb-badge-top,
.color-card.light-text .target-bottom-text h3 {
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.25);
}

.panel-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 20px;
  align-self: flex-start;
  backdrop-filter: blur(4px);
  transition: color 200ms ease, background 200ms ease;
}

.round-badge-small {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  transition: color 200ms ease, background 200ms ease;
}

.hsb-badge-top {
  position: absolute;
  top: 16px;
  right: 70px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
  transition: color 200ms ease, background 200ms ease;
}

.target-bottom-text {
  margin-top: auto;
  margin-bottom: 4px;
}

.target-bottom-text h3 {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 0;
  transition: color 200ms ease;
}

/* ============================================================
   SLIDERS VIEW
   ============================================================ */
#sliders-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 8px 0;
}

.glass-panel {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  padding: 24px 22px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  animation: fadeInUp 0.3s ease;
}

.glass-badge {
  color: #6b7280 !important;
  background: rgba(0,0,0,0.06) !important;
  margin-bottom: 14px;
}

.sliders-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
}

.slider-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
}

.slider-track-wrap {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
}

/* custom range slider */
.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  position: relative;
}

/* Hue slider gradient */
.hue-track .custom-slider {
  background: linear-gradient(to right,
    hsl(0,100%,50%), hsl(30,100%,50%), hsl(60,100%,50%),
    hsl(90,100%,50%), hsl(120,100%,50%), hsl(150,100%,50%),
    hsl(180,100%,50%), hsl(210,100%,50%), hsl(240,100%,50%),
    hsl(270,100%,50%), hsl(300,100%,50%), hsl(330,100%,50%),
    hsl(360,100%,50%));
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.custom-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
}

.slider-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  padding-top: 4px;
}

/* ============================================================
   RESULT VIEW
   ============================================================ */
#result-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  justify-content: center;
  align-items: center;
  animation: fadeInUp 0.4s ease;
  padding: 8px 0;
}

.result-score-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 8px;
}

.result-big-score {
  font-size: 2.4rem;
  font-weight: 900;
  color: #111827;
  line-height: 1;
}

.result-delta-label {
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 600;
  margin-top: 3px;
}

.result-grade {
  text-align: right;
}

.result-grade span {
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  background: rgba(0,0,0,0.06);
  padding: 4px 12px;
  border-radius: 20px;
}

.result-colors-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
}

.compare-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.compare-swatch {
  width: 100%;
  flex: 1;
  min-height: 80px;
  border-radius: var(--radius-sm);
  transition: background-color 0.3s ease;
}

.compare-caption {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
}

.compare-hsb {
  font-size: 0.65rem;
  color: #9ca3af;
  font-weight: 500;
}

/* ============================================================
   PANEL FOOTER
   ============================================================ */
.panel-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding: 4px 2px;
}

/* ============================================================
   FINAL RESULTS SCREEN
   ============================================================ */
#final-screen {
  padding: 24px 0 40px;
  animation: fadeInUp 0.5s ease;
}

.final-header {
  margin-bottom: 24px;
}

.final-brand {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.final-title {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* SUMMARY CARD */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 30px;
  box-shadow: var(--shadow-card);
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 0;
}

.summary-col {
  flex: 1;
}

.summary-divider {
  width: 1px;
  height: 60px;
  background: var(--border);
  margin: 0 28px;
  flex-shrink: 0;
}

.summary-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.summary-big {
  font-size: 3rem;
  font-weight: 900;
  color: var(--text-dark);
  line-height: 1;
  margin-bottom: 4px;
}

.summary-sub {
  font-size: 0.78rem;
  color: #6b7280;
  font-weight: 500;
}

/* HISTORY GRID */
.history-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.history-card {
  background: transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: default;
  animation: fadeInUp 0.3s ease both;
}

.history-card-swatches {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  overflow: hidden;
}

.history-swatch-top,
.history-swatch-bot {
  width: 100%;
  height: 44px;
  display: block;
  transition: background-color 0.3s ease;
}

.history-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 2px 0;
}

.history-round-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.history-score {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-primary);
}

.history-score.best {
  color: var(--accent);
}

/* LEGEND */
.legend-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 28px;
}

.legend-item {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* FINAL ACTIONS */
.final-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.final-domain {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes scoreCount {
  from { transform: scale(1.3); color: var(--accent); }
  to   { transform: scale(1); }
}

.score-update {
  animation: scoreCount 0.4s ease;
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 700px)
   ============================================================ */
@media (max-width: 700px) {
  #app {
    padding: 0 12px 48px;
  }

  .brand-tagline {
    font-size: 1.6rem;
  }

  #nav-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .nav-right {
    width: 100%;
    justify-content: flex-end;
  }

  .mode-hint {
    display: none;
  }

  #progress-section {
    flex-direction: row;
    align-items: flex-start;
  }

  .progress-round-row h2 {
    font-size: 1.2rem;
  }

  #game-area {
    grid-template-columns: 1fr;
  }

  #target-panel {
    min-height: 260px;
  }

  #selection-panel {
    min-height: 360px;
  }

  .target-center-text h3 {
    font-size: 1.6rem;
  }

  .result-big-score {
    font-size: 2rem;
  }

  .history-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .history-swatch-top,
  .history-swatch-bot {
    height: 32px;
  }

  .summary-big {
    font-size: 2.2rem;
  }

  .final-title {
    font-size: 2rem;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 420px)
   ============================================================ */
@media (max-width: 420px) {
  .brand-tagline {
    font-size: 1.35rem;
  }

  .progress-round-row h2 {
    font-size: 1rem;
  }

  .history-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  .history-swatch-top,
  .history-swatch-bot {
    height: 24px;
  }

  .history-card-footer {
    padding: 4px 1px 0;
  }

  .history-round-num,
  .history-score {
    font-size: 0.62rem;
  }

  .summary-card {
    padding: 20px;
  }

  .summary-big {
    font-size: 1.8rem;
  }

  .summary-divider {
    margin: 0 16px;
  }

  .final-title {
    font-size: 1.7rem;
  }

  .target-center-text h3 {
    font-size: 1.3rem;
  }
}
