:root {
  --ink: #19324b;
  --panel: rgba(255, 248, 231, 0.95);
  --blue: #244f7c;
  --blue-dark: #173552;
  --green: #2fb765;
  --red: #d4433c;
  --gold: #f5ad32;
  --shadow: 0 18px 40px rgba(20, 38, 64, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #14243a;
  background-size: 18px 18px;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 0;
}

.game-card {
  width: 100%;
}

.game-root {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #101927;
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: none;
}

.layer {
  position: absolute;
  pointer-events: none;
}

.layer-bg {
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.customer-layer {
  inset: 0;
  z-index: 2;
}

.customer {
  position: absolute;
  left: 50%;
  top: 41%;
  width: 10.8%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 10px 8px rgba(38, 42, 51, 0.22));
}

.customer-enter {
  animation: customerEnter 0.38s ease-out both;
}

.customer-exit {
  animation: customerExit 0.65s ease-in both;
}

.maodie-back {
  left: 39%;
  bottom: 1.2%;
  z-index: 5;
  width: 15.6%;
  transform: translateX(-50%);
  filter: drop-shadow(0 14px 10px rgba(25, 30, 38, 0.16));
}

.counter-front {
  left: 50%;
  bottom: 1.8%;
  z-index: 4;
  width: 72%;
  transform: translateX(-50%);
  filter: drop-shadow(0 -4px 4px rgba(16, 24, 38, 0.12));
}

.guard-layer {
  inset: 0;
  z-index: 5;
}

.guard {
  position: absolute;
  right: 30%;
  top: 44%;
  width: 10.5%;
  transform: translateY(-50%);
  filter: drop-shadow(0 10px 8px rgba(38, 42, 51, 0.24));
}

.drag-layer {
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.drag-item {
  position: absolute;
  z-index: 10;
  pointer-events: none;
}

.drag-image {
  width: clamp(30px, 4.4vw, 58px);
  max-width: none;
  image-rendering: auto;
  filter: drop-shadow(0 8px 8px rgba(12, 25, 40, 0.24));
}

.code-card {
  display: grid;
  width: clamp(58px, 7vw, 94px);
  aspect-ratio: 1 / 0.72;
  place-items: center;
  border: 3px solid #f7f0d8;
  border-radius: 10px;
  color: white;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2);
}

.code-green {
  background: var(--green);
}

.code-red {
  background: var(--red);
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  color: #fff7df;
  font-weight: 900;
  pointer-events: none;
}

.hud-pill {
  position: absolute;
  top: 2.35%;
  display: flex;
  height: 5.2%;
  align-items: center;
  justify-content: center;
  font-size: clamp(13px, 1.8vw, 27px);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  white-space: nowrap;
}

.hud-time {
  left: 28.2%;
  width: 8.4%;
}

.hud-score {
  left: 46.5%;
  width: 8.4%;
}

.hud-queue {
  left: 67.8%;
  width: 5.2%;
}

.result-board {
  position: absolute;
  top: 40.7%;
  right: 5.2%;
  z-index: 20;
  display: grid;
  align-items: center;
  width: 4.2%;
  height: 4.8%;
  padding: 0.4% 0.9%;
  color: #172f4a;
  font-size: clamp(10px, 1.25vw, 18px);
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.tool-layer {
  position: absolute;
  inset: 0;
  z-index: 21;
}

.hitbox {
  position: absolute;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.hitbox:disabled {
  cursor: not-allowed;
}

.hitbox:focus-visible {
  outline: 3px solid var(--gold);
}

.hitbox-swab {
  left: 18%;
  top: 73%;
  width: 12%;
  height: 16%;
}

.hitbox-used-swab {
  left: 47.5%;
  top: 31%;
  z-index: 23;
  width: 5.2%;
  height: 16%;
  display: grid;
  place-items: center;
  background: rgba(255, 245, 205, 0.72);
  border: 2px dashed rgba(27, 66, 104, 0.5);
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(17, 40, 62, 0.18);
  animation: usedSwabHint 0.9s ease-in-out infinite alternate;
}

.hitbox-used-swab img {
  height: 105%;
  transform: rotate(-18deg);
  pointer-events: none;
}

.hitbox-green {
  left: 55.2%;
  top: 69.6%;
  width: 9.6%;
  height: 16.8%;
}

.hitbox-red {
  left: 66.5%;
  top: 69.6%;
  width: 9.6%;
  height: 16.8%;
}

.call-button {
  position: absolute;
  right: 7%;
  bottom: 6%;
  z-index: 22;
  width: 16%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 8px 6px rgba(10, 24, 40, 0.22));
  animation: callPulse 1.15s ease-in-out infinite;
}

.call-button img,
.bgm-button img,
.image-start img,
.badge {
  display: block;
  width: 100%;
}

.bgm-button {
  position: absolute;
  left: 2.3%;
  bottom: 2.6%;
  z-index: 22;
  display: grid;
  width: 12%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.bgm-button span {
  position: absolute;
  inset: 50% auto auto 50%;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(13, 33, 54, 0.78);
  color: white;
  font-size: clamp(9px, 0.85vw, 12px);
  font-weight: 900;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 26%;
  z-index: 24;
  max-width: 56%;
  padding: 0.65% 1.2%;
  border: 3px solid var(--blue-dark);
  border-radius: 999px;
  background: var(--panel);
  color: var(--blue-dark);
  font-size: clamp(12px, 1.35vw, 18px);
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 4px 4px 0 rgba(23, 53, 82, 0.22);
  pointer-events: none;
}

.toast-pop {
  animation: toastPop 0.24s ease-out;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 3%;
  background: rgba(11, 25, 42, 0.48);
  backdrop-filter: blur(3px);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  display: grid;
  justify-items: center;
  gap: min(1.5vw, 14px);
  width: min(62%, 720px);
  max-height: 90%;
  overflow: auto;
  padding: min(2.4vw, 24px);
  border: 4px solid var(--blue-dark);
  border-radius: 20px;
  background: #fff8e8;
  box-shadow: 8px 8px 0 rgba(18, 40, 64, 0.28);
  text-align: center;
}

.modal-panel h1,
.modal-panel h2,
.modal-panel p {
  margin: 0;
}

.modal-panel h1 {
  color: var(--blue-dark);
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.08;
}

.modal-panel h2 {
  color: var(--blue-dark);
  font-size: clamp(25px, 4vw, 45px);
}

.modal-panel p {
  font-size: clamp(13px, 1.45vw, 18px);
  font-weight: 800;
}

.eyebrow {
  color: #b45f23;
  font-weight: 900;
}

.fine-print {
  color: #6a7783;
}

.image-start {
  width: min(52%, 320px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.restart-button {
  min-height: 44px;
  padding: 10px 18px;
  border: 3px solid var(--blue-dark);
  border-radius: 12px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(18, 40, 64, 0.22);
}

.result-panel {
  width: min(58%, 640px);
  gap: min(1.1vw, 10px);
}

.badge {
  width: min(30%, 160px);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.summary-grid span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 2px solid #d8b579;
  border-radius: 12px;
  background: #fffdf5;
  font-weight: 900;
}

.summary-grid b {
  color: var(--blue-dark);
  font-size: 1.35em;
}

.is-testing .counter-front {
  animation: bottleFlash 0.42s ease-in-out infinite alternate;
}

.pulse-success {
  animation: pulseSuccess 0.42s ease-out;
}

.pulse-error {
  animation: pulseError 0.4s ease-out;
}

.wrong-drop {
  animation: screenShake 0.22s linear;
}

.guard-enter {
  animation: guardEnter 0.6s ease-out both;
}

@keyframes customerEnter {
  from {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.9);
  }
}

@keyframes customerExit {
  to {
    opacity: 0;
    transform: translate(-20%, -50%) scale(0.9);
  }
}

@keyframes guardEnter {
  from {
    opacity: 0;
    transform: translate(90%, -50%);
  }
}

@keyframes callPulse {
  50% {
    transform: translateY(-4px);
  }
}

@keyframes usedSwabHint {
  to {
    transform: translateY(-4px);
  }
}

@keyframes toastPop {
  from {
    transform: translateX(-50%) translateY(8px) scale(0.96);
    opacity: 0.4;
  }
}

@keyframes bottleFlash {
  to {
    filter: drop-shadow(0 0 16px rgba(255, 219, 95, 0.86));
  }
}

@keyframes pulseSuccess {
  50% {
    filter: drop-shadow(0 0 16px rgba(47, 183, 101, 0.9));
  }
}

@keyframes pulseError {
  20%,
  60% {
    transform: translate(-53%, -50%);
  }
  40%,
  80% {
    transform: translate(-47%, -50%);
  }
}

@keyframes screenShake {
  25% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
  }

  .game-root {
    border-width: 2px;
    border-radius: 14px;
  }

  .modal-panel,
  .result-panel {
    width: 88%;
    gap: 8px;
    padding: 14px;
  }

  .summary-grid {
    gap: 6px;
  }

  .toast {
    max-width: 78%;
    bottom: 25%;
  }
}
