/* ==============================
   ホロメンおぼえてますか？
   シュールゲームス - Holographic Edition
   ============================== */

:root {
  --holo-blue: #00b8ff;
  --holo-pink: #e84080;
  --holo-purple: #9b59b6;
  --holo-gold: #ffd700;
  --card-back-base: #1a1040;
}

/* ==============================
   Animated Background
   ============================== */

body {
  font-family: 'M PLUS Rounded 1c', 'Zen Maru Gothic', sans-serif;
  background: linear-gradient(135deg,
    #ffe4f0 0%, #e4f0ff 20%, #f0e4ff 40%,
    #e4fff0 60%, #ffe4f0 80%, #e4f0ff 100%);
  background-size: 400% 400%;
  animation: bgShift 12s ease infinite;
  min-height: 100vh;
  min-height: 100dvh;
  color: #333;
  overflow-x: hidden;
}

@keyframes bgShift {
  0% { background-position: 0% 50%; }
  25% { background-position: 50% 0%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 100%; }
  100% { background-position: 0% 50%; }
}

/* ==============================
   Floating Background Stars
   ============================== */

.bg-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-star {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: 1.2rem;
  opacity: 0;
  animation: twinkleDrift var(--dur) ease-in-out var(--delay) infinite;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}

@keyframes twinkleDrift {
  0% { opacity: 0; transform: translateY(0) scale(0.5) rotate(0deg); }
  20% { opacity: 0.8; }
  50% { opacity: 1; transform: translateY(-30px) scale(1.1) rotate(180deg); }
  80% { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-60px) scale(0.5) rotate(360deg); }
}

/* ==============================
   Holographic Overlay
   ============================== */

.holo-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(
    135deg,
    rgba(255, 0, 100, 0.02) 0%,
    rgba(0, 184, 255, 0.02) 25%,
    rgba(155, 89, 182, 0.02) 50%,
    rgba(255, 215, 0, 0.02) 75%,
    rgba(255, 0, 100, 0.02) 100%
  );
  background-size: 200% 200%;
  animation: holoShift 8s linear infinite;
}

@keyframes holoShift {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 200%; }
}

/* ==============================
   Rainbow Flash Overlay
   ============================== */

.rainbow-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: linear-gradient(
    135deg,
    rgba(255, 0, 100, 0.15),
    rgba(0, 184, 255, 0.15),
    rgba(155, 89, 182, 0.15),
    rgba(255, 215, 0, 0.15)
  );
  opacity: 0;
  transition: opacity 0.15s;
}

.rainbow-flash.active {
  animation: flashIn 0.5s ease-out forwards;
}

@keyframes flashIn {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ==============================
   Back to top link
   ============================== */

.back-to-top-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  color: var(--holo-pink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.92);
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(232, 64, 128, 0.15);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(8px);
}

.back-to-top-link:hover {
  background: #fff;
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(232, 64, 128, 0.25);
}

/* ==============================
   Screen management
   ============================== */

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 20px;
  position: relative;
  z-index: 2;
}

.screen.active {
  display: flex;
}

/* ゲーム画面は上から配置（カードグリッドが大きいのでcenterだとヘッダーが見えなくなる） */
#game-screen.active {
  justify-content: flex-start;
  padding-top: 50px;
}

/* ==============================
   Title Screen
   ============================== */

.title-container {
  text-align: center;
  position: relative;
  padding: 50px 30px;
}

/* Holographic frame around title area */
.title-holo-frame {
  position: absolute;
  inset: 0;
  border-radius: 30px;
  padding: 3px;
  background: linear-gradient(
    90deg,
    #ff006e, #00b8ff, #9b59b6, #ffd700,
    #ff006e, #00b8ff, #9b59b6, #ffd700
  );
  background-size: 300% 100%;
  animation: holoFrame 4s linear infinite;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.5;
}

@keyframes holoFrame {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* Title floating sparkle decorations */
.title-sparkle-deco {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.7));
}

