/* 
 * 計算の迷宮 - 暗算力を鍛える迷路型パズルゲーム
 * 共通スタイルシート
 */

:root {
  /* メインカラーパレット */
  --primary-color: #3498db; /* 知性を象徴する青 */
  --secondary-color: #2ecc71; /* 成長を象徴する緑 */
  --accent-color: #f39c12; /* アクセントカラー（ゴールド） */
  --bg-color: #f5f8fa; /* 背景色：明るい灰色 */
  --text-color: #2c3e50; /* テキスト色：ダークブルー */
  --header-bg: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); /* ヘッダーグラデーション */
  --game-border: #bdc3c7; /* ゲームボードの境界線 */
  --border-color: #e5e7eb; /* 一般的な境界線色 */
  --correct-color: #27ae60; /* 正解を示す緑 */
  --wrong-color: #e74c3c; /* 不正解を示す赤 */
  --panel-bg: #ffffff; /* パネル背景 */
  --shadow-color: rgba(0, 0, 0, 0.1); /* 影の色 */
  --bg-accent: #f3f4f6; /* アクセント背景色 */
  --bg-secondary: #f9fafb; /* セカンダリ背景色 */
  --text-secondary: #6b7280; /* セカンダリテキスト色 */
  --text-muted: #9ca3af; /* ミュートテキスト色 */
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* 中サイズの影 */
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* 大サイズの影 */
  
  /* フォントサイズ変数（テキストサイズ変更機能用） */
  --font-size-xs: 0.75rem; /* 極小 */
  --font-size-sm: 0.875rem; /* 小 */
  --font-size-md: 1rem; /* 標準 */
  --font-size-lg: 1.125rem; /* 大 */
  --font-size-xl: 1.25rem; /* 特大 */
  
  /* 現在のフォントサイズ設定（初期値は標準） */
  --current-font-size: var(--font-size-md);
  
  /* アニメーション速度 */
  --transition-speed: 0.3s;
  
  /* サイズと間隔 */
  --header-height: 60px;
  --footer-height: 50px;
  --sidebar-width: 250px;
  --container-padding: 20px;
  --border-radius: 8px;
}

/* フォント設定 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: var(--current-font-size);
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

/* 共通レイアウト */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--container-padding);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
header {
  background: var(--header-bg);
  color: white;
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 5px var(--shadow-color);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 var(--container-padding);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
}

.logo svg {
  margin-right: 10px;
  height: 30px;
  width: 30px;
}

.logo a {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
}

/* ナビゲーションメニュー - デスクトップ */
.nav-menu {
  display: flex;
}

.nav-menu ul {
  list-style: none;
  display: flex;
}

.nav-menu li {
  margin: 0 15px;
}

.nav-menu a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--transition-speed);
}

.nav-menu a:hover {
  opacity: 0.8;
}

/* ハンバーガーメニュー（モバイル用） */
.hamburger {
  display: none;
  cursor: pointer;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
}

/* サイドバー */
.sidebar {
  background: white;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height) - var(--footer-height));
  position: fixed;
  top: var(--header-height);
  left: 0;
  overflow-y: auto;
  box-shadow: 2px 0 5px var(--shadow-color);
  z-index: 900;
  transition: transform var(--transition-speed);
}

.sidebar-right {
  left: auto;
  right: 0;
  transform: translateX(100%);
  box-shadow: -2px 0 5px var(--shadow-color);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 15px;
  border-bottom: 1px solid #e1e1e1;
  font-weight: 700;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
}

.sidebar-menu li {
  padding: 10px 15px;
  border-bottom: 1px solid #e1e1e1;
}

.sidebar-menu a {
  color: var(--text-color);
  text-decoration: none;
  display: block;
  transition: color var(--transition-speed);
}

.sidebar-menu a:hover {
  color: var(--primary-color);
}

/* メインコンテンツ */
.main-content {
  flex: 1;
  padding-top: 20px;
  padding-bottom: 20px;
  margin-left: 0;
  transition: margin-left var(--transition-speed);
}

/* フッター */
footer {
  background-color: #2c3e50;
  color: white;
  padding: 15px 0;
  text-align: center;
  height: var(--footer-height);
}

