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

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  background: #FFFFFF;
  min-height: 100vh;
  padding: 10px;
  -webkit-tap-highlight-color: transparent;
}

body.locked {
  overflow: hidden;
}

body.locked #mainContent {
  filter: blur(10px);
  pointer-events: none;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(123, 31, 162, 0.2);
  border: 3px solid #7B1FA2;
  overflow: hidden;
  min-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
}

header {
  background: #FFFFFF;
  color: #7B1FA2;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-bottom: 4px solid #7B1FA2;
}

header h1 {
  font-size: 28px;
  font-weight: bold;
}

/* タブナビゲーション */
.tabs {
  display: flex;
  background: #f5f5f5;
  border-bottom: 3px solid #e0e0e0;
}

.tab-button {
  flex: 1;
  padding: 20px;
  font-size: 20px;
  font-weight: bold;
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #666;
}

.tab-button.active {
  background: white;
  color: #7B1FA2;
  border-bottom: 4px solid #7B1FA2;
  font-weight: bold;
}

.tab-button:hover {
  background: #F3E5F5;
}

/* タブコンテンツ */
.tab-content {
  display: none;
  padding: 15px;
  flex: 1;
  overflow-y: auto;
}

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

/* 50音表グリッド */
.gojuon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.gojuon-section {
  margin-bottom: 20px;
}

.gojuon-section:first-of-type {
  grid-row: 1 / 3;
}

.gojuon-section h2 {
  font-size: 22px;
  color: #7B1FA2;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 3px solid #7B1FA2;
  text-align: center;
  font-weight: bold;
}

.gojuon-row {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
  justify-content: center;
}

.gojuon-button {
  flex: 1;
  min-width: 60px;
  max-width: 90px;
  height: 100px;
  font-size: 50px;
  font-weight: bold;
  background: #FFFFFF;
  color: #7B1FA2;
  border: 3px solid #7B1FA2;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  touch-action: manipulation;
}

.gojuon-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.gojuon-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gojuon-button.spacer {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

/* はい・いいえセクション */
.yes-no-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 3px solid #e0e0e0;
}

.yes-no-button {
  padding: 15px 30px;
  font-size: 32px;
  font-weight: bold;
  color: #003366;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
}

.yes-button {
  background: #FFFACD;
  color: #003366;
  border: 4px solid #F0E68C;
}

.yes-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(255, 250, 205, 0.5);
  background: #FFF8B8;
}

.yes-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.no-button {
  background: #ADD8E6;
  color: #003366;
  border: 4px solid #87CEEB;
}

.no-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(173, 216, 230, 0.5);
  background: #9ED2E6;
}

.no-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 日常フレーズグリッド */
.phrases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

/* 自由入力セクション */
.custom-input-section {
  margin-bottom: 30px;
  padding: 20px;
  background: #F3E5F5;
  border-radius: 12px;
  border: 2px solid #7B1FA2;
}

.custom-input-section h2 {
  font-size: 22px;
  color: #7B1FA2;
  margin-bottom: 15px;
  font-weight: bold;
}

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

#customWordInput {
  flex: 1;
  padding: 15px 20px;
  font-size: 18px;
  border: 3px solid #7B1FA2;
  border-radius: 8px;
  outline: none;
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}

#customWordInput:focus {
  border-color: #6A1B9A;
  box-shadow: 0 0 0 3px rgba(123, 31, 162, 0.1);
}

.mic-button {
  padding: 15px 20px;
  font-size: 24px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  min-width: 60px;
}

.mic-button:hover {
  background: #45A049;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(76, 175, 80, 0.3);
}

.mic-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mic-button.recording {
  background: #EF5350;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.add-button {
  padding: 15px 40px;
  font-size: 18px;
  font-weight: bold;
  background: #7B1FA2;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.add-button:hover {
  background: #6A1B9A;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(123, 31, 162, 0.3);
}

.add-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* カスタムワードグリッド */
.custom-words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.custom-word-item {
  position: relative;
  display: flex;
}

.custom-word-button {
  flex: 1;
  padding: 35px 50px 35px 30px;
  font-size: 45px;
  font-weight: bold;
  background: #FFFFFF;
  color: #7B1FA2;
  border: 3px solid #7B1FA2;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
  word-break: break-all;
}

