*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Roboto', 'Sarabun', sans-serif;
  color: #eef3f8;
  background: #031527;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }

:root {
  --blue: #0069B4;
  --dark: #042E52;
  --orange: #EF781A;
  --cool: #7ec8ff;
  --heat: #ff6b3d;
  --ink: #0b2038;
  --panel: rgba(255,255,255,0.06);
  --panel-strong: rgba(255,255,255,0.12);
  --border: rgba(255,255,255,0.14);
  --text: #eef3f8;
  --muted: rgba(238,243,248,0.68);
  --radius: 16px;
  --t: 300ms;
}

/* ====== BACKDROP ====== */
.stage {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: 440px 1fr;
  background:
    radial-gradient(1200px 900px at 85% 15%, rgba(239,120,26,0.18), transparent 60%),
    radial-gradient(900px 800px at 10% 90%, rgba(0,105,180,0.22), transparent 60%),
    radial-gradient(700px 600px at 60% 60%, rgba(126,200,255,0.08), transparent 70%),
    linear-gradient(160deg, #031527 0%, #042E52 60%, #031527 100%);
}
@media (max-width: 968px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 40vh 60vh; }
}

/* ====== WIZARD PANEL ====== */
.panel {
  position: relative; z-index: 3;
  padding: 32px 36px;
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, rgba(4,46,82,0.55), rgba(3,21,39,0.75));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
@media (max-width: 968px) {
  .panel { border-right: 0; border-top: 1px solid var(--border); padding: 24px; order: 2; }
}

.brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 32px;
  transition: opacity var(--t) ease;
}
.brand:hover { opacity: 0.85; }
.brand-logo {
  height: 30px; width: auto;
  filter: drop-shadow(0 4px 14px rgba(0,105,180,0.35));
}
.brand-sep {
  color: rgba(255,255,255,0.25); font-size: 1.2rem; font-weight: 300;
}
.brand-label {
  font-size: 0.82rem; letter-spacing: 0.14em; font-weight: 600;
  text-transform: uppercase; color: var(--muted);
}

/* progress */
.progress {
  display: flex; gap: 6px; margin-bottom: 28px;
}
.progress span {
  flex: 1; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.08);
  transition: background var(--t) ease;
}
.progress span.done { background: var(--orange); }
.progress span.active { background: linear-gradient(90deg, var(--orange), var(--cool)); }

/* step */
.step { display: none; animation: fade 500ms ease both; }
.step.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  background: rgba(239,120,26,0.14); color: var(--orange);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; margin-bottom: 12px;
}
.step h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.75rem);
  font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.2;
}
.step p.lede { color: var(--muted); margin-bottom: 24px; font-size: 0.95rem; }

/* slider */
.field { margin-bottom: 24px; }
.field label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.85rem; color: var(--muted); margin-bottom: 10px;
  font-weight: 500;
}
.field label b { color: var(--text); font-size: 1.1rem; font-weight: 700; }
.field input[type=range] {
  width: 100%; appearance: none; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--orange) var(--pct,50%), rgba(255,255,255,0.12) var(--pct,50%));
  outline: none;
}
.field input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--orange);
  cursor: grab; transition: transform var(--t) ease, box-shadow var(--t) ease;
  box-shadow: 0 4px 14px rgba(239,120,26,0.45);
}
.field input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.12); }
.field input[type=range]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.05); }

/* option chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 10px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: 0.88rem; color: var(--text);
  transition: all var(--t) ease;
}
.chip:hover { background: var(--panel-strong); transform: translateY(-1px); }
.chip.active {
  background: linear-gradient(135deg, var(--orange), #d56a10);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(239,120,26,0.35);
}

/* direction compass */
.compass {
  position: relative; width: 160px; height: 160px; margin: 8px auto 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05), rgba(0,0,0,0.18) 70%),
    conic-gradient(from 0deg, rgba(239,120,26,0.12), rgba(0,105,180,0.12), rgba(239,120,26,0.12));
  border: 1px solid var(--border);
  display: grid; place-items: center;
}
.compass::after {
  content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 12px rgba(255,255,255,0.15);
}
.compass-btn {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 0.7rem; font-weight: 700;
  color: var(--muted); transition: all var(--t) ease;
}
.compass-btn:hover { background: var(--panel-strong); color: var(--text); }
.compass-btn.active {
  background: var(--orange); color: #fff; border-color: transparent;
  box-shadow: 0 0 24px rgba(239,120,26,0.6);
}
.compass-btn.n { top: 6px; left: 50%; transform: translateX(-50%); }
.compass-btn.e { right: 6px; top: 50%; transform: translateY(-50%); }
.compass-btn.s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.compass-btn.w { left: 6px; top: 50%; transform: translateY(-50%); }

/* toggle tiles (heat sources) */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  padding: 14px 10px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
  text-align: center; transition: all var(--t) ease;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tile:hover { background: var(--panel-strong); transform: translateY(-1px); }
.tile.active {
  background: linear-gradient(135deg, rgba(239,120,26,0.25), rgba(255,107,61,0.15));
  border-color: rgba(239,120,26,0.6);
}
.tile .emoji { font-size: 1.4rem; }
.tile span { font-size: 0.78rem; color: var(--muted); }
.tile.active span { color: var(--text); }

