/* =========================================================
   ちいくゲーム デザインシステム
   ・丸ゴシック / やわらかい配色 / 奥行きのある影 / 3Dボタン
   ・操作は単純なまま、見た目を本格的に
   ========================================================= */
:root {
  --bg-top: #fff6fb;
  --bg-bot: #ffe6f0;
  --ink: #5d4658;
  --ink-soft: #b89aaa;
  --card: #ffffff;
  --sun: #ffcf4d;
  --sun-d: #f3b324;

  /* カテゴリ配色（日本のかわいいパステル）: c=主役 / cd=濃い(下辺) / cl=淡い背景 */
  --moji-c: #ff8fb3;  --moji-cd: #f06d99;  --moji-cl: #ffeef5;
  --kazu-c: #6cc4f0;  --kazu-cd: #41a8e0;  --kazu-cl: #e9f6fd;
  --sekai-c: #6fd6ab; --sekai-cd: #44bf8d; --sekai-cl: #e8faf1;
  --asobi-c: #b69bf0; --asobi-cd: #9a79e6; --asobi-cl: #f3eefc;

  /* ゲーム画面の基調 */
  --accent: #ff8fb3;
  --accent-d: #f06d99;

  --r: 30px;
  --r-sm: 20px;
  --sh-soft: 0 18px 38px rgba(220, 130, 165, 0.20);
  --sh-card: 0 10px 22px rgba(220, 130, 165, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-weight: 700;
  color: var(--ink);
  /* 桜色グラデ＋やさしい水玉模様 */
  background:
    radial-gradient(rgba(255,255,255,0.6) 2px, transparent 2.5px) 0 0 / 26px 26px,
    linear-gradient(165deg, var(--bg-top) 0%, var(--bg-bot) 100%) fixed;
  -webkit-user-select: none;
  user-select: none;
}
/* 見出し・ラベル・記号は「ぽってり丸い」ポップフォント */
.home-header h1, .home-section h2, .tile .label, .topbar .title,
.choice, .big-char, .question, .result-msg, .big-btn, .calc-key, .pz-cell, .lv {
  font-family: "Mochiy Pop One", "Zen Maru Gothic", sans-serif;
}

/* かわいい装飾（桜・キラキラ・ハート） */
.deco { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.deco span { position: absolute; background-repeat: no-repeat; background-size: contain; opacity: 0.85; }
.deco .petal {
  width: 30px; height: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23ffb3cd'%3E%3Ccircle cx='12' cy='5' r='4.2'/%3E%3Ccircle cx='19' cy='10' r='4.2'/%3E%3Ccircle cx='16' cy='18' r='4.2'/%3E%3Ccircle cx='8' cy='18' r='4.2'/%3E%3Ccircle cx='5' cy='10' r='4.2'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='3' fill='%23ffe06b'/%3E%3C/svg%3E");
  animation: drift 13s ease-in-out infinite;
}
.deco .sparkle {
  width: 24px; height: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1C13 8 16 11 23 12 16 13 13 16 12 23 11 16 8 13 1 12 8 11 11 8 12 1Z' fill='%23ffd86b'/%3E%3C/svg%3E");
  animation: twinkle 3.2s ease-in-out infinite;
}
.deco .heart {
  width: 24px; height: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21S3 14 3 8a4.5 4.5 0 0 1 9-2 4.5 4.5 0 0 1 9 2c0 6-9 13-9 13Z' fill='%23ff9fc0'/%3E%3C/svg%3E");
  animation: drift 11s ease-in-out infinite;
}
@keyframes drift { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-16px) rotate(8deg); } }
@keyframes twinkle { 0%,100% { transform: scale(0.7); opacity: 0.4; } 50% { transform: scale(1.1); opacity: 0.95; } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

/* コンテンツは装飾より前面に */
.home-header, .grid, .home-section, .topbar, .stage, .overlay, .calc { position: relative; z-index: 1; }

/* ====================== ホーム ====================== */
.home-header {
  text-align: center;
  padding: 30px 16px 4px;
}
.home-header .mascot { width: 96px; height: 96px; filter: drop-shadow(0 8px 10px rgba(0,0,0,0.12)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.home-header h1 {
  margin: 10px 0 0;
  font-size: clamp(34px, 8.5vw, 54px);
  letter-spacing: 2px;
  color: #ff7aa8;
  /* 白フチ＋やわらかい影でステッカー風（アニメっぽいぷっくりタイトル） */
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #ffd6e6, 0 7px 10px rgba(240, 110, 150, 0.3);
}
.home-header p { margin: 14px 0 0; font-size: 14px; font-weight: 700; line-height: 1.8; color: var(--ink-soft); }

.home-section { max-width: 960px; margin: 30px auto 0; padding: 0 18px; }
.home-section h2 {
  display: flex; align-items: center; gap: 9px;
  font-size: 19px; margin: 0 0 16px;
  color: var(--ink); letter-spacing: 0.5px;
}
.home-section h2::before {
  content: ""; width: 22px; height: 22px; background: #ccc;
  background-repeat: no-repeat; background-size: contain;
  /* 桜マーク */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Ccircle cx='12' cy='5' r='4.2'/%3E%3Ccircle cx='19' cy='10' r='4.2'/%3E%3Ccircle cx='16' cy='18' r='4.2'/%3E%3Ccircle cx='8' cy='18' r='4.2'/%3E%3Ccircle cx='5' cy='10' r='4.2'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Ccircle cx='12' cy='5' r='4.2'/%3E%3Ccircle cx='19' cy='10' r='4.2'/%3E%3Ccircle cx='16' cy='18' r='4.2'/%3E%3Ccircle cx='8' cy='18' r='4.2'/%3E%3Ccircle cx='5' cy='10' r='4.2'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
}
.home-section.moji h2::before { background: var(--moji-c); }
.home-section.kazu h2::before { background: var(--kazu-c); }
.home-section.sekai h2::before { background: var(--sekai-c); }
.home-section.asobi h2::before { background: var(--asobi-c); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 16px;
  max-width: 960px;
  margin: 0 auto 14px;
  padding: 0 18px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 20px 10px 16px;
  aspect-ratio: 1 / 1;
  border-radius: var(--r);
  text-decoration: none;
  color: var(--ink);
  font-size: 18px;
  background: var(--card);
  border: 4px solid #fff; /* 白フチ＝シール風 */
  box-shadow: var(--sh-card);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s;
}
.tile:hover { transform: translateY(-5px) scale(1.02); box-shadow: var(--sh-soft); }
.tile:hover .ico { transform: rotate(-6deg) scale(1.05); }
.tile:active { transform: translateY(1px) scale(0.99); }
.tile .ico {
  width: 78px; height: 78px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff; /* アイコンは白 */
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12), inset 0 -5px 8px rgba(0, 0, 0, 0.1), inset 0 5px 7px rgba(255, 255, 255, 0.55);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
}
.tile .ico svg { width: 46px; height: 46px; display: block; }
.tile .label { z-index: 1; font-size: 18px; }
.tile .stars { font-size: 13px; min-height: 16px; letter-spacing: -2px; z-index: 1; }

/* カテゴリ色：淡いタイル背景＋まるい色バッジ（白アイコン） */
.tile.cat-moji  { background: var(--moji-cl); }
.tile.cat-kazu  { background: var(--kazu-cl); }
.tile.cat-sekai { background: var(--sekai-cl); }
.tile.cat-asobi { background: var(--asobi-cl); }
.tile.cat-moji  .ico { background: linear-gradient(155deg, #ffadc9, var(--moji-cd)); }
.tile.cat-kazu  .ico { background: linear-gradient(155deg, #91d6f6, var(--kazu-cd)); }
.tile.cat-sekai .ico { background: linear-gradient(155deg, #90e3c2, var(--sekai-cd)); }
.tile.cat-asobi .ico { background: linear-gradient(155deg, #c9b4f6, var(--asobi-cd)); }

.home-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  margin: 30px auto 40px;
  padding: 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.9;
}
.home-footer strong { color: var(--moji-c); font-weight: 800; }
.home-footer .copy { font-size: 12px; opacity: 0.8; }

/* ====================== ゲーム共通 ====================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 18px 6px;
}
.home-btn {
  font-size: 26px;
  text-decoration: none;
  background: var(--card);
  border-radius: 16px;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  box-shadow: var(--sh-card);
  border-bottom: 4px solid #eadfe2;
  transition: transform 0.1s;
}
.home-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.topbar .title { font-size: 22px; font-weight: 900; color: var(--accent); }

/* 進捗バー */
.progress {
  margin-left: auto;
  display: flex;
  gap: 5px;
  background: rgba(255,255,255,0.6);
  padding: 7px 9px;
  border-radius: 999px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}
.dot { width: 11px; height: 11px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #e7c9d6; transition: all 0.2s; }
.dot.done { background: var(--sekai-c); box-shadow: none; }
.dot.now { background: var(--sun); box-shadow: 0 0 0 3px rgba(255,201,60,0.3); transform: scale(1.3); }

.stage { max-width: 640px; margin: 0 auto; padding: 8px 18px 48px; }

.prompt {
  position: relative;
  background: var(--card);
  border-radius: 34px;
  box-shadow: var(--sh-soft);
  padding: 34px 22px 30px;
  text-align: center;
  margin: 10px 0 24px;
  border-bottom: 8px solid rgba(0,0,0,0.05);
}
.prompt .big-char { font-size: clamp(86px, 28vw, 172px); font-weight: 900; line-height: 1; color: var(--ink); }
.prompt .big-emoji { font-size: clamp(78px, 24vw, 140px); line-height: 1; filter: drop-shadow(0 8px 10px rgba(0,0,0,0.12)); }
.prompt .question { font-size: clamp(22px, 6vw, 32px); font-weight: 900; margin-top: 6px; color: var(--ink); }
.prompt .count-objs { font-size: clamp(40px, 12vw, 68px); line-height: 1.3; word-break: break-word; }
.prompt svg { max-width: 100%; height: auto; }

/* 国旗画像（絵文字はWindowsで表示できないためSVG画像を使う） */
.flag-img { display: block; margin: 0 auto; height: auto; border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18); }
.flag-prompt { width: clamp(150px, 44vw, 240px); }
.flag-choice { width: clamp(74px, 22vw, 120px); }

/* せかいちず（世界地図） */
.map-q {
  position: relative;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--sh-card);
  border: 4px solid #fff;
  padding: 20px 60px 18px 20px;
  text-align: center;
  font-size: clamp(20px, 5.6vw, 30px);
  color: var(--ink);
  margin-bottom: 14px;
}
.wmap-wrap { background: #e6f2fb; border: 4px solid #fff; border-radius: 22px; padding: 8px; box-shadow: var(--sh-card); }
.wmap { width: 100%; height: auto; display: block; }
.wc { fill: #cfe6d6; stroke: #fff; stroke-width: 0.4; }
.cand { fill: #95d8b6; cursor: pointer; }
.pin { fill: rgba(255, 122, 168, 0.9); stroke: #fff; stroke-width: 3.5; cursor: pointer; transition: transform 0.1s; transform-box: fill-box; transform-origin: center; }
.pin:hover { fill: #ff5f93; }
.cand.correct { fill: var(--sekai-c); }
.pin.correct { fill: var(--sekai-c); }
.pin.wrong { fill: #ff7a7a; animation: shake 0.4s; }

.speak-btn {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 24px;
  border: none;
  background: linear-gradient(180deg, var(--kazu-c), var(--kazu-cd));
  color: #fff;
  width: 56px; height: 56px;
  border-radius: 50%;
  box-shadow: 0 5px 0 #1f7fbd, 0 8px 14px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.1s;
}
.speak-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #1f7fbd; }

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.choice {
  position: relative;
  font-family: inherit;
  font-size: clamp(34px, 9vw, 50px);
  font-weight: 900;
  padding: 24px 8px;
  border: none;
  border-radius: 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--sh-card);
  border-bottom: 7px solid #e7dbde;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.choice::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 44%;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.6), transparent);
  pointer-events: none;
}
.choice:hover { transform: translateY(-3px); box-shadow: var(--sh-soft); }
.choice:active { transform: translateY(3px); border-bottom-width: 3px; }
.choice.correct {
  background: linear-gradient(180deg, #7ee29a, var(--sekai-c));
  color: #fff;
  border-bottom-color: var(--sekai-cd);
  animation: pop 0.45s;
}
.choice.wrong { background: #ffd7d7; border-bottom-color: #e89a9a; animation: shake 0.4s; }
.choice:disabled { opacity: 0.45; }

@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }

/* ごほうびの星 */
.star-pop {
  position: fixed;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 130px;
  pointer-events: none;
  z-index: 50;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.2));
  animation: starpop 1s ease-out forwards;
}
@keyframes starpop {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-25deg); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(1) rotate(0); opacity: 0; }
}

/* ====================== STEP レベル切替 ====================== */
.levels {
  display: flex; gap: 8px; justify-content: center;
  margin: 0 auto 4px; max-width: 640px; padding: 0 18px;
}
.levels .lv {
  flex: 1; max-width: 150px;
  font-family: inherit; font-size: 15px; font-weight: 800;
  padding: 9px 6px; border: none; border-radius: 14px;
  background: rgba(255,255,255,0.7); color: var(--ink-soft);
  box-shadow: var(--sh-card); cursor: pointer; text-decoration: none; text-align: center;
}
.levels .lv.on { background: linear-gradient(180deg, var(--sun), var(--sun-d)); color: #fff; }

/* ====================== 結果（クリア） ====================== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(255, 244, 248, 0.96);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay[hidden] { display: none; }
.result {
  text-align: center; padding: 30px 24px;
  background: var(--card);
  border-radius: 34px;
  box-shadow: var(--sh-soft);
  border-bottom: 10px solid rgba(0,0,0,0.05);
  animation: rise 0.4s ease-out;
}
@keyframes rise { from { transform: translateY(24px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.result .mascot { width: 88px; height: 88px; }
.result-stars { font-size: 60px; min-height: 68px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.12)); }
.result-msg { font-size: 32px; font-weight: 900; color: var(--accent); margin: 6px 0; }
.result-count { font-size: 22px; font-weight: 700; color: var(--ink-soft); margin-bottom: 22px; }
.result-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.big-btn {
  font-family: inherit; font-size: 22px; font-weight: 900;
  padding: 15px 26px; border: none; border-radius: 18px;
  background: linear-gradient(180deg, #ff95b4, var(--accent));
  color: #fff; text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 0 var(--accent-d), 0 8px 14px rgba(0,0,0,0.16);
  transition: transform 0.1s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--accent-d); }
.big-btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 6px 0 #e7dbde, 0 8px 14px rgba(0,0,0,0.1); }
.big-btn.ghost:active { box-shadow: 0 3px 0 #e7dbde; }

/* 紙吹雪 */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 11px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.9; }
}

/* ====================== パズル ====================== */
.pz-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 360px; margin: 16px auto; }
.pz-cell {
  aspect-ratio: 1 / 1; border: none; border-radius: 20px;
  font-family: inherit; font-size: clamp(36px, 12vw, 54px); font-weight: 900; color: #fff;
  background: linear-gradient(180deg, #5cc0f8, var(--kazu-c));
  box-shadow: 0 6px 0 var(--kazu-cd), 0 8px 14px rgba(0,0,0,0.14);
  cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
}
.pz-cell:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--kazu-cd); }
.pz-cell.blank { background: rgba(255,255,255,0.4); box-shadow: inset 0 2px 6px rgba(0,0,0,0.08); cursor: default; }
.pz-moves { margin-left: auto; font-weight: 800; color: var(--ink); background: rgba(255,255,255,0.7); padding: 8px 14px; border-radius: 999px; box-shadow: var(--sh-card); }

/* ====================== でんたく ====================== */
.calc { max-width: 360px; margin: 14px auto; padding: 0 8px; }
.calc-display {
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
  color: #fff; font-size: clamp(38px, 11vw, 54px); font-weight: 800;
  text-align: right; padding: 22px 22px; border-radius: 20px;
  min-height: 1.5em; word-break: break-all;
  box-shadow: var(--sh-card), inset 0 2px 6px rgba(0,0,0,0.4);
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 14px; }
.calc-key {
  aspect-ratio: 1 / 1; font-family: inherit; font-size: clamp(26px, 8vw, 36px); font-weight: 900;
  border: none; border-radius: 18px; background: var(--card); color: var(--ink);
  box-shadow: 0 5px 0 #e7dbde, 0 7px 12px rgba(0,0,0,0.1); cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
}
.calc-key:active { transform: translateY(3px); box-shadow: 0 2px 0 #e7dbde; }
.calc-key.op { background: linear-gradient(180deg, #5cc0f8, var(--kazu-c)); color: #fff; box-shadow: 0 5px 0 var(--kazu-cd), 0 7px 12px rgba(0,0,0,0.12); }
.calc-key.eq { background: linear-gradient(180deg, #ff95b4, var(--accent)); color: #fff; box-shadow: 0 5px 0 var(--accent-d), 0 7px 12px rgba(0,0,0,0.12); }
.calc-key.clear { background: linear-gradient(180deg, var(--sun), var(--sun-d)); color: #fff; box-shadow: 0 5px 0 #c98a06, 0 7px 12px rgba(0,0,0,0.12); }
