* {
  box-sizing: border-box;
}

:root {
  --bg: #fff7fb;
  --bg2: #f3f0ff;
  --text: #4a4055;
  --muted: #8b8194;
  --pink: #ff6fae;
  --pink-dark: #f45197;
  --purple: #9b7cff;
  --blue: #63c8ff;
  --yellow: #ffd85c;
  --card: rgba(255, 255, 255, 0.88);
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Noto Sans JP",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #ffd6e8 0, transparent 28%),
    radial-gradient(circle at 90% 15%, #dcd2ff 0, transparent 28%),
    radial-gradient(circle at 50% 100%, #cfefff 0, transparent 35%),
    linear-gradient(135deg, #fff8fc, #f5f1ff);
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  z-index: 0;
}

body::before {
  width: 180px;
  height: 180px;
  top: 18%;
  left: -90px;
  background: rgba(255, 216, 92, 0.28);
}

body::after {
  width: 220px;
  height: 220px;
  right: -110px;
  bottom: 12%;
  background: rgba(99, 200, 255, 0.2);
}

.container {
  position: relative;
  z-index: 1;
  width: min(100% - 28px, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px 0 70px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--pink-dark);
}

h1::before {
  content: "✨";
  display: inline-block;
  margin-right: 7px;
  animation: sparkle 1.8s ease-in-out infinite;
}

h2 {
  margin: 28px 0 14px;
  font-size: clamp(31px, 8vw, 44px);
  line-height: 1.25;
  font-weight: 950;
  letter-spacing: -0.04em;
  background: linear-gradient(
    135deg,
    #ff4f9a,
    #9b6cff 55%,
    #48bff5
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.description {
  max-width: 420px;
  margin: 0 auto 30px;
  line-height: 1.9;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

section {
  margin-top: 24px;
}

button {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 60px;
  margin: 8px 0;
  padding: 14px 22px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff6fae, #a477ff);
  color: white;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    0 10px 0 rgba(202, 76, 141, 0.18),
    0 14px 28px rgba(196, 104, 171, 0.22);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

button::after {
  content: "";
  position: absolute;
  top: -30%;
  left: -80%;
  width: 45%;
  height: 160%;
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(20deg);
  transition: left 0.5s ease;
}

button:hover {
  transform: translateY(-3px);
  box-shadow:
    0 13px 0 rgba(202, 76, 141, 0.18),
    0 18px 34px rgba(196, 104, 171, 0.27);
  filter: brightness(1.04);
}

button:hover::after {
  left: 140%;
}

button:active {
  transform: translateY(3px);
  box-shadow:
    0 5px 0 rgba(202, 76, 141, 0.18),
    0 8px 18px rgba(196, 104, 171, 0.2);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary {
  background: white;
  color: #7a6a83;
  border: 2px solid #eadff1;
  box-shadow: 0 7px 18px rgba(120, 91, 132, 0.1);
}

button.secondary:hover {
  background: #fff8fd;
  box-shadow: 0 10px 22px rgba(120, 91, 132, 0.13);
}

.hidden {
  display: none !important;
}

/* トップ画面 */

#startArea {
  position: relative;
  margin-top: 24px;
  padding: 34px 20px 28px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: var(--card);
  box-shadow:
    0 18px 50px rgba(137, 105, 157, 0.13),
    0 5px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
}

#startArea::before {
  content: "✨ 顔面偏差値チェック ✨";
  display: inline-block;
  margin-bottom: 8px;
  padding: 8px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff0f7, #f0eaff);
  color: #a35a87;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 5px 14px rgba(173, 119, 160, 0.1);
}

#cameraButton {
  margin-top: 18px;
  font-size: 17px;
}

#fileButton {
  font-size: 15px;
}

/* カメラ・プレビュー */

#cameraArea,
#previewArea {
  padding: 18px;
  border: 3px solid white;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 50px rgba(137, 105, 157, 0.13);
  backdrop-filter: blur(12px);
}

video,
#previewImage {
  display: block;
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 22px;
  background: #f1edf5;
  border: 3px solid #f1e6f1;
}

label {
  display: block;
  margin: 22px 2px 8px;
  text-align: left;
  color: #67586f;
  font-size: 14px;
  font-weight: 900;
}

input[type="text"] {
  width: 100%;
  min-height: 56px;
  padding: 13px 16px;
  border: 3px solid #eadff1;
  border-radius: 18px;
  outline: none;
  background: white;
  color: #51445a;
  font-size: 16px;
  font-weight: 600;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input[type="text"]::placeholder {
  color: #b5a9ba;
}

input[type="text"]:focus {
  border-color: #ff91bd;
  box-shadow: 0 0 0 5px rgba(255, 111, 174, 0.13);
}

/* ローディング */

#loadingArea {
  padding: 80px 20px;
}

#loadingArea::before {
  content: "";
  display: block;
  width: 58px;
  height: 58px;
  margin: 0 auto 26px;
  border: 6px solid #f0e7f2;
  border-top-color: var(--pink);
  border-right-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#loadingText {
  font-size: 17px;
  font-weight: 900;
  color: #75657d;
}

/* 結果画面 */

#resultArea {
  position: relative;
  margin-top: 30px;
  padding: 28px 18px 30px;
  border: 3px solid white;
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 5%, rgba(255, 191, 221, 0.5), transparent 40%),
    rgba(255, 255, 255, 0.9);
  box-shadow:
    0 22px 60px rgba(137, 105, 157, 0.17),
    0 5px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(15px);
  animation: resultAppear 0.6s ease both;
}

#resultArea > p:first-child {
  margin: 24px 0 20px;
  font-size: 20px;
  font-weight: 950;
  color: #66556f;
}

#resultArea > p:first-child::before {
  content: "💖 ";
}

#resultImage {
  display: block;
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  object-fit: cover;
  border-radius: 26px;
  border: 5px solid white;
  background: #f4edf6;
  box-shadow:
    0 8px 25px rgba(126, 96, 139, 0.18),
    0 0 0 3px #ffd1e4;
}

/* スコア */

#score {
  position: relative;
  margin: 34px 0 18px;
  font-size: clamp(110px, 30vw, 160px);
  line-height: 0.9;
  font-weight: 950;
  letter-spacing: -0.08em;
  background: linear-gradient(
    135deg,
    #ff4f9a,
    #a06cff 55%,
    #46bff5
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 8px 20px rgba(190, 112, 178, 0.15);
  animation: scorePop 0.75s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

#resultMessage {
  margin: 0 0 26px;
  padding: 18px 14px;
  border: 2px solid #f1dce9;
  border-radius: 20px;
  background: #fff7fb;
  font-size: 17px;
  line-height: 1.7;
  font-weight: 800;
  color: #765c71;
}

/* アニメーション */

@keyframes sparkle {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }

  50% {
    transform: scale(1.2) rotate(10deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes resultAppear {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scorePop {
  from {
    opacity: 0;
    transform: scale(0.65);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 480px) {
  .container {
    width: min(100% - 20px, 560px);
    padding-top: 24px;
  }

  #startArea {
    padding: 28px 15px 22px;
  }

  h2 {
    margin-top: 24px;
  }

  .description {
    font-size: 14px;
  }

  button {
    min-height: 62px;
  }
}