:root {
  --primary-color: #2c3e50;
  /* Dark Blue - High Contrast */
  --accent-color: #d35400;
  /* Burnt Orange - Actionable items */
  --bg-color: #fdfdfd;
  /* Off-white - Easy on eyes */
  --text-color: #333333;
  /* Dark Gray - Softer than pure black */
  --card-bg: #ffffff;
  --border-color: #bdc3c7;
  --font-base: "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  font-size: 20px;
  /* Base font size increased for legibility */
  line-height: 1.6;
}

header {
  /* ここで背景画像を指定します */
  /* ↓ご自身の画像ファイルの場所に書き換えてください */
  background-image: url('../images/header-banner.png');

  /* 画像をヘッダー全体に広げ、中央寄せにする設定 */
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;

  /* テキストの上下に余白を持たせて画像を見せる */
  padding: 60px 20px 40px;
  text-align: center;

  /* 背景画像が読み込まれるまでの背景色（優しいクリーム色） */
  background-color: #fffbeb;
}

/* タイトルの文字を見やすく調整 */
header h1 {
  margin: 0;
  font-size: 2.5rem;
  /* 真っ黒よりも少し柔らかい焦げ茶色が見やすいです */
  color: #4a3b32;
  /* 文字の周りに白いフチを少し付けて読みやすくする */
  text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
}

/* サブタイトルの調整 */
header p {
  margin: 15px 0 30px;
  font-size: 1.1rem;
  color: #5e4f45;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

/* ナビゲーション（参考：中央寄せにする場合） */
header nav ul {
  display: flex;
  justify-content: center;
  list-style: none;
  padding: 0;
  gap: 20px;
}

header nav ul li a {
  text-decoration: none;
  color: #4a3b32;
  background-color: rgba(255, 255, 255, 0.7);
  /* 半透明の白背景でボタンっぽく */
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: bold;
}

nav ul {
  list-style: none;
  padding: 0;
  text-align: center;
  margin-top: 1rem;
}

nav ul li {
  display: inline-block;
  margin: 0 10px;
}

nav a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.2rem;
  border-bottom: 2px solid transparent;
}

nav a:hover {
  border-bottom: 2px solid var(--accent-color);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem;
  background-color: #e8f6f3;
  border-radius: 15px;
  border: 2px solid var(--primary-color);
}

.hero h2 {
  font-size: 2.2rem;
  color: var(--primary-color);
  margin-top: 0;
}

/* Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.game-card {
  background-color: var(--card-bg);
  border: 3px solid var(--border-color);
  border-radius: 15px;
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.game-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent-color);
}

.game-card h3 {
  font-size: 1.8rem;
  margin: 0.5rem 0;
  color: var(--primary-color);
}

.game-card p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-block;
  background-color: var(--accent-color);
  color: #fff;
  padding: 1rem 2rem;
  text-decoration: none;
  border-radius: 50px;
  font-size: 1.3rem;
  font-weight: bold;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: #e67e22;
}

/* Contact Form */
.contact-form {
  max-width: 600px;
  margin: 0 auto;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 15px;
  border: 2px solid var(--border-color);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  font-size: 1.2rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 1rem;
  font-size: 1.2rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-color);
  outline: none;
}

footer {
  background-color: var(--primary-color);
  color: #fff;
  text-align: center;
  padding: 2rem;
  margin-top: 3rem;
}

footer p {
  font-size: 1rem;
}

/* Game Specific Styles */
.game-container {
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--card-bg);
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.game-header {
  background-color: #e8f6f3;
  padding: 1rem 2rem;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary-color);
}

.game-info {
  font-weight: bold;
  font-size: 1.2rem;
}

.game-info span {
  margin-left: 1rem;
}

.game-area {
  padding: 2rem;
  min-height: 400px;
  position: relative;
  text-align: center;
}

.screen {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Start Screen */
.game-description {
  font-size: 1.4rem;
  margin-bottom: 2rem;
}

#high-score-display {
  font-size: 1.5rem;
  color: var(--accent-color);
  font-weight: bold;
  margin-bottom: 2rem;
}

/* Play Screen */
.question-box {
  background-color: #f0f0f0;
  border: 3px solid var(--primary-color);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 2rem;
  display: inline-block;
  min-width: 300px;
}

#question-text {
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 5px;
  color: #333;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  max-width: 400px;
  margin: 0 auto;
}

.number-btn {
  background-color: #fff;
  border: 2px solid var(--primary-color);
  border-radius: 10px;
  font-size: 2.5rem;
  font-weight: bold;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 4px 0 var(--border-color);
  color: var(--primary-color);
}

.number-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.number-btn:hover {
  background-color: #e8f6f3;
}