.title-sparkle-deco.s1 { top: 5%; left: 8%; animation: sparkleFloat 3s ease-in-out 0s infinite; }
.title-sparkle-deco.s2 { top: 12%; right: 10%; animation: sparkleFloat 3.5s ease-in-out 0.5s infinite; }
.title-sparkle-deco.s3 { bottom: 25%; left: 5%; animation: sparkleFloat 2.8s ease-in-out 1s infinite; }
.title-sparkle-deco.s4 { top: 30%; right: 3%; animation: sparkleFloat 4s ease-in-out 0.3s infinite; }
.title-sparkle-deco.s5 { bottom: 15%; right: 8%; animation: sparkleFloat 3.2s ease-in-out 1.5s infinite; color: #e84080; }
.title-sparkle-deco.s6 { bottom: 35%; left: 12%; animation: sparkleFloat 3.8s ease-in-out 0.8s infinite; }

@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 0.7; }
  50% { transform: translateY(-15px) scale(1.3) rotate(180deg); opacity: 1; }
}

/* Rainbow gradient title */
.game-title {
  font-family: 'Hachi Maru Pop', cursive;
  font-size: clamp(2rem, 7vw, 3.5rem);
  background: linear-gradient(
    90deg,
    #ff006e, #00b8ff, #9b59b6, #ffd700,
    #ff006e, #00b8ff
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowText 4s linear infinite;
  text-shadow: none;
  margin-bottom: 10px;
  line-height: 1.3;
  filter: drop-shadow(2px 2px 4px rgba(232, 64, 128, 0.3));
}

@keyframes rainbowText {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

.game-subtitle {
  font-family: 'Dela Gothic One', 'Hachi Maru Pop', cursive;
  font-size: clamp(1rem, 3.5vw, 1.6rem);
  color: var(--holo-pink);
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(232, 64, 128, 0.3);
}

.game-description {
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  color: #888;
  margin-bottom: 30px;
  line-height: 1.6;
}

.title-nose-hair-deco {
  position: absolute;
  font-size: 2rem;
  top: 10px;
  animation: wiggle 2s ease-in-out infinite;
}

.title-nose-hair-deco.left {
  left: 10px;
}

.title-nose-hair-deco.right {
  right: 10px;
  animation-delay: 0.5s;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
}

/* Title preview faces - multiple bouncing characters */
.title-character-preview {
  margin: 20px auto 30px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.preview-face {
  width: 80px;
  height: 80px;
  background: #ffe8d6;
  border-radius: 50%;
  position: relative;
  border: 3px solid #ffcba4;
  animation: floatBig 3s ease-in-out infinite;
  box-shadow: 0 4px 20px rgba(232, 64, 128, 0.2);
}

.preview-face.face-1 {
  width: 100px;
  height: 100px;
  animation: floatBig 3s ease-in-out infinite;
}

.preview-face.face-2 {
  width: 70px;
  height: 70px;
  animation: floatBig 2.5s ease-in-out 0.5s infinite;
  align-self: flex-end;
}

.preview-face.face-3 {
  width: 60px;
  height: 60px;
  animation: floatBig 3.5s ease-in-out 1s infinite;
}

@keyframes floatBig {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-18px) rotate(3deg); }
}

.preview-eye {
  width: 12px;
  height: 14px;
  background: #333;
  border-radius: 50%;
  position: absolute;
  top: 32%;
}

.preview-eye.left { left: 28%; }
.preview-eye.right { right: 28%; }

.preview-eye.happy {
  height: 6px;
  border-radius: 0 0 12px 12px;
  top: 36%;
}

.preview-nose {
  width: 10px;
  height: 8px;
  background: #f5c4a1;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%);
}

.preview-nose-hair {
  position: absolute;
  top: 52%;
  width: 20px;
  height: 8px;
  border-bottom: 3px wavy #555;
}

.preview-nose-hair.left {
  left: 22%;
  border-bottom: 3px solid #555;
  border-radius: 0 0 0 50%;
  transform: rotate(10deg);
}

.preview-nose-hair.right {
  right: 22%;
  border-bottom: 3px solid #555;
  border-radius: 0 0 50% 0;
  transform: rotate(-10deg);
}

.preview-mouth {
  width: 14px;
  height: 7px;
  border-bottom: 3px solid #e88;
  border-radius: 0 0 14px 14px;
  position: absolute;
  bottom: 25%;
  left: 50%;
  transform: translateX(-50%);
}

.preview-mouth.happy {
  width: 20px;
  height: 10px;
  border-bottom: 3px solid #e88;
  border-radius: 0 0 20px 20px;
}

/* Start button with rainbow shimmer */
.btn-start {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--holo-pink), #ff6b9d, var(--holo-blue));
  background-size: 200% 200%;
  border: none;
  padding: 16px 44px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow:
    0 4px 20px rgba(232, 64, 128, 0.4),
    0 0 40px rgba(0, 184, 255, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: btnPulse 2s ease-in-out infinite, btnShimmer 3s linear infinite;
  position: relative;
  overflow: hidden;
}

.btn-start::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: shimmerSlide 2.5s linear infinite;
  border-radius: inherit;
}

