@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: #1a0a00;
  background-image:
    radial-gradient(ellipse at top, #3d1a00 0%, #1a0a00 60%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif JP', serif;
  overflow-x: hidden;
}

.shrine {
  text-align: center;
  z-index: 10;
  padding: 2rem 1rem;
}

.title {
  font-size: 1.8rem;
  color: #f5d87a;
  text-shadow: 0 0 20px rgba(245, 216, 122, 0.6), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 0.3em;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* --- キャラクター --- */
.character-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.character-img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #f5d87a;
  box-shadow: 0 0 20px rgba(245, 216, 122, 0.4), 0 4px 12px rgba(0,0,0,0.6);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.speech-bubble {
  background: rgba(255, 248, 220, 0.95);
  color: #3a2800;
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 0.75rem 1.2rem;
  border-radius: 16px;
  border: 2px solid #d4b870;
  margin-bottom: 14px;
  position: relative;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: fadeIn 0.4s ease;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #d4b870;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(255, 248, 220, 0.95);
  z-index: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- 待機画面 --- */
.box-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.method-desc {
  color: #c9a96e;
  font-size: 0.85rem;
  line-height: 1.9;
  letter-spacing: 0.1em;
  border: 1px solid #6b4c10;
  padding: 0.8rem 1.4rem;
  border-radius: 4px;
  background: rgba(100, 50, 0, 0.2);
}

/* --- ボタン --- */
.draw-btn {
  background: linear-gradient(135deg, #c8860a, #8b5c00);
  color: #fff8e8;
  border: none;
  padding: 0.75rem 2.5rem;
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  letter-spacing: 0.3em;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(200, 134, 10, 0.4), 0 2px 4px rgba(0,0,0,0.5);
  transition: all 0.2s ease;
  position: relative;
}

.draw-btn::before {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 3px;
  border: 1px solid rgba(255, 220, 120, 0.3);
}

.draw-btn:hover {
  background: linear-gradient(135deg, #e09a1a, #a87010);
  box-shadow: 0 6px 20px rgba(200, 134, 10, 0.6), 0 2px 6px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}

.draw-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(200, 134, 10, 0.4);
}

.again-btn {
  margin-top: 1.5rem;
}

/* --- お尻燃焼エリア --- */
.butt-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  position: relative;
}

/* 火の粉用canvas（円の外側も含むので親に配置） */
.spark-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  pointer-events: none;
  z-index: 20;
}

.butt-container {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid #c04000;
  box-shadow: 0 0 40px rgba(255, 80, 0, 0.5), 0 0 80px rgba(255, 40, 0, 0.2);
  transition: box-shadow 0.3s ease;
}

.butt-container.burning {
  animation: shake 0.08s infinite alternate;
  box-shadow:
    0 0 60px rgba(255, 120, 0, 0.9),
    0 0 120px rgba(255, 60, 0, 0.6),
    0 0 200px rgba(255, 20, 0, 0.3);
}

@keyframes shake {
  from { transform: translate(-2px, -1px) rotate(-0.5deg); }
  to   { transform: translate(2px,  1px) rotate(0.5deg); }
}

.butt-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 炎オーバーレイ（3層） */
.fire-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.fire-overlay.burning {
  opacity: 1;
}

.fire-layer-1 {
  background: radial-gradient(ellipse at 50% 110%, rgba(255,220,0,0.85) 0%, rgba(255,100,0,0.6) 30%, transparent 65%);
  animation: flicker1 0.1s infinite alternate;
}
.fire-layer-2 {
  background: radial-gradient(ellipse at 40% 105%, rgba(255,140,0,0.7) 0%, rgba(255,40,0,0.5) 35%, transparent 60%);
  animation: flicker2 0.13s infinite alternate;
}
.fire-layer-3 {
  background: radial-gradient(ellipse at 60% 115%, rgba(255,60,0,0.8) 0%, rgba(200,0,0,0.4) 30%, transparent 55%);
  animation: flicker3 0.09s infinite alternate;
}
/* 全体を赤く照らす */
.fire-layer-4 {
  background: radial-gradient(ellipse at 50% 50%, rgba(255,80,0,0.25) 0%, transparent 80%);
  animation: flicker4 0.2s infinite alternate;
}

@keyframes flicker1 {
  from { transform: scaleY(1)    scaleX(1);    opacity: 0.85; }
  to   { transform: scaleY(1.12) scaleX(0.96); opacity: 1; }
}
@keyframes flicker2 {
  from { transform: scaleY(0.95) scaleX(1.04); opacity: 0.7; }
  to   { transform: scaleY(1.1)  scaleX(0.98); opacity: 0.9; }
}
@keyframes flicker3 {
  from { transform: scaleY(1.05) scaleX(0.97); opacity: 0.8; }
  to   { transform: scaleY(0.92) scaleX(1.03); opacity: 1; }
}
@keyframes flicker4 {
  from { opacity: 0.2; }
  to   { opacity: 0.45; }
}

/* ひびcanvas */
.crack-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.crack-canvas.visible {
  opacity: 1;
}

/* --- 結果紙 --- */
.result-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: unfold 0.6s ease forwards;
}

