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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  user-select: none;
  touch-action: none;
  background: #87b7d9;
}

#game-container {
  position: fixed;
  inset: 0;
}

#game-container canvas {
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 10;
  font-weight: 700;
}

.hud-score {
  font-size: 26px;
  margin-bottom: 4px;
}

.hud-row {
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.92;
}

.hud-right {
  text-align: right;
  pointer-events: auto;
}

.chase-wrap {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(260px, 42vw);
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  z-index: 11;
  pointer-events: none;
}

.chase-label {
  font-size: 12px;
  white-space: nowrap;
  opacity: 0.95;
}

.invuln-tag {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255, 214, 80, 0.92);
  color: #4a1c1c;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: invulnPulse 0.55s ease-in-out infinite alternate;
}

@keyframes invulnPulse {
  from { opacity: 0.75; transform: translateX(-50%) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) scale(1.06); }
}

.chase-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.chase-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: #4ade80;
  transition: width 0.2s ease, background 0.2s ease;
}

@media (max-width: 600px) {
  .chase-wrap {
    top: 112px;
    width: 170px;
    padding: 4px 8px;
  }
  .invuln-tag {
    top: 140px;
  }
}

.skill-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 8px 0 0;
}

.skill-slots {
  display: flex;
  gap: 4px;
}

.skill-slot {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.skill-slot.filled {
  background: #ffd54f;
  box-shadow: 0 0 8px rgba(255, 213, 79, 0.9);
}

.skill-btn {
  position: relative;
  padding: 6px 12px 6px 16px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 800;
  color: #5d4037;
  background: linear-gradient(180deg, #ffe082, #ffb300);
  box-shadow: 0 3px 0 #b26a00;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  pointer-events: auto;
}

.skill-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.skill-btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.skill-btn:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b26a00;
}

.skill-btn.danger {
  animation: skillDanger 0.45s ease-in-out infinite alternate;
  box-shadow: 0 0 20px rgba(255, 60, 60, 0.95);
}

@keyframes skillDanger {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

.skill-key {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid rgba(93, 64, 55, 0.45);
  border-radius: 4px;
  font-size: 10px;
  vertical-align: 1px;
}

.icon-btn {
  margin-top: 8px;
  width: 38px;
  height: 38px;
  font-size: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.55);
}

/* ---------- 台词气泡 ---------- */
.bubble {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -10px) scale(0.8);
  padding: 10px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: #b71c1c;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 12;
  white-space: nowrap;
  pointer-events: none;
}

.bubble.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.bubble.big {
  font-size: 38px;
  padding: 14px 28px;
  color: #fff;
  background: rgba(183, 28, 28, 0.92);
}

/* ---------- 新手提示 ---------- */
.tip {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(360px, 88vw);
  padding: 10px 18px;
  border-radius: 18px;
  background: rgba(20, 24, 30, 0.84);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  z-index: 13;
}

/* ---------- 彩蛋解锁提示 ---------- */
.egg-toast {
  position: fixed;
  top: 110px;
  left: 50%;
  transform: translate(-50%, -12px);
  max-width: min(340px, 86vw);
  padding: 10px 18px;
  border-radius: 20px;
  background: rgba(255, 213, 79, 0.95);
  color: #4e342e;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
  z-index: 40;
}

.egg-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 红色暗角 ---------- */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(180, 20, 20, 0.55) 100%);
}

/* ---------- 技能金色闪光 ---------- */
#goldFlash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.95) 0%, rgba(255, 213, 79, 0.9) 45%, rgba(255, 171, 0, 0.55) 100%);
  transition: opacity 0.35s ease-out;
}

/* ---------- 左下角作者署名 ---------- */
#creditLine {
  position: fixed;
  left: 12px;
  bottom: 6px;
  z-index: 7;
  font-size: 11px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  user-select: none;
}

@media (max-width: 768px) {
  .skill-wrap {
    position: fixed;
    left: 14px;
    bottom: 20px;
    z-index: 11;
    background: rgba(0, 0, 0, 0.28);
    padding: 10px 12px;
    border-radius: 30px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .skill-btn {
    min-width: 76px;
    min-height: 50px;
    padding: 12px 20px;
    font-size: 19px;
    border-radius: 28px;
  }

  .skill-key {
    display: none;
  }

  .skill-slot {
    width: 22px;
    height: 22px;
  }

  #creditLine {
    left: 14px;
    bottom: 132px;
  }
}