@keyframes shimmerSlide {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes btnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes btnShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.btn-start:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow:
    0 8px 30px rgba(232, 64, 128, 0.5),
    0 0 60px rgba(0, 184, 255, 0.25);
  animation: btnShimmer 1.5s linear infinite;
}

.btn-start:active {
  transform: translateY(0) scale(0.98);
}

.studio-name {
  margin-top: 24px;
  font-weight: 700;
  color: #bbb;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

/* ==============================
   Game Screen
   ============================== */

.game-header {
  width: 100%;
  max-width: 420px;
  margin-bottom: 12px;
}

/* Game info bar with holographic shine */
.game-info {
  display: flex;
  justify-content: space-between;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9),
    rgba(240, 245, 255, 0.9),
    rgba(255, 240, 250, 0.9)
  );
  background-size: 200% 200%;
  animation: infoShine 5s ease infinite;
  border-radius: 20px;
  padding: 12px 18px;
  box-shadow:
    0 2px 15px rgba(0, 184, 255, 0.1),
    0 2px 15px rgba(232, 64, 128, 0.1);
  border: 2px solid rgba(0, 184, 255, 0.15);
  position: relative;
  overflow: hidden;
}

.game-info::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 60%
  );
  background-size: 200% 100%;
  animation: shimmerSlide 4s linear infinite;
}

@keyframes infoShine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.info-item {
  font-weight: 700;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  color: var(--holo-pink);
  position: relative;
  z-index: 1;
}

.info-item .timer-item {
  color: var(--holo-blue);
}

.info-item .pairs-item {
  color: var(--holo-purple);
}

#turn-count { color: var(--holo-pink); }
#timer { color: var(--holo-blue); }
#pairs-found { color: var(--holo-purple); }

/* Message Bubble with rainbow border */
.message-bubble {
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid transparent;
  border-image: linear-gradient(
    90deg,
    #ff006e, #00b8ff, #9b59b6, #ffd700, #ff006e
  ) 1;
  border-radius: 24px;
  padding: 10px 24px;
  margin-bottom: 12px;
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-weight: 700;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  color: var(--holo-pink);
  box-shadow:
    0 4px 20px rgba(232, 64, 128, 0.15),
    0 0 30px rgba(0, 184, 255, 0.1);
  transition: opacity 0.3s, transform 0.3s;
  min-height: 44px;
  display: flex;
  align-items: center;
  position: relative;
  /* border-image doesn't work with border-radius, so we use outline trick */
  border: none;
  outline: 3px solid var(--holo-pink);
  outline-offset: -3px;
  animation: bubbleBorderColor 3s linear infinite;
}