/* Result Screen */
.final-score {
  font-size: 2rem;
  font-weight: bold;
  margin: 2rem 0;
}

#final-score-value {
  color: var(--accent-color);
  font-size: 3rem;
}

#new-record-msg {
  color: #e74c3c;
  font-size: 1.5rem;
  font-weight: bold;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

.hidden {
  display: none;
}

.btn-large {
  font-size: 1.5rem;
  padding: 1rem 3rem;
  margin: 1rem;
}

.btn-secondary {
  display: inline-block;
  background-color: var(--border-color);
  color: #333;
  padding: 1rem 2rem;
  text-decoration: none;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: bold;
  margin: 1rem;
}

/* Feedback Overlay */
.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.feedback-overlay.active {
  opacity: 1;
}

.feedback-icon {
  font-size: 15rem;
  font-weight: bold;
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-overlay.active .feedback-icon {
  transform: scale(1);
}

.feedback-icon.correct {
  color: #2ecc71;
  /* Green */
  text-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

.feedback-icon.incorrect {
  color: #e74c3c;
  /* Red */
  text-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

/* Ranking Modal Styles - Wakuwaku Design */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(3px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: #fff;
  padding: 2rem;
  border-radius: 20px;
  width: 95%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 5px solid #FFD700;
  /* Gold border */
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-content h2 {
  text-align: center;
  color: #e67e22;
  font-size: 2rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-shadow: 1px 1px 0 #ffeaa7;
}

.close-modal {
  position: absolute;
  top: -15px;
  right: -15px;
  background: #ff6b6b;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  border: 2px solid #fff;
}

/* Ranking Tabs */
.ranking-tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  background: #f1f2f6;
  padding: 5px;
  border-radius: 30px;
  gap: 5px;
}

.tab-btn {
  flex: 1;
  padding: 0.8rem 0.5rem;
  border: none;
  background: transparent;
  color: #7f8c8d;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #fff;
  color: #e67e22;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

/* Ranking List */
.ranking-list {
  max-height: 300px;
  overflow-y: auto;
}

.ranking-list ol {
  list-style: none;
  /* Remove default numbering */
  padding: 0;
  margin: 0;
}

.ranking-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: #f8f9fa;
  border-radius: 10px;
  font-size: 1.1rem;
  border-bottom: 2px solid #eee;
}

.ranking-list li:nth-child(1) {
  background: #fff9c4;
  border-color: #fbc02d;
}

.ranking-list li:nth-child(2) {
  background: #f5f5f5;
  border-color: #bdbdbd;
}

.ranking-list li:nth-child(3) {
  background: #ffccbc;
  border-color: #ff7043;
}

.ranking-list .rank {
  font-weight: bold;
  width: 50px;
  font-size: 1.2rem;
}

.ranking-list li:nth-child(1) .rank::before {
  content: "🥇 ";
}

.ranking-list li:nth-child(2) .rank::before {
  content: "🥈 ";
}

.ranking-list li:nth-child(3) .rank::before {
  content: "🥉 ";
}

.ranking-list .name {
  flex-grow: 1;
  text-align: left;
  padding: 0 10px;
  font-weight: bold;
  color: #2c3e50;
}

.ranking-list .score {
  font-weight: bold;
  color: #e74c3c;
  font-size: 1.3rem;
}

/* Ranking Input Area */
.ranking-input-area {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: #fff3e0;
  border-radius: 15px;
  text-align: center;
  border: 2px dashed #ffb74d;
}

.ranking-input-area input {
  padding: 0.8rem;
  font-size: 1.2rem;
  width: 80%;
  margin-bottom: 1rem;
  border: 2px solid #ffe0b2;
  border-radius: 10px;
  text-align: center;
}

.btn-small {
  padding: 0.5rem 1.5rem;
  font-size: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .game-container {
    border-radius: 0;
  }

  .game-area {
    padding: 1rem;
    min-height: 300px;
  }

  #question-text {
    font-size: 2rem;
    letter-spacing: 2px;
  }

  .question-box {
    min-width: auto;
    width: 100%;
    padding: 0.5rem;
  }

  .number-grid {
    gap: 10px;
    max-width: 300px;
  }

  .number-btn {
    font-size: 2rem;
    padding: 0.5rem;
  }

  .modal-content {
    width: 95%;
    padding: 1rem;
  }

  .ranking-list li {
    font-size: 0.9rem;
    padding: 0.5rem;
  }

  .ranking-list .rank {
    width: 30px;
    font-size: 1rem;
  }

  .ranking-list .score {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .hero h2 {
    font-size: 1.5rem;
  }

  .game-header {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }

  .game-info {
    font-size: 1rem;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 1rem;
  }

  .game-info span {
    margin-left: 0;
  }
}