:root {
  --bg: #fffdf5;
  --bg2: #fff8e8;
  --gold: #f5a623;
  --orange: #ff8c00;
  --text: #3a2e1e;
  --text-dim: #8a7a60;
  --accent: #ff6b35;
  --accent2: #ffad33;
  --success: #4caf50;
  --border: #f0d88a;
  --border2: #e8c860;
  --box-bg: rgba(255, 248, 232, 0.97);
  --box-bg2: rgba(255, 240, 200, 0.6);
  --brown: #5a4020;
  --cream: #fff3d0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* 斜線ストライプ背景 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(-45deg,
      transparent,
      transparent 8px,
      rgba(245, 200, 100, 0.06) 8px,
      rgba(245, 200, 100, 0.06) 9px);
  pointer-events: none;
  z-index: 0;
}

/* 波型の上部装飾 */
.bg-school {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 50px;
  z-index: 2;
  pointer-events: none;
}

.bg-school svg {
  width: 100%;
  height: 50px;
}

.game-container {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  padding: 16px;
  padding-top: 46px;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
}

.screen.active {
  display: flex;
}

/* ===== アニメーション ===== */
@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 200%;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes glowPulse {

  0%,
  100% {
    text-shadow: 0 0 8px rgba(245, 166, 35, 0.3);
  }

  50% {
    text-shadow: 0 0 20px rgba(245, 166, 35, 0.7), 0 0 40px rgba(245, 166, 35, 0.2);
  }
}

@keyframes ring-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes sparkle {

  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.4);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.85);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-8px);
  }

  60% {
    transform: translateY(-4px);
  }
}

/* レアリティ用アニメーション */
@keyframes shimmerGold {
  0% {
    background-position: -200% center;
  }

  100% {
    background-position: 200% center;
  }
}

@keyframes rainbowBorder {
  0% {
    border-color: #ff4444;
  }

  16% {
    border-color: #ff8c00;
  }

  33% {
    border-color: #f5c842;
  }

  50% {
    border-color: #4caf50;
  }

  66% {
    border-color: #1da1f2;
  }

  83% {
    border-color: #c060ff;
  }

  100% {
    border-color: #ff4444;
  }
}

@keyframes cardGlowSSR {

  0%,
  100% {
    box-shadow: 0 0 16px rgba(255, 180, 50, 0.4), 0 4px 24px rgba(200, 140, 0, 0.2);
  }

  50% {
    box-shadow: 0 0 32px rgba(255, 200, 60, 0.7), 0 4px 32px rgba(230, 160, 0, 0.4);
  }
}

@keyframes cardGlowUR {
  0% {
    box-shadow: 0 0 20px rgba(255, 80, 80, 0.5), 0 4px 32px rgba(200, 0, 80, 0.2);
  }

  25% {
    box-shadow: 0 0 20px rgba(255, 160, 0, 0.5), 0 4px 32px rgba(200, 100, 0, 0.2);
  }

  50% {
    box-shadow: 0 0 20px rgba(80, 200, 80, 0.5), 0 4px 32px rgba(0, 150, 50, 0.2);
  }

  75% {
    box-shadow: 0 0 20px rgba(80, 120, 255, 0.5), 0 4px 32px rgba(0, 60, 200, 0.2);
  }

  100% {
    box-shadow: 0 0 20px rgba(200, 80, 255, 0.5), 0 4px 32px rgba(130, 0, 200, 0.2);
  }
}

@keyframes starSpin {
  from {
    transform: rotate(0deg) scale(1);
  }

  50% {
    transform: rotate(180deg) scale(1.2);
  }

  to {
    transform: rotate(360deg) scale(1);
  }
}

.particle {
  animation: sparkle 3s ease infinite;
}

.p1 {
  animation-delay: 0s;
}

.p2 {
  animation-delay: 0.5s;
}

.p3 {
  animation-delay: 1s;
}

.p4 {
  animation-delay: 1.5s;
}

.p5 {
  animation-delay: 2s;
}

