:root {
  --bg: #08090c;
  --surface: rgba(13, 15, 20, 0.94);
  --surface-2: #171a21;
  --border: #31343d;
  --text: #d8d9df;
  --muted: #777c89;
  --green: #68d391;
  --pink: #ff5c8a;
  --pink-soft: #ff9fba;
  --amber: #f6c85f;
  --cyan: #65d1dd;
  --shadow: rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 92, 138, 0.07), transparent 34%),
    linear-gradient(150deg, #08090c 0%, #0f1118 50%, #08090c 100%);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", monospace;
}

button {
  font: inherit;
}

#particle-canvas,
.code-rain,
.scanlines,
.screen-flash {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#particle-canvas {
  z-index: 0;
}

.code-rain {
  z-index: 0;
  overflow: hidden;
  opacity: 0.22;
  mask-image: linear-gradient(to bottom, transparent, black 18%, black 82%, transparent);
}

.rain-column {
  position: absolute;
  top: -24vh;
  color: #68d391;
  font-size: 10px;
  line-height: 1.65;
  opacity: var(--opacity);
  text-shadow: 0 0 8px rgba(104, 211, 145, 0.45);
  writing-mode: vertical-rl;
  animation: code-fall var(--fall-duration) linear var(--fall-delay) infinite;
}

.screen-flash {
  z-index: 4;
  opacity: 0;
  background: rgba(255, 92, 138, 0.16);
}

body.celebrating .screen-flash {
  animation: screen-flash 600ms ease-out both;
}

.scanlines {
  z-index: 3;
  opacity: 0.08;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.16) 4px
  );
  mix-blend-mode: soft-light;
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 36px 20px 28px;
}

.terminal {
  width: min(820px, 100%);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow:
    0 28px 80px var(--shadow),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 0 60px rgba(255, 92, 138, 0.05);
  backdrop-filter: blur(18px);
  animation: terminal-enter 850ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-style: preserve-3d;
  transition: transform 180ms ease-out, box-shadow 180ms ease-out;
}

.terminal::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.055) 49%, transparent 63%);
  content: "";
  pointer-events: none;
  transform: translateX(-130%);
}

.terminal.scanning::after {
  animation: terminal-scan 900ms ease-out;
}

body.celebrating .terminal {
  animation: terminal-shake 520ms cubic-bezier(0.36, 0.07, 0.19, 0.97), border-flare 1.4s ease-out;
}

.terminal-bar {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr 112px;
  min-height: 45px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: #1b1e25;
  padding: 0 14px;
}

.traffic-lights {
  display: flex;
  gap: 8px;
}

