/* =========================================================
   Mogu Mogu City - スタイルシート
   モバイル最優先 / セーフエリア対応 / タップしやすい大きめUI
   ========================================================= */

:root {
  --c-sky: #7ec8e3;
  --c-panel: rgba(255, 255, 255, 0.92);
  --c-text: #4a3b32;
  --c-primary: #ff6b81;
  --c-primary-dark: #e14e66;
  --c-accent: #ffd24d;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI",
          "Segoe UI", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #222;
  font-family: var(--font);
  color: var(--c-text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none; /* スクロール・ピンチ無効化(ゲーム操作優先) */
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ===== 画面(スクリーン)共通 ===== */
.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

.overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(16px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  text-align: center;
  z-index: 10;
}

/* 背景を完全に塗りつぶす画面(ローディング / スキン) */
.overlay.solid {
  background: linear-gradient(160deg, #9be0f7 0%, #7ec8e3 45%, #b8e39b 100%);
}

.panel {
  background: var(--c-panel);
  border-radius: 28px;
  padding: 26px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  min-width: min(320px, 84vw);
}

.screen-heading {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--c-text);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}

/* ===== ボタン ===== */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--c-text);
  background: #fff;
  border-radius: 999px;
  padding: 14px 24px;
  min-width: 220px;
  min-height: 56px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15), 0 8px 18px rgba(0, 0, 0, 0.12);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.btn-primary {
  background: linear-gradient(180deg, #ff8a9b, var(--c-primary));
  color: #fff;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.15);
  box-shadow: 0 5px 0 var(--c-primary-dark), 0 8px 18px rgba(0, 0, 0, 0.2);
}
.btn-primary:active { box-shadow: 0 1px 0 var(--c-primary-dark); }

.icon-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--c-text);
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }

/* ===== 起動画面 ===== */
.splash {
  background:
    linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.28)),
    url("public/opt/splash-bg.webp") center / cover no-repeat;
}

