@import url('https://fonts.googleapis.com/css2?family=Kaisei+Decol:wght@400;700&family=Zen+Maru+Gothic:wght@400;500;700&display=swap');

/* ===== 子ども向け「やさしい夜」テーマ ===== */
:root {
  --bg: #1b2a4a;
  --room-bg: #243558;
  --card: #2e4270;
  --accent: #FFD93D;
  --accent2: #FF7979;
  --accent3: #55E6A5;
  --text: #F7F3EB;
  --text-sub: #B8C8E0;
  --border: #4A6494;
  --shadow: rgba(255, 217, 61, 0.3);
  --glow: rgba(85, 230, 165, 0.25);
}

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

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(85,130,200,0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(130,100,200,0.12) 0%, transparent 60%);
  color: var(--text);
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== ほし（やさしい夜空） ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(2px 2px at 12% 18%, rgba(255,255,200,0.5) 0%, transparent 100%),
    radial-gradient(2px 2px at 30% 45%, rgba(255,255,200,0.35) 0%, transparent 100%),
    radial-gradient(2px 2px at 55% 12%, rgba(255,255,200,0.45) 0%, transparent 100%),
    radial-gradient(2px 2px at 75% 30%, rgba(255,255,200,0.4) 0%, transparent 100%),
    radial-gradient(2px 2px at 88% 55%, rgba(255,255,200,0.35) 0%, transparent 100%),
    radial-gradient(3px 3px at 45% 72%, rgba(255,217,61,0.3) 0%, transparent 100%),
    radial-gradient(2px 2px at 20% 80%, rgba(255,255,200,0.3) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

/* ===== レイアウト ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 18px 48px;
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
.room-header {
  text-align: center;
  margin-bottom: 20px;
  padding-top: 16px;
}

.room-title {
  font-family: 'Kaisei Decol', serif;
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  color: var(--accent);
  text-shadow: 0 2px 12px var(--shadow);
  letter-spacing: 0.06em;
}

.room-subtitle {
  font-size: 0.95rem;
  color: var(--text-sub);
  margin-top: 6px;
  line-height: 1.6;
}

/* ===== プログレスバー ===== */
.progress-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.progress-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.4s;
  border: 2px solid transparent;
}

.progress-dot.done {
  background: var(--accent3);
  box-shadow: 0 0 10px var(--glow);
  border-color: rgba(85,230,165,0.4);
}

.progress-dot.current {
  background: var(--accent);
  box-shadow: 0 0 12px var(--shadow);
  transform: scale(1.4);
  border-color: rgba(255,217,61,0.4);
}

/* ===== へやの表示 ===== */
.room-visual {
  background: var(--room-bg);
  border: 3px solid var(--border);
  border-radius: 24px;
  padding: 28px 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}

.room-visual::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -30%;
  width: 160%;
  height: 160%;
  background: radial-gradient(ellipse at 40% 30%, rgba(255,217,61,0.06) 0%, transparent 60%);
  pointer-events: none;
}

.room-emoji-scene {
  font-size: clamp(3rem, 10vw, 4rem);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
}

.room-description {
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text);
  text-align: center;
}

/* ===== コインのヒント ===== */
.coin-hint {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(85,230,165,0.08);
  border: 2px solid rgba(85,230,165,0.25);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

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

.coin-avatar {
  font-size: 2.4rem;
  flex-shrink: 0;
}

.coin-text {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--accent3);
}

.coin-text strong {
  display: block;
  font-size: 0.8rem;
  color: rgba(85,230,165,0.6);
  margin-bottom: 4px;
}

/* ===== アイテムグリッド ===== */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.item-card {
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 18px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.item-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(255,217,61,0.15);
}

.item-card.obtained {
  border-color: var(--accent3);
  background: rgba(85,230,165,0.1);
  cursor: default;
  transform: none;
}

.item-card.obtained::before {
  content: '✓ ゲット！';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.7rem;
  color: var(--accent3);
  font-weight: 700;
}

.item-emoji {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 8px;
}

.item-name {
  font-size: 0.9rem;
  color: var(--text-sub);
  display: block;
  font-weight: 500;
}

/* ===== パズルボックス ===== */
.puzzle-box {
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 20px;
}

.puzzle-title {
  font-size: 1rem;
  color: var(--text-sub);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.puzzle-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.puzzle-input {
  flex: 1;
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--text);
  font-family: 'Kaisei Decol', serif;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 0.2em;
  outline: none;
  transition: border-color 0.2s;
}

.puzzle-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,217,61,0.15);
}

/* ===== ボタン ===== */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #1b2a4a;
}

.btn-primary:hover {
  background: #FFE566;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--shadow);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-success {
  background: var(--accent3);
  color: #1b2a4a;
  width: 100%;
  padding: 18px;
  font-size: 1.1rem;
  border-radius: 18px;
  margin-top: 8px;
}

