:root {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background-color: #f4f6f8;
  color: #333;
}

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

.root {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background-color: #2c3e50;
}

.game-root {
  max-width: 1000px;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: #fff;

  border: 0.5em solid #1e272e;
}

@media (min-width: 1000px) {
  .game-root {
    margin-top: 1em;
  }
}

/* ヘッダー */
.site-header {
  width: 100%;
  height: 60px;
  background-color: #2c3e50;
  color: #fff;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-text {
  font-size: 1.2rem;
  font-weight: bold;
  letter-spacing: 0.05em;
}

.btn-text-link {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-text-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}

.stage-counter strong {
  color: #f1c40f;
  font-size: 1.4rem;
}

/* メインコンテンツ（Webサイト本体） */
.main-content {
  background: #fff;
  padding-bottom: 30px;
  transition: background-color 0.3s ease;
}

.hero-banner {
  background: linear-gradient(135deg, darkcyan, purple);
  color: white;
  text-align: center;
  padding: 40px 20px;
}

.hero-title {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.hero-sub {
  font-size: 1rem;
  opacity: 0.9;
}

.products-section,
.notice-section {
  margin: 24px 20px;
}

.notice-section {
  background: #f8f9fa;
  border-left: 4px solid #3498db;
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
}

.notice-title {
  font-size: 1rem;
  margin-bottom: 6px;
  color: #2c3e50;
}

.section-title {
  font-size: 1.4rem;
  margin-bottom: 16px;
  color: #2c3e50;
  border-bottom: 2px solid #ecf0f1;
  padding-bottom: 8px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.product-card {
  border: 1px solid #e2e8f0;
  padding: 1em;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.product-image {
  font-size: 56px;
  margin-bottom: 12px;
  line-height: 1;
}

.product-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-category {
  font-size: 0.75rem;
  color: #718096;
  background: #edf2f7;
  padding: 2px 6px;
  border-radius: 4px;
  align-self: center;
}

.product-name {
  font-size: 0.95rem;
  color: #2d3748;
  margin: 4px 0;
}

.product-rating {
  font-size: 0.8rem;
  color: #f39c12;
}

.review-count {
  color: #a0aec0;
  font-size: 0.75rem;
}

.product-price {
  font-size: 1.15rem;
  font-weight: bold;
  color: #e53e3e;
  margin-top: 4px;
}

.footer-text {
  text-align: center;
  color: #a0aec0;
  font-size: 0.85rem;
  padding-top: 20px;
  border-top: 1px solid #edf2f7;
}

/* 下部アクションバー */
.action-bar {
  flex-shrink: 0;
  width: 100%;
  max-width: 1000px;
  background: #1e272e;
  color: white;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 100;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
}

@media (min-width: 1000px) {
  .action-bar {
    margin-bottom: 1em;
  }
}

.action-inner {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.action-buttons {
  margin-top: 0.6em;
  display: flex;
  justify-content: center;
  gap: 1em;
}

/* モーダル共通デザイン */
.modal {
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 12px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.4),
    0 10px 10px -5px rgba(0, 0, 0, 0.2);
  background: #ffffff;
  max-width: 800px;
  width: 90%;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal-content {
  padding: 1rem;
  text-align: center;
}

.rule-box {
  margin: 1em 0;
  text-align: start;
  padding-left: 2em;
}

.btn {
  min-width: 110px;
  font-size: 1rem;
  padding: 0.6em 1.2em;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition:
    transform 0.1s ease,
    filter 0.2s ease;
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background-color: #3182ce;
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-start-game {
  width: 100%;
  padding: 0.8em;
}

.btn-normal {
  background-color: #27ae60;
  color: white;
}

.btn-normal:hover {
  background-color: #2ecc71;
}

.btn-anomaly {
  background-color: #c0392b;
  color: white;
}

.btn-anomaly:hover {
  background-color: #e74c3c;
}

/* 異変用スタイル・キーフレームアニメーション */
@keyframes anomaly-shake {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(-2px, 2px) rotate(-3deg);
  }
  50% {
    transform: translate(2px, -2px) rotate(3deg);
  }
  75% {
    transform: translate(-2px, -2px) rotate(-1deg);
  }
}

.anomaly-shaking {
  animation: anomaly-shake 0.15s infinite;
  display: inline-block;
}

@keyframes anomaly-pulse-grow {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
}

.anomaly-pulsing {
  animation: anomaly-pulse-grow 1s infinite ease-in-out;
}

@keyframes glitch-skew {
  0%,
  100% {
    transform: skew(0deg);
  }
  20% {
    transform: skew(10deg);
    filter: hue-rotate(90deg);
  }
  40% {
    transform: skew(-10deg);
    filter: hue-rotate(180deg);
  }
  60% {
    transform: skew(5deg);
  }
  80% {
    transform: skew(-5deg);
  }
}

.anomaly-glitch {
  animation: glitch-skew 0.3s infinite steps(2);
}

/* 画面遷移・暗転フェード演出 */
.transition-overlay {
  position: fixed;
  inset: -60px;
  background-color: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.35s ease;
  user-select: none;
}

.transition-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* 正解時（通常暗転） */
.transition-overlay.correct {
  background-color: #05080c;
}

/* 不正解時（警告・赤みがかった暗転＋画面揺れ） */
.transition-overlay.incorrect {
  background: radial-gradient(circle, #2a0505 0%, #080000 100%);
  animation: shake 0.4s ease-in-out;
  transition:
    opacity 0.15s ease,
    background-color 0.15s ease;
}

.transition-message {
  color: #fff;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.3s ease 0.1s,
    transform 0.3s ease 0.1s;
  padding: 0 20px;
}

.transition-overlay.active .transition-message {
  opacity: 1;
  transform: translateY(0);
}

.transition-message.incorrect-text {
  color: #ff6b6b;
  text-shadow: 0 0 10px rgba(255, 77, 77, 0.6);
}

.transition-message.correct-text {
  color: #a8e6cf;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

/* クリア画面の異変統計表示 */
.clear-stats {
  margin: 1.25rem auto;
  padding: 0.85rem 1.2rem;
  background-color: #f7fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: inline-block;
  min-width: 220px;
}

.clear-stats p {
  margin: 0.25rem 0;
  font-size: 1.1rem;
  color: #2d3748;
}

.clear-stats .highlight-count {
  font-size: 1.35rem;
  color: #3182ce;
  font-weight: bold;
}

.clear-anomaly-detail {
  font-size: 0.85rem !important;
  color: #718096 !important;
}

/* モバイル向けレスポンシブ最適化 */
@media (max-width: 600px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .products-section,
  .notice-section {
    margin: 16px 10px;
  }

  .hero-banner {
    padding: 24px 12px;
  }

  .hero-title {
    font-size: 1.4rem;
  }

  .hero-sub {
    font-size: 0.9rem;
  }

  .product-card {
    padding: 0.75em 0.5em;
  }

  .product-image {
    font-size: 42px;
    margin-bottom: 8px;
  }

  .product-name {
    font-size: 0.85rem;
  }

  .product-price {
    font-size: 1.05rem;
  }

  .action-bar {
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .btn {
    min-width: 95px;
    padding: 0.55em 0.9em;
    font-size: 0.95rem;
  }

  .modal-content {
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.25rem 1rem;
  }

  .rule-box {
    font-size: 0.9rem;
    padding-left: 1.2em;
    line-height: 1.5;
  }
}