.load-title {
  font-size: clamp(34px, 9vw, 56px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}
.load-bar {
  width: min(280px, 70vw);
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  overflow: hidden;
}
#load-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--c-accent), #ffb347);
  transition: width 0.15s ease;
}
.load-text { color: #fff; font-weight: 700; }

/* ===== タイトル画面 ===== */
#screen-title {
  background: linear-gradient(180deg, rgba(126, 200, 227, 0.25), rgba(126, 200, 227, 0) 40%);
  justify-content: flex-start;
  padding-top: calc(10vh + var(--safe-top));
}
.game-title {
  font-size: clamp(44px, 13vw, 84px);
  font-weight: 900;
  line-height: 1.02;
  color: #fff;
  text-shadow:
    0 3px 0 #e14e66,
    0 7px 0 rgba(0, 0, 0, 0.12),
    0 12px 24px rgba(0, 0, 0, 0.25);
  -webkit-text-stroke: 2px var(--c-primary);
  animation: title-bounce 2.4s ease-in-out infinite;
}
@keyframes title-bounce {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-10px) rotate(1.5deg); }
}
.title-hint {
  margin-top: 6px;
  font-weight: 800;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
}
.menu {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 4vh;
}
.cross-promo {
  width: min(340px, 90vw);
  min-height: 72px;
  display: grid;
  grid-template-columns: 58px 1fr 20px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 8px;
  background: rgba(35, 39, 53, 0.9);
  color: #fff;
  text-decoration: none;
  text-align: left;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2), 0 8px 18px rgba(0,0,0,0.15);
}
.cross-promo:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.cross-promo img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
}
.cross-promo > span:not(.cross-promo-arrow) {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cross-promo small { font-size: 10px; color: #d8dbe8; }
.cross-promo strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cross-promo b { font-size: 11px; color: #ffd24d; }
.cross-promo-arrow { font-size: 32px; line-height: 1; color: #fff; }
.coin-balance {
  position: absolute;
  top: calc(14px + var(--safe-top));
  right: 16px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  color: #b87800;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 6px;
}
.currency-icon {
  width: 1.35em;
  height: 1.35em;
  object-fit: contain;
  vertical-align: -0.28em;
  flex: 0 0 auto;
}

#stage-grid {
  width: min(680px, 92vw);
  max-height: 68vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 4px;
}
.stage-card {
  min-height: 150px;
  border: 3px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,0.94);
  color: var(--c-text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.14);
}
.stage-card strong { font-size: 20px; }
.stage-card span { font-size: 12px; font-weight: 800; }
.stage-card .stage-number { color: var(--c-primary-dark); font-size: 15px; }
.stage-card b { color: #27885e; }
.stage-card:disabled { opacity: 0.55; cursor: default; filter: grayscale(1); }
.stage-card.cleared { border-color: #49ad7f; }

/* ===== スキン画面 ===== */
#skin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 160px));
  gap: 14px;
  justify-content: center;
  max-height: 62vh;
  overflow-y: auto;
  padding: 6px;
}
.shop-balance {
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.9);
  color: #b87800;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.shop-notice {
  min-height: 18px;
  margin: -6px 0;
  font-size: 12px;
  font-weight: 800;
  color: #27885e;
}
.shop-notice.error { color: #c43d50; }
.shop-tabs {
  display: flex;
  width: min(330px, 88vw);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.55);
}
.shop-tab {
  flex: 1;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--c-text);
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
}
.shop-tab.selected { background: #fff; color: var(--c-primary-dark); }
.skin-card {
  appearance: none;
  border: 4px solid transparent;
  cursor: pointer;
  background: var(--c-panel);
  border-radius: 8px;
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s ease;
  position: relative;
  overflow: hidden;
  min-height: 194px;
}
.skin-card:active { transform: scale(0.95); }
.skin-card.selected {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 4px rgba(255, 210, 77, 0.45), 0 4px 0 rgba(0, 0, 0, 0.12);
}
.skin-card.unaffordable, .effect-card.unaffordable { opacity: 0.58; }
.skin-card.locked {
  background: #c8cbd0;
  border-color: #9298a1;
  color: #555c66;
}
.skin-card.locked > .skin-image {
  filter: grayscale(1) contrast(0.75);
  opacity: 0.58;
}
.skin-card.locked .skin-ability { color: #656b73; }
.skin-card.locked .shop-price {
  color: #fff;
  background: #626974;
  border-radius: 5px;
  padding: 4px 7px;
}
.lock-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 1;
  padding: 3px 6px;
  border-radius: 5px;
  background: #424851;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
}
.skin-card > .skin-image {
  width: 84px;
  height: 84px;
  object-fit: contain;
  pointer-events: none;
}
.skin-name { font-size: 16px; font-weight: 900; }
.skin-ability {
  font-size: 11px;
  font-weight: 700;
  color: #8a7a6e;
  line-height: 1.25;
  min-height: 28px;
  display: flex;
  align-items: center;
}
.shop-price {
  min-height: 28px;
  margin-top: auto;
  font-size: 12px;
  color: #b87800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

#effect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 160px));
  gap: 12px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 5px;
}
.effect-card {
  min-height: 145px;
  border: 3px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  color: var(--c-text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.effect-card.selected { border-color: var(--c-accent); }
.effect-card > span:not(.effect-preview) { font-size: 12px; font-weight: 700; }
.effect-preview {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--effect-color);
  color: #fff;
  font-size: 27px;
  font-weight: 900;
}

.boost-stage-name { font-weight: 900; color: #fff; }
#boost-grid {
  width: min(480px, 90vw);
  display: grid;
  gap: 10px;
}
.boost-card {
  min-height: 72px;
  border: 3px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  color: var(--c-text);
  font-family: inherit;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  align-items: center;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
}
.boost-card strong { font-size: 17px; }
.boost-card span { font-size: 12px; font-weight: 700; }
.boost-card b { grid-row: 1 / 3; grid-column: 2; color: #b87800; }
.boost-card b { display: flex; align-items: center; gap: 3px; }
.boost-card.selected { border-color: #49ad7f; background: #edfff5; }
.boost-total {
  min-width: 220px;
  display: flex;
  justify-content: space-between;
  font-weight: 900;
  color: #fff;
}
.boost-total strong { color: var(--c-accent); }
#btn-boost-start:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

/* ===== HUD ===== */
#hud { z-index: 5; pointer-events: none; }
.hud-top {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 16px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  min-width: 0;
}
.hud-label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #a08c7d;
}
.hud-value {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}
#hud-time.warn { color: #e63946; animation: time-pulse 0.5s ease infinite; }
@keyframes time-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
#btn-pause { pointer-events: auto; }
#btn-pause:disabled { opacity: 0.55; pointer-events: none; }

/* コンボ表示 */
#combo-pop {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 40px;
  font-weight: 900;
  color: var(--c-accent);
  -webkit-text-stroke: 2px #b8860b;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
}
#combo-pop.show { animation: combo-pop 0.7s ease forwards; }
@keyframes combo-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.4) rotate(-8deg); }
  25% { opacity: 1; transform: translateX(-50%) scale(1.25) rotate(3deg); }
  55% { opacity: 1; transform: translateX(-50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.1) translateY(-24px); }
}

