/* ================= ジュエルストーリー ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #ffd76a;
  --pink: #ff6b9d;
  --violet: #8b5cf6;
  --panel: rgba(30, 22, 60, 0.88);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f1eaff;
  --text-dim: #a89cc8;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  background: #0b0820;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: relative; width: 100%; height: 100%; }

/* ---------- 背景 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 20% -10%, #2a1a5e 0%, transparent 55%),
    radial-gradient(1000px 700px at 90% 110%, #3d1245 0%, transparent 55%),
    linear-gradient(160deg, #171033 0%, #0b0820 60%, #120a2a 100%);
}
.screen.active { display: flex; }

.bg-orbs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bg-orbs i {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  animation: orbFloat 14s ease-in-out infinite alternate;
}
.bg-orbs i:nth-child(1) { width: 340px; height: 340px; left: -80px; top: 12%; background: #5b2fd0; }
.bg-orbs i:nth-child(2) { width: 280px; height: 280px; right: -60px; top: 55%; background: #d0308a; animation-delay: -5s; }
.bg-orbs i:nth-child(3) { width: 220px; height: 220px; left: 42%; bottom: -80px; background: #1f6fd0; animation-delay: -9s; }
@keyframes orbFloat {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, -50px) scale(1.15); }
}

/* ---------- タイトル画面 ---------- */
.title-box { position: relative; text-align: center; z-index: 1; }
.game-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(180deg, #fff6d8 0%, var(--gold) 45%, #ff9d4d 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 180, 60, 0.35));
  animation: titleGlow 3s ease-in-out infinite alternate;
}
@keyframes titleGlow {
  from { filter: drop-shadow(0 4px 14px rgba(255, 180, 60, 0.25)); }
  to { filter: drop-shadow(0 6px 26px rgba(255, 200, 90, 0.55)); }
}
.game-subtitle {
  margin-top: 8px;
  font-size: 17px;
  letter-spacing: 6px;
  color: var(--text-dim);
}
#title-gems { margin: 26px auto 8px; display: block; max-width: 90vw; height: auto; }
.title-btns { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 18px; }
.title-btn-row { display: flex; gap: 14px; }
.title-progress { margin-top: 22px; font-size: 14px; color: var(--text-dim); letter-spacing: 1px; }

/* ---------- ボタン ---------- */
.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding: 11px 28px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03));
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.15); }
.btn:active { transform: translateY(1px) scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, #a86bff 0%, #7a3cf0 55%, #5b21c9 100%);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 20px rgba(130, 70, 240, 0.5), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-big { font-size: 21px; padding: 15px 52px; border-radius: 18px; }

.icon-btn {
  font-family: inherit;
  width: 44px; height: 44px;
  font-size: 20px;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.15); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.92); }

#btn-sound-title { position: absolute; top: 20px; right: 20px; z-index: 2; }

/* ---------- ステージマップ ---------- */
#screen-map { justify-content: flex-start; }
.map-header {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
}
.map-title { font-size: 24px; letter-spacing: 4px; font-weight: 800; }
.map-stars {
  margin-left: auto;
  font-size: 17px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(255, 215, 106, 0.1);
  border: 1px solid rgba(255, 215, 106, 0.3);
  padding: 7px 16px;
  border-radius: 999px;
  letter-spacing: 1px;
}
#map-scroll {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
#map-inner { position: relative; width: 100%; }
#map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.map-node {
  position: absolute;
  width: 66px; height: 66px;
  margin: -33px 0 0 -33px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(180deg, #8b5cf6, #5b21c9);
  color: #fff;
  font-family: inherit;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(90, 40, 200, 0.55), inset 0 2px 0 rgba(255,255,255,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
  padding-top: 2px;
}
.map-node:hover { transform: scale(1.12); }
.map-node:active { transform: scale(0.95); }
.map-node .node-stars { font-size: 11px; margin-top: 3px; color: var(--gold); letter-spacing: 1px; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.map-node .node-stars .off { color: rgba(255, 255, 255, 0.28); }
.map-node.locked {
  background: linear-gradient(180deg, #3a3454, #241f3a);
  color: #6f6790;
  cursor: not-allowed;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.12);
}
.map-node.locked:hover { transform: none; }
.map-node.current {
  border-color: var(--gold);
  animation: nodePulse 1.6s ease-in-out infinite;
}
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 106, 0.55), 0 6px 18px rgba(90, 40, 200, 0.55); }
  50% { box-shadow: 0 0 0 14px rgba(255, 215, 106, 0), 0 6px 18px rgba(90, 40, 200, 0.55); }
}

/* ---------- ゲーム画面 ---------- */
#screen-game { justify-content: flex-start; }
#game-hud {
  position: relative;
  z-index: 2;
  width: min(680px, 96vw);
  padding: 12px 4px 6px;
}
.hud-row { display: flex; align-items: center; gap: 14px; }
.hud-row-top { justify-content: space-between; }
.hud-item {
  display: flex; flex-direction: column; align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px 16px;
  min-width: 72px;
}
.hud-label { font-size: 11px; color: var(--text-dim); letter-spacing: 2px; }
.hud-value { font-size: 21px; font-weight: 900; color: #fff; }
.hud-value.low { color: #ff7b7b; animation: lowPulse 0.9s ease-in-out infinite; }
@keyframes lowPulse { 50% { transform: scale(1.18); } }

.hud-goal {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px 14px;
  min-height: 54px;
  font-weight: 700;
}
.goal-item { display: flex; align-items: center; gap: 6px; font-size: 17px; }
.goal-item img { width: 30px; height: 30px; display: block; }
.goal-item .done { color: #7dff9e; }
.goal-text { font-size: 15px; color: var(--text-dim); letter-spacing: 1px; }
.goal-text b { color: var(--gold); font-size: 17px; margin: 0 2px; }

.hud-row-score { margin-top: 8px; gap: 12px; }
.hud-score {
  font-size: 22px; font-weight: 900;
  color: var(--gold);
  min-width: 92px;
  text-align: right;
  text-shadow: 0 2px 8px rgba(255, 200, 90, 0.35);
}
.score-bar {
  position: relative;
  flex: 1;
  height: 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--panel-border);
}
.score-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7a3cf0, #c86bff, var(--gold));
  box-shadow: 0 0 12px rgba(200, 120, 255, 0.6);
  transition: width 0.35s ease;
}
.bar-star {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -52%);
  font-size: 17px;
  color: rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  transition: color 0.3s ease, transform 0.3s ease;
}
.bar-star.lit { color: var(--gold); transform: translate(-50%, -52%) scale(1.25); text-shadow: 0 0 10px rgba(255, 210, 90, 0.8); }