/* ---------- 屏幕 ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: rgba(0, 0, 0, 0.42);
}

.panel {
  width: min(440px, 92vw);
  padding: 34px 30px;
  text-align: center;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 244, 214, 0.97), rgba(255, 224, 160, 0.97));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.title {
  font-size: 52px;
  color: #b71c1c;
  letter-spacing: 4px;
  text-shadow: 3px 3px 0 #ffd54f;
}

.subtitle {
  margin: 6px 0 18px;
  font-size: 20px;
  font-weight: 800;
  color: #5d4037;
}

.legend {
  margin: -8px 0 14px;
}

.legend-item {
  font-size: 14px;
  font-weight: 700;
  color: #4e342e;
  line-height: 1.8;
}

.items {
  margin: 2px 0 12px;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 14px;
}

.item-title {
  font-size: 13px;
  font-weight: 800;
  color: #6d4c41;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.item-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.item {
  flex: 1;
  max-width: 124px;
  text-align: center;
}

.item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.22));
}

.item-name {
  font-size: 13px;
  font-weight: 800;
  color: #4e342e;
  margin-top: 4px;
}

.item-desc {
  font-size: 11px;
  color: #8d6e63;
  line-height: 1.4;
  margin-top: 2px;
}

.controls {
  margin: 0 auto 14px;
  text-align: center;
}

.ctrl {
  font-size: 15px;
  color: #4e342e;
  line-height: 1.9;
}

.ctrl-touch {
  color: #8d6e63;
  font-size: 13px;
}

.hint {
  margin: 10px 0 14px;
  font-size: 14px;
  color: #b71c1c;
  font-weight: 700;
}

.best-line {
  margin-bottom: 18px;
  font-size: 14px;
  color: #6d4c41;
}

.credit {
  margin: -6px 0 14px;
  font-size: 12px;
  color: #8d6e63;
}

/* ---------- 开场剧情卡 ---------- */
#introScreen {
  z-index: 30;
  background: rgba(0, 0, 0, 0.38);
}

#eggModal,
#helpModal {
  z-index: 30;
}

