/**
 * ゲームプラットフォーム共通スタイル
 */

/* 全体のリセットとベーススタイル */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Yusei Magic', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

a {
  color: #007bff;
  text-decoration: none;
  transition: color 0.3s;
}

a:hover {
  color: #0056b3;
}

button {
  cursor: pointer;
}

/* コンテナ */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* ヘッダー */
header {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: #333;
}

.logo a {
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo img {
  height: 40px;
  width: auto;
}

/* ナビゲーション */
nav ul {
  display: flex;
  list-style: none;
}

nav ul li {
  margin-left: 20px;
}

nav ul li a {
  color: #333;
  font-weight: 500;
}

/* ハンバーガーメニュー */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: #333;
}

/* メインコンテンツ */
main {
  margin-top: 80px;
  padding: 20px 0;
  min-height: calc(100vh - 160px);
}

/* フッター */
footer {
  background-color: #333;
  color: #fff;
  padding: 20px 0;
  text-align: center;
}

/* カード */
.card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}

.card-content {
  margin-bottom: 15px;
}

/* ボタン */
.btn {
  display: inline-block;
  padding: 10px 20px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  transition: background-color 0.3s;
}

.btn:hover {
  background-color: #0056b3;
  color: #fff;
}

.btn-secondary {
  background-color: #6c757d;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

.btn-success {
  background-color: #28a745;
}

.btn-success:hover {
  background-color: #218838;
}

.btn-danger {
  background-color: #dc3545;
}

.btn-danger:hover {
  background-color: #c82333;
}

/* フォーム */
.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: 4px;
  font-size: 16px;
}

.form-control:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* アラート */
.alert {
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-danger {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* ゲームカード */
.game-card {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.game-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.game-card-content {
  padding: 0px;
  width: 100%;
  text-align: center;
}

.game-card-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 0px;
  display: none;
}

.game-card-description {
  color: #666;
  margin-bottom: 0px;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.4em;
  display: none;
}

/* ゲームグリッド */
#games-container .game-card,
#group-modal-games-container .game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin: 0px auto;
  padding: 0px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  color: inherit;
  width: 80%;
  max-width: 500px;
}

#games-container .game-card:active,
#group-modal-games-container .game-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-card-image {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  border-radius: 4px;
  margin-right: 0;
  margin-bottom: 0px;
}

.game-card-content {
  flex-grow: 1;
}

.game-card-title {
  margin: 0 0 3px 0;
  font-size: 16px;
  color: var(--text-color);
  display: none;
}

.game-card-description {
  font-size: 10px;
  color: var(--secondary-text-color);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.4em;
  display: none;
}

.group-arrow {
  font-size: 24px;
  color: var(--secondary-text-color);
  margin-left: 20px;
}

.ranking-score {
  font-weight: bold;
  color: #007bff;
  margin-left: 10px;
}

/* プロフィール */
.profile {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 20px;
}

.profile-info {
  flex: 1;
}

.profile-name {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 5px;
}

.profile-email {
  color: #666;
  margin-bottom: 10px;
}

/* 実績 */
.achievement {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #eee;
}

.achievement-icon {
  width: 40px;
  height: 40px;
  margin-right: 15px;
  color: #ffc107;
}

.achievement-info {
  flex: 1;
}

.achievement-title {
  font-weight: 500;
  margin-bottom: 5px;
}

.achievement-description {
  color: #666;
  font-size: 14px;
}

.achievement-date {
  color: #999;
  font-size: 12px;
}

/* ローディング */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
}

.loading-spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #007bff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: #fff;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  padding: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  position: relative;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
}

.modal-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 15px;
}

.modal-body {
  margin-bottom: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

/* タブ */
.tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  border-bottom-color: #007bff;
  color: #007bff;
  font-weight: 500;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .header-content {
    padding: 10px 0;
  }
  
  nav {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s;
    z-index: 999;
  }
  
  nav.active {
    transform: translateY(0);
  }
  
  nav ul {
    flex-direction: column;
    padding: 10px 0;
  }
  
  nav ul li {
    margin: 0;
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
  }
  
  nav ul li:last-child {
    border-bottom: none;
  }
  
  .hamburger {
    display: block;
  }
  
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  
  .profile {
    flex-direction: column;
    text-align: center;
  }
  
  .profile-avatar {
    margin-right: 0;
    margin-bottom: 15px;
  }
}

@media (max-width: 480px) {
  .game-grid {
    grid-template-columns: 1fr;
  }
  
  .btn {
    width: 100%;
    margin-bottom: 10px;
  }
  
  .modal-content {
    width: 95%;
    padding: 15px;
  }

  /* Ranking List for Mobile */
  .ranking-item {
    padding: 5px 0;
  }
  .ranking-position {
    font-size: 14px;
    width: 30px;
  }
  .ranking-user-avatar {
    width: 35px;
    height: 35px;
    margin-right: 8px;
  }
  .ranking-user-name {
    font-size: 14px;
  }
  .ranking-score {
    font-size: 14px;
    min-width: 60px;
  }
}

/* --- ランキングページ & モーダル追加スタイル --- */

/* Group Modal Header */
.group-modal-header {
  padding: 0 20px 15px;
  border-bottom: 1px solid var(--border-color);
}

#group-modal-description {
  margin-bottom: 15px;
  color: var(--secondary-text-color);
  font-size: 14px;
}

.group-modal-actions {
  display: flex;
  gap: 10px;
}

.group-modal-actions .btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 14px;
}

/* Ranking Page */
.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.ranking-header .btn {
  width: auto;
  margin-bottom: 0;
}

/* Ranking Tabs */
.tabs {
  width: 100%;
  display: block; /* flexからblockに変更 */
  border-bottom: none; /* 下線をtab-navに移動 */
}

.tab-nav {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
  -ms-overflow-style: none; /* IE, Edge */
  scrollbar-width: none; /* Firefox */
}

.tab-nav::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

.tab-link {
  padding: 10px 15px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--secondary-text-color);
  font-size: 16px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
}

.tab-link.active {
  color: var(--primary-color);
  font-weight: bold;
  border-bottom-color: var(--primary-color);
}

.tab-content {
  padding-top: 20px;
}

/* My Ranking Modal */
#my-ranking-modal .modal-body {
  padding: 15px;
}

.my-ranking-list {
  list-style: none;
  padding: 0;
}

.my-ranking-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.my-ranking-list li:last-child {
  border-bottom: none;
}

/* Static Content (rule.html) */
.static-content {
  background: var(--card-background);
  padding: 20px;
  border-radius: 8px;
}

.static-content h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 5px;
}
.static-content h3:first-child {
  margin-top: 0;
}

.static-content p {
  margin-bottom: 1em;
}

/* Ranking List Item */
.ranking-list {
  list-style: none;
  padding: 0;
}

.ranking-item {
  display: flex;
  align-items: center;
  padding: 10px 5px;
  border-bottom: 1px solid var(--border-color);
}

.ranking-item:last-child {
  border-bottom: none;
}

.ranking-position {
  font-size: 18px;
  font-weight: bold;
  color: var(--secondary-text-color);
  width: 40px;
  text-align: center;
}

.ranking-user {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0; /* flexアイテムの縮小を許可 */
  margin: 0 10px;
}

.ranking-user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 10px;
}

.ranking-user-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-score {
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-color);
  min-width: 80px;
  text-align: right;
}