#board-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 6px 0 14px;
}
#board-canvas {
  touch-action: none;
  cursor: pointer;
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  max-width: 96vw;
  max-height: 100%;
}

#combo-banner {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 170, 60, 0.9), 0 4px 8px rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}
#combo-banner.show { animation: comboPop 0.9s ease-out forwards; }
@keyframes comboPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.3); }
  18% { opacity: 1; transform: translateX(-50%) scale(1.25); }
  32% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.05) translateY(-22px); }
}

/* ---------- オーバーレイ / パネル ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 5, 22, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.12);
  animation: panelIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: min(560px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes panelIn {
  from { opacity: 0; transform: scale(0.7) translateY(30px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.panel-title { font-size: 30px; font-weight: 900; letter-spacing: 5px; margin-bottom: 18px; }
.panel-btns { display: flex; flex-direction: column; gap: 11px; margin-top: 20px; align-items: stretch; }

.panel-result { min-width: min(400px, 90vw); }
.result-stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; height: 74px; align-items: center; }
.result-star {
  font-size: 56px;
  color: rgba(255, 255, 255, 0.14);
  transition: none;
  line-height: 1;
}
.result-star-mid { font-size: 70px; }
.result-star.earned {
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 200, 80, 0.95), 0 3px 6px rgba(0,0,0,0.4);
  animation: starPop 0.5s cubic-bezier(0.34, 1.8, 0.64, 1);
}
@keyframes starPop {
  0% { transform: scale(0) rotate(-160deg); }
  70% { transform: scale(1.35) rotate(12deg); }
  100% { transform: scale(1) rotate(0); }
}
.result-goal { color: var(--text-dim); font-size: 14px; letter-spacing: 1px; margin-bottom: 10px; }
.result-score-label { font-size: 13px; color: var(--text-dim); letter-spacing: 4px; }
.result-score { font-size: 42px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 14px rgba(255, 200, 90, 0.4); }

/* ---------- 遊び方 / 実績 ---------- */
.panel-help { text-align: left; width: min(560px, 92vw); }
.panel-help .panel-title { text-align: center; }
.help-body { font-size: 14.5px; line-height: 1.8; color: #d8d0ee; }
.help-body p { margin-bottom: 8px; }
.help-body ul { margin: 4px 0 10px 20px; }
.help-body b { color: var(--gold); }
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 4px;
}
.tag-stripe { background: rgba(90, 170, 255, 0.22); color: #8cc5ff; }
.tag-bomb { background: rgba(255, 120, 80, 0.22); color: #ffab8c; }
.tag-rainbow { background: rgba(200, 120, 255, 0.22); color: #dfa8ff; }

.ach-list { display: flex; flex-direction: column; gap: 9px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.ach-item {
  display: flex; align-items: center; gap: 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 14px;
}
.ach-item .ach-icon { font-size: 27px; filter: grayscale(1) opacity(0.4); }
.ach-item.unlocked .ach-icon { filter: none; }
.ach-item .ach-name { font-size: 15px; font-weight: 800; }
.ach-item .ach-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.ach-item.unlocked .ach-name { color: var(--gold); }

/* ---------- 全画面フラッシュ / トースト ---------- */
#flash-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(255, 240, 200, 0.9), rgba(255, 200, 120, 0.25) 55%, transparent 75%);
  opacity: 0;
  transition: opacity 0.5s ease-out;
}
#flash-overlay.on { opacity: 1; transition: opacity 0.04s ease-in; }

#toast {
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(20, 14, 44, 0.94);
  border: 1px solid rgba(255, 215, 106, 0.45);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 11px 26px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: toastIn 0.25s ease-out;
  white-space: nowrap;
  max-width: 92vw;
}
#toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 小画面対応 ---------- */
@media (max-width: 720px) {
  .game-title { font-size: 34px; letter-spacing: 3px; }
  .hud-goal { gap: 8px; padding: 4px 8px; }
  .goal-item { font-size: 14px; }
  .goal-item img { width: 24px; height: 24px; }
  .hud-item { padding: 4px 10px; min-width: 58px; }
  .hud-value { font-size: 17px; }
  .hud-score { font-size: 17px; min-width: 66px; }
  #combo-banner { font-size: 30px; }
  .panel { padding: 22px 20px; }
}
@media (max-height: 700px) {
  #game-hud { padding-top: 6px; }
  .game-title { font-size: 44px; }
}

/* ---------- KanaWorks_AI クレジット ---------- */
.kw-credit {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 16px; padding: 6px 16px 6px 8px;
  background: rgba(30, 22, 60, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  text-decoration: none;
  color: #c3b4e8; font-size: 12.5px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.kw-credit img { width: 28px; height: 28px; display: block; }
.kw-credit b { color: var(--gold); }
.kw-credit:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 215, 106, 0.55);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