footer a {
  color: white;
  text-decoration: none;
  margin: 0 10px;
}

footer a:hover {
  text-decoration: underline;
}

/* パネルとカードスタイル */
.panel {
  background: var(--panel-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px var(--shadow-color);
  padding: 20px;
  margin-bottom: 20px;
}

.panel-header {
  border-bottom: 1px solid #e1e1e1;
  padding-bottom: 10px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* ボタンスタイル */
.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 8px 16px;
  font-size: var(--current-font-size);
  cursor: pointer;
  transition: background-color var(--transition-speed);
  text-align: center;
  text-decoration: none;
}

.btn:hover {
  background-color: #2980b9;
}

.btn-secondary {
  background-color: var(--secondary-color);
}

.btn-secondary:hover {
  background-color: #27ae60;
}

.btn-accent {
  background-color: var(--accent-color);
}

.btn-accent:hover {
  background-color: #d35400;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.9em;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1.1em;
}

/* フォームスタイル */
.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  font-size: var(--current-font-size);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* ゲームエリア共通スタイル */
.game-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.game-board {
  position: relative;
  border: 2px solid var(--game-border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.maze-cell {
  border: 1px solid var(--game-border);
  background-color: white;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

/* 利用規約・プライバシーポリシー */
.policy-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.policy-section {
  margin-bottom: 30px;
}

.policy-section h2 {
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 5px;
  margin-bottom: 15px;
}

/* ユーティリティクラス */
.text-center {
  text-align: center;
}

.mt-20 {
  margin-top: 20px;
}

.mb-20 {
  margin-bottom: 20px;
}

.hidden {
  display: none;
}

.visible {
  display: block;
}

.fade-in {
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* テキストサイズ変更コントロール */
.font-size-controls {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.font-size-controls button {
  background: none;
  border: 1px solid #ddd;
  padding: 5px 10px;
  margin: 0 2px;
  cursor: pointer;
  border-radius: 4px;
}

.font-size-controls button:hover,
.font-size-controls button.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* メッセージ表示 */
.message {
  padding: 10px 15px;
  margin: 10px 0;
  border-radius: var(--border-radius);
}

.message-success {
  background-color: rgba(46, 204, 113, 0.2);
  border-left: 4px solid var(--secondary-color);
}

.message-error {
  background-color: rgba(231, 76, 60, 0.2);
  border-left: 4px solid var(--wrong-color);
}

.message-info {
  background-color: rgba(52, 152, 219, 0.2);
  border-left: 4px solid var(--primary-color);
}

/* ローディングスピナー */
.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

/* 回答ボタンのフィードバック */
.answer-btn.correct {
  background-color: #10b981 !important;
  color: white !important;
  transform: scale(1.05);
  transition: all 0.3s ease;
}

.answer-btn.incorrect {
  background-color: #ef4444 !important;
  color: white !important;
  animation: shake 0.5s ease;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1100;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s linear 0.25s, opacity 0.25s;
}

.modal-overlay.active {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.modal-content {
  background-color: white;
  width: 90%;
  max-width: 500px;
  border-radius: var(--border-radius);
  padding: 20px;
  position: relative;
  transform: scale(0.8);
  transition: transform 0.25s;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
}

/* 言語切替ボタン */
.language-switcher {
  display: flex;
  align-items: center;
}

.language-switcher button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  margin: 0 5px;
  opacity: 0.6;
  transition: opacity var(--transition-speed);
}

.language-switcher button.active {
  opacity: 1;
  font-weight: bold;
  border-bottom: 2px solid white;
}

/* SNSシェアボタン */
.share-buttons {
  display: flex;
  gap: 10px;
  margin: 15px 0;
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border-radius: 20px;
  color: white;
  text-decoration: none;
  font-size: 0.9em;
}

.share-twitter {
  background-color: #1da1f2;
}

.share-facebook {
  background-color: #1877f2;
}

.share-line {
  background-color: #00b900;
}

/* ステータスバーとスコア表示 */
.status-bar {
  display: flex;
  justify-content: space-between;
  background-color: #f8f9fa;
  padding: 10px 15px;
  border-radius: var(--border-radius);
  margin-bottom: 15px;
}

.score-display {
  font-weight: 700;
  color: var(--primary-color);
}

.timer-display {
  font-weight: 700;
  color: var(--accent-color);
}

/* レスポンシブデザイン */
@media (max-width: 992px) {
  :root {
    --sidebar-width: 220px;
  }
}

@media (max-width: 768px) {
  .nav-menu {
    display: none;
  }
  
  .hamburger {
    display: block;
  }
  
  .main-content {
    margin-left: 0 !important;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .desktop-sidebar {
    display: none;
  }
}

@media (min-width: 769px) {
  .main-content {
    margin-left: var(--sidebar-width);
  }
  
  .sidebar-right {
    display: none;
  }
  
  .hamburger {
    display: none;
  }
}

@media (max-width: 576px) {
  .container {
    padding: 10px;
  }
  
  :root {
    --header-height: 50px;
  }
}

/* アニメーションとトランジション */
.slide-in-left {
  animation: slideInLeft 0.3s forwards;
}

.slide-out-left {
  animation: slideOutLeft 0.3s forwards;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slideOutLeft {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a202c;
    --text-color: #e2e8f0;
    --panel-bg: #2d3748;
    --game-border: #4a5568;
    --border-color: #4a5568;
    --bg-accent: #374151;
    --bg-secondary: #4b5563;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
  }
  
  .form-control {
    background-color: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
  }
  
  .sidebar, .maze-cell {
    background-color: #2d3748;
  }
  
  .sidebar-menu li {
    border-bottom-color: #4a5568;
  }
  
  .sidebar-menu a {
    color: #e2e8f0;
  }
  
  .panel-header {
    border-bottom-color: #4a5568;
  }
}

/* PWA対応 */
@media (display-mode: standalone) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
  }
}

/* 追加のユーティリティクラス（既存のクラスとの統合） */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }

.bg-white { background-color: white; }
.bg-gray-50 { background-color: var(--bg-color); }
.bg-gray-100 { background-color: #f3f4f6; }

.rounded { border-radius: var(--border-radius); }
.rounded-sm { border-radius: 4px; }
.rounded-lg { border-radius: 12px; }
.rounded-full { border-radius: 9999px; }

.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }

/* Flexboxの追加ユーティリティ */
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.space-x-4 > * + * { margin-left: 1rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* パディング・マージンの追加 */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }

.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 0.75rem; }
.m-4 { margin: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.ml-4 { margin-left: 1rem; }

.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.mr-4 { margin-right: 1rem; }

/* 幅と高さのユーティリティ */
.w-full { width: 100%; }
.w-auto { width: auto; }
.h-full { height: 100%; }
.h-auto { height: auto; }

/* 文字色の追加 */
.text-white { color: white; }
.text-black { color: black; }
.text-gray-500 { color: #6b7280; }
.text-gray-700 { color: #374151; }
.text-blue-500 { color: var(--primary-color); }
.text-green-500 { color: var(--secondary-color); }
.text-yellow-500 { color: var(--accent-color); }
.text-red-500 { color: var(--wrong-color); }

/* カーソルスタイル */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }

/* オーバーフロー制御 */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ポジション */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Z-index */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* トランジション */
.transition { transition: all var(--transition-speed); }
.transition-colors { transition: color var(--transition-speed), background-color var(--transition-speed); }
.transition-opacity { transition: opacity var(--transition-speed); }
.transition-transform { transition: transform var(--transition-speed); }

/* ブロック表示の制御 */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* アクセシビリティ向上のためのフォーカススタイル */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* 印刷時のスタイル */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .btn, .form-control, .modal {
    box-shadow: none !important;
  }
}

/* アニメーションの追加 */
.bounce {
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .5;
  }
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #0066cc;
    --secondary-color: #008844;
    --text-color: #000000;
    --bg-color: #ffffff;
    --border-color: #000000;
  }
  
  .btn {
    border: 2px solid currentColor;
  }
}

/* 動作を軽減したい人向けの設定 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}