:root {
  --bg: #050505;
  --ink: #f5f5f5;
  --ink-soft: rgba(245, 245, 245, 0.72);
  --muted: rgba(245, 245, 245, 0.38);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --danger: #ff6b6b;
  --ok: #7dffb3;
  --hev: #ff9a00;
  --hev-dim: rgba(255, 154, 0, 0.22);
  --perfect: #7dffb3;
  --good: #ffd36a;
  --miss: #ff6b6b;
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font: "Outfit", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.panel {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(255, 154, 0, 0.07), transparent 55%),
    radial-gradient(700px 420px at 100% 110%, rgba(255, 255, 255, 0.035), transparent 50%),
    linear-gradient(180deg, #080808 0%, #040404 100%);
}

.noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 15%, transparent 72%);
}

.panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 40px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.9;
  color: var(--ink);
  text-transform: uppercase;
  overflow: hidden;
}

.brand-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: shine 4.8s ease-in-out 1.2s infinite;
  pointer-events: none;
}

@keyframes shine {
  0%, 70%, 100% { transform: translateX(-120%); }
  85% { transform: translateX(120%); }
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.head-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  padding-bottom: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--mono);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
  animation: pulse 2.4s ease infinite;
}

.pill.is-live .pill-dot {
  background: var(--hev);
  box-shadow: 0 0 0 4px var(--hev-dim);
  animation: pulseHev 1.2s ease infinite;
}

.pill.is-ok .pill-dot {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(125, 255, 179, 0.18);
}

.pill.is-bad .pill-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.18);
  animation: none;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12); opacity: 1; }
  50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.04); opacity: 0.85; }
}

@keyframes pulseHev {
  0%, 100% { box-shadow: 0 0 0 4px var(--hev-dim); }
  50% { box-shadow: 0 0 0 9px rgba(255, 154, 0, 0.05); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.panel-body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  padding: 16px 40px 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: rise 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.course {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  flex-shrink: 0;
}

.stat {
  padding: 12px 14px;
  border-top: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 70%);
  min-height: 68px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stat:nth-child(2) { animation-delay: 0.04s; }
.stat:nth-child(3) { animation-delay: 0.08s; }
.stat:nth-child(4) { animation-delay: 0.12s; }

.stat-label {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-value.mono {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 154, 0, 0.05), transparent 30%),
    linear-gradient(180deg, #0c0c0c, #060606);
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
  touch-action: manipulation;
  user-select: none;
}

.stage-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  background:
    linear-gradient(90deg, var(--hev) 0 10px, transparent 10px) top left / 40px 2px no-repeat,
    linear-gradient(90deg, transparent calc(100% - 10px), var(--hev) 0) top right / 40px 2px no-repeat,
    linear-gradient(90deg, var(--hev) 0 10px, transparent 10px) bottom left / 40px 2px no-repeat,
    linear-gradient(90deg, transparent calc(100% - 10px), var(--hev) 0) bottom right / 40px 2px no-repeat;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0.06;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.55) 3px);
}

.lanes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 2;
}

.lane {
  position: relative;
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  margin: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.lane:last-child { border-right: 0; }

.lane:active,
.lane.is-hit {
  background: linear-gradient(180deg, transparent 55%, rgba(255, 154, 0, 0.14));
}

.lane-key {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 4;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.strike {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 3px;
  z-index: 3;
  background: linear-gradient(90deg, transparent, var(--hev), transparent);
  box-shadow: 0 0 18px var(--hev-dim);
  pointer-events: none;
}

.strike::before {
  content: "";
  position: absolute;
  inset: -10px 0;
  background: linear-gradient(180deg, transparent, rgba(255, 154, 0, 0.08), transparent);
}

.note {
  position: absolute;
  top: -48px;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  z-index: 3;
  pointer-events: none;
  will-change: transform;
}

.note::before {
  content: "λ";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  color: #050505;
  background: var(--hev);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: 0 0 16px var(--hev-dim);
}

.note.is-gold::before {
  background: #fff;
  color: #111;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.35);
}

.hud-float {
  position: absolute;
  left: 0;
  right: 0;
  top: 18%;
  z-index: 7;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.judgement {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  animation: judgePop 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.judgement.perfect { color: var(--perfect); }
.judgement.good { color: var(--good); }
.judgement.miss { color: var(--miss); }

@keyframes judgePop {
  from { opacity: 0; transform: scale(0.7) translateY(8px); }
  40% { opacity: 1; transform: scale(1.08) translateY(0); }
  to { opacity: 0; transform: scale(1) translateY(-10px); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background: rgba(5, 5, 5, 0.82);
  backdrop-filter: blur(2px);
}

.overlay[hidden] { display: none; }

.empty-mark {
  width: 56px;
  height: 56px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--hev);
  animation: pulseSoft 2.8s ease infinite;
}

@keyframes pulseSoft {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.status {
  margin: 0;
  max-width: 26rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.4;
}

.status.ok { color: var(--ok); }
.status.bad { color: #ffb0b0; }

.howto {
  margin: 0;
  max-width: 26rem;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 500;
}

.howto kbd,
.hint kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  margin: 0 2px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.srv-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.srv-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
}

.srv-btn.primary {
  background: var(--ink);
  color: #050505;
  border-color: var(--ink);
}

.srv-btn.primary:hover {
  background: #fff;
  transform: translateY(-1px);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.45;
  flex-shrink: 0;
}

.panel-foot {
  position: relative;
  z-index: 1;
  padding: 12px 40px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.foot-line {
  width: 28px;
  height: 1px;
  background: rgba(255, 255, 255, 0.28);
}

@media (max-width: 640px) {
  .panel-head,
  .panel-body,
  .panel-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .lane-key { bottom: 12px; font-size: 0.7rem; }
  .strike { bottom: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
