/* ==========================================================
   ブラックホール・ギャラクシー - style.css
   ========================================================== */

:root {
  --color-bg-top: #120a24;
  --color-bg-bottom: #05030d;
  --color-box: #1c1236;
  --color-box-border: #7c4dff;
  --color-primary: #b57bff;
  --color-primary-2: #7cf9ff;
  --color-good: #7cf9ff;
  --color-text: #efe8ff;
  --color-text-muted: #a89bd6;
  --color-border: #3a2a63;
  --header-h: 56px;
  --ad-h: 60px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(ellipse at 50% 30%, #24144a 0%, var(--color-bg-top) 45%, var(--color-bg-bottom) 100%);
  color: var(--color-text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.8rem;
  background: rgba(12, 7, 26, 0.75);
  border-bottom: 2px solid var(--color-box-border);
  z-index: 20;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.back-link:active {
  background: rgba(255, 255, 255, 0.18);
}

.game-title {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

.icon-btn.is-muted {
  color: var(--color-text-muted);
}

/* ---------- HUD ---------- */
.stat-row {
  flex: 0 0 auto;
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem 0.3rem;
  z-index: 10;
}

.stat-box {
  flex: 1 1 0;
  min-width: 0;
  background: rgba(28, 18, 54, 0.8);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 0.3rem 0.5rem;
  text-align: center;
  line-height: 1.25;
}

.stat-box__label {
  display: block;
  font-size: 0.6rem;
  font-weight: bold;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stat-box__value {
  display: block;
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-box--mps .stat-box__value {
  color: var(--color-good);
}

/* ---------- ブラックホール表示エリア ---------- */
.blackhole-view {
  position: relative;
  flex: 1 1 46%;
  min-height: 200px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(124, 77, 255, 0.18), transparent 65%);
  border-bottom: 2px solid var(--color-border);
}

.orbit-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.orbit-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  animation: orbit-spin linear infinite;
}

.orbit-particle__icon {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  opacity: 0.85;
  filter: drop-shadow(0 0 4px rgba(124, 249, 255, 0.5));
}

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

.blackhole-wrap {
  position: relative;
  z-index: 3;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.blackhole {
  --bh-glow: rgba(181, 123, 255, 0.55);
  --bh-glow-strong: rgba(124, 249, 255, 0.85);
  width: clamp(120px, 34vw, 220px);
  height: clamp(120px, 34vw, 220px);
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 26px var(--bh-glow));
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.6s ease;
  transform-origin: center center;
  will-change: transform;
}

.blackhole-wrap.is-tapped .blackhole {
  animation: blackhole-pulse 0.18s ease;
}

@keyframes blackhole-pulse {
  0% { filter: drop-shadow(0 0 26px var(--bh-glow)); }
  45% { filter: drop-shadow(0 0 42px var(--bh-glow-strong)); }
  100% { filter: drop-shadow(0 0 26px var(--bh-glow)); }
}

.blackhole__tap-hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 800;
  color: rgba(239, 232, 255, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------- 吸収スケール表示バー ---------- */
.stage-bar {
  position: relative;
  z-index: 3;
  width: min(90vw, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.stage-bar__badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(12, 7, 26, 0.6);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--color-primary-2);
}

.stage-bar__badge img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
}

.stage-bar__progress {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.stage-bar__progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-2));
  transition: width 0.3s ease;
}

.stage-bar__next {
  font-size: 0.62rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- 飛び出す +N エフェクト ---------- */
.float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

.float-text {
  position: absolute;
  font-size: 1rem;
  font-weight: 900;
  color: var(--color-primary-2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 2px 8px rgba(124, 249, 255, 0.4);
  transform: translate(-50%, -50%);
  animation: float-up 0.85s ease-out forwards;
  white-space: nowrap;
}

@keyframes float-up {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
  }
  20% {
    transform: translate(-50%, -70%) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -140%) scale(1);
  }
}

/* ---------- タップ時に吸い込まれる粒子エフェクト ---------- */
.absorb-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 4;
}

.absorb-particle {
  position: absolute;
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  animation: absorb-in 0.5s ease-in forwards;
}

@keyframes absorb-in {
  0% {
    opacity: 0.95;
    transform: translate(var(--from-x), var(--from-y)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(0, 0) scale(0.15);
  }
}

/* ---------- 重力強化ショップ ---------- */
.shop-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(5, 3, 13, 0.4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.shop-panel__title {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.55rem 0.8rem 0.25rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--color-text);
}

.shop-list {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.15rem 0.65rem 0.5rem;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--color-box);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 0.45rem 0.6rem;
}

.shop-item__icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-color: rgba(124, 77, 255, 0.1);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 78%;
  image-rendering: pixelated;
}

.shop-item__info {
  flex: 1 1 auto;
  min-width: 0;
}

.shop-item__name {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.shop-item__owned {
  font-size: 0.64rem;
  font-weight: 800;
  color: #1c1236;
  background: var(--color-primary-2);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.shop-item__desc {
  font-size: 0.66rem;
  color: var(--color-text-muted);
  margin: 0.15rem 0 0;
}

.shop-item__buy {
  flex: 0 0 auto;
  border: none;
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  min-width: 86px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #170c33;
  font-weight: 900;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
}

.shop-item__buy:active {
  filter: brightness(0.92);
}

.shop-item__buy:disabled {
  background: #362a52;
  color: #7d739a;
  cursor: not-allowed;
}

.shop-item__buy-label {
  font-size: 0.6rem;
  opacity: 0.85;
}

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 10, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay__box {
  text-align: center;
  padding: 1.8rem 2rem;
  background: var(--color-box);
  border: 3px solid var(--color-box-border);
  border-radius: 22px;
  max-width: 85%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.overlay__box--wide {
  max-width: min(92%, 460px);
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.guide-section {
  text-align: left;
  margin: 1rem 0;
}

.guide-section__title {
  font-size: 0.92rem;
  color: var(--color-primary);
  margin: 0 0 0.4rem;
}

.guide-section__text {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.6;
}

.guide-section__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.7;
}

.guide-section__list li {
  margin-bottom: 0.3rem;
}

.overlay__title {
  font-size: 1.3rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
  color: var(--color-primary);
}

.overlay__result-emoji {
  font-size: 2.4rem;
  margin: 0 0 0.2rem;
}

.overlay__desc {
  color: var(--color-text-muted);
  margin: 0 0 1.3rem;
  font-size: 0.9rem;
  font-weight: bold;
}

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #170c33;
  font-weight: bold;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.overlay__btn:active {
  filter: brightness(0.92);
}

.overlay__btn-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.overlay__btn--ghost {
  background: rgba(181, 123, 255, 0.12);
  color: var(--color-primary);
}

/* ---------- ランクアップ通知トースト ---------- */
.stage-toast {
  position: fixed;
  top: calc(var(--header-h) + 66px);
  left: 50%;
  transform: translate(-50%, -140%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(124, 77, 255, 0.95), rgba(124, 249, 255, 0.95));
  color: #14082b;
  font-weight: 900;
  font-size: 0.82rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(124, 77, 255, 0.5);
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  opacity: 0;
  white-space: nowrap;
}

.stage-toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.stage-toast img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ---------- 広告スペース ---------- */
.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.3rem 0.65rem 0.6rem;
  border: 2px dashed var(--color-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  overflow: hidden;
}

@media (max-height: 620px) {
  .blackhole-view {
    flex-basis: 38%;
    min-height: 170px;
  }
  .blackhole {
    width: clamp(100px, 28vw, 180px);
    height: clamp(100px, 28vw, 180px);
  }
}