.p6 {
  animation-delay: 2.5s;
}

/* ===== TITLE SCREEN ===== */
.title-header {
  text-align: center;
  padding-top: 8px;
  margin-bottom: 8px;
}

.title-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: white;
  font-size: 10px;
  font-family: 'DotGothic16', monospace;
  padding: 5px 16px;
  border-radius: 20px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
}

.title-logo {
  font-family: 'DotGothic16', monospace;
  font-size: 26px;
  color: var(--brown);
  line-height: 1.5;
  margin-bottom: 4px;
}

.title-sub-logo {
  color: var(--accent);
  font-size: 28px;
}

.title-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'DotGothic16', monospace;
}

.title-art {
  width: 200px;
  height: 200px;
  margin: 6px auto 10px;
  animation: float 4s ease-in-out infinite;
}

.ring1 {
  transform-origin: 110px 110px;
  animation: ring-rotate 20s linear infinite;
}

.ring2 {
  transform-origin: 110px 110px;
  animation: ring-rotate 15s linear infinite reverse;
}

/* RPGボックス */
.rpg-box {
  background: var(--box-bg);
  border: 2.5px solid var(--border2);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  box-shadow:
    0 2px 12px rgba(200, 160, 60, 0.15);
}

.rpg-box::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border: 1.5px solid rgba(240, 216, 138, 0.3);
  border-radius: 8px;
  pointer-events: none;
}

.rpg-box-corner {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 0 6px rgba(245, 166, 35, 0.4);
}

.rpg-box-corner.tl {
  top: -4px;
  left: -4px;
}

.rpg-box-corner.tr {
  top: -4px;
  right: -4px;
}

.rpg-box-corner.bl {
  bottom: -4px;
  left: -4px;
}

.rpg-box-corner.br {
  bottom: -4px;
  right: -4px;
}

.title-desc {
  font-size: 13px;
  line-height: 2;
  text-align: center;
  color: var(--text);
}

.title-desc .highlight {
  color: var(--accent);
  font-weight: 900;
}

.start-btn {
  width: 100%;
  padding: 18px;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  border: 2px solid var(--orange);
  border-radius: 12px;
  color: white;
  font-size: 18px;
  font-family: 'DotGothic16', monospace;
  cursor: pointer;
  letter-spacing: 4px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(255, 140, 0, 0.35);
}

.start-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 140, 0, 0.5);
}

.title-footer {
  text-align: center;
  padding: 14px 0 10px;
}

.back-link {
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent);
}

/* ===== QUESTION SCREEN ===== */
.question-header {
  padding: 8px 0 8px;
}

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.progress-label {
  font-family: 'DotGothic16', monospace;
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  font-weight: bold;
}

.progress-track {
  flex: 1;
  height: 14px;
  background: var(--cream);
  border: 2px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  border-radius: 6px;
  transition: width 0.5s ease;
}

.progress-steps {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  justify-content: center;
}

.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--border2);
  transition: all 0.3s;
}

.progress-dot.done {
  background: var(--success);
  border-color: var(--success);
}

.progress-dot.current {
  background: var(--gold);
  border-color: var(--gold);
  animation: pulse 1s infinite;
  box-shadow: 0 0 8px rgba(245, 166, 35, 0.5);
}

/* 質問イラスト */
.question-illustration {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  animation: fadeInScale 0.5s ease;
}

.question-illustration svg {
  width: 160px;
  height: 100px;
}

.question-box {
  margin-bottom: 10px;
  padding: 12px 16px;
}

.question-number {
  font-family: 'DotGothic16', monospace;
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 3px;
  margin-bottom: 6px;
  font-weight: bold;
}

.question-text {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--text);
  min-height: 44px;
}

.choices-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-btn {
  background: white;
  border: 2.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease both;
  box-shadow: 0 2px 6px rgba(200, 160, 60, 0.1);
}

.choice-btn:nth-child(1) {
  animation-delay: 0.05s;
}

.choice-btn:nth-child(2) {
  animation-delay: 0.10s;
}

