/* リセットと基本設定 */
body {
  margin: 0;
  font-family: Arial, sans-serif;
}

/* メインコンテンツのスタイル変更 */
#mainContent {
  display: flex;
  flex-direction: column;
  align-items: center; /* 中央寄せ推奨 */
  padding: 20px;
}

#inputField {
  width: 290px !important; /* 200px × 1.45 = 290px */
  min-width: 145px !important; /* 100px × 1.45 = 145px */
  height: 1.5em;
  font-family: 'Courier New', monospace;
  font-size: 1.2em;
  text-align: center;
  caret-color: black;
  padding: 5px;
  margin: 5px 0;
  border: 2px solid #000000 !important;
  border-radius: 5px !important;
  order: 2;
  font-size: 1.6em !important;
  height: 1em !important;
  line-height: 1.2;
  transform-origin: center;
  padding: 0.3em 5px;
}


#inputField {
    border: 1px solid #000000 !important;
    border-radius: 5px;
}




#inputField:focus {
  outline: 2px solid #4CAF50;
  background-color: white;
}



/* ボタン */

.final-message {
  font-weight: bold;
  color: red;
}

.final-message + span {
  color: black;
}

/* モーダル */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
}

.close {
  float: right;
  font-size: 24px;
  cursor: pointer;
}

/* 追加/修正すべきスタイル */
#stats-container {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-top: 12px;
  width: 100%; /* 親要素いっぱいに広げる */
}


/* モバイル対応追加 */
@media (max-width: 768px) {
  #stats-container {
    flex-direction: column;
  }
  #stats-display {
    position: relative;
    margin-top: 15px;
  }
  #resultImage {
    top: 250px !important;
  }
}

.tab-buttons {
  display: flex;
  border-bottom: 1px solid #ddd;
}

.tab-button {
  padding: 8px 16px;
  background: #f1f1f1;
  border: none;
  cursor: pointer;
}

.tab-button.active {
  background: #4CAF50;
  color: white;
}

.tab-panel {
  display: none;
  padding: 10px 0;
}

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

/* アニメーション */
@keyframes runAcross {
  from { transform: translateX(-200px); }
  to { transform: translateX(calc(100vw + 200px)); }
}

#runningHorse {
  position: absolute;
  top: 400px;
  left: -200px;
  height: 50px;
  display: none;
  z-index: 1001;
  animation: runAcross 40s linear forwards;
  will-change: transform;
}

/* 画像 */
#resultImage {
  display: none;
  width: 200px;
  position: fixed;
  top: 170px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
}

.encourage-image {
  position: absolute;
  top: 50%;
  right: 5%;
  transform: translateY(-50%);
  width: 120px;
  height: auto;
  z-index: 1000;
}

/* 追加する新しいスタイル */
#problem {
  margin-left: 10px;
  text-align: left;
  font-size: 1.4em;
  position: absolute;
  top: 60px; /* 20px → 60px に変更（4行分下げる） */
  line-height: 1.2;
}


/* 四則演算ボタン */
#operationButtons button {
  font-size: 1.9em; /* 2em × 0.95 */
  font-weight: bold;
  padding: 14.25px 19px; /* 15px × 0.95, 20px × 0.95 */
  min-width: 57px; /* 60px × 0.95 */
  height: 57px; /* 60px × 0.95 */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-family: Arial, sans-serif;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

/* ホバー効果（5%縮小） */
#operationButtons button:hover {
  transform: scale(0.95);
}

/* ＋ボタン（5%小さく） */
#operationButtons button:first-child {
  font-size: 1.52em; /* 1.6em × 0.95 */
  font-family: Arial, sans-serif !important;
}



#operationButtons {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  justify-content: flex-start; /* 左詰め固定 */
  width: 100%;
  order: 1; /* 最上部に表示 */
}



/* 四則演算ボタンの色設定 */
#operationButtons button:nth-child(1) {
    background-color: #ff6b6b !important;
    margin: 5px !important;
}

#operationButtons button:nth-child(2) {
    background-color: #4ecdc4 !important;
    margin: 5px !important;
}

#operationButtons button:nth-child(3) {
    background-color: #ffe66d !important;
    margin: 5px !important;
}

#operationButtons button:nth-child(4) {
    background-color: #a3d9ff !important;
    margin: 5px !important;
}



#message {
  margin-left: 10px; /* ボタンとの間隔 */
  display: inline-block; /* 横並びにする */
  vertical-align: middle;
  color: red;
  font-weight: bold;
}


/* ランキングボタンのスタイル（詳細セレクタ版） */
body #rankingButtons {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
  width: 34.5% !important; /* 30% × 1.15 = 34.5% */
  min-width: 207px !important; /* 180px × 1.15 = 207px */
  max-width: 287.5px !important; /* 250px × 1.15 = 287.5px */
  margin: 12px 0 !important;
  justify-items: stretch !important;
}

body #rankingButtons button {
  width: 100% !important;
  min-width: 0 !important;
  padding: 8px 5px !important;
  font-size: 11px !important;
  white-space: normal !important;
  word-break: keep-all !important;
  line-height: 1.2 !important;
  border: none !important;
  margin: 2px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  text-align: center !important;
  transition: all 0.2s ease !important;
}