@keyframes bubbleBorderColor {
  0% { outline-color: #ff006e; }
  25% { outline-color: #00b8ff; }
  50% { outline-color: #9b59b6; }
  75% { outline-color: #ffd700; }
  100% { outline-color: #ff006e; }
}

.message-bubble.hidden {
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  pointer-events: none;
}

.message-bubble.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Card Grid with subtle glow */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 420px;
  -webkit-perspective: 1000px;
  perspective: 1000px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 30px rgba(0, 184, 255, 0.08),
    0 0 60px rgba(232, 64, 128, 0.05),
    inset 0 0 30px rgba(255, 255, 255, 0.1);
  /* preserve-3dが子要素で壊れないようにする */
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

/* ==============================
   Card Styles
   ============================== */

.card {
  aspect-ratio: 3 / 4;
  cursor: pointer;
  position: relative;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.flipped {
  transform: rotateY(180deg);
}

.card.matched {
  transform: rotateY(180deg);
}

/* Matched cards rainbow glow pulse */
.card.matched .card-front {
  animation: rainbowGlow 2s ease-in-out infinite;
}

@keyframes rainbowGlow {
  0% { box-shadow: 0 0 10px rgba(255, 0, 110, 0.5), 0 0 25px rgba(255, 0, 110, 0.2); }
  33% { box-shadow: 0 0 10px rgba(0, 184, 255, 0.5), 0 0 25px rgba(0, 184, 255, 0.2); }
  66% { box-shadow: 0 0 10px rgba(155, 89, 182, 0.5), 0 0 25px rgba(155, 89, 182, 0.2); }
  100% { box-shadow: 0 0 10px rgba(255, 0, 110, 0.5), 0 0 25px rgba(255, 0, 110, 0.2); }
}

/* Matched cards floating star decorations */
.card.matched::after {
  content: '✦';
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 0.8rem;
  animation: matchStar 1.5s ease-in-out infinite;
  z-index: 10;
  filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.8));
}

.card.matched::before {
  content: '✧';
  position: absolute;
  bottom: -6px;
  left: -2px;
  font-size: 0.7rem;
  animation: matchStar 1.5s ease-in-out 0.5s infinite;
  z-index: 10;
  filter: drop-shadow(0 0 3px rgba(0, 184, 255, 0.8));
}

@keyframes matchStar {
  0%, 100% { opacity: 0.5; transform: scale(0.8) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
}

/* Card back with holographic shimmer */
.card-back {
  z-index: 1;
  background: linear-gradient(135deg, #1a1040, #2d1b69, #1a1040);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(0, 184, 255, 0.4);
  box-shadow:
    0 3px 15px rgba(0, 0, 0, 0.2),
    inset 0 0 20px rgba(0, 184, 255, 0.1);
  position: relative;
  overflow: hidden;
}

/* Holographic shimmer overlay on card back */
.card-back::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    125deg,
    transparent 0%,
    rgba(255, 0, 110, 0.15) 15%,
    transparent 25%,
    rgba(0, 184, 255, 0.15) 40%,
    transparent 50%,
    rgba(155, 89, 182, 0.15) 65%,
    transparent 75%,
    rgba(255, 215, 0, 0.15) 90%,
    transparent 100%
  );
  background-size: 200% 200%;
  animation: holoShimmer 3s linear infinite;
  z-index: 1;
  pointer-events: none;
}

.card-back::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 35%,
    rgba(255, 255, 255, 0.2) 45%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0.2) 55%,
    transparent 65%
  );
  background-size: 250% 100%;
  animation: cardShine 2.5s ease-in-out infinite;
  z-index: 2;
  pointer-events: none;
}

@keyframes holoShimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 200%; }
}

@keyframes cardShine {
  0% { background-position: -250% 0; }
  100% { background-position: 250% 0; }
}

/* Nose hair pattern on card back */
.card-back-pattern {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  align-items: center;
  justify-items: center;
  padding: 4px;
  position: relative;
  z-index: 0;
}

