/* ===========================================
   ヴィレヴァン福袋たたき
   PixiJS Version
   =========================================== */

/* Google Fonts - Zen Maru Gothic (コーポレートロゴ風) */
@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@900&display=swap');

/* CSS Variables */
:root {
  /* Colors */
  --color-red: #ff0000;
  --color-yellow: #ffff00;
  --color-blue: #0066ff;
  --color-cyan: #00ffff;
  --color-green: #00ff00;
  --color-orange: #ff6600;

  /* Text */
  --text-primary: #ffffff;

  /* Fonts */
  --font-main: 'Zen Maru Gothic', sans-serif;
  --font-comic: 'Zen Maru Gothic', sans-serif;
  --font-marker: 'Zen Maru Gothic', sans-serif;
  --font-body: 'Zen Maru Gothic', sans-serif;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* Game Container - PixiJS Canvas */
#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Screen shake animations */
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

@keyframes screen-shake-strong {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-6px, 4px); }
  30% { transform: translate(6px, -4px); }
  50% { transform: translate(-4px, -3px); }
  70% { transform: translate(4px, 3px); }
  90% { transform: translate(-2px, 2px); }
}

#game-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* UI Overlay */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* ============================================
   Header UI - Score & Time (Comic Style)
   ============================================ */
#header-ui {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  pointer-events: none;
  z-index: 20;
  opacity: 0;
}

.header-title {
  max-height: 140px;
  max-width: 40%;
  width: auto;
  margin-top: 5px;
}

/* Game Banner - Fixed Bottom */
.game-banner {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  display: block;
  z-index: 30;
  pointer-events: auto;
  padding: 12px 16px;
}

.game-banner img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: relative;
}

.stat-score {
  width: 110px;
  height: 85px;
  background-image: url('assets/images/game_score.png');
  padding-top: 5px;
  margin-top: 30px;
}

.stat-time {
  width: 90px;
  height: 90px;
  background-image: url('assets/images/game_time.png');
  padding-top: 5px;
  margin-top: 30px;
}

.stat-value {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 32px;
  color: #fff;
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
  line-height: 1;
}

#time-value.warning {
  color: #ff0000;
  animation: pulse-warning 0.3s ease-in-out infinite, shake 0.1s infinite;
  text-shadow:
    3px 3px 0 #000,
    0 0 20px #ff0000;
}

@keyframes pulse-warning {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ============================================
   Combo Display - Pop Style
   ============================================ */
#combo-display {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 20px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
  border: 3px solid #000;
  border-radius: 14px;
  animation: combo-pop 0.3s ease-out;
  z-index: 50;
}

#combo-display.hidden {
  display: none;
}

#combo-value {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 24px;
  color: #fff;
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
  line-height: 1;
}

#combo-label {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 10px;
  color: #fff;
  -webkit-text-stroke: 1px #000;
  paint-order: stroke fill;
  letter-spacing: 2px;
}

@keyframes combo-pop {
  0% { transform: translateX(-50%) scale(0); opacity: 0; }
  70% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ============================================
   Screens (Title, Result)
   ============================================ */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-y: auto;
}

.screen.hidden {
  display: none;
}

/* ============================================
   Title Screen - Comic Style
   ============================================ */
.game-title {
  font-family: var(--font-comic);
  font-size: 42px;
  color: #ffffff;
  text-align: center;
  margin-bottom: 12px;
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
  text-shadow:
    4px 4px 0 #ff0000,
    6px 6px 0 #000,
    0 0 20px rgba(255, 0, 0, 0.5);
  animation: title-slam 0.5s ease-out, title-wobble 2s ease-in-out infinite 0.5s;
  position: relative;
  z-index: 1;
  transform: rotate(-2deg) skewX(-3deg);
  letter-spacing: 2px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #ff0000 0%, #cc0000 100%);
  border: 5px solid #000;
  border-radius: 10px;
  box-shadow: 6px 6px 0 #000;
}

