:root {
  --bg: #03050a;
  --glass: rgba(10, 16, 28, 0.58);
  --glass-edge: rgba(140, 200, 255, 0.16);
  --text: #e8f1ff;
  --muted: #8ea3bf;
  --accent: #66e0ff;
  --accent-2: #ffd166;
  --good: #5dffa0;
  --warn: #ff7a6b;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; }
canvas#gl, canvas#overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
canvas#gl { touch-action: none; }  /* drag rotates the model instead of scrolling the page */
canvas#overlay { pointer-events: none; }
video#cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ---------- brand */
.brand { position: fixed; top: 18px; left: 20px; display: flex; gap: 12px; align-items: center; z-index: 5; pointer-events: none; }
.brand-name { font-weight: 800; letter-spacing: 0.04em; font-size: 20px; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: 0.06em; }
.logo { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--accent); position: relative; box-shadow: 0 0 18px rgba(102, 224, 255, 0.55); }
.logo span { position: absolute; inset: 10px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); }
.logo.big { width: 64px; height: 64px; margin: 0 auto 8px; }
.logo.big span { inset: 20px; }

/* ---------- left panel */
.panel { position: fixed; top: 74px; left: 20px; width: 300px; max-height: calc(100vh - 170px); overflow: auto; padding: 16px 16px 12px; z-index: 4; }
.panel section + section { margin-top: 14px; }
.now .cat { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); border: 1px solid rgba(102, 224, 255, 0.35); padding: 2px 8px; border-radius: 99px; }
.now h1 { margin: 8px 0 2px; font-size: 24px; line-height: 1.15; }
.fact { margin: 0; color: var(--muted); font-size: 13px; }
.k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.status .row { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); text-transform: uppercase; letter-spacing: 0.06em; }
.pill[data-state="sphere"] { color: var(--accent); border-color: rgba(102, 224, 255, 0.5); }
.pill[data-state="formed"] { color: var(--good); border-color: rgba(93, 255, 160, 0.5); }
.pill[data-state="dissolve"] { color: var(--warn); border-color: rgba(255, 122, 107, 0.5); }
.pill.pose { text-transform: none; }
.sensitivity { margin-top: 10px; }
.sensitivity-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sensitivity select { max-width: 145px; padding: 4px 7px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 7px; background: #101826; color: var(--text); font: inherit; font-size: 12px; }
.sensitivity .hint { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.meter { margin-top: 10px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.meter-head b { font-size: 13px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width 0.08s linear; }
.explode input[type="range"] { width: 100%; accent-color: var(--accent-2); }
.explode .hint { color: var(--muted); font-size: 11px; margin-top: 2px; }
.guide { list-style: none; padding: 0; margin: 6px 0 0; }
.guide li { display: grid; grid-template-columns: 30px 1fr; gap: 6px; align-items: center; padding: 6px 8px; border-radius: 10px; font-size: 13px; color: var(--muted); transition: background 0.2s, color 0.2s; }
.guide li .e { font-size: 18px; text-align: center; }
.guide li b { color: var(--text); font-weight: 650; }
.guide li.hot { background: rgba(102, 224, 255, 0.1); color: var(--text); box-shadow: inset 0 0 0 1px rgba(102, 224, 255, 0.25); }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.buttons button, .start-buttons button { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; padding: 8px 10px; font-size: 13px; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.buttons button:hover, .start-buttons button:hover { background: rgba(102, 224, 255, 0.14); border-color: rgba(102, 224, 255, 0.4); }
button:active { transform: translateY(1px); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- catalog: category tabs + chips */
.catalog { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 8px 12px; z-index: 4; width: max-content; max-width: min(1180px, calc(100vw - 32px)); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.tab { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; padding: 4px 10px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-color: rgba(102, 224, 255, 0.45); background: rgba(102, 224, 255, 0.1); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.chip { white-space: nowrap; font-size: 11.5px; padding: 5px 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); display: inline-flex; align-items: center; gap: 6px; }
.chip[hidden] { display: none; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.chip:hover { border-color: rgba(102, 224, 255, 0.45); }
.chip.active { background: rgba(102, 224, 255, 0.16); border-color: var(--accent); color: #fff; }

/* ---------- part card + quiz */
.part-card { position: fixed; right: 16px; top: 196px; width: 300px; padding: 12px 14px; z-index: 6; font-size: 13px; }
.part-card[hidden], .quiz[hidden] { display: none; }
.part-card .phead { display: flex; align-items: center; gap: 8px; }
.part-card .swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 10px currentColor; flex: none; }
.part-card .pname { font-weight: 800; font-size: 16px; flex: 1; }
.part-card .pinfo { margin: 6px 0 4px; color: var(--text); line-height: 1.4; }
.part-card .pmodel, .part-card .phint { color: var(--muted); font-size: 11px; }
.part-card .pactions { display: flex; gap: 6px; margin: 8px 0 6px; }
.part-card .pactions button { flex: 1; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 8px; padding: 5px 8px; font-size: 12px; }
.part-card.pulled { border-color: rgba(255, 159, 67, 0.7); box-shadow: 0 0 24px rgba(255, 159, 67, 0.25); }
.x { background: transparent; border: none; color: var(--muted); font-size: 14px; padding: 2px 4px; }
.quiz { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); min-width: 360px; max-width: calc(100vw - 32px); padding: 10px 40px 10px 18px; z-index: 6; text-align: center; }
.quiz .q { font-weight: 800; font-size: 20px; }
.quiz .qs { color: var(--muted); font-size: 12px; margin-top: 2px; }
.quiz .qf { margin-top: 6px; font-size: 13px; }
.quiz.good { border-color: rgba(93, 255, 160, 0.6); }
.quiz.bad { border-color: rgba(255, 122, 107, 0.6); }
.quiz .x { position: absolute; right: 8px; top: 8px; }
.rec { color: #ff5a5a; font-weight: 700; }

/* ---------- top right */
.top-right { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 5; }
.stats { font-size: 11px; color: var(--muted); padding: 8px 12px; font-variant-numeric: tabular-nums; line-height: 1.5; text-align: right; }
.stats b { color: var(--text); font-weight: 650; }
.icons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 330px; }
.icon { width: 36px; height: 36px; border-radius: 10px; background: var(--glass); border: 1px solid var(--glass-edge); font-size: 15px; }
.icon.on { border-color: rgba(102, 224, 255, 0.55); box-shadow: 0 0 12px rgba(102, 224, 255, 0.25); }
.help { position: fixed; top: 176px; right: 16px; width: 330px; padding: 14px 16px; z-index: 6; font-size: 13px; }
.help h2 { margin: 0 0 8px; font-size: 15px; }
.help td { padding: 4px 6px; vertical-align: top; color: var(--muted); }
.help td:first-child { white-space: nowrap; color: var(--text); }
kbd { font-family: inherit; font-size: 11px; padding: 1px 6px; border: 1px solid rgba(255, 255, 255, 0.25); border-bottom-width: 2px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); }

/* ---------- titles, toast */
.big-title { position: fixed; right: 5vw; top: 196px; text-align: right; z-index: 3; opacity: 0; transform: translateY(8px); transition: opacity 0.6s, transform 0.6s; pointer-events: none; text-shadow: 0 0 24px rgba(0, 0, 0, 0.8); }
.big-title.show { opacity: 1; transform: none; }
.big-title .t { font-size: clamp(22px, 3.2vw, 44px); font-weight: 800; letter-spacing: 0.02em; }
.big-title .s { color: var(--muted); font-size: 14px; margin-top: 2px; }
.toast { position: fixed; left: 50%; top: 20px; transform: translate(-50%, -8px); background: rgba(8, 14, 24, 0.8); border: 1px solid var(--glass-edge); padding: 8px 16px; border-radius: 99px; font-size: 14px; opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 7; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- start overlay */
.start { position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; background: radial-gradient(ellipse at 60% 40%, rgba(20, 40, 70, 0.55), rgba(0, 0, 0, 0.82)); padding: 16px; }
.start[hidden] { display: none; }
.start-card { max-width: 560px; padding: 28px 30px; text-align: center; }
.start-card h1 { margin: 4px 0 6px; font-size: 32px; letter-spacing: 0.03em; }
.start-card p { color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.steps { text-align: left; color: var(--muted); line-height: 1.55; margin: 0 0 18px; padding-left: 22px; }
.steps b { color: var(--text); }
.start-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.start-buttons button { padding: 11px 18px; font-size: 15px; }
.start-buttons .primary { background: linear-gradient(90deg, rgba(102, 224, 255, 0.35), rgba(255, 209, 102, 0.3)); border-color: rgba(102, 224, 255, 0.6); font-weight: 700; }
.start-msg { min-height: 1.4em; margin-top: 12px !important; color: var(--accent-2) !important; }

@media (max-width: 820px) {
  .panel { width: calc(100vw - 32px); left: 16px; top: auto; bottom: 86px; max-height: 38vh; }
  .brand-sub { display: none; }
  .big-title { right: 16px; top: 70px; }
  .help { width: calc(100vw - 32px); }
}

/* ---------- phones: one column, panel on top, catalog scrolls sideways at the bottom */
@media (max-width: 600px) {
  .brand { top: 10px; left: 12px; gap: 8px; }
  .brand-name { font-size: 16px; }
  .logo { width: 28px; height: 28px; }
  .logo span { inset: 8px; }
  .top-right { top: 10px; right: 12px; }
  .stats { display: none; }
  .icons { max-width: 216px; }
  .panel { top: auto; bottom: 100px; left: 12px; width: calc(100vw - 24px); max-height: 40dvh; padding: 12px; }
  .panel .guide-sec, .status .row, .sensitivity, .meter:not(.explode) { display: none; }
  .now h1 { font-size: 20px; }
  .catalog { bottom: 8px; padding: 6px 8px; max-width: calc(100vw - 16px); width: calc(100vw - 16px); }
  .tabs, .chips { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; width: 100%; scrollbar-width: none; }
  .tab, .chip { flex: none; }
  .part-card, .quiz { left: 12px; right: 12px; top: 100px; width: auto; min-width: 0; max-width: none; transform: none; }
  .help { top: 100px; left: 12px; right: 12px; width: auto; max-height: 60dvh; overflow: auto; }
  .toast { top: 96px; max-width: calc(100vw - 24px); text-align: center; border-radius: 14px; }
  .big-title { left: 12px; right: 12px; top: 100px; text-align: center; }
  .start { align-items: start; overflow-y: auto; padding: 12px; }
  .start-card { margin: auto; padding: 20px 16px; }
  .start-card h1 { font-size: 26px; }
  .steps { font-size: 14px; padding-left: 18px; }
}