.custom-word-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(123, 31, 162, 0.3);
  background: #F3E5F5;
}

.custom-word-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background: #E1BEE7;
}

.delete-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  font-size: 20px;
  font-weight: bold;
  background: #EF5350;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  line-height: 1;
  padding: 0;
}

.delete-button:hover {
  background: #E53935;
  transform: scale(1.1);
}

.delete-button:active {
  transform: scale(0.95);
}

.empty-message {
  text-align: center;
  color: #999;
  font-size: 18px;
  padding: 40px;
  grid-column: 1 / -1;
}

.phrase-button {
  padding: 35px 30px;
  font-size: 45px;
  font-weight: bold;
  background: #FFFFFF;
  color: #7B1FA2;
  border: 3px solid #7B1FA2;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
}

.phrase-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(123, 31, 162, 0.3);
  background: #F3E5F5;
}

.phrase-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background: #E1BEE7;
}

/* フッター */
footer {
  background: #f5f5f5;
  padding: 15px;
  text-align: center;
  border-top: 2px solid #e0e0e0;
  margin-top: auto;
}

footer p {
  font-size: 18px;
  color: #7B1FA2;
  font-weight: bold;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .gojuon-grid {
    grid-template-columns: 1fr;
  }

  .gojuon-section:first-of-type {
    grid-row: auto;
  }

  .gojuon-button {
    min-width: 70px;
    max-width: 100px;
    height: 90px;
    font-size: 45px;
  }

  .gojuon-row {
    gap: 5px;
  }
}

@media (max-width: 600px) {
  header h1 {
    font-size: 24px;
  }

  .tab-content {
    padding: 10px;
  }

  .tab-button {
    padding: 15px 10px;
    font-size: 16px;
  }

  .gojuon-button {
    min-width: 55px;
    max-width: 80px;
    height: 75px;
    font-size: 38px;
  }

  .gojuon-row {
    gap: 4px;
  }

  .yes-no-button {
    padding: 12px 20px;
    font-size: 28px;
    min-height: 35px;
  }

  .phrases-grid {
    grid-template-columns: 1fr;
  }

  .phrase-button {
    font-size: 38px;
    padding: 30px 20px;
    min-height: 130px;
  }

  .gojuon-section h2 {
    font-size: 20px;
  }

  .custom-input-section {
    padding: 15px;
  }

  .input-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  #customWordInput {
    font-size: 16px;
    grid-column: 1 / -1;
  }

  .mic-button {
    font-size: 20px;
    padding: 12px 18px;
  }

  .add-button {
    padding: 15px 30px;
    font-size: 16px;
  }

  .custom-words-grid {
    grid-template-columns: 1fr;
  }

  .custom-word-button {
    font-size: 38px;
    min-height: 130px;
  }
}

/* iOS Safari用の調整 */
@supports (-webkit-touch-callout: none) {
  .gojuon-button,
  .phrase-button {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
}

/* パスワード認証ダイアログ */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.password-overlay.hidden {
  display: none;
}

.password-dialog {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.password-dialog h2 {
  font-size: 24px;
  color: #7B1FA2;
  margin-bottom: 25px;
  font-weight: bold;
}

.password-dialog input[type="password"] {
  width: 100%;
  padding: 15px 20px;
  font-size: 18px;
  border: 3px solid #7B1FA2;
  border-radius: 8px;
  outline: none;
  margin-bottom: 20px;
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  box-sizing: border-box;
}

.password-dialog input[type="password"]:focus {
  border-color: #6A1B9A;
  box-shadow: 0 0 0 3px rgba(123, 31, 162, 0.1);
}

.password-dialog button {
  width: 100%;
  padding: 15px 40px;
  font-size: 20px;
  font-weight: bold;
  background: #7B1FA2;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.password-dialog button:hover {
  background: #6A1B9A;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(123, 31, 162, 0.3);
}

.password-dialog button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.password-error {
  color: #EF5350;
  font-size: 16px;
  margin-top: 15px;
  min-height: 20px;
  font-weight: bold;
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