@keyframes title-slam {
  0% { transform: scale(3) rotate(10deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(-5deg); }
  100% { transform: scale(1) rotate(-2deg) skewX(-3deg); opacity: 1; }
}

@keyframes title-wobble {
  0%, 100% { transform: rotate(-2deg) skewX(-3deg) scale(1); }
  25% { transform: rotate(-1deg) skewX(-2deg) scale(1.02); }
  75% { transform: rotate(-3deg) skewX(-4deg) scale(0.98); }
}

.game-subtitle {
  font-family: var(--font-comic);
  font-size: 20px;
  color: var(--color-cyan);
  margin-bottom: 8px;
  -webkit-text-stroke: 2px #000;
  text-shadow: 3px 3px 0 #000;
  position: relative;
  z-index: 1;
  transform: rotate(1deg);
}

.game-hint {
  font-family: var(--font-marker);
  font-size: 14px;
  color: #000;
  margin-bottom: 24px;
  padding: 10px 20px;
  background: var(--color-yellow);
  border: 4px solid #000;
  box-shadow: var(--shadow-comic);
  position: relative;
  z-index: 1;
  transform: rotate(2deg);
}

/* Speech bubble tail */
.game-hint::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 30px;
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 15px solid #000;
}

.game-hint::before {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 33px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid var(--color-yellow);
  z-index: 1;
}

/* Bag Info Grid - Comic Panel Style */
.bag-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin-bottom: 32px;
  background: #fff;
  padding: 16px 20px;
  border: 5px solid #000;
  box-shadow: var(--shadow-pop);
  position: relative;
  z-index: 1;
  transform: rotate(-1deg);
}


.bag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-comic);
  font-size: 16px;
  color: #000;
  letter-spacing: 1px;
}

.bag-color {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  border: 3px solid #000;
  box-shadow: 2px 2px 0 #000;
}

.bag-color.gold {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
}
.bag-color.red {
  background: linear-gradient(135deg, #ff0000, #cc0000);
}
.bag-color.blue {
  background: linear-gradient(135deg, #0066ff, #0044cc);
}
.bag-color.green {
  background: linear-gradient(135deg, #00cc00, #009900);
}
.bag-color.chicken {
  background: linear-gradient(135deg, #ffcc00, #ff9900);
}
.bag-color.trash {
  background: linear-gradient(135deg, #888888, #555555);
}
.bag-color.skull {
  background: linear-gradient(135deg, #ffffff, #cccccc);
  border-color: #ff0000;
}

/* Combo Hint */
.combo-hint {
  font-family: var(--font-comic);
  font-size: 18px;
  color: #fff;
  margin-bottom: 20px;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--color-orange), #ff3300);
  border: 4px solid #000;
  border-radius: 8px;
  box-shadow: var(--shadow-comic);
  position: relative;
  z-index: 1;
  transform: rotate(1deg);
  -webkit-text-stroke: 1px #000;
  text-shadow: 2px 2px 0 #000;
  letter-spacing: 1px;
}

/* ============================================
   Title Screen - Image Based
   ============================================ */
#title-screen {
  background: url('assets/images/bg_back.png') center center / cover no-repeat;
  background-color: #000;
  justify-content: center;
  padding: 0;
}

#title-screen::before {
  display: none;
}

/* スマホファースト: 最大幅を制限した内部コンテナ */
#title-screen .title-wrapper {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.title-images {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(12px, 2vh);
  width: 100%;
  padding: 10px;
  position: relative;
  z-index: 1;
}

.start-image {
  width: 100%;
  max-width: min(320px, 85vw);
  height: auto;
  display: block;
  flex-shrink: 0;
}

.start-image.start-title {
  max-width: 100%;
  max-height: 35vh;
  object-fit: contain;
  animation: title-slam 0.5s ease-out, title-wobble 2s ease-in-out infinite 0.5s;
}

.start-image.start-mission {
  max-width: min(280px, 75vw);
  max-height: 24vh;
  object-fit: contain;
}

.start-image.start-descriptions {
  max-width: 100%;
  max-height: 20vh;
  object-fit: contain;
}

.start-button {
  max-width: min(200px, 55vw);
  max-height: 12vh;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.1s ease;
  animation: button-pulse 1.2s ease-in-out infinite;
}

@keyframes button-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.start-button:active {
  transform: scale(0.95);
  animation: none;
}

/* 小さい画面用の調整 */
@media (max-height: 600px) {
  .title-images {
    gap: 8px;
  }

  .start-title {
    max-height: 26vh;
  }

  .start-mission {
    max-height: 15vh;
  }

  .start-descriptions {
    max-height: 22vh;
  }

  .start-button {
    max-height: 10vh;
  }
}

/* ============================================
   Game Buttons - Comic Action Style
   ============================================ */
.game-button {
  padding: 18px 56px;
  font-family: var(--font-comic);
  font-size: 28px;
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(180deg, #ff0000 0%, #cc0000 100%);
  border: 5px solid #000;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: transform 0.1s ease;
  box-shadow: 6px 6px 0 #000;
  -webkit-text-stroke: 2px #000;
  text-shadow: 3px 3px 0 #660000;
  transform: rotate(-1deg) skewX(-2deg);
}


.game-button:active {
  transform: translateY(4px) translateX(4px) rotate(-1deg) skewX(-2deg);
  box-shadow: 2px 2px 0 #000;
}

.game-button.secondary {
  background: linear-gradient(180deg, #666666 0%, #444444 100%);
  text-shadow: 3px 3px 0 #222;
}

/* ============================================
   Countdown - Comic Impact Style
   ============================================ */
#countdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
}

#countdown.hidden {
  display: none;
}

#countdown-number {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 200px;
  color: #fff;
  -webkit-text-stroke: 10px #000;
  paint-order: stroke fill;
  animation: countdown-slam 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes countdown-slam {
  0% { transform: scale(5) rotate(20deg); opacity: 0; }
  40% { transform: scale(0.8) rotate(-10deg); opacity: 1; }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ============================================
   Result Screen - Simple Pop Style
   ============================================ */
#result-screen {
  background: url('assets/images/bg_back.png') center center / cover no-repeat;
  background-color: #000;
  justify-content: center;
  padding: 0;
}

#result-screen::before {
  display: none;
}

/* スマホファースト: 最大幅を制限した内部コンテナ */
#result-screen .result-wrapper {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  padding-top: calc(30px + env(safe-area-inset-top));
  padding-bottom: calc(30px + env(safe-area-inset-bottom));
}

