/* Chrono Echo: 时空回响 - Cyberpunk Holographic Timeline UI */
:root {
  --bg-dark: #070914;
  --bg-lab: #0c1228;
  --cyan-echo: #00f5ff;
  --magenta-echo: #ff007f;
  --gold-echo: #ffd166;
  --danger-red: #ff3366;
  --hud-bg: rgba(12, 18, 40, 0.78);
  --hud-border: rgba(0, 245, 255, 0.25);
  --text-main: #f0f6fc;
  --text-dim: #7f8ca3;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Rewind Glitch Scanline Effect */
#rewind-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 245, 255, 0.12);
  pointer-events: none;
  opacity: 0;
  z-index: 15;
  transition: opacity 0.15s ease;
}

#rewind-overlay.active {
  opacity: 1;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 245, 255, 0.25) 0px,
    rgba(0, 245, 255, 0.25) 2px,
    transparent 2px,
    transparent 4px
  );
}

/* Top HUD Navigation */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.level-title-wrap {
  display: flex;
  flex-direction: column;
}

.level-number {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cyan-echo);
}

.level-name {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.4);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  padding: 8px 18px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  min-width: 170px;
}

.timeline-info-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.loop-badge {
  color: var(--cyan-echo);
}

.time-counter {
  color: #ffffff;
  font-family: monospace;
}

.time-counter.urgent {
  color: var(--danger-red);
  text-shadow: 0 0 8px rgba(255, 51, 102, 0.8);
}

.timeline-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.timeline-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #00f5ff, #38bdf8);
  box-shadow: 0 0 8px #00f5ff;
  transition: width 0.05s linear;
}

.timeline-bar.urgent {
  background: linear-gradient(90deg, #ffd166, #ff3366);
  box-shadow: 0 0 10px #ff3366;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--cyan-echo);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.hud-btn:active {
  transform: scale(0.92);
  background: rgba(0, 245, 255, 0.2);
}

.hud-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Bottom Controls (Mobile D-Pad & Rewind Button) */
#bottom-bar {
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 100%;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

/* Virtual D-Pad */
#dpad {
  position: relative;
  width: 120px;
  height: 120px;
  pointer-events: auto;
}

.dpad-btn {
  position: absolute;
  width: 38px;
  height: 38px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 10px;
  color: var(--cyan-echo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.15s ease;
}

.dpad-btn:active {
  background: rgba(0, 245, 255, 0.3);
  transform: scale(0.92);
}

.dpad-up { top: 0; left: 41px; }
.dpad-down { bottom: 0; left: 41px; }
.dpad-left { top: 41px; left: 0; }
.dpad-right { top: 41px; right: 0; }

/* Big Rewind Button */
#btn-rewind {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.8) 0%, rgba(121, 40, 202, 0.9) 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.45);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

#btn-rewind:active {
  transform: scale(0.94);
  box-shadow: 0 0 30px rgba(255, 0, 127, 0.7);
}

#btn-rewind svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Modals & Screens */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 9, 20, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.screen-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.card-modal {
  width: 90%;
  max-width: 420px;
  background: linear-gradient(135deg, rgba(16, 22, 48, 0.92) 0%, rgba(8, 10, 24, 0.98) 100%);
  border: 1px solid rgba(0, 245, 255, 0.3);
  box-shadow: 0 0 35px rgba(0, 245, 255, 0.15), 0 20px 45px rgba(0, 0, 0, 0.7);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: floatUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes floatUp {
  from {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.game-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 0%, #00f5ff 50%, #ff007f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(0, 245, 255, 0.5));
}

.game-tagline {
  font-size: 13px;
  color: var(--cyan-echo);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 700;
}

.instructions-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
  width: 100%;
  font-size: 13px;
  line-height: 1.6;
  color: #c7d2fe;
  text-align: left;
}

.instructions-box p {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.instructions-box p:last-child {
  margin-bottom: 0;
}

.key-badge {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(0, 245, 255, 0.15);
  border: 1px solid var(--cyan-echo);
  border-radius: 6px;
  color: var(--cyan-echo);
  font-weight: 700;
  font-size: 11px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(90deg, #00f5ff 0%, #7928ca 100%);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 245, 255, 0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(0, 245, 255, 0.6);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Level Grid Selector */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.level-card {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.level-card:hover {
  background: rgba(0, 245, 255, 0.1);
  border-color: var(--cyan-echo);
}

.level-card.current {
  border-color: var(--cyan-echo);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.4);
}

.level-card.locked {
  opacity: 0.35;
  cursor: not-allowed;
}

.level-card-num {
  font-size: 16px;
  font-weight: 800;
}

.level-card-badge {
  font-size: 10px;
  color: var(--gold-echo);
  margin-top: 2px;
}