/* controls */
.controls {
  display: flex; gap: 10px; margin-top: auto; padding-top: 24px;
}
.btn {
  padding: 13px 22px; border-radius: 999px; font-weight: 600;
  font-size: 0.9rem; transition: all var(--t) ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary {
  background: var(--orange); color: #fff;
  box-shadow: 0 10px 28px rgba(239,120,26,0.35);
}
.btn-primary:hover { transform: translateY(-2px); background: #d56a10; box-shadow: 0 14px 36px rgba(239,120,26,0.5); }
.btn-ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--panel-strong); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none !important; }

/* ====== VIEWPORT ====== */
.viewport {
  position: relative; z-index: 2;
  overflow: hidden;
}
.viewport canvas {
  display: block; width: 100% !important; height: 100% !important;
  cursor: grab;
}
.viewport canvas:active { cursor: grabbing; }

/* cinematic color-grade overlays */
.scene-tint {
  position: absolute; inset: 0; pointer-events: none;
  z-index: 3;
  mix-blend-mode: overlay;
  transition: opacity 1400ms cubic-bezier(.55,.02,.3,1);
}
.warm-tint {
  background:
    radial-gradient(ellipse at 70% 25%, rgba(255,170,75,0.55) 0%, rgba(240,120,40,0.20) 45%, rgba(180,70,30,0) 75%),
    linear-gradient(180deg, rgba(255,140,60,0.18), rgba(120,50,20,0.10));
  opacity: 1;
}
.cool-tint {
  background:
    radial-gradient(ellipse at 35% 50%, rgba(150,220,255,0.55) 0%, rgba(70,160,240,0.22) 45%, rgba(20,80,160,0) 75%),
    linear-gradient(180deg, rgba(120,200,255,0.12), rgba(20,60,130,0.08));
  opacity: 0;
}
.warm-tint.hide { opacity: 0; }
.cool-tint.show { opacity: 1; }

/* live readout */
.readout {
  position: absolute; top: 24px; right: 24px; z-index: 5;
  background: rgba(3,21,39,0.68);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  min-width: 180px;
  text-align: right;
}
.readout small {
  display: block; color: var(--muted); font-size: 0.68rem;
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 4px;
}
.readout .btu-num {
  font-family: 'Roboto', monospace;
  font-size: 2rem; font-weight: 900;
  background: linear-gradient(135deg, #fff, var(--cool));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  letter-spacing: -0.01em;
}
.readout .btu-unit { color: var(--muted); font-size: 0.85rem; font-weight: 500; margin-left: 4px; }

/* floating hint */
.hint {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 5; font-size: 0.82rem; color: var(--muted);
  background: rgba(3,21,39,0.55); backdrop-filter: blur(10px);
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border);
  pointer-events: none;
  opacity: 0.8;
}

/* ====== FINAL RESULT OVERLAY ====== */
.result {
  position: fixed; inset: 0; z-index: 10;
  display: none; place-items: center;
  background: radial-gradient(ellipse at center, rgba(3,21,39,0.55), rgba(3,21,39,0.92));
  backdrop-filter: blur(20px);
  padding: 24px;
}
.result.show { display: grid; animation: fade 600ms ease both; }
.result-card {
  max-width: 720px; width: 100%;
  background: linear-gradient(180deg, rgba(4,46,82,0.7), rgba(3,21,39,0.9));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: ''; position: absolute; top: -100px; left: -100px;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(126,200,255,0.18), transparent 70%);
  pointer-events: none;
}
.result-card::after {
  content: ''; position: absolute; bottom: -120px; right: -80px;
  width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(239,120,26,0.14), transparent 70%);
  pointer-events: none;
}
.result-card > * { position: relative; z-index: 1; }
.result-eyebrow {
  display: inline-block; padding: 8px 16px; border-radius: 999px;
  background: rgba(126,200,255,0.12); color: var(--cool);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; margin-bottom: 18px;
}
.result-card h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; margin-bottom: 8px; }
.result-card .big {
  font-size: clamp(3.5rem, 9vw, 5.5rem); font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--cool), #fff 50%, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 16px 0 4px;
  letter-spacing: -0.03em;
}
.result-card .big small { font-size: 0.35em; color: var(--muted); font-weight: 500; margin-left: 12px; letter-spacing: 0; }
.result-card p.lede { color: var(--muted); font-size: 1rem; margin-bottom: 28px; }
.sku {
  display: inline-flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--blue), var(--dark));
  padding: 18px 28px; border-radius: 16px;
  margin-bottom: 28px;
  box-shadow: 0 12px 40px rgba(0,105,180,0.35);
}
.sku-badge {
  background: var(--orange); color: #fff;
  padding: 4px 10px; border-radius: 6px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
}
.sku-name { font-weight: 700; font-size: 1.05rem; }
.sku-size { color: var(--cool); font-weight: 600; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.result-back {
  margin-top: 20px;
  font-size: 0.85rem; color: var(--muted);
  transition: color var(--t) ease;
}
.result-back:hover { color: var(--text); }

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
