:root {
  --bg-top: #0d1533;
  --bg-bottom: #220f21;
  --panel: rgba(12, 18, 40, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.07);
  --text-main: #f6f8ff;
  --text-dim: #aeb8d8;
  --danger: #ff4a66;
  --danger-soft: #ff8a9c;
  --safe: #35d69f;
  --calm: #4db6ff;
  --line: rgba(255, 255, 255, 0.14);
  --glow: 0 10px 30px rgba(77, 182, 255, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--text-main);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  display: flex;
  justify-content: center;
}

.app {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  overflow: hidden;
}

.bg-noise {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 18%, rgba(53, 214, 159, 0.08), transparent 30%),
    radial-gradient(circle at 88% 20%, rgba(255, 74, 102, 0.12), transparent 33%),
    radial-gradient(circle at 52% 92%, rgba(77, 182, 255, 0.11), transparent 36%);
  pointer-events: none;
  z-index: 0;
}

.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 20px 14px calc(26px + env(safe-area-inset-bottom));
}

.screen.active {
  display: block;
}

.start-screen {
  display: none;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  justify-content: center;
}

.start-screen.active {
  display: flex;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 1px;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.rule-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(4px);
}

.rule-card p {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.4;
}

.rule-card p:last-child {
  margin-bottom: 0;
}

.rule-card strong {
  color: #fff2a8;
}

.best-score,
.hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 13px;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(135deg, #ff4a66, #ff8d37);
  box-shadow: 0 10px 24px rgba(255, 74, 102, 0.28);
}

.secondary-btn {
  background: linear-gradient(135deg, #2e6eff, #3bb0ff);
  box-shadow: var(--glow);
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.985);
}

.game-screen {
  padding-top: 12px;
}

.hud {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(3, 8, 21, 0.4);
}

.hud-top {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.score-box {
  text-align: center;
  border-radius: 10px;
  padding: 8px 4px;
  background: var(--panel-soft);
  font-size: 12px;
  color: var(--text-dim);
}

.score-box span {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 19px;
  font-weight: 800;
}

.meter-row {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.meter {
  display: grid;
  gap: 4px;
}

.meter label {
  font-size: 12px;
  color: #e1e6fa;
}

.meter-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.meter-fill {
  height: 100%;
  width: 0;
  transition: width 160ms linear;
}

.meter-track.danger .meter-fill {
  background: linear-gradient(90deg, #ff6f78, var(--danger));
}

.meter-track.relation .meter-fill {
  background: linear-gradient(90deg, #4be29c, var(--safe));
}

.meter-track.calm .meter-fill {
  background: linear-gradient(90deg, #88d8ff, var(--calm));
}

.cards-area {
  position: relative;
  margin-top: 12px;
  min-height: calc(100vh - 212px);
  padding-bottom: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.message-card {
  position: relative;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: linear-gradient(160deg, rgba(20, 30, 59, 0.98), rgba(17, 24, 44, 0.98));
  border-radius: 14px;
  padding: 10px 11px 9px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  animation: card-in 180ms ease-out;
}

.message-card.suspect {
  border-color: rgba(255, 125, 145, 0.42);
}

.message-card.suspect::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger-soft);
  opacity: 0.62;
}

.message-card.urgent {
  animation: pulse 420ms linear infinite;
}

.message-card.leaving {
  animation: card-out 150ms ease-in forwards;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.sender {
  font-size: 13px;
  color: #d6e0ff;
  font-weight: 700;
}

.clock {
  font-size: 12px;
  color: #d9ddf0;
}

.msg-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  color: #f7fbff;
}

.countdown {
  margin-top: 9px;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.countdown-fill {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #74c8ff, #ff7d94);
}

.floating {
  position: absolute;
  right: 12px;
  top: 6px;
  pointer-events: none;
  font-size: 13px;
  font-weight: 700;
  animation: float-out 720ms ease-out forwards;
}

.floating.good {
  color: #78ffc5;
}

.floating.bad {
  color: #ff9ab3;
}

.floating.combo {
  color: #ffe37d;
}

.bullet-time-indicator {
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  margin-top: 10px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(119, 203, 255, 0.55);
  background: rgba(32, 73, 124, 0.6);
  color: #d9f1ff;
  font-size: 13px;
  font-weight: 700;
  transition: opacity 150ms ease, transform 150ms ease;
}

.bullet-time-indicator.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.app.bullet-time .message-card {
  box-shadow: 0 0 0 1px rgba(111, 210, 255, 0.22), 0 12px 26px rgba(29, 94, 173, 0.26);
}

.app.hit-danger {
  animation: screen-hit 220ms ease;
}

.app.hit-wrong {
  animation: screen-warn 220ms ease;
}

.result-screen {
  display: none;
  align-content: center;
  gap: 12px;
}

.result-screen.active {
  display: grid;
}

.result-screen h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
}

.result-desc {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.45;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.result-grid div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.result-grid span {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
}

.result-grid strong {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 22px;
}

.share-text {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  min-height: 88px;
  resize: none;
  background: rgba(11, 16, 36, 0.9);
  color: #f4f7ff;
  padding: 10px;
  font: inherit;
  line-height: 1.45;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes card-out {
  to {
    opacity: 0;
    transform: scale(0.94) translateY(6px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(0.7px);
  }

  75% {
    transform: translateX(-0.7px);
  }
}

@keyframes float-out {
  0% {
    opacity: 0;
    transform: translateY(4px);
  }

  18% {
    opacity: 1;
    transform: translateY(-4px);
  }

  100% {
    opacity: 0;
    transform: translateY(-18px);
  }
}

@keyframes screen-hit {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

@keyframes screen-warn {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(3px);
  }

  75% {
    transform: translateX(-3px);
  }
}

@media (min-width: 480px) {
  .screen {
    padding-left: 18px;
    padding-right: 18px;
  }

  .msg-text {
    font-size: 16px;
  }
}
