/* Plug In — styles. Dark charcoal theme, neon-cyan accent. */
:root {
  --bg: #0d0d10;
  --panel: #131419;
  --card: #15161a;
  --plot: #101115;
  --line: #1f2127;
  --text: #e8eaee;
  --muted: #8a8f9b;
  --cyan: #00e5ff;
  --green: #2ee27a;
  --red: #ff4d5e;
  --gold: #ffcf5c;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 30% -10%, #16181f 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body.grabbing, body.grabbing * { cursor: grabbing !important; }

#app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* ---- top bar ------------------------------------------------------- */
#topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: rgba(18, 19, 24, 0.85);
  border-bottom: 1px solid #1c1d23;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: opacity 0.25s;
}
#topbar.dim { opacity: 0.25; pointer-events: none; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name {
  font-weight: 800; font-size: 18px; letter-spacing: 0.5px;
  background: linear-gradient(90deg, #fff, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-jack {
  width: 26px; height: 12px; border-radius: 3px;
  background: linear-gradient(180deg, #f2f3f5, #6c7079);
  position: relative; box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}
.brand-jack::before, .brand-jack::after {
  content: ""; position: absolute; top: 0; width: 2px; height: 12px; background: #0a0a0c;
}
.brand-jack::before { left: 8px; } .brand-jack::after { left: 13px; }
.mode-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; padding-left: 4px;
}

.hud { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 42px; }
.stat-k { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat-v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
#score { color: var(--cyan); }

.lives { display: flex; gap: 4px; align-items: center; }
.life-ic { width: 20px; height: 20px; fill: var(--red); filter: drop-shadow(0 0 4px rgba(255, 77, 94, 0.5)); transition: opacity 0.3s, transform 0.3s; }
.life-ic.lost { fill: #34363d; filter: none; opacity: 0.5; transform: scale(0.85); }

.controls { display: flex; gap: 6px; }
.ctl {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid #2a2c33;
  background: #1a1b21; color: var(--text); font-size: 16px; cursor: pointer;
  display: grid; place-items: center; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ctl:hover { background: #23252c; border-color: #3a3d45; }
#btn-target.on { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 10px rgba(0, 229, 255, 0.25) inset; }

/* ---- play area ----------------------------------------------------- */
#play { flex: 1 1 auto; display: flex; min-height: 0; }
#left-panel {
  flex: 0 0 40%; display: grid; place-items: center; padding: 16px;
  position: relative;
}
#left-panel::after { /* faint vertical divider */
  content: ""; position: absolute; right: 0; top: 12%; bottom: 12%; width: 1px;
  background: linear-gradient(180deg, transparent, #23252c, transparent);
}
#headphone-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
#headphone-illustration { width: min(76%, 286px); filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.55)); }
#headphone-illustration svg { width: 100%; height: auto; display: block; }
.headphone-name {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  opacity: 0; transform: translateY(-4px); transition: opacity 0.3s, transform 0.3s; text-align: center;
}
.headphone-name.show { opacity: 1; transform: none; }
.iem-kicker { font-size: 10px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--muted); }
.iem-model {
  font-size: 21px; font-weight: 800; line-height: 1.1;
  background: linear-gradient(90deg, #ffffff, #9fe9f5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

#right-panel {
  flex: 1 1 60%; display: flex; align-items: center; justify-content: center;
  padding: 14px 26px; min-width: 0; overflow-y: auto;
}
#graphs { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 388px; margin: auto 0; }

/* ---- graph card ---------------------------------------------------- */
.graph-card {
  position: relative; color: var(--cyan);
  background: var(--card); border: 1px solid #23252c; border-radius: 12px;
  padding: 10px 12px 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.graph-plot { width: 100%; height: auto; display: block; }
.graph-plot .ax { fill: var(--muted); font-size: 9px; font-family: inherit; }
.fr-curve { filter: drop-shadow(0 0 5px color-mix(in srgb, currentColor 55%, transparent)); transition: stroke 0.25s; }

.graph-card.correct, .graph-card.reveal { color: var(--green); border-color: var(--green); box-shadow: 0 0 22px rgba(46, 226, 122, 0.25); }
.graph-card.wrong { color: var(--red); border-color: var(--red); box-shadow: 0 0 22px rgba(255, 77, 94, 0.25); animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}

/* input port (snap target) */
.graph-port {
  position: absolute; top: -16px; width: 40px; height: 40px; cursor: default;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
.graph-port.port-left { left: -16px; }
.graph-port.port-right { right: -16px; }
.port-svg { width: 100%; height: 100%; display: block; }
.port-glow { transition: opacity 0.15s; }
.graph-port.near { transform: scale(1.12); }
.graph-port.near .port-glow { opacity: 1 !important; }
.graph-card.correct .port-glow, .graph-card.reveal .port-glow { opacity: 1 !important; stroke: var(--green); }
.graph-card.wrong .port-glow { opacity: 1 !important; stroke: var(--red); }
.port-num {
  position: absolute; top: -2px; left: 50%; transform: translateX(-50%) translateY(-100%);
  font-size: 10px; color: var(--muted); font-weight: 700;
}
.graph-port.port-left .port-num { left: 6px; transform: translateY(-100%); }
.graph-port.port-right .port-num { left: auto; right: 6px; transform: translateY(-100%); }
.graph-caption { height: 2px; }

/* ---- cable overlay ------------------------------------------------- */
#cable-layer {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  transition: opacity 0.3s;
}
body.in-menu #cable-layer { opacity: 0; pointer-events: none; }
.cable-line { filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.55)); }
.jack-hit { pointer-events: auto; cursor: grab; touch-action: none; }
.jack { filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.6)); }

