@import url('data:text/css,');

:root {
  --ink: #0a0b0a;
  --paper: #eeeee7;
  --panel: #141613;
  --panel-2: #1b1d19;
  --muted: #969b8d;
  --acid: #c8ff2e;
  --acid-soft: #e3ff95;
  --orange: #ff6a28;
  --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; min-height: 100%; background: var(--ink); }

body {
  overflow: hidden;
  color: var(--paper);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.grain {
  position: fixed; inset: 0; z-index: 99; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
}

.topbar {
  height: 68px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: rgba(10, 11, 10, .92); position: relative; z-index: 10;
}

.brand { color: var(--paper); text-decoration: none; display: flex; align-items: center; gap: 11px; font-size: 20px; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { width: 35px; height: 35px; fill: var(--acid); }
.brand-mark circle { fill: var(--ink); }
.brand-mark .brand-mouth { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.header-note { display: flex; align-items: center; gap: 9px; color: #aeb2a5; font-size: 12px; letter-spacing: .08em; }
.signal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 14px var(--acid); }

.app-shell { height: calc(100dvh - 68px); display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.viewport { position: relative; overflow: hidden; min-width: 0; background: #090a09; touch-action: none; cursor: grab; }
.viewport:active { cursor: grabbing; }
#glCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 2; }

.viewport::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(circle at 52% 42%, rgba(173, 255, 47, .085), transparent 31%),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: auto, 54px 54px, 54px 54px;
  mask-image: radial-gradient(circle at center, #000, transparent 77%);
}

.viewport::after { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; box-shadow: inset 0 0 140px rgba(0,0,0,.85); }
.ambient { position: absolute; z-index: 1; width: 280px; height: 280px; border-radius: 50%; filter: blur(100px); pointer-events: none; opacity: .1; }
.ambient-a { background: var(--acid); left: 8%; bottom: -140px; }
.ambient-b { background: #fc4d83; right: 4%; top: 1%; }

.stage-topline { position: absolute; z-index: 4; left: 24px; right: 24px; top: 22px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.live-badge { height: 28px; display: inline-flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid rgba(255,255,255,.15); border-radius: 99px; background: rgba(13,14,12,.55); backdrop-filter: blur(8px); text-transform: uppercase; font-size: 10px; letter-spacing: .12em; color: #b6baae; }
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: #74776e; }
.live-badge.running i { background: var(--orange); box-shadow: 0 0 12px var(--orange); animation: blink 1.1s infinite; }
.live-badge.running b { color: #fff; }
.stage-index { color: rgba(255,255,255,.35); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .13em; }

.intro { position: absolute; z-index: 5; left: 8.5%; top: 50%; width: min(470px, 83%); transform: translateY(-48%); transition: opacity .45s ease, transform .45s ease, visibility .45s; pointer-events: auto; cursor: default; }
.intro.hidden { opacity: 0; visibility: hidden; transform: translateY(-44%); pointer-events: none; }
.eyebrow { color: var(--acid); font-size: 11px; font-weight: 800; letter-spacing: .19em; margin-bottom: 20px; }
.intro h1 { margin: 0; max-width: 620px; color: #f5f5ed; font-size: clamp(42px, 6vw, 76px); line-height: .98; letter-spacing: -.075em; font-weight: 780; }
.intro h1 em { color: var(--acid); font-style: normal; }
.intro p { width: min(390px, 100%); margin: 24px 0 27px; color: #b0b4a8; font-size: 15px; line-height: 1.7; }
.intro small { display: block; margin-top: 14px; color: #6f736a; font-size: 11px; }

.primary-button { border: 0; min-width: 172px; height: 50px; padding: 0 18px 0 22px; display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; border-radius: 5px; background: var(--acid); color: #11130d; font-weight: 800; cursor: pointer; box-shadow: 0 0 0 0 rgba(200,255,46,.35); transition: transform .2s, background .2s, box-shadow .2s; }
.primary-button:hover { background: #d6ff61; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(200,255,46,.15); }
.primary-button:active { transform: translateY(0) scale(.98); }
.primary-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.primary-button.compact { min-width: 140px; justify-content: center; height: 44px; margin-top: 18px; }

.gesture-hint { position: absolute; z-index: 4; left: 24px; bottom: 22px; display: flex; align-items: center; gap: 10px; color: #777b70; font-size: 11px; pointer-events: none; opacity: 0; transition: opacity .5s; }
.gesture-hint.visible { opacity: 1; }
.gesture-hint svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.dashboard { position: relative; z-index: 6; padding: 26px 22px 18px; display: flex; flex-direction: column; gap: 20px; background: #111310; border-left: 1px solid var(--line); overflow-y: auto; }
.dash-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dash-heading span, .metric-label { color: #777d70; font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.dash-heading h2 { margin: 6px 0 0; font-size: 18px; letter-spacing: -.03em; }
.phase-number { color: #30342d !important; font: 800 34px/1 ui-monospace, monospace !important; letter-spacing: -.08em !important; }

.timer-block { padding: 18px 18px 14px; border: 1px solid var(--line); border-radius: 7px; background: linear-gradient(140deg, rgba(200,255,46,.065), transparent 58%); }
.timer { margin: 6px 0 10px; color: var(--acid); font: 700 clamp(35px, 3.4vw, 45px)/1.1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.075em; text-shadow: 0 0 22px rgba(200,255,46,.14); }
.best-line { padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: #70756a; font-size: 10px; }
.best-line b { color: #b5b9ae; font-family: ui-monospace, monospace; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metric-card { min-width: 0; min-height: 112px; padding: 15px 14px; border-radius: 6px; background: var(--panel-2); border: 1px solid rgba(255,255,255,.06); }
.metric-card.accent { background: var(--acid); border-color: var(--acid); }
.metric-card.accent .metric-label, .metric-card.accent small { color: rgba(10,11,10,.57); }
.metric-card strong { display: block; margin: 17px 0 5px; overflow: hidden; color: #f0f1ea; font: 700 21px/1 ui-monospace, monospace; letter-spacing: -.05em; text-overflow: ellipsis; }
.metric-card.accent strong { color: var(--ink); }
.metric-card strong i { color: #818678; font: normal 9px Inter, sans-serif; letter-spacing: .04em; }
.metric-card small { color: #62675d; font-size: 8px; letter-spacing: .12em; }

.pressure-block { padding: 2px 2px 0; }
.pressure-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.pressure-head b { color: #d0d3c8; font: 11px ui-monospace, monospace; }
.pressure-track { height: 5px; background: #292c27; overflow: hidden; }
.pressure-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--acid), #ffd42e, var(--orange)); box-shadow: 0 0 12px var(--acid); transition: width .35s; }
.pressure-scale { margin-top: 8px; display: flex; justify-content: space-between; color: #54594f; font-size: 8px; }

.speed-block { padding: 13px 14px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.025); }
.speed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.speed-head output { color: var(--acid); font: 700 12px ui-monospace, monospace; }
.speed-control { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; color: #62675d; font-size: 8px; }
.speed-control input { --speed-position: 20%; width: 100%; height: 16px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
.speed-control input::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: linear-gradient(90deg, var(--acid) 0 var(--speed-position), #30332d var(--speed-position) 100%); }
.speed-control input::-webkit-slider-thumb { width: 15px; height: 15px; margin-top: -5.5px; appearance: none; -webkit-appearance: none; border: 3px solid var(--panel); border-radius: 50%; background: var(--acid); box-shadow: 0 0 0 1px rgba(200,255,46,.35), 0 0 12px rgba(200,255,46,.22); }
.speed-control input::-moz-range-track { height: 4px; border: 0; border-radius: 99px; background: #30332d; }
.speed-control input::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--acid); }
.speed-control input::-moz-range-thumb { width: 10px; height: 10px; border: 3px solid var(--panel); border-radius: 50%; background: var(--acid); box-shadow: 0 0 0 1px rgba(200,255,46,.35); }

.status-box { display: flex; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.025); }
.status-icon { flex: 0 0 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: var(--acid); font-size: 12px; font-weight: 900; }
.status-box b { display: block; color: #d6d8d0; font-size: 11px; }
.status-box p { margin: 4px 0 0; color: #6e7368; font-size: 9px; line-height: 1.5; }

.dash-actions { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.dash-actions button { height: 42px; border-radius: 5px; font-size: 11px; font-weight: 750; cursor: pointer; transition: .2s; }
.dash-actions button:disabled { opacity: .35; cursor: not-allowed; }
.secondary-button { color: #c8cbc2; background: transparent; border: 1px solid #383c35; }
.secondary-button:not(:disabled):hover { border-color: #646b5e; }
.stop-button { color: #17100d; background: #ff7a42; border: 1px solid #ff7a42; }
.stop-button:not(:disabled):hover { background: #ff956c; }

.dashboard footer { margin-top: auto; padding-top: 14px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: #44483f; font-size: 8px; letter-spacing: .08em; }

.result-card { position: absolute; z-index: 7; left: 50%; top: 50%; transform: translate(-50%, -45%) scale(.97); width: min(390px, calc(100% - 38px)); padding: 30px; border: 1px solid rgba(200,255,46,.3); border-radius: 9px; background: rgba(17,19,16,.94); backdrop-filter: blur(20px); box-shadow: 0 28px 90px rgba(0,0,0,.6); text-align: center; opacity: 0; visibility: hidden; transition: .35s; cursor: default; }
.result-card.visible { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.result-label { color: #777c71; font-size: 9px; letter-spacing: .2em; }
.result-card > strong { display: block; margin: 10px 0 24px; color: var(--acid); font-size: 28px; letter-spacing: -.04em; }
.result-score b { display: block; color: #f4f5ef; font: 700 42px/1 ui-monospace, monospace; letter-spacing: -.08em; }
.result-score span { display: block; margin-top: 7px; color: #686d63; font-size: 9px; }
.result-card p { color: #979c90; font-size: 11px; }

.unsupported { display: none; position: fixed; z-index: 100; inset: 0; padding: 30px; place-content: center; text-align: center; background: #0a0b0a; }
.unsupported.show { display: grid; }
.unsupported strong { color: var(--acid); font-size: 20px; }
.unsupported p { color: #8a8f82; }

@keyframes blink { 50% { opacity: .3; } }

@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { height: 58px; padding: 0 16px; }
  .brand { font-size: 18px; }
  .brand-mark { width: 31px; height: 31px; }
  .header-note { font-size: 9px; }
  .app-shell { height: calc(100dvh - 58px); display: block; position: relative; }
  .viewport { height: 100%; }
  .dashboard { position: absolute; inset: auto 0 0; height: auto; max-height: 48dvh; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 6px; border-left: 0; border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(17,19,16,.72), rgba(17,19,16,.98) 24%); backdrop-filter: blur(14px); overflow-y: auto; pointer-events: none; }
  .status-box, .dashboard footer, .best-line { display: none; }
  .dash-heading { grid-column: 1 / -1; min-height: 24px; align-items: center; pointer-events: auto; }
  .dash-heading > div { display: flex; align-items: baseline; gap: 8px; }
  .dash-heading > div > span { font-size: 7px; }
  .dash-heading h2 { margin: 0; font-size: 13px; }
  .phase-number { font-size: 18px !important; }
  .timer-block { min-width: 0; padding: 9px 12px; background: rgba(16,18,15,.8); pointer-events: auto; }
  .timer-block > .metric-label { font-size: 7px; }
  .timer { margin: 3px 0 0; font-size: 27px; }
  .metric-grid { min-width: 0; width: 100%; gap: 5px; pointer-events: auto; }
  .metric-card { min-width: 0; min-height: 64px; padding: 8px 7px; }
  .metric-card .metric-label { white-space: nowrap; font-size: 7px; letter-spacing: .06em; }
  .metric-card strong { margin: 8px 0 2px; font-size: 15px; }
  .metric-card small { display: none; }
  .pressure-block { display: block; grid-column: 1 / -1; padding: 5px 4px 3px; pointer-events: auto; }
  .pressure-head { margin-bottom: 5px; }
  .pressure-head .metric-label, .pressure-head b { font-size: 8px; }
  .pressure-track { height: 4px; }
  .pressure-scale { display: none; }
  .speed-block { grid-column: 1 / -1; padding: 7px 10px; pointer-events: auto; }
  .speed-head { margin-bottom: 5px; }
  .speed-control { gap: 7px; }
  .dash-actions { grid-column: 1 / -1; pointer-events: auto; }
  .dash-actions button { height: 35px; }
  .stage-topline { left: 15px; right: 15px; top: 15px; }
  .intro { left: 22px; top: 37%; width: calc(100% - 44px); }
  .intro h1 { font-size: clamp(38px, 11vw, 48px); }
  .intro p { width: 88%; margin: 18px 0 21px; font-size: 13px; }
  .intro small { font-size: 9px; }
  .gesture-hint { left: 15px; bottom: min(300px, 49dvh); }
  .result-card { top: 36%; }
}

@media (max-width: 390px) {
  .header-note { max-width: 80px; line-height: 1.2; }
  .intro h1 { font-size: 39px; }
  .intro p { font-size: 12px; }
  .primary-button { height: 46px; }
  .metric-card strong { font-size: 14px; }
}

@media (max-width: 760px) and (max-height: 700px) {
  .dashboard { max-height: 52dvh; padding-top: 7px; gap: 4px; }
  .dash-heading { min-height: 20px; }
  .timer-block { padding: 7px 10px; }
  .timer { font-size: 24px; }
  .metric-card { min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
  .speed-block { padding-top: 5px; padding-bottom: 5px; }
  .dash-actions button { height: 32px; }
}

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