/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ===== Universe Background ===== */
.universe {
  width: 100vw;
  height: 100vh;
  background: radial-gradient(ellipse at center, #0d0d2b 0%, #000005 80%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'Georgia', serif;
}

/* ===== Stars ===== */
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--dur) ease-in-out infinite alternate;
  opacity: var(--op);
}

@keyframes twinkle {
  from { opacity: var(--op); }
  to   { opacity: calc(var(--op) * 0.2); }
}

/* ===== Main Container ===== */
.container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 560px;
  padding: 0 16px;
}

.title {
  color: #e8e0d0;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-shadow: 0 0 20px rgba(150, 120, 255, 0.4);
}

.subtitle {
  color: #8080a0;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  margin-top: -16px;
}

/* ===== Paper ===== */
.paper-wrapper {
  width: 100%;
  perspective: 800px;
}

.paper {
  background: #fdfaf3;
  background-image:
    linear-gradient(#e8e0cc 1px, transparent 1px);
  background-size: 100% 28px;
  border-radius: 3px;
  padding: 24px 28px 16px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.4),
    inset 0 0 60px rgba(230, 220, 190, 0.3);
  position: relative;
  transform-origin: center center;
  transition: box-shadow 0.3s ease;
}

.paper::before {
  content: '';
  position: absolute;
  left: 40px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 100, 100, 0.25);
}

textarea#trashInput {
  width: 100%;
  min-height: 180px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 28px;
  color: #2a2a2a;
  padding-left: 20px;
  caret-color: #555;
}

textarea#trashInput::placeholder {
  color: #bbb;
  font-size: 0.88rem;
}

.paper-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.char-count {
  font-size: 0.75rem;
  color: #999;
  font-family: monospace;
}

.charge-notice {
  font-size: 0.75rem;
  color: #c06020;
  font-family: sans-serif;
  transition: opacity 0.3s;
}

/* ===== Throw Button ===== */
.throw-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #2a0a4a, #1a0530);
  border: 1px solid rgba(150, 80, 255, 0.4);
  color: #d0b0ff;
  font-size: 1rem;
  letter-spacing: 0.2em;
  padding: 14px 40px;
  border-radius: 40px;
  cursor: pointer;
  font-family: inherit;
  box-shadow:
    0 0 20px rgba(120, 60, 220, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.25s ease;
}

.throw-btn:hover {
  background: linear-gradient(135deg, #3a1060, #250840);
  box-shadow:
    0 0 35px rgba(150, 80, 255, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-2px);
}

.throw-btn:active {
  transform: translateY(0);
}

.throw-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.throw-btn-icon {
  font-size: 1.1rem;
}

/* ===== Black Hole ===== */
.blackhole-container {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
}

.blackhole {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.blackhole-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
}

.ring1 {
  width: 120px;
  height: 120px;
  border-color: rgba(180, 80, 255, 0.6);
  box-shadow:
    0 0 20px rgba(180, 80, 255, 0.4),
    inset 0 0 20px rgba(180, 80, 255, 0.2);
  animation: rotateRing 3s linear infinite;
}

.ring2 {
  width: 90px;
  height: 90px;
  border-color: rgba(100, 60, 220, 0.7);
  box-shadow:
    0 0 15px rgba(100, 60, 220, 0.5),
    inset 0 0 15px rgba(100, 60, 220, 0.3);
  animation: rotateRing 2s linear infinite reverse;
}

.ring3 {
  width: 65px;
  height: 65px;
  border-color: rgba(60, 20, 160, 0.8);
  box-shadow: 0 0 10px rgba(60, 20, 160, 0.6);
  animation: rotateRing 1.2s linear infinite;
}

.blackhole-core {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, #000 60%, #1a0030 100%);
  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.9),
    0 0 60px rgba(80, 0, 160, 0.4);
  z-index: 2;
}

.gravitational-lens {
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle,
    transparent 30%,
    rgba(80, 20, 160, 0.06) 60%,
    rgba(150, 60, 255, 0.12) 80%,
    transparent 100%
  );
  animation: pulse 2s ease-in-out infinite alternate;
}

@keyframes rotateRing {
  from { transform: rotate(0deg) scaleY(0.3); }
  to   { transform: rotate(360deg) scaleY(0.3); }
}