/* ---- hint ---------------------------------------------------------- */
.hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: var(--muted); background: rgba(20, 21, 26, 0.8);
  border: 1px solid #23252c; padding: 7px 14px; border-radius: 999px;
  opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap;
}
.hint.show { opacity: 1; }

/* ---- result tooltip ------------------------------------------------ */
.tooltip {
  position: fixed; z-index: 20; display: none; max-width: 260px;
  background: #1a1c22; border: 1px solid #2c2f37; border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none; animation: pop 0.18s ease-out;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.tooltip.good { border-color: var(--green); }
.tooltip.bad { border-color: var(--red); }
.tt-head { font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.tooltip.good .tt-head { color: var(--green); }
.tooltip.bad .tt-head { color: var(--red); }
.tt-name { font-size: 15px; font-weight: 700; margin-top: 2px; }
.tt-sig { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.tt-extra { font-size: 11px; color: var(--cyan); margin-top: 6px; }

/* ---- toast --------------------------------------------------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(10px);
  z-index: 30; background: #21232a; border: 1px solid #34373f; color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; opacity: 0;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- overlay (menu + game over) ----------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 8, 11, 0.72);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.overlay.show { display: flex; animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  background: linear-gradient(180deg, #17181e, #121319);
  border: 1px solid #262830; border-radius: 18px; padding: 28px 30px;
  width: min(440px, 92vw); text-align: center; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.logo { font-size: 34px; font-weight: 900; letter-spacing: 0.5px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.logo-jack {
  width: 40px; height: 16px; border-radius: 4px; display: inline-block;
  background: linear-gradient(180deg, #f2f3f5, #6c7079); position: relative;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.5);
}
.logo-jack::before, .logo-jack::after { content: ""; position: absolute; top: 0; width: 2.5px; height: 16px; background: #0a0a0c; }
.logo-jack::before { left: 12px; } .logo-jack::after { left: 19px; }
.tagline { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 14px 4px 6px; }
.best-line { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.best-line b { color: var(--cyan); font-size: 15px; }

.modes { display: flex; flex-direction: column; gap: 10px; }
.btn {
  appearance: none; border: 1px solid #2c2f38; background: #1c1e25; color: var(--text);
  border-radius: 11px; padding: 12px 16px; cursor: pointer; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn span { font-size: 11px; color: var(--muted); font-weight: 400; }
.btn:hover { transform: translateY(-1px); border-color: #3c4049; background: #22242c; }
.btn.primary { border-color: var(--cyan); background: rgba(0, 229, 255, 0.1); box-shadow: 0 0 18px rgba(0, 229, 255, 0.18); }
.btn.primary:hover { background: rgba(0, 229, 255, 0.16); }
.btn.ghost { background: transparent; }
.controls-hint { font-size: 12px; color: var(--muted); margin: 18px 0 0; line-height: 1.6; }
kbd {
  background: #23252c; border: 1px solid #3a3d45; border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 6px; font-size: 11px; font-family: inherit; color: var(--text);
}

/* game over */
.over-title { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); }
.record { color: var(--gold); font-weight: 800; margin-top: 8px; text-shadow: 0 0 12px rgba(255, 207, 92, 0.4); }
.final-score { font-size: 64px; font-weight: 900; color: var(--cyan); line-height: 1; margin: 8px 0 6px; text-shadow: 0 0 24px rgba(0, 229, 255, 0.35); font-variant-numeric: tabular-nums; }
.over-stats { display: flex; justify-content: center; gap: 26px; margin: 18px 0 24px; }
.over-stats div { display: flex; flex-direction: column; gap: 2px; }
.over-stats b { font-size: 22px; font-weight: 800; }
.over-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.over-actions { display: flex; gap: 10px; justify-content: center; }
.over-actions .btn { flex-direction: row; padding: 11px 18px; }

/* ---- about footer -------------------------------------------------- */
#about {
  position: fixed; bottom: 4px; right: 10px; z-index: 2;
  font-size: 10px; color: #4a4d55; pointer-events: none;
}

/* ---- responsive ---------------------------------------------------- */
@media (max-width: 820px) {
  #play { flex-direction: column; }
  #left-panel { flex: 0 0 38%; padding: 8px; }
  #left-panel::after { display: none; }
  #headphone-illustration { width: min(46%, 200px); }
  #right-panel { flex: 1 1 auto; padding: 8px 26px 18px; align-items: flex-start; overflow-y: auto; }
  #graphs { gap: 12px; max-width: 520px; margin: 0 auto; }
  .hud { gap: 12px; }
  .stat { min-width: 34px; }
  .stat-v { font-size: 16px; }
}
@media (max-width: 560px) {
  :root { --topbar-h: auto; }
  #topbar { flex-wrap: wrap; padding: 8px 12px; gap: 10px 14px; }
  .brand { order: 0; }
  .controls { order: 1; margin-left: auto; }
  .hud { order: 2; width: 100%; margin-left: 0; justify-content: space-between; gap: 8px; }
  #about { display: none; }
  .final-score { font-size: 52px; }
}
@media (max-height: 560px) and (min-width: 821px) {
  #graphs { gap: 10px; }
}