.choice-btn:nth-child(3) {
  animation-delay: 0.15s;
}

.choice-btn:nth-child(4) {
  animation-delay: 0.20s;
}

.choice-letter {
  font-family: 'DotGothic16', monospace;
  font-size: 13px;
  color: white;
  background: var(--gold);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  font-weight: bold;
}

.choice-btn:hover {
  border-color: var(--accent);
  background: #fff8e8;
  transform: translateX(4px);
  box-shadow: -3px 0 0 var(--accent), 0 4px 12px rgba(255, 107, 53, 0.15);
}

.choice-btn.selected {
  border-color: var(--orange);
  background: #fff3d0;
  box-shadow: -4px 0 0 var(--orange);
  pointer-events: none;
}

/* ===== RESULT SCREEN ===== */
.result-header {
  text-align: center;
  padding: 12px 0 8px;
  animation: slideUp 0.5s ease;
}

.result-label {
  font-family: 'DotGothic16', monospace;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--accent);
  margin-bottom: 4px;
}

.result-acquired {
  font-family: 'DotGothic16', monospace;
  font-size: 22px;
  color: var(--brown);
  animation: glowPulse 2s infinite;
  letter-spacing: 4px;
}

.result-card {
  animation: slideUp 0.6s ease;
  transition: border-color 0.3s, box-shadow 0.3s;
}

/* ===== レアリティ別カードスタイル ===== */
.result-card.card-N {
  border-color: #ccc0a8;
  background: #faf8f3;
}