/* 結果画面のコンテンツ */
#result-screen .result-wrapper > * {
  flex-shrink: 0;
}

.result-title {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 36px;
  color: #fff;
  -webkit-text-stroke: 4px #000;
  paint-order: stroke fill;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
  letter-spacing: 2px;
  animation: result-pop 0.5s ease-out;
}

@keyframes result-pop {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.final-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  width: 220px;
  height: 165px;
  background: url('assets/images/game_score.png') center center / contain no-repeat;
  position: relative;
  z-index: 1;
  margin-top: 0;
  padding-top: 20px;
}

.final-score-label {
  display: none;
}

.final-score-number {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 48px;
  color: #fff;
  -webkit-text-stroke: 4px #000;
  paint-order: stroke fill;
  line-height: 1;
}

/* New Record Badge - Pop Style */
.new-record-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ffeb3b, #ffc107);
  border: 4px solid #000;
  border-radius: 30px;
  animation: badge-bounce 0.6s ease-out;
  position: relative;
  z-index: 2;
}

.new-record-badge.hidden {
  display: none;
}

.new-record-text {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 16px;
  color: #fff;
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
  letter-spacing: 1px;
}

@keyframes badge-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Best Score - フラット表示 */
.best-score {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  padding: 6px 12px;
  background: #ffc107;
  border-radius: 16px;
  z-index: 10;
}

.best-score-label {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 12px;
  color: #000;
  letter-spacing: 1px;
}

.best-score-number {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 18px;
  color: #000;
  line-height: 1;
}

/* Share Buttons - Flat Style */
.share-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.share-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 1px;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.share-button:active {
  opacity: 0.8;
}

.share-icon {
  font-size: 16px;
}

.share-x {
  background: #222;
}

.share-copy {
  background: #4a90d9;
}

.share-copy.copied {
  background: #4CAF50;
}

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 320px;
  position: relative;
  z-index: 1;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border-radius: 8px;
}

.breakdown-item.plus {
  background: #4CAF50;
}

.breakdown-item.minus {
  background: #f44336;
}