/* モバイル対応（詳細セレクタ版） */
@media (max-width: 600px) {
  body #rankingButtons {
    width: 100% !important;
    grid-template-columns: 1fr !important;
    min-width: unset !important;
    max-width: unset !important;
    gap: 6px !important;
  }
  
  body #rankingButtons button {
    font-size: 13px !important;
    padding: 10px 5px !important;
    min-width: unset !important;
  }
  
  #stats-display {
    width: 90%;
    max-height: 30vh;
  }
}


#rankingButtons button:hover {
  background: #e0e0e0;
  transform: translateY(-1px);
}

#rankingButtons button:active {
  transform: scale(0.98);
}

/* ランキングボタンの色設定 */
#rankingButtons button:nth-child(1) {
    background-color: #ff6b6b !important;
}

#rankingButtons button:nth-child(2) {
    background-color: #4ecdc4 !important;
}

#rankingButtons button:nth-child(3) {
    background-color: #ffe66d !important;
}

#rankingButtons button:nth-child(4) {
    background-color: #a3d9ff !important;
}



/* OKボタンのスタイル */
#submitBtn {
  font-size: 16px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#submitBtn:active {
  transform: scale(0.98);
  background: #45a049;
}



#submitBtn:hover {
  background: #45a049;
}

#submitBtn:active {
  transform: scale(0.98);
  background: #3d8b40;
}



/* OKボタンのスタイル */
#submitBtn {
  width: 60px;
  height: calc(45px * 4 + 9px); /* 4ボタン分の高さ */
  font-size: 16px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0; /* ← マージン削除 */
}

#submitBtn:hover {
  background: #45a049;
}

#submitBtn:active {
  transform: scale(0.98);
  background: #3d8b40;
}

/* 家族選択ボタンコンテナ */
#familySelect {
  display: flex;
  gap: 8px;
  margin: 12px;
  align-items: center;
  flex-wrap: wrap;
}

#familySelect button {
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
  cursor: pointer;
  height: auto; /* 縦長にならないように */
  white-space: nowrap; /* テキスト折り返し防止 */
}



/* 記録表示ウィンドウ中のコンテンツの余白を調整 */
#stats-display .day,
#stats-display .record {
  margin-bottom: 4px;
  padding-bottom: 3px;
  font-size: 0.9em;
  line-height: 1.1;
}

/* 記録表示ウィンドウタイトルもコンパクトに */
#stats-display h4 {
  font-size: 0.95em;
  margin: 0 0 6px 0;
  padding: 0;
}

/* 記録表示ウィンドウのスタイル（統一版） */
#stats-display {
  width: 180px;
  max-width: 180px;
  min-width: 180px;
  max-height: 40vh;
  overflow: auto;
  background: rgba(255,255,255,0.96);
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  z-index: 1500;
  cursor: default;
  font-size: 0.85em;
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: auto;
  margin-left: 0; /* 左マージンをゼロに */
  margin-right: 0; /* 右マージンをゼロに */
  transform: none; /* 変形をリセット */
  text-align: right;
}

/* 記録リストの右寄せ */
#stats-list {
  text-align: right;
}

/* 記録項目の右寄せ */
#stats-list .record {
  text-align: right;
  justify-content: flex-end;
  margin: 2px 0;
}

/* 日付グループの右寄せ */
#stats-list .day {
  text-align: right;
  margin-bottom: 6px;
}

/* 日付見出しの右寄せ */
#stats-list .day strong {
  display: block;
  text-align: right;
  margin-bottom: 2px;
}

/* 既存のCSSにこの1行を追加 */
.addition-problem { font-weight: bold; }




/* 音量トグルボタンの枠線を太くする */
#volumeToggleBtn {
    border: 3px solid #ddd !important; /* 1px → 3pxに変更 */
    border-radius: 8px !important;
    padding: 6px 10px !important;
    font-size: 12px !important;
    background: #fff !important;
    cursor: pointer !important;
    font-weight: bold !important; /* 文字も太くしてより目立たせる */
}

/* ホバー時の効果も追加 */
#volumeToggleBtn:hover {
    border-color: #999 !important;
    background: #f8f9fa !important;

#volume-toggle {
  position: fixed;
  right: 12px;
  top: 160px !important; /* 1ボタン分下に移動 */
  z-index: 1600;
}

/* ダイアログ内のボタンコンテナを横並びに */
#nicknameDialog div[style*="text-align: right"] {
    display: flex !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}
}



/* テンキーとOKボタンのコンテナ */
.keypad-container {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-start;
  width: 100%;
}

/* テンキーのスタイル */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 207px !important; /* 180px × 1.15 = 207px */
  padding: 3px;
}

/* テンキーボタン */
.keypad button {
  width: 100%;
  height: 45px;
  padding: 0;
  font-size: 14px;
  border: 1px solid #000000 !important;
  border-radius: 5px;
  background: #f9f9f9;
  cursor: pointer;
}

/* OKボタン */
.big-ok {
  height: 45px;
  padding: 0 15px;
  font-size: 14px;
  border: 1px solid #000000 !important;
  border-radius: 5px;
  background: #4CAF50;
  color: white;
  cursor: pointer;
}
