:root {
  color-scheme: dark;
  --tox-pink: #e6007e;
  --tox-green: #009b87;
  --tox-gray: #4a4a49;
  --steel: #b9c1ca;
  --panel: rgba(18, 24, 31, 0.82);
  --ink: #f6f8fb;
  --muted: #9aa8b8;
  --green: var(--tox-green);
  --yellow: #f5c542;
  --danger: var(--tox-pink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #070b10;
  color: var(--ink);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, rgba(230, 0, 126, 0.2), transparent 26%),
    radial-gradient(circle at 82% 18%, rgba(0, 155, 135, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(9, 14, 20, 0.4), rgba(4, 6, 9, 0.94)),
    #090d13;
}

#factory-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  z-index: 5;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}


.audio-toggle {
  pointer-events: auto;
  flex: 0 0 auto;
  min-width: 74px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(230, 0, 126, 0.88), rgba(122, 0, 68, 0.92));
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(230, 0, 126, 0.22), inset 0 1px 0 rgba(255,255,255,0.28);
  backdrop-filter: blur(10px);
}

.audio-toggle.is-muted {
  background: linear-gradient(180deg, rgba(74, 74, 73, 0.94), rgba(22, 26, 32, 0.96));
  color: #d6dde6;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  padding: 2px 10px 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background:
    radial-gradient(ellipse 68% 120% at 28% 50%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.42) 32%, rgba(255, 255, 255, 0.12) 62%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02), rgba(10, 15, 21, 0.22) 58%, rgba(10, 15, 21, 0.34));
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.24),
    0 0 28px rgba(230, 0, 126, 0.16);
  backdrop-filter: blur(12px) saturate(1.18);
}

 .brand-logo {
  display: block;
  width: 74px;
  height: 74px;
  object-fit: contain;
  filter: drop-shadow(0 7px 12px rgba(0, 0, 0, 0.28));
}

.brand-name {
  color: #ffffff;
  font-size: 20px;
  font-weight: 1000;
  letter-spacing: 0.02em;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.22),
    0 8px 18px rgba(0, 0, 0, 0.55),
    0 0 16px rgba(230, 0, 126, 0.32);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  gap: 8px;
  min-width: min(520px, calc(100vw - 320px));
}

.stats div {
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid rgba(185, 193, 202, 0.18);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  line-height: 1;
}

.order-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(185, 193, 202, 0.18);
  border-radius: 10px;
  background: rgba(10, 15, 21, 0.76);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.order-panel span,
.order-panel em {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(230, 0, 126, 0.16);
  color: #ffd9ed;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.order-panel strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-panel em {
  background: rgba(0, 155, 135, 0.16);
  color: #b9fff3;
}

.production-alert {
  position: absolute;
  z-index: 8;
  top: 178px;
  left: 50%;
  padding: 10px 22px;
  border: 1px solid rgba(245, 197, 66, 0.44);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(230, 0, 126, 0.88), rgba(245, 197, 66, 0.88));
  color: #fff;
  font-size: 22px;
  font-weight: 1000;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.36);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.32);
  transform: translateX(-50%);
  pointer-events: none;
  animation: alert-pop 1.7s ease both;
}

.hit-feedback {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  min-width: 180px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(7, 10, 15, 0.72);
  color: #fff;
  font-size: 34px;
  font-weight: 1000;
  letter-spacing: 0.03em;
  text-align: center;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.48);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.34);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: hit-pop 0.82s ease both;
}

.hit-feedback.perfect {
  border: 2px solid rgba(0, 155, 135, 0.78);
  color: #b9fff3;
  box-shadow: 0 0 34px rgba(0, 155, 135, 0.42);
}

.hit-feedback.okay {
  border: 2px solid rgba(245, 197, 66, 0.78);
  color: #fff1a8;
  box-shadow: 0 0 34px rgba(245, 197, 66, 0.38);
}

.hit-feedback.bad {
  border: 2px solid rgba(230, 0, 126, 0.82);
  color: #ffd0e8;
  box-shadow: 0 0 34px rgba(230, 0, 126, 0.42);
}

@keyframes hit-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.62) rotate(-2deg);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.18) rotate(1deg);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -66%) scale(0.9);
  }
}

@keyframes alert-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 18px) scale(0.82);
  }
  14% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.06);
  }
  74% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -18px) scale(0.96);
  }
}

.control-panel {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: minmax(280px, 620px) 120px;
  align-items: end;
  gap: 10px 14px;
  width: min(760px, calc(100vw - 28px));
  transform: translateX(-50%);
}