.breakdown-image {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.breakdown-count {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 14px;
  color: #fff;
  line-height: 1;
}

.result-buttons {
  display: flex;
  flex-direction: row;
  gap: 12px;
  position: relative;
  z-index: 1;
  margin-top: 8px;
  margin-bottom: 0;
}

/* リトライボタン（画像） */
.retry-button-img {
  width: 180px;
  height: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
  animation: button-pulse 1.2s ease-in-out infinite;
}

.retry-button-img:active {
  transform: scale(0.95);
  animation: none;
}

/* 結果画面のバナー */
.result-banner {
  display: block;
  margin-top: 24px;
  max-width: 300px;
  width: 100%;
  position: relative;
  z-index: 1;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transition: transform 0.2s ease;
}

.result-banner:active {
  transform: scale(0.98);
}

.result-banner img {
  display: block;
  width: 100%;
  height: auto;
}

/* ============================================
   Score Popup Animation - Comic Impact
   ============================================ */
.score-popup {
  position: absolute;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 32px;
  pointer-events: none;
  animation: score-impact 0.8s ease-out forwards;
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
}

.score-popup.positive {
  color: var(--color-green);
  text-shadow: 4px 4px 0 #000;
}

.score-popup.negative {
  color: var(--color-red);
  text-shadow: 4px 4px 0 #000;
}

@keyframes score-impact {
  0% {
    opacity: 1;
    transform: translateY(0) scale(2) rotate(-10deg);
  }
  30% {
    transform: translateY(-20px) scale(1.5) rotate(5deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(1) rotate(0deg);
  }
}

/* ============================================
   Hidden class
   ============================================ */
.hidden {
  display: none !important;
}

/* ============================================
   Responsive adjustments
   ============================================ */
@media (max-height: 700px) {
  .game-title {
    font-size: 32px;
    padding: 8px 16px;
  }

  .bag-info {
    gap: 4px 12px;
    padding: 10px 14px;
  }

  .bag-row {
    font-size: 13px;
  }

  .bag-color {
    width: 22px;
    height: 22px;
  }

  #countdown-number {
    font-size: 120px;
  }

  .result-title {
    font-size: 28px;
    margin-bottom: 6px;
  }

  .final-score {
    padding: 10px 30px;
    margin-bottom: 8px;
  }

  .final-score-number {
    font-size: 48px;
  }

  .best-score {
    padding: 4px 10px;
    right: 14px;
  }

  .best-score-number {
    font-size: 16px;
  }

  .result-breakdown {
    gap: 4px;
    margin-bottom: 8px;
  }

  .breakdown-item {
    padding: 4px 2px;
  }

  .breakdown-image {
    width: 26px;
    height: 26px;
  }

  .breakdown-count {
    font-size: 12px;
  }

  .share-buttons {
    margin-bottom: 8px;
  }

  .share-button {
    padding: 10px 16px;
    font-size: 14px;
  }

  #result-screen .game-button {
    padding: 12px 40px;
    font-size: 20px;
  }

  .result-buttons {
    gap: 8px;
  }
}

@media (max-width: 360px) {
  .game-title {
    font-size: 32px;
  }

  .stat-value {
    font-size: 32px;
  }

  .game-button {
    padding: 14px 40px;
    font-size: 22px;
  }
}

/* ============================================
   Comic Sound Effect Animations
   ============================================ */
@keyframes pow-effect {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes bam-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Star decoration - Comic style */
.star-decoration {
  position: absolute;
  width: 24px;
  height: 24px;
  background: var(--color-yellow);
  border: 3px solid #000;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: star-spin 2s linear infinite;
}

@keyframes star-spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

/* ============================================
   Sound Confirmation Popup
   ============================================ */
.sound-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-popup.hidden {
  display: none;
}

.sound-popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
}

.sound-popup-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: popup-appear 0.3s ease-out;
  max-width: 300px;
  width: 90%;
}

@keyframes popup-appear {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.sound-popup-message {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 18px;
  color: #333;
  margin-bottom: 20px;
  line-height: 1.4;
}

.sound-popup-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.sound-popup-btn {
  padding: 12px 32px;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}

.sound-popup-btn:active {
  transform: scale(0.95);
}

.sound-popup-yes {
  background: #4CAF50;
  color: #fff;
}

.sound-popup-no {
  background: #666;
  color: #fff;
}

/* ============================================
   Sound Toggle Button - Fixed Bottom Right
   ============================================ */
.sound-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #fff;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.sound-toggle:active {
  transform: scale(0.9);
}

.sound-toggle:hover {
  background: rgba(0, 0, 0, 0.85);
}

.sound-icon {
  font-size: 24px;
  line-height: 1;
}

.sound-icon.hidden {
  display: none;
}

.sound-toggle.muted {
  background: rgba(255, 0, 0, 0.5);
  border-color: #ff6666;
}

/* Game Banner との位置調整 */
.game-banner ~ .sound-toggle {
  bottom: 100px;
}

/* Safe area 対応 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sound-toggle {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .game-banner ~ .sound-toggle {
    bottom: calc(100px + env(safe-area-inset-bottom));
  }
}