.result-card.card-R {
  border-color: #66bb6a;
  border-width: 3px;
  background: linear-gradient(160deg, #f0fff4 0%, #ffffff 100%);
  box-shadow: 0 2px 16px rgba(76, 175, 80, 0.15);
}

.result-card.card-SR {
  border-color: #42a5f5;
  border-width: 3px;
  background: linear-gradient(160deg, #e8f4ff 0%, #ffffff 100%);
  box-shadow: 0 2px 20px rgba(66, 165, 245, 0.2);
}

.result-card.card-SSR {
  border-color: #ffa726;
  border-width: 3.5px;
  background: linear-gradient(160deg, #fffde7 0%, #fff8e1 60%, #ffffff 100%);
  animation: slideUp 0.6s ease, cardGlowSSR 3s ease infinite;
}

.result-card.card-UR {
  border-width: 4px;
  background: linear-gradient(160deg, #fff8f0 0%, #f8f0ff 50%, #f0f8ff 100%);
  animation: slideUp 0.6s ease, cardGlowUR 4s linear infinite, rainbowBorder 4s linear infinite;
}

/* 角の装飾をレアリティに合わせる */
.card-N .rpg-box-corner {
  background: #aaa090;
  box-shadow: none;
}

.card-R .rpg-box-corner {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.4);
}

.card-SR .rpg-box-corner {
  background: #1da1f2;
  box-shadow: 0 0 8px rgba(29, 161, 242, 0.5);
}

.card-SSR .rpg-box-corner {
  background: #ffa726;
  box-shadow: 0 0 12px rgba(255, 167, 38, 0.7);
  width: 12px;
  height: 12px;
}

.card-UR .rpg-box-corner {
  width: 14px;
  height: 14px;
  animation: starSpin 3s linear infinite;
}

.card-UR .rpg-box-corner.tl {
  background: #ff6b6b;
  top: -5px;
  left: -5px;
}

.card-UR .rpg-box-corner.tr {
  background: #ffa726;
  top: -5px;
  right: -5px;
}

.card-UR .rpg-box-corner.bl {
  background: #4caf50;
  bottom: -5px;
  left: -5px;
}

.card-UR .rpg-box-corner.br {
  background: #1da1f2;
  bottom: -5px;
  right: -5px;
}

.rarity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* レアリティバッジ */
.rarity-badge {
  font-family: 'DotGothic16', monospace;
  font-size: 13px;
  padding: 5px 16px;
  border-radius: 20px;
  letter-spacing: 3px;
  font-weight: bold;
  position: relative;
  overflow: hidden;
}

.rarity-N {
  background: #e8e0d0;
  color: #8a7a60;
  border: 2px solid #ccc0a8;
}

.rarity-R {
  background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
  color: #1b5e20;
  border: 2px solid #66bb6a;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.rarity-SR {
  background: linear-gradient(135deg, #bbdefb, #90caf9);
  color: #0d47a1;
  border: 2px solid #42a5f5;
  box-shadow: 0 2px 10px rgba(66, 165, 245, 0.35);
}

.rarity-SSR {
  background: linear-gradient(90deg, #ffe082, #ffa726, #ffe082, #ffa726);
  background-size: 200% auto;
  color: #bf360c;
  border: 2px solid #ffa726;
  box-shadow: 0 2px 12px rgba(255, 167, 38, 0.5);
  animation: shimmerGold 2s linear infinite;
  font-size: 14px;
}

.rarity-UR {
  background: linear-gradient(90deg, #ff8a80, #ea80fc, #82b1ff, #ccff90, #ffff8d, #ff8a80);
  background-size: 300% auto;
  color: #4a148c;
  border: 2px solid transparent;
  box-shadow: 0 0 16px rgba(200, 80, 255, 0.5);
  animation: shimmerGold 2s linear infinite;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.skill-code {
  font-family: 'DotGothic16', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.skill-name {
  font-family: 'DotGothic16', monospace;
  font-size: 22px;
  color: var(--brown);
  margin-bottom: 4px;
  line-height: 1.4;
}

.skill-subtitle {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 8px;
  font-family: 'DotGothic16', monospace;
  letter-spacing: 1px;
  line-height: 1.6;
}

/* スキルタイプ行 */
.skill-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.skill-type-badge {
  font-family: 'DotGothic16', monospace;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 2px;
  font-weight: bold;
}

/* タイプ別色 */
#skill-type-badge[data-type="PASSIVE"] {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1.5px solid #66bb6a;
}

#skill-type-badge[data-type="ACTIVE"] {
  background: #fff3e0;
  color: #e65100;
  border: 1.5px solid #ffa726;
}

#skill-type-badge[data-type="AUTO"] {
  background: #e3f2fd;
  color: #0d47a1;
  border: 1.5px solid #42a5f5;
}

.skill-cost {
  font-family: 'DotGothic16', monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--cream);
  border: 1.5px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
}

/* 結果SVGアイコン */
.result-icon {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}

.result-icon svg {
  width: 80px;
  height: 80px;
}

/* ステータスバー */
.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-row {
  display: grid;
  grid-template-columns: 55px 1fr 26px;
  align-items: center;
  gap: 6px;
}

.stat-label {
  font-family: 'DotGothic16', monospace;
  font-size: 9px;
  color: var(--text-dim);
  text-align: right;
}

.stat-track {
  height: 10px;
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s ease;
}

.stat-val {
  font-family: 'DotGothic16', monospace;
  font-size: 9px;
  color: var(--text-dim);
  text-align: right;
}

.skill-desc {
  font-size: 12px;
  line-height: 1.9;
  padding: 12px 14px;
  color: var(--text);
  background: var(--box-bg2) !important;
  border-color: var(--border) !important;
  margin-top: 14px;
}

/* ===== RESULT BUTTONS ===== */
.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 24px;
  animation: slideUp 0.8s ease;
}

.share-btn {
  width: 100%;
  padding: 14px;
  background: #1da1f2;
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  font-family: 'DotGothic16', monospace;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(29, 161, 242, 0.3);
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(29, 161, 242, 0.4);
}

.retry-btn {
  width: 100%;
  padding: 12px;
  background: white;
  border: 2.5px solid var(--border2);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-family: 'DotGothic16', monospace;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
}

.retry-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.back-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 12px;
  font-family: 'DotGothic16', monospace;
  text-decoration: none;
  text-align: center;
  letter-spacing: 2px;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(245, 166, 35, 0.3);
}

.back-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(245, 166, 35, 0.5);
}