@keyframes pulse {
  from { transform: scale(1); opacity: 0.6; }
  to   { transform: scale(1.15); opacity: 1; }
}

/* ===== Animation States ===== */

/* ブラックホール出現 */
.blackhole-container.appear {
  animation: blackholeAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes blackholeAppear {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.1);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

/* 紙が吸い込まれる */
.paper-wrapper.sucked {
  animation: suckIntoBH 1.4s cubic-bezier(0.55, 0, 1, 0.45) forwards;
  transform-origin: center bottom;
  pointer-events: none;
}

@keyframes suckIntoBH {
  0% {
    transform: translateY(0) scale(1) rotate(0deg) skewX(0deg);
    opacity: 1;
    filter: blur(0px);
  }
  15% {
    transform: translateY(8px) scale(1.02) rotate(-1deg) skewX(1deg);
    opacity: 1;
    filter: blur(0px);
  }
  35% {
    transform: translateY(30px) scale(0.85) rotate(-4deg) skewX(4deg) skewY(-2deg);
    opacity: 0.95;
    filter: blur(0px);
  }
  55% {
    transform: translateY(80px) scale(0.55) rotate(-12deg) skewX(10deg) skewY(-5deg);
    opacity: 0.85;
    filter: blur(1px);
  }
  75% {
    transform: translateY(160px) scale(0.25) rotate(-30deg) skewX(20deg) skewY(-10deg);
    opacity: 0.6;
    filter: blur(3px);
  }
  90% {
    transform: translateY(240px) scale(0.08) rotate(-60deg) skewX(35deg);
    opacity: 0.2;
    filter: blur(6px);
  }
  100% {
    transform: translateY(300px) scale(0) rotate(-90deg);
    opacity: 0;
    filter: blur(10px);
  }
}

/* ブラックホール消滅 */
.blackhole-container.disappear {
  animation: blackholeDisappear 0.5s ease-in forwards;
}

@keyframes blackholeDisappear {
  0%   { opacity: 1; transform: translateX(-50%) scale(1); }
  60%  { opacity: 1; transform: translateX(-50%) scale(1.2); }
  100% { opacity: 0; transform: translateX(-50%) scale(0); }
}

/* ===== Done Message ===== */
.done-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
}

.done-message p {
  color: #c0a0ff;
  font-size: 2rem;
  letter-spacing: 0.5em;
  text-shadow:
    0 0 30px rgba(180, 120, 255, 0.8),
    0 0 60px rgba(120, 60, 200, 0.4);
}

.done-message.show {
  animation: fadeInOut 2.5s ease forwards;
}

@keyframes fadeInOut {
  0%   { opacity: 0; transform: scale(0.8); }
  20%  { opacity: 1; transform: scale(1); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* ===== Stripe Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 5, 0.85);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: linear-gradient(160deg, #12082a, #0a0518);
  border: 1px solid rgba(150, 80, 255, 0.3);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow:
    0 0 60px rgba(100, 40, 200, 0.3),
    0 20px 60px rgba(0,0,0,0.7);
  color: #e0d0ff;
  font-family: sans-serif;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.modal-title span {
  color: #a080ff;
  font-size: 1.4rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: #9080b0;
  margin-bottom: 24px;
  line-height: 1.6;
}

.card-element {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(150, 80, 255, 0.3);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.card-error {
  color: #ff8080;
  font-size: 0.8rem;
  min-height: 20px;
  margin-bottom: 16px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-cancel {
  background: transparent;
  border: 1px solid rgba(150, 80, 255, 0.3);
  color: #9080b0;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.modal-cancel:hover {
  border-color: rgba(150, 80, 255, 0.6);
  color: #c0a0ff;
}

.modal-pay {
  background: linear-gradient(135deg, #5020a0, #301070);
  border: 1px solid rgba(150, 80, 255, 0.5);
  color: #e0c0ff;
  padding: 10px 28px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: 0 0 20px rgba(100, 40, 200, 0.4);
  transition: all 0.2s;
}

.modal-pay:hover {
  background: linear-gradient(135deg, #6030b0, #4020808);
  box-shadow: 0 0 30px rgba(130, 60, 220, 0.6);
}

.modal-pay:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