.meter-wrap {
  padding: 14px;
  border: 1px solid rgba(185, 193, 202, 0.18);
  border-radius: 8px;
  background: rgba(10, 15, 21, 0.86);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.meter-labels strong {
  color: var(--ink);
  font-size: 14px;
  text-align: center;
}

.meter {
  position: relative;
  height: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #202831;
}

.zone {
  position: absolute;
  top: 0;
  height: 100%;
}

.zone-red {
  width: 22%;
  background: linear-gradient(180deg, #6b1e28, #46141c);
}

.zone-yellow {
  width: 14%;
  background: linear-gradient(180deg, #8b6b1f, #5a4211);
}

.zone-green {
  left: 36%;
  width: 28%;
  background: linear-gradient(180deg, #00b59d, #007f70);
}

.zone-red.left,
.zone-yellow.left {
  left: 0;
}

.zone-yellow.left {
  left: 22%;
}

.zone-yellow.right {
  left: 64%;
}

.zone-red.right {
  left: 78%;
}

.needle {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 4px;
  height: 38px;
  border-radius: 4px;
  background: #f6f8fb;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.7);
  transform: translateX(-50%);
}

.press-button {
  min-height: 86px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ff1997, #b90065);
  color: white;
  font-size: 22px;
  font-weight: 900;
  box-shadow:
    0 14px 0 #6c003b,
    0 22px 34px rgba(0, 0, 0, 0.36);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.press-button:active,
.press-button.pressed {
  transform: translateY(8px);
  box-shadow:
    0 6px 0 #6c003b,
    0 14px 24px rgba(0, 0, 0, 0.36);
}

.start-layer,
.game-over-layer {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(4, 7, 11, 0.62);
  backdrop-filter: blur(8px);
}

.hidden {
  display: none;
}

.start-box {
  width: min(520px, calc(100vw - 44px));
  padding: 28px;
  border: 1px solid rgba(185, 193, 202, 0.2);
  border-radius: 8px;
  background: rgba(12, 17, 23, 0.92);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.start-logo {
  display: block;
  width: min(168px, 46vw);
  height: auto;
  margin: 0 auto 14px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.28),
    0 0 28px rgba(230, 0, 126, 0.18);
}

.kicker {
  margin: 0 0 8px;
  color: var(--tox-pink);
  font-size: 14px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}

.start-box p:not(.kicker) {
  margin: 16px auto 22px;
  max-width: 420px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 20px;
}

.final-grid span {
  min-height: 42px;
  padding: 10px 8px;
  border: 1px solid rgba(185, 193, 202, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--steel);
  font-size: 13px;
  font-weight: 800;
}

.start-box button {
  min-width: 168px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 6px;
  background: var(--tox-pink);
  color: white;
  font-size: 17px;
  font-weight: 800;
}

@media (max-width: 760px) {
  html,
  body {
    height: 100dvh;
  }

  .game-shell {
    min-height: 0;
  }

  .hud {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .brand {
    justify-content: center;
    min-width: 0;
    gap: 10px;
    padding: 2px 10px;
    border-radius: 12px;
  }

  .brand-logo {
    width: clamp(62px, 18vw, 74px);
    height: clamp(62px, 18vw, 74px);
  }

  .brand-name {
    color: #f6f8fb;
    font-size: clamp(22px, 6.2vw, 28px);
    font-weight: 1000;
    text-shadow: 0 8px 18px rgba(0, 0, 0, 0.42);
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    min-width: 0;
  }

  .stats div {
    min-height: 40px;
    padding: 5px 6px;
    border-radius: 7px;
    text-align: center;
  }

  .stats span {
    font-size: 10px;
  }

  .stats strong {
    font-size: 16px;
  }

  .order-panel {
    grid-template-columns: auto 1fr auto;
    gap: 6px;
    width: 100%;
    padding: 7px;
    border-radius: 8px;
  }

  .order-panel span,
  .order-panel em {
    min-height: 24px;
    padding: 0 7px;
    font-size: 10px;
  }

  .order-panel strong {
    font-size: 12px;
  }

  .production-alert {
    top: calc(158px + env(safe-area-inset-top, 0px));
    padding: 8px 16px;
    font-size: 17px;
  }

  .hit-feedback {
    top: 44%;
    min-width: 142px;
    padding: 8px 14px;
    font-size: 24px;
  }

  .control-panel {
    bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: min(520px, calc(100vw - 20px));
    align-items: stretch;
  }

  .meter-wrap {
    grid-column: 1 / -1;
    padding: 9px;
    border-radius: 7px;
  }

  .meter-labels {
    margin-bottom: 6px;
    font-size: 10px;
  }

  .meter-labels strong {
    max-width: 58vw;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .meter {
    height: 24px;
  }

  .press-button {
    grid-column: 1 / -1;
    min-height: 58px;
    border-radius: 8px;
    font-size: 20px;
    box-shadow:
      0 9px 0 #6c003b,
      0 16px 24px rgba(0, 0, 0, 0.34);
  }

  .press-button:active,
  .press-button.pressed {
    transform: translateY(5px);
    box-shadow:
      0 4px 0 #6c003b,
      0 10px 18px rgba(0, 0, 0, 0.34);
  }

  .start-layer,
  .game-over-layer {
    padding: 16px;
  }

  .start-box {
    width: min(460px, calc(100vw - 32px));
    padding: 20px 16px;
  }

  .start-logo {
    width: min(142px, 42vw);
    margin-bottom: 12px;
    padding: 7px 12px;
  }

  h1,
  h2 {
    font-size: clamp(28px, 9vw, 42px);
  }

  .start-box p:not(.kicker) {
    margin: 12px auto 18px;
    font-size: 14px;
    line-height: 1.55;
  }

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

@media (max-width: 430px) {
  .hud {
    left: 8px;
    right: 8px;
  }

  .brand-logo {
    width: 62px;
    height: 62px;
  }

  .brand-name {
    font-size: 22px;
  }

  .stats div {
    min-height: 36px;
    padding: 4px 4px;
  }

  .stats strong {
    font-size: 15px;
  }

  .production-alert {
    top: calc(148px + env(safe-area-inset-top, 0px));
  }

  .control-panel {
    bottom: calc(42px + env(safe-area-inset-bottom, 0px));
    gap: 7px;
  }

  .press-button {
    min-height: 54px;
  }
}

@media (max-height: 700px) and (max-width: 760px) {
  .brand-logo {
    width: 56px;
    height: 56px;
  }

  .brand-name {
    font-size: 20px;
  }

  .stats div {
    min-height: 34px;
  }

  .production-alert {
    top: calc(132px + env(safe-area-inset-top, 0px));
    font-size: 15px;
  }

  .hit-feedback {
    top: 43%;
    font-size: 21px;
  }

  .meter-wrap {
    padding: 7px;
  }

  .press-button {
    min-height: 48px;
    font-size: 18px;
  }

  .control-panel {
    bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 760px) {
  .audio-toggle {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 64px;
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }
}
