:root {
  --bg-top: #fdf4ff;
  --bg-mid: #f6e6ff;
  --bg-bottom: #e3e0fb;
  --text-main: #6b4f3a;
  --text-sub: #8a6f5a;
  --heading-color: #6f55a4;
  --heading-shadow: #b8a7d9;
  --lavender: #d9cdf0;
  --lavender-shadow: #b39ddb;
  --lavender-text: #4a2f7a;
  --yellow: #fff3a8;
  --yellow-shadow: #ffdd6b;
  --yellow-text: #7a5c00;
  --blue: #bfeaff;
  --blue-shadow: #7fd4f7;
  --blue-text: #01579b;
  --pink: #f8bbd0;
  --pink-shadow: #f48fb1;
  --pink-text: #ad1457;
  --star-gold: #ffd54f;
  --reward-color: #F28C28;
  --card-bg: rgba(255, 255, 255, 0.72);
  --chip-bg: rgba(255, 255, 255, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  background: #e3e0fb;
}

body {
  min-height: 100dvh;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Rounded Mplus 1c", sans-serif;
  color: var(--text-main);
  display: flex;
  justify-content: center;
}

.app-frame {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 45%, var(--bg-bottom) 100%);
  overflow: hidden;
  container-type: inline-size;
}

@media (min-width: 481px) {
  body { background: linear-gradient(180deg, #efe9fb, #dcd6f5); }
  .app-frame {
    margin: 24px 0;
    min-height: calc(100dvh - 48px);
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(80, 60, 120, .18);
  }
}

/* 上部のヘッダー(戻るボタンなどが入る場所) */
.sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 8px;
}
.sub-header .title-chip {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-main);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 8px 18px;
  margin: 0 4px;
}
.icon-btn {
  all: unset;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  flex-shrink: 0;
}
.icon-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.08);
}
/* ヘッダー右の「いまの人」の名前(表示だけ。押しても何も起きない) */
.user-badge {
  box-sizing: border-box;
  flex-shrink: 0;
  min-width: 48px;
  max-width: 64px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
  color: var(--lavender-text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  word-break: break-all; /* 長い名前は2行に折り返す */
}
.user-badge:empty { visibility: hidden; }

/* キラキラの飾り(全画面共通) */
.sparkle {
  position: absolute;
  opacity: 0.5;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
  animation: twinkle 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes twinkle {
  0%, 100% { opacity: .3; transform: scale(.85); }
  50% { opacity: .85; transform: scale(1.05); }
}

/* 本文エリア */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px 28px;
  position: relative;
  overflow-y: auto;
}

/* 半透明のカード */
.card {
  width: 100%;
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: 0 10px 30px rgba(90, 60, 120, 0.1);
}

/* ===== 小さな星の飾り(背景装飾・全画面共通) ===== */
.deco-star {
  position: absolute;
  pointer-events: none;
  opacity: .5;
  background-repeat: no-repeat;
}
.deco-star.star-stripe-sm {
  width: 28px; height: 27px;
  background-image: url('images/common/star_stripe_01.png');
  background-size: 32px 57px;
  background-position: -2px -15px;
}
.deco-star.star-stripe {
  width: 34px; height: 32px;
  background-image: url('images/common/star_stripe_01.png');
  background-size: 39px 69px;
  background-position: -3px -18px;
}
/* ===== 星くん(案内役キャラクター) ===== */
.hoshi-kun {
  position: absolute;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image: url('../../../shared/images/characters/hoshi_kun.png');
  animation: hoshiFloat 3.6s ease-in-out infinite;
  transition: transform .3s ease;
}
.hoshi-kun.size-sub {
  width: 48px; height: 55px;
  background-size: 60px 107px;
  background-position: -6px -24px;
}
.hoshi-kun.subtle {
  animation-duration: 5s;
  opacity: .8;
}
.hoshi-kun.boost {
  transform: scale(1.18);
}
@keyframes hoshiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* 星くん＋小さい星を横に並べた、学習内容と重ならない専用の帯 */
.hoshi-band {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  margin: 0 0 10px;
}
.hoshi-band .hoshi-kun,
.hoshi-band .deco-star {
  position: static;
}

/* ===== ごほうび表示(できた！／やったね！／クリア！／おしい！ をHTML文字で表示) ===== */
.reward-slot {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.reward-slot.show {
  display: flex;
  opacity: 1;
}
.reward-slot.show .reward-text {
  animation: rewardPop .5s ease-out;
}
.reward-text {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: clamp(44px, 20cqw, 96px);
  font-weight: 800;
  color: var(--reward-color);
  letter-spacing: .02em;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .8), 0 4px 10px rgba(200, 100, 20, .3);
}
@keyframes rewardPop {
  0% { opacity: 0; transform: scale(1.35); }
  60% { opacity: 1; transform: scale(.96); }
  100% { opacity: 1; transform: scale(1); }
}

/* ===== 段の進捗バー(段選択・チャレンジ選択で共通) ===== */
.dan-progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dan-progress-count {
  font-size: 15px;
  font-weight: 800;
  color: var(--lavender-text);
}
.dan-bar {
  width: 100%;
  max-width: 220px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .08);
  overflow: hidden;
}
.dan-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--lavender-shadow);
  transition: width .3s ease;
}