.light {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.close { background: #ff5f57; }
.minimize { background: #febc2e; }
.maximize { background: #28c840; }

.terminal-title {
  margin: 0;
  overflow: hidden;
  color: #a6a9b2;
  font-size: 12px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.replay-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  justify-self: end;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.icon-button:hover,
.replay-button:hover {
  border-color: #474b55;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.icon-button:focus-visible,
.replay-button:focus-visible,
.success-replay-button:focus-visible,
.yes-button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.sound-off {
  display: none;
}

.icon-button.muted .sound-on {
  display: none;
}

.icon-button.muted .sound-off {
  display: inline;
}

.terminal-body {
  position: relative;
  min-height: 610px;
  padding: clamp(22px, 4vw, 38px) clamp(18px, 5vw, 52px) 32px;
}

.command-line {
  min-height: 22px;
  font-size: clamp(11px, 2.4vw, 14px);
  line-height: 1.6;
}

.prompt {
  color: var(--green);
}

.path {
  color: var(--cyan);
}

.command {
  color: var(--text);
}

.boot-log {
  min-height: 71px;
  margin-top: 16px;
  color: var(--muted);
  font-size: clamp(10px, 2.2vw, 12px);
  line-height: 1.8;
}

.log-line {
  margin: 0;
  animation: log-enter 260ms ease both;
}

.log-ok { color: var(--green); }
.log-heart { color: var(--pink-soft); }

.progress-track {
  position: relative;
  width: 100%;
  height: 2px;
  overflow: hidden;
  margin-top: 7px;
  background: rgba(255, 255, 255, 0.055);
  opacity: 1;
  transition: opacity 320ms ease;
}

.progress-track.complete {
  opacity: 0;
}

.progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--pink));
  box-shadow: 0 0 10px rgba(101, 209, 221, 0.55);
  transition: width 240ms ease-out;
}

.heart-wrap {
  position: relative;
  display: grid;
  min-height: 238px;
  place-items: center;
  margin: 8px 0 2px;
}

.ascii-heart {
  position: relative;
  z-index: 2;
  margin: 0;
  color: var(--pink);
  font: 700 clamp(8px, 1.75vw, 15px)/1.08 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
  text-align: left;
  filter: drop-shadow(0 0 10px rgba(255, 92, 138, 0.6));
  white-space: pre;
  animation: heart-beat 1.7s ease-in-out infinite;
}

.heart-glow {
  position: absolute;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 45, 104, 0.11);
  filter: blur(38px);
  animation: glow-pulse 1.7s ease-in-out infinite;
}

.confession {
  min-height: 82px;
  text-align: center;
}

.main-message {
  margin: 0;
  color: #fff;
  font: 700 clamp(20px, 4.2vw, 32px)/1.5 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
  text-wrap: balance;
}

.sub-message {
  margin: 12px 0 0;
  color: #a9adb8;
  font: 400 clamp(12px, 2.6vw, 15px)/1.8 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

.question-area {
  visibility: hidden;
  margin-top: 22px;
  opacity: 0;
  transform: translateY(8px);
}

.question-area.visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 500ms ease, transform 500ms ease;
}

.question {
  margin: 0 0 18px;
  color: var(--text);
  font: 500 clamp(12px, 2.6vw, 14px)/1.6 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
  text-align: center;
}

.prompt-symbol {
  margin-right: 7px;
  color: var(--green);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.05em;
  margin-left: 5px;
  vertical-align: -0.12em;
  background: var(--pink-soft);
  animation: blink 1s steps(1) infinite;
}

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

.yes-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--pink);
  border-radius: 5px;
  padding: 0 22px;
  color: #0b0c10;
  background: var(--pink);
  box-shadow: 0 0 24px rgba(255, 92, 138, 0.2);
  cursor: pointer;
  font-family: system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.yes-button:hover {
  background: #ff759d;
  box-shadow: 0 0 32px rgba(255, 92, 138, 0.4);
  transform: translateY(-2px);
}

.yes-button:active {
  transform: translateY(0) scale(0.98);
}

.replay-button {
  width: 42px;
  height: 42px;
  border-color: #3f434d;
}

.success {
  display: none;
  padding: 46px 10px 34px;
  text-align: center;
}

.success.visible {
  display: block;
  animation: success-enter 650ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.success-code {
  margin: 0 0 20px;
  color: var(--green);
  font-size: 12px;
}

.success h1 {
  margin: 0;
  color: #fff;
  font: 700 clamp(22px, 4.6vw, 35px)/1.45 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
  text-wrap: balance;
}

.success > p:not(.success-code) {
  color: #abb0bb;
  font: 400 15px/1.8 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

.signature {
  margin-top: 31px;
  color: var(--pink-soft);
  font-size: clamp(11px, 2.5vw, 14px);
}

.success-replay-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin-top: 30px;
  border: 1px solid #424751;
  border-radius: 5px;
  padding: 0 15px;
  color: #a9adb8;
  background: transparent;
  cursor: pointer;
  font: 500 12px/1 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease;
}

.success-replay-button:hover {
  border-color: var(--pink-soft);
  color: #fff;
  background: rgba(255, 92, 138, 0.08);
  transform: translateY(-1px);
}

.status-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 28px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: 0 13px;
  color: #696e79;
  background: #15181e;
  font-size: 9px;
}

.status-bar span:nth-child(2) { justify-self: center; }
.status-bar span:last-child { justify-self: end; }
.status-bar span:first-child { color: var(--pink-soft); }

.ambient-copy {
  position: absolute;
  bottom: 8px;
  margin: 0;
  color: #555a66;
  font: 400 10px/1.4 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

body.accepted .intro-line,
body.accepted .boot-log,
body.accepted .progress-track,
body.accepted .heart-wrap,
body.accepted .confession,
body.accepted .question-area {
  display: none;
}

body.accepted .terminal-body {
  display: grid;
  min-height: 610px;
  place-items: center;
}

.floating-heart {
  position: fixed;
  z-index: 5;
  color: var(--pink);
  pointer-events: none;
  animation: float-away var(--duration) ease-out forwards;
  filter: drop-shadow(0 0 5px rgba(255, 92, 138, 0.7));
}

@keyframes code-fall {
  from { transform: translateY(-20vh); }
  to { transform: translateY(145vh); }
}

@keyframes terminal-enter {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes terminal-scan {
  from { transform: translateX(-130%); }
  to { transform: translateX(130%); }
}

@keyframes terminal-shake {
  0%, 100% { transform: translate(0, 0); }
  18% { transform: translate(-5px, 2px) rotate(-0.2deg); }
  36% { transform: translate(5px, -2px) rotate(0.2deg); }
  54% { transform: translate(-3px, 1px); }
  72% { transform: translate(3px, -1px); }
}

@keyframes border-flare {
  0% { box-shadow: 0 28px 80px var(--shadow), 0 0 0 1px #ff5c8a inset, -5px 0 20px rgba(101, 209, 221, 0.55), 5px 0 20px rgba(255, 92, 138, 0.55); }
  100% { box-shadow: 0 28px 80px var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 0 60px rgba(255, 92, 138, 0.05); }
}

@keyframes screen-flash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes log-enter {
  from { opacity: 0; transform: translateX(-5px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  10% { transform: scale(1.035); }
  20% { transform: scale(1); }
  30% { transform: scale(1.055); }
  45% { transform: scale(1); }
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.65; transform: scale(0.92); }
  30% { opacity: 1; transform: scale(1.13); }
}

@keyframes blink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

@keyframes success-enter {
  from { opacity: 0; transform: scale(0.94); filter: blur(5px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes float-away {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.7) rotate(0deg); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift)), -180px) scale(1.35) rotate(var(--rotate)); }
}

@media (max-width: 600px) {
  .stage {
    place-items: start center;
    padding: 14px 10px 30px;
  }

  .terminal-bar {
    grid-template-columns: 78px 1fr 78px;
    padding: 0 10px;
  }

  .terminal-title {
    font-size: 10px;
  }

  .light {
    width: 10px;
    height: 10px;
  }

  .traffic-lights {
    gap: 6px;
  }

  .terminal-body {
    min-height: calc(100svh - 118px);
    padding: 21px 13px 24px;
  }

  .heart-wrap {
    min-height: 210px;
    overflow: hidden;
  }

  .ascii-heart {
    font-size: clamp(6px, 2.35vw, 10px);
  }

  .boot-log {
    min-height: 65px;
  }

  body.accepted .terminal-body {
    min-height: calc(100svh - 88px);
  }

  .ambient-copy {
    display: none;
  }

  .status-bar span:nth-child(2) {
    display: none;
  }

  .status-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (pointer: coarse) {
  .terminal {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .code-rain {
    display: none;
  }

  *, 
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