@keyframes unfold {
  from { opacity: 0; transform: scaleY(0.3) translateY(-20px); }
  to   { opacity: 1; transform: scaleY(1) translateY(0); }
}

.paper {
  background: linear-gradient(170deg, #fef9ef, #fdf0d0);
  width: 280px;
  padding: 2rem 1.5rem;
  border-radius: 2px;
  box-shadow:
    0 0 40px rgba(200, 134, 10, 0.3),
    0 10px 30px rgba(0,0,0,0.6),
    inset 0 0 60px rgba(200,160,80,0.1);
  border: 1px solid #d4b870;
  position: relative;
}

.paper::before {
  content: '';
  position: absolute;
  top: 6px; left: 6px; right: 6px; bottom: 6px;
  border: 1px solid rgba(180, 130, 50, 0.3);
  border-radius: 1px;
  pointer-events: none;
}

.paper-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.fortune-label {
  font-size: 0.75rem;
  color: #8b6914;
  letter-spacing: 0.4em;
}

.fortune-rank {
  font-size: 2.8rem;
  font-weight: 700;
  margin-top: 0.25rem;
  letter-spacing: 0.1em;
}

.rank-daikichi  { color: #c00000; text-shadow: 0 0 12px rgba(200,0,0,0.4); }
.rank-kichi     { color: #b06000; }
.rank-chukichi  { color: #4a7a00; }
.rank-shokichi  { color: #2a6a8a; }
.rank-suekichi  { color: #5a5a8a; }
.rank-kyo       { color: #404040; }
.rank-daikyo    { color: #1a1a1a; text-shadow: 0 0 8px rgba(0,0,0,0.5); }

.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #c8a055, transparent);
  margin: 0.75rem 0;
}

.fortune-items {
  text-align: left;
  margin-bottom: 1rem;
}

.fortune-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px dotted rgba(180,130,50,0.3);
  font-size: 0.85rem;
}

.fortune-item:last-child {
  border-bottom: none;
}

.item-label {
  color: #6b4c10;
  letter-spacing: 0.1em;
  min-width: 70px;
}

.item-value {
  color: #2c1a00;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.precure-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(180,130,50,0.3);
  text-align: center;
}

.precure-label {
  font-size: 0.7rem;
  color: #8b6914;
  letter-spacing: 0.15em;
  margin-bottom: 0.4rem;
}

.precure-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #8b1a6b;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
  text-shadow: 0 0 8px rgba(200, 50, 150, 0.2);
}

.precure-reason {
  font-size: 0.78rem;
  color: #3a2800;
  line-height: 1.7;
}

/* --- 提灯 --- */
.lantern {
  position: fixed;
  top: 30px;
  width: 40px;
  height: 60px;
  background: radial-gradient(ellipse at center, #ff6600 0%, #cc3300 60%, #8b1a00 100%);
  border-radius: 50% 50% 40% 40%;
  box-shadow: 0 0 30px rgba(255, 100, 0, 0.6), 0 0 60px rgba(255, 50, 0, 0.3);
  opacity: 0.85;
}

.lantern::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 12px;
  background: #8b5c00;
  border-radius: 2px;
}

.lantern::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 12px;
  background: #c8a055;
}

.lantern-left  { left: 20px; }
.lantern-right { right: 20px; }

@media (max-width: 400px) {
  .title { font-size: 1.5rem; }
  .paper { width: 260px; }
  .butt-container { width: 200px; height: 200px; }
}