.card-back-pattern span {
  color: rgba(100, 150, 255, 0.3);
  font-weight: 900;
  font-size: clamp(0.6rem, 2vw, 0.9rem);
}

.card-front {
  z-index: 2;
  background: #fff;
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid #ffb8d9;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.12);
  padding: 4px;
}

/* ==============================
   Character Face (CSS Art)
   ============================== */

.char-face-container {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.char-face {
  width: clamp(52px, 14vw, 76px);
  height: clamp(52px, 14vw, 76px);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

/* Hair base */
.char-hair {
  position: absolute;
  width: 110%;
  height: 65%;
  top: -12%;
  left: -5%;
  border-radius: 50% 50% 30% 30%;
  z-index: 2;
}

/* Skin */
.char-skin {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #ffe8d6;
  border-radius: 50%;
  z-index: 1;
  border: 2px solid #f5c4a1;
}

/* Eyes */
.char-eye {
  width: clamp(6px, 1.8vw, 10px);
  height: clamp(8px, 2.2vw, 12px);
  background: #333;
  border-radius: 50%;
  position: absolute;
  top: 36%;
  z-index: 3;
}

.char-eye.left { left: 22%; }
.char-eye.right { right: 22%; }

/* Eye shine */
.char-eye::after {
  content: '';
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  right: 1px;
}

/* Nose */
.char-nose {
  width: 8px;
  height: 6px;
  background: #f5c4a1;
  border-radius: 50%;
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}

/* NOSE HAIR - The signature feature! */
.char-nose-hair {
  position: absolute;
  top: 55%;
  z-index: 5;
  width: 0;
  height: 0;
}

.char-nose-hair.left {
  left: 25%;
}

.char-nose-hair.right {
  right: 25%;
}

.char-nose-hair::before,
.char-nose-hair::after {
  content: '';
  position: absolute;
  height: 2.5px;
  background: #444;
  border-radius: 2px;
}

.char-nose-hair.left::before {
  width: clamp(10px, 3vw, 16px);
  top: 0;
  right: 0;
  transform: rotate(25deg);
  transform-origin: right center;
}

.char-nose-hair.left::after {
  width: clamp(8px, 2.5vw, 14px);
  top: 4px;
  right: 0;
  transform: rotate(40deg);
  transform-origin: right center;
}

.char-nose-hair.right::before {
  width: clamp(10px, 3vw, 16px);
  top: 0;
  left: 0;
  transform: rotate(-25deg);
  transform-origin: left center;
}

.char-nose-hair.right::after {
  width: clamp(8px, 2.5vw, 14px);
  top: 4px;
  left: 0;
  transform: rotate(-40deg);
  transform-origin: left center;
}

/* Extra curly nose hair */
.char-nose-hair-extra {
  position: absolute;
  top: 58%;
  z-index: 5;
}

.char-nose-hair-extra.left {
  left: 18%;
}

.char-nose-hair-extra.right {
  right: 18%;
}

.char-nose-hair-extra::before {
  content: '';
  position: absolute;
  width: clamp(6px, 2vw, 10px);
  height: 2px;
  background: #444;
  border-radius: 2px;
}

.char-nose-hair-extra.left::before {
  transform: rotate(55deg);
}

.char-nose-hair-extra.right::before {
  transform: rotate(-55deg);
}

/* Mouth */
.char-mouth {
  width: 10px;
  height: 5px;
  border-bottom: 2.5px solid #e88;
  border-radius: 0 0 10px 10px;
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
}

/* Blush */
.char-blush {
  position: absolute;
  width: 10px;
  height: 6px;
  background: rgba(255, 150, 150, 0.4);
  border-radius: 50%;
  top: 56%;
  z-index: 3;
}

.char-blush.left { left: 12%; }
.char-blush.right { right: 12%; }

/* Character name */
.char-name {
  font-family: 'Hachi Maru Pop', cursive;
  font-size: clamp(0.5rem, 1.8vw, 0.7rem);
  color: var(--holo-pink);
  text-align: center;
  margin-top: 2px;
  white-space: nowrap;
}

/* ==============================
   Character-specific accessories
   ============================== */

/* 1. ソラちゃん - blue hair */
.char-type-0 .char-hair { background: linear-gradient(135deg, #4a9eff, #2878e0); }
.char-type-0 .char-eye { background: #2878e0; }

/* 2. フブちゃん - white hair, fox ears */
.char-type-1 .char-hair { background: linear-gradient(135deg, #f0f0f0, #ddd); }
.char-type-1 .char-eye { background: #5bc0de; }

.fox-ear {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 3;
  border-left: clamp(6px, 1.8vw, 10px) solid transparent;
  border-right: clamp(6px, 1.8vw, 10px) solid transparent;
  border-bottom: clamp(14px, 4vw, 22px) solid #f0f0f0;
}

.fox-ear.left {
  top: -18%;
  left: 5%;
  transform: rotate(-15deg);
}

.fox-ear.right {
  top: -18%;
  right: 5%;
  transform: rotate(15deg);
}

.fox-ear-inner {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 4;
  border-left: clamp(3px, 1vw, 6px) solid transparent;
  border-right: clamp(3px, 1vw, 6px) solid transparent;
  border-bottom: clamp(8px, 2.5vw, 14px) solid #ffb8c6;
}

.fox-ear-inner.left {
  top: -10%;
  left: 10%;
  transform: rotate(-15deg);
}

.fox-ear-inner.right {
  top: -10%;
  right: 10%;
  transform: rotate(15deg);
}

/* 3. ぺこちゃん - orange hair, bunny ears */
.char-type-2 .char-hair { background: linear-gradient(135deg, #ff9f43, #ee7621); }
.char-type-2 .char-eye { background: #ff6b35; }

.bunny-ear {
  position: absolute;
  width: clamp(8px, 2.2vw, 12px);
  height: clamp(24px, 6vw, 36px);
  background: #ff9f43;
  border-radius: 50% 50% 30% 30%;
  z-index: 3;
}

.bunny-ear.left {
  top: -32%;
  left: 18%;
  transform: rotate(-10deg);
}

.bunny-ear.right {
  top: -32%;
  right: 18%;
  transform: rotate(10deg);
}

.bunny-ear-inner {
  position: absolute;
  width: clamp(4px, 1.2vw, 6px);
  height: clamp(16px, 4vw, 24px);
  background: #ffcba4;
  border-radius: 50%;
  z-index: 4;
}

.bunny-ear-inner.left {
  top: -26%;
  left: 20%;
  transform: rotate(-10deg);
}

.bunny-ear-inner.right {
  top: -26%;
  right: 20%;
  transform: rotate(10deg);
}

/* 4. マリちゃん - red hair, pirate hat */
.char-type-3 .char-hair { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.char-type-3 .char-eye { background: #c0392b; }

.pirate-hat {
  position: absolute;
  width: 120%;
  height: 30%;
  background: #2c3e50;
  top: -22%;
  left: -10%;
  border-radius: 50% 50% 0 0;
  z-index: 5;
}

.pirate-hat::before {
  content: '☠';
  position: absolute;
  font-size: clamp(0.5rem, 1.5vw, 0.8rem);
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
}

.pirate-hat-brim {
  position: absolute;
  width: 130%;
  height: 6px;
  background: #2c3e50;
  top: -2%;
  left: -15%;
  border-radius: 3px;
  z-index: 5;
}

/* 5. スイちゃん - pink/blue gradient hair */
.char-type-4 .char-hair { background: linear-gradient(135deg, #ff6b9d, #6bb5ff); }
.char-type-4 .char-eye { background: #9b59b6; }

.star-clip {
  position: absolute;
  top: -5%;
  right: 5%;
  z-index: 6;
  font-size: clamp(0.6rem, 1.8vw, 0.9rem);
  color: #ffd700;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.7);
  animation: starTwinkle 1.5s ease-in-out infinite;
}

@keyframes starTwinkle {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.2); filter: brightness(1.3); }
}

/* 6. あくちゃん - purple hair, horns */
.char-type-5 .char-hair { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.char-type-5 .char-eye { background: #e74c3c; }

.horn {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 3;
  border-left: clamp(4px, 1.2vw, 7px) solid transparent;
  border-right: clamp(4px, 1.2vw, 7px) solid transparent;
  border-bottom: clamp(14px, 4vw, 22px) solid #e74c3c;
}

.horn.left {
  top: -20%;
  left: 10%;
  transform: rotate(-15deg);
}

.horn.right {
  top: -20%;
  right: 10%;
  transform: rotate(15deg);
}

/* 7. ころちゃん - yellow/brown hair, dog ears */
.char-type-6 .char-hair { background: linear-gradient(135deg, #f9ca24, #c8a415); }
.char-type-6 .char-eye { background: #d35400; }

.dog-ear {
  position: absolute;
  width: clamp(12px, 3.5vw, 18px);
  height: clamp(16px, 4.5vw, 24px);
  background: #c8a415;
  border-radius: 0 0 50% 50%;
  z-index: 3;
}

.dog-ear.left {
  top: -8%;
  left: -8%;
  transform: rotate(20deg);
}

.dog-ear.right {
  top: -8%;
  right: -8%;
  transform: rotate(-20deg);
}

/* 8. みこちゃん - pink hair, shrine maiden headpiece */
.char-type-7 .char-hair { background: linear-gradient(135deg, #ff8fab, #ff6b9d); }
.char-type-7 .char-eye { background: #e91e63; }

.miko-headpiece {
  position: absolute;
  width: 80%;
  height: 10px;
  background: #fff;
  top: -8%;
  left: 10%;
  border-radius: 3px;
  z-index: 5;
  border: 1.5px solid #e74c3c;
}

.miko-headpiece::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: #e74c3c;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.miko-ribbon {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid #e74c3c;
  z-index: 5;
}

.miko-ribbon.left {
  top: 0%;
  left: 2%;
}

.miko-ribbon.right {
  top: 0%;
  right: 2%;
}

/* ==============================
   Result Screen
   ============================== */

.result-container {
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 40px 30px;
  border-radius: 28px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.1),
    0 0 60px rgba(232, 64, 128, 0.1),
    0 0 60px rgba(0, 184, 255, 0.08);
  max-width: 380px;
  width: 90%;
  position: relative;
  border: 2px solid rgba(232, 64, 128, 0.15);
}

/* Star shower on result screen */
.result-stars-shower {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.shower-star {
  position: absolute;
  left: var(--sx);
  top: -20px;
  font-size: 1.2rem;
  animation: starShower 2s ease-in var(--sd) infinite;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}

@keyframes starShower {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(360deg); opacity: 0; }
}

.result-title {
  font-family: 'Dela Gothic One', 'Hachi Maru Pop', cursive;
  font-size: clamp(1.6rem, 5.5vw, 2.5rem);
  background: linear-gradient(
    90deg,
    #ff006e, #00b8ff, #ffd700, #9b59b6, #ff006e
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowText 3s linear infinite;
  margin-bottom: 20px;
  filter: drop-shadow(2px 2px 4px rgba(232, 64, 128, 0.3));
  position: relative;
  z-index: 1;
}

.result-character {
  margin: 16px auto;
  position: relative;
  z-index: 1;
}

.result-face {
  width: 90px;
  height: 90px;
  background: #ffe8d6;
  border-radius: 50%;
  margin: 0 auto;
  position: relative;
  border: 3px solid #ffcba4;
  animation: celebrateBounce 1s ease-in-out infinite;
  box-shadow: 0 4px 20px rgba(232, 64, 128, 0.3);
}

@keyframes celebrateBounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  25% { transform: translateY(-12px) rotate(5deg); }
  50% { transform: translateY(0) rotate(-3deg); }
  75% { transform: translateY(-8px) rotate(3deg); }
}

.result-stats {
  margin: 20px 0;
  position: relative;
  z-index: 1;
}

.result-stat {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #555;
  margin: 8px 0;
}

/* Rainbow rating text */
.result-rating {
  font-family: 'Hachi Maru Pop', cursive;
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  background: linear-gradient(
    90deg,
    #ff006e, #ffd700, #00b8ff, #ff006e
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowText 3s linear infinite;
  margin: 20px 0;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

/* ==============================
   Sparkle particle (spawned by JS)
   ============================== */

.sparkle-particle {
  position: fixed;
  pointer-events: none;
  z-index: 998;
  font-size: 1rem;
  animation: sparkleRise 1s ease-out forwards;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.8));
}

@keyframes sparkleRise {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0.3) rotate(360deg);
  }
}

.sparkle-particle.heart {
  filter: drop-shadow(0 0 4px rgba(232, 64, 128, 0.8));
  animation: heartFloat 1.2s ease-out forwards;
}

@keyframes heartFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translateY(-50px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) scale(0.8);
  }
}

/* Big star shower for game complete */
.celebration-star {
  position: fixed;
  pointer-events: none;
  z-index: 997;
  font-size: 1.5rem;
  animation: celebrationFall 2.5s ease-in forwards;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
}

@keyframes celebrationFall {
  0% {
    opacity: 1;
    transform: translateY(-20px) rotate(0deg) scale(0);
  }
  20% {
    transform: translateY(0) rotate(72deg) scale(1.2);
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg) scale(0.5);
  }
}

/* ==============================
   Animations
   ============================== */

@keyframes cardBounce {
  0% { transform: rotateY(180deg) scale(1); }
  30% { transform: rotateY(180deg) scale(1.12); }
  60% { transform: rotateY(180deg) scale(0.95); }
  100% { transform: rotateY(180deg) scale(1); }
}

.card.match-bounce {
  animation: cardBounce 0.5s ease-out;
}

/* Wrong match: red flash + shake */
@keyframes wrongShake {
  0%, 100% { transform: rotateY(180deg) translateX(0); }
  15% { transform: rotateY(180deg) translateX(-6px); }
  30% { transform: rotateY(180deg) translateX(6px); }
  45% { transform: rotateY(180deg) translateX(-5px); }
  60% { transform: rotateY(180deg) translateX(5px); }
  75% { transform: rotateY(180deg) translateX(-3px); }
  90% { transform: rotateY(180deg) translateX(3px); }
}

.card.wrong-shake {
  animation: wrongShake 0.5s ease-out;
}

.card.wrong-shake .card-front {
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.5), inset 0 0 20px rgba(255, 0, 0, 0.1);
  border-color: rgba(255, 0, 0, 0.5);
}

/* ==============================
   Disclaimer
   ============================== */

.disclaimer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 8px 64px;
  text-align: center;
  font-size: 0.65rem;
  color: #aaa;
  border-top: 1px solid #eee;
  z-index: 100;
  box-sizing: border-box;
}

/* 共通の音量・シェアボタンをディスクレイマーの上に逃がす */
.sg-sound-toggle,
.sg-share-btn {
  bottom: calc(8px + 2.4em + 16px + env(safe-area-inset-bottom, 0px));
}

/* ==============================
   Responsive
   ============================== */

@media (min-width: 480px) {
  .card-grid {
    gap: 10px;
  }
}

@media (min-width: 600px) {
  .card-grid {
    gap: 12px;
    max-width: 480px;
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  .screen {
    padding: 10px;
    min-height: auto;
  }

  .card-grid {
    max-width: 380px;
    gap: 6px;
  }

  .title-container {
    padding: 20px;
  }

  .title-character-preview {
    margin: 10px auto 16px;
  }

  .game-description {
    margin-bottom: 12px;
  }
}
