:root {
  color-scheme: dark;
  --bg: #090d12;
  --surface: #111822;
  --surface-2: #172231;
  --text: #f6f8fb;
  --muted: #9eabbc;
  --line: rgba(255, 255, 255, 0.13);
  --laser-color: rgb(88, 255, 0);
  --laser-soft: rgba(88, 255, 0, 0.28);
  --beam-opacity: 0.7;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 50% 0%, var(--laser-soft), transparent 24rem),
    linear-gradient(180deg, #111923 0%, #090d12 78%);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.laser-app {
  width: min(430px, 100%);
  min-height: min(890px, 100dvh - 28px);
  display: flex;
  flex-direction: column;
  gap: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012)),
    rgba(9, 13, 18, 0.94);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.52);
  padding: 18px;
}

.app-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--laser-color);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.status-pill {
  min-width: 74px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--laser-color), white 30%);
  border-radius: 999px;
  color: #07100a;
  background: var(--laser-color);
  font-size: 0.8rem;
  font-weight: 900;
  box-shadow: 0 0 20px var(--laser-soft);
}

.laser-stage,
.control-panel,
.stats article {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.052);
}

.laser-stage {
  position: relative;
  min-height: 278px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.048) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.048) 1px, transparent 1px),
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.13), transparent 9rem);
  background-size: 31px 31px, 31px 31px, auto;
}

.emitter {
  position: absolute;
  left: 20px;
  top: 50%;
  width: 96px;
  height: 118px;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 22px 44px 44px 22px;
  background: linear-gradient(90deg, #273142, #111822);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.42);
}

.emitter::before,
.emitter::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.emitter::before {
  top: 24px;
}

.emitter::after {
  bottom: 24px;
}

.emitter-core {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 34px;
  height: 54px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--laser-color);
  box-shadow:
    0 0 28px var(--laser-color),
    0 0 88px var(--laser-color);
}

.laser-beam {
  position: absolute;
  left: 104px;
  right: -22px;
  top: 50%;
  height: 168px;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 24px var(--laser-color));
}

.beam-glow,
.beam-core {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(90deg, var(--laser-color), rgba(255, 255, 255, 0));
}

.beam-glow {
  height: 126px;
  opacity: calc(var(--beam-opacity) * 0.32);
  filter: blur(22px);
  clip-path: polygon(0 28%, 100% 0, 100% 100%, 0 72%);
}

.beam-core {
  height: 14px;
  opacity: var(--beam-opacity);
  box-shadow:
    0 0 16px var(--laser-color),
    0 0 44px var(--laser-color);
}

.photon-stream {
  position: absolute;
  top: 50%;
  left: -20px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 18px 7px var(--laser-color);
  animation: photon 1.25s linear infinite;
}

.stream-a {
  margin-top: -38px;
}

.stream-b {
  margin-top: -6px;
  animation-delay: -0.42s;
}

.stream-c {
  margin-top: 30px;
  animation-delay: -0.84s;
}

@keyframes photon {
  from {
    transform: translateX(0) scale(0.8);
    opacity: 0;
  }

  12%,
  82% {
    opacity: var(--beam-opacity);
  }

  to {
    transform: translateX(330px) scale(1.08);
    opacity: 0;
  }
}

.beam-label {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.beam-label strong {
  color: var(--text);
  font-size: 0.95rem;
}

.control-panel {
  display: grid;
  gap: 14px;
  padding: 17px;
}

.dial-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  color: var(--laser-color);
}

.dial-readout span:first-child {
  font-size: clamp(3.3rem, 19vw, 5.3rem);
  line-height: 0.9;
  font-weight: 930;
  font-variant-numeric: tabular-nums;
}

.dial-readout span:last-child {
  color: var(--muted);
  font-size: 1.12rem;
  font-weight: 850;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="range"] {
  width: 100%;
  height: 30px;
  margin: 0;
  cursor: pointer;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(
    90deg,
    #6b21ff 0%,
    #004dff 18%,
    #00b7ff 32%,
    #00ff6a 45%,
    #d7ff00 53%,
    #ffd400 58%,
    #ff7b00 66%,
    #ff0000 100%
  );
}

#power::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, rgba(255,255,255,0.22), var(--laser-color));
}

input[type="range"]::-webkit-slider-thumb {
  width: 31px;
  height: 31px;
  margin-top: -8px;
  appearance: none;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--laser-color);
  box-shadow: 0 0 22px var(--laser-color);
}

input[type="range"]::-moz-range-track {
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(90deg, #6b21ff, #004dff, #00b7ff, #00ff6a, #ffd400, #ff0000);
}

input[type="range"]::-moz-range-thumb {
  width: 27px;
  height: 27px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--laser-color);
}

.photon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.photon-grid button {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 850;
}

.photon-grid button span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch, var(--laser-color));
  box-shadow: 0 0 16px var(--swatch, var(--laser-color));
}

.photon-grid button:nth-child(1) { --swatch: rgb(130, 0, 200); }
.photon-grid button:nth-child(2) { --swatch: rgb(0, 82, 255); }
.photon-grid button:nth-child(3) { --swatch: rgb(88, 255, 0); }
.photon-grid button:nth-child(4) { --swatch: rgb(255, 220, 0); }
.photon-grid button:nth-child(5) { --swatch: rgb(255, 0, 0); }

.photon-grid button.active,
.photon-grid button:focus-visible {
  border-color: var(--laser-color);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--laser-color);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats article {
  min-height: 76px;
  padding: 13px 14px;
}

.stats span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.stats strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  line-height: 1.25;
}

@media (min-width: 780px) {
  .laser-app {
    width: min(980px, 100%);
    min-height: min(720px, 100dvh - 28px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .app-header {
    grid-column: 1 / -1;
  }

  .laser-stage {
    min-height: 0;
  }

  .stats {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 10px;
  }

  .laser-app {
    border-radius: 22px;
    padding: 14px;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}