.stage-intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: #fff;
  text-align: center;
  animation: stage-intro 3.5s ease both;
}
.stage-intro span {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--c-accent);
}
.stage-intro strong {
  max-width: 90vw;
  font-size: 38px;
  font-weight: 900;
  text-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.stage-intro p {
  width: min(500px, 88vw);
  font-size: 14px;
  line-height: 1.7;
  font-weight: 700;
  text-shadow: 0 2px 5px rgba(0,0,0,0.55);
}
@keyframes stage-intro {
  0% { opacity: 0; }
  18%, 75% { opacity: 1; }
  100% { opacity: 0; }
}

/* バキュームゲージ */
#gauge-wrap {
  position: absolute;
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 64vw);
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 3px solid rgba(255, 255, 255, 0.85);
  overflow: hidden;
}
#gauge-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #7bd0ff, #b388ff);
  transition: width 0.12s linear;
}
#gauge-wrap.active { animation: gauge-glow 0.4s ease infinite alternate; }
#gauge-wrap.active #gauge-fill {
  background: linear-gradient(90deg, #ffd24d, #ff6b81, #b388ff);
}
@keyframes gauge-glow {
  from { box-shadow: 0 0 6px 2px rgba(255, 210, 77, 0.8); }
  to { box-shadow: 0 0 16px 6px rgba(255, 107, 129, 0.9); }
}
#gauge-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ===== ポーズ / リザルト ===== */
#screen-pause, #screen-result {
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}
#screen-result .panel {
  max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow-y: auto;
}

.result-list { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.result-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-bottom: 2px dashed rgba(0, 0, 0, 0.1);
  padding: 4px 2px;
}
.result-list dt {
  font-size: 13px;
  font-weight: 900;
  color: #a08c7d;
  letter-spacing: 0.06em;
}
.result-list dd { font-size: 24px; font-weight: 900; }

.new-badge {
  background: linear-gradient(90deg, #ffd24d, #ffb347);
  color: #7a4c00;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 6px 18px;
  border-radius: 999px;
  animation: time-pulse 0.6s ease infinite;
}
.reward-badge {
  background: #ffd24d;
  color: #7a4c00;
  font-size: 18px;
  font-weight: 900;
  padding: 8px 18px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.result-story {
  max-width: 290px;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 700;
  color: #75665d;
}
.bonus-overlay { z-index: 50; background: rgba(0,0,0,0.55); }
.bonus-panel { border-radius: 8px; }
.bonus-panel p { font-weight: 700; }
.bonus-panel strong { font-size: 25px; color: #b87800; }
.bonus-coin {
  width: 76px;
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 5px 0 #b87800);
}

/* 横向きスマホなど低い画面向けの調整 */
@media (max-height: 480px) {
  .game-title { font-size: 40px; }
  .menu { gap: 8px; }
  .btn { min-height: 46px; padding: 8px 20px; }
  #skin-grid { grid-template-columns: repeat(5, minmax(96px, 1fr)); max-height: 52vh; }
  .skin-card > .skin-image { width: 56px; height: 56px; }
  .skin-card { min-height: 158px; }
  .cross-promo { min-height: 52px; grid-template-columns: 42px 1fr 16px; padding: 5px 8px; }
  .cross-promo img { width: 42px; height: 42px; }
  .cross-promo small { display: none; }
}

@media (max-height: 700px) and (orientation: portrait) {
  #screen-title { padding-top: calc(5vh + var(--safe-top)); }
  .game-title { font-size: 44px; }
  .menu { gap: 8px; padding-bottom: 1vh; }
  .menu .btn { min-height: 48px; padding: 9px 20px; }
  .cross-promo { min-height: 60px; grid-template-columns: 48px 1fr 18px; }
  .cross-promo img { width: 48px; height: 48px; }
}

/* ===== Privacy banner ===== */
.privacy-banner {
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(12px + var(--safe-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--c-text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}
.privacy-banner p {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  text-align: left;
}
.privacy-banner a {
  color: var(--c-primary-dark);
  text-decoration: underline;
  -webkit-tap-highlight-color: rgba(255, 107, 129, 0.2);
}

/* タイトル下部のプライバシーポリシーリンク */
.legal-link {
  align-self: center;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  padding: 6px 12px; /* タップしやすい余白 */
}
.privacy-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.privacy-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--c-primary);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--c-primary-dark);
}
.privacy-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--c-primary-dark);
}
.privacy-btn-ghost {
  background: #ece7e1;
  color: var(--c-text);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}
.privacy-btn-ghost:active {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

@media (max-width: 560px) {
  .privacy-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .privacy-actions {
    justify-content: flex-end;
  }
}