.btn-success:hover {
  background: #6FFFB8;
  transform: translateY(-3px);
  box-shadow: 0 6px 24px var(--glow);
}

/* ===== フィードバック ===== */
.feedback {
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 1rem;
  margin-top: 12px;
  display: none;
  animation: popIn 0.3s ease;
  font-weight: 500;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.feedback.show { display: block; }

.feedback.error {
  background: rgba(255,121,121,0.12);
  border: 2px solid rgba(255,121,121,0.3);
  color: var(--accent2);
}

.feedback.success {
  background: rgba(85,230,165,0.12);
  border: 2px solid rgba(85,230,165,0.3);
  color: var(--accent3);
}

/* ===== インベントリ ===== */
.inventory {
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.inventory-title {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 10px;
  font-weight: 700;
}

.inventory-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inv-item {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--room-bg);
  border: 3px solid var(--accent);
  border-radius: 28px;
  padding: 32px 26px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 6px rgba(255,217,61,0.1);
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 14px;
}

.modal-title {
  font-family: 'Kaisei Decol', serif;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.modal-body {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text-sub);
  margin-bottom: 22px;
}

.learn-badge {
  background: rgba(255,217,61,0.1);
  border: 2px solid rgba(255,217,61,0.25);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 0.95rem;
  color: var(--accent);
  text-align: left;
  line-height: 1.7;
}

.learn-badge::before {
  content: '💡 まなびポイント';
  display: block;
  font-size: 0.78rem;
  color: rgba(255,217,61,0.6);
  margin-bottom: 6px;
  font-weight: 700;
}

/* ===== タイトルスクリーン ===== */
.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.title-logo {
  font-family: 'Kaisei Decol', serif;
  font-size: clamp(2rem, 8vw, 3.2rem);
  color: var(--accent);
  text-shadow: 0 2px 16px var(--shadow);
  line-height: 1.4;
  margin-bottom: 10px;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  from { text-shadow: 0 2px 16px var(--shadow); }
  to   { text-shadow: 0 2px 28px var(--shadow), 0 0 48px rgba(255,217,61,0.2); }
}

.title-sub {
  font-size: 1rem;
  color: var(--text-sub);
  margin-bottom: 32px;
}

.title-scene {
  font-size: clamp(3.5rem, 14vw, 5.5rem);
  margin-bottom: 32px;
  animation: bounce 1.2s ease-in-out infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-10px); }
}

.story-box {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 22px 26px;
  max-width: 500px;
  margin-bottom: 32px;
  text-align: left;
  line-height: 2;
  font-size: 1.02rem;
}

.story-box .highlight {
  color: var(--accent);
  font-weight: 700;
}

.btn-start {
  background: linear-gradient(135deg, var(--accent), #FFB347);
  color: #1b2a4a;
  border: none;
  border-radius: 60px;
  padding: 20px 52px;
  font-family: 'Kaisei Decol', serif;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 8px 28px var(--shadow);
  letter-spacing: 0.06em;
}

.btn-start:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 14px 36px var(--shadow);
}

/* ===== エンディング ===== */
.ending-screen {
  text-align: center;
  padding: 40px 20px;
}

.ending-fireworks {
  font-size: 3.5rem;
  margin-bottom: 16px;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ending-title {
  font-family: 'Kaisei Decol', serif;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  color: var(--accent);
  margin-bottom: 10px;
  text-shadow: 0 2px 16px var(--shadow);
}

.learn-summary {
  background: var(--card);
  border: 3px solid rgba(255,217,61,0.3);
  border-radius: 20px;
  padding: 26px;
  margin: 24px 0;
  text-align: left;
}

.learn-summary h3 {
  color: var(--accent);
  font-family: 'Kaisei Decol', serif;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.learn-item {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 1rem;
  line-height: 1.7;
}

.learn-item .icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ===== ゲームオーバー ===== */
.gameover-screen {
  text-align: center;
  padding: 60px 20px;
}

.gameover-title {
  font-family: 'Kaisei Decol', serif;
  font-size: clamp(2rem, 8vw, 3.2rem);
  color: var(--accent2);
  margin-bottom: 14px;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-8px); }
  75%      { transform: translateX(8px); }
}

/* ===== ライフ表示 ===== */
.lives-display {
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin-bottom: 4px;
  opacity: 0.6;
}

/* ===== レスポンシブ ===== */
@media (max-width: 480px) {
  .items-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .puzzle-input-row {
    flex-direction: column;
  }

  .puzzle-input {
    width: 100%;
  }

  .btn {
    width: 100%;
  }

  .room-description {
    font-size: 0.95rem;
  }

  .coin-text {
    font-size: 0.92rem;
  }
}