.intro-panel {
  width: min(400px, 90vw);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.story-step {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.story-title {
  font-size: 34px;
  font-weight: 800;
  color: #b71c1c;
  margin-bottom: 14px;
  letter-spacing: 2px;
}

.story-text {
  font-size: 18px;
  line-height: 1.8;
  color: #4e342e;
  font-weight: 700;
}

.intro-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.btn-ghost {
  padding: 12px 26px;
  font-size: 16px;
  background: rgba(93, 64, 55, 0.14);
  color: #4e342e;
  box-shadow: none;
}

.btn-ghost:hover {
  transform: translateY(-2px);
}

.btn-ghost:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-small {
  padding: 10px 24px;
  font-size: 15px;
}

.egg-panel {
  width: min(520px, 94vw);
  max-height: 86vh;
  overflow: auto;
}

.egg-title {
  font-size: 26px;
  color: #b71c1c;
  letter-spacing: 4px;
  margin-bottom: 16px;
  text-shadow: 2px 2px 0 #ffd54f;
}

.egg-progress {
  font-size: 14px;
  font-weight: 800;
  color: #6d4c41;
  margin-bottom: 12px;
  text-align: center;
}

.egg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.egg-item {
  padding: 12px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(93, 64, 55, 0.2);
  text-align: left;
}

.egg-item.locked {
  opacity: 0.55;
}

.egg-name {
  font-size: 14px;
  font-weight: 800;
  color: #4e342e;
}

.egg-desc {
  font-size: 12px;
  color: #6d4c41;
  margin-top: 4px;
  line-height: 1.4;
}

.egg-status {
  font-size: 12px;
  font-weight: 800;
  margin-top: 6px;
  color: #2e7d32;
}

.egg-item.locked .egg-status {
  color: #9e9e9e;
}

.help-panel {
  width: min(520px, 94vw);
  max-height: 86vh;
  overflow: auto;
}

.help-title {
  font-size: 26px;
  color: #b71c1c;
  letter-spacing: 4px;
  margin-bottom: 16px;
  text-shadow: 2px 2px 0 #ffd54f;
}

@media (max-width: 600px) {
  .egg-grid {
    grid-template-columns: 1fr;
  }
}

.help-box {
  margin-top: 18px;
  text-align: left;
  border: 1px solid rgba(93, 64, 55, 0.25);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  padding: 4px 14px 10px;
  max-height: 38vh;
  overflow: auto;
}

.help-box .legend {
  margin: 4px 0 10px;
}

.help-box .items {
  margin: 2px 0 12px;
}

.help-box .btn-small {
  margin: 4px auto 6px;
  display: block;
}

@media (max-height: 720px) {
  .panel {
    padding: 22px 22px;
  }

  .story-step {
    min-height: 120px;
  }
}

.btn {
  padding: 14px 46px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  border: none;
  border-radius: 40px;
  background: linear-gradient(180deg, #e53935, #b71c1c);
  box-shadow: 0 6px 0 #7f1414, 0 10px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #7f1414;
}

.skip-btn {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 21;
  padding: 10px 22px;
  font-size: 15px;
  border-radius: 24px;
}

.skip-hint {
  position: fixed;
  right: 14px;
  bottom: 74px;
  z-index: 21;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(20, 24, 30, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.skip-hint .skip-key {
  opacity: 0.8;
}

@media (max-width: 768px) {
  .skip-btn {
    right: 12px;
    bottom: 14px;
    min-height: 46px;
  }

  .skip-hint {
    right: 12px;
    bottom: 70px;
  }

  .skip-hint .skip-key {
    display: none;
  }
}

.over-title {
  font-size: 34px;
  color: #b71c1c;
  margin-bottom: 18px;
  letter-spacing: 2px;
}

.over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 20px;
  font-weight: 800;
  color: #4e342e;
}

.stat .label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #8d6e63;
  margin-bottom: 4px;
}

.record {
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #f57f17;
}

/* ---------- 暂停 ---------- */
.pause-panel {
  width: min(380px, 88vw);
}

.pause-title {
  font-size: 34px;
  color: #b71c1c;
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-shadow: 2px 2px 0 #ffd54f;
}

.pause-sub {
  font-size: 15px;
  color: #6d4c41;
  margin-bottom: 18px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pause-actions .btn {
  width: min(240px, 70vw);
}

.pause-actions .btn-small {
  padding: 11px 30px;
}
.street-turn {
  position: fixed;
  z-index: 12;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  min-width: 9.6rem;
  padding: .56rem .75rem;
  border: 1px solid rgba(239, 221, 183, .42);
  border-radius: .35rem;
  background: rgba(24, 26, 23, .91);
  color: #fff4df;
  font-size: clamp(.89rem, 3.8vw, 1.08rem);
  text-align: center;
  pointer-events: none;
}

.street-turn-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: .6rem;
}

.street-turn-status { font-weight: 700; }
.street-turn-distance {
  color: #dbc9a9;
  font-variant-numeric: tabular-nums;
}

.street-turn-controls {
  margin-top: .34rem;
  font-size: .83em;
}

.street-turn-swipe,
.street-turn-help { display: none; }

.street-turn-ready {
  background: #243a29;
  border-color: #b9ee8d;
  color: #e7ffd3;
}

.street-turn-ready .street-turn-distance { color: #c7eab5; }
.street-turn-confirmed { border-color: #83b57e; }
.street-turn button {
  pointer-events: auto;
  touch-action: manipulation;
  margin-top: .4rem;
  min-height: 44px;
  min-width: 6.25rem;
  padding: .36rem .8rem;
  border: 1px solid #c9f3a9;
  border-radius: 3px;
  background: #b9ee8d;
  color: #1b2f21;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (pointer: coarse) {
  .street-turn { bottom: max(16%, env(safe-area-inset-bottom)); }
  .street-turn-key { display: none; }
  .street-turn-swipe { display: inline; }
}


/* ---- 原剧结尾演出 2.35:1 宽银幕电影遮幅与纯净画幅 ---- */
body.ending-cinema #hud,
body.ending-cinema #chapterHud {
  display: none !important;
}
body::before,
body::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  height: 0;
  background: #060708;
  z-index: 18;
  pointer-events: none;
  transition: height 0.35s ease;
}
body::before { top: 0; }
body::after { bottom: 0; }
body.ending-cinema::before,
body.ending-cinema::after {
  height: 7.2vh;
}
