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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* ヘッダー */
.header {
  background: #3b82f6;
  color: white;
  padding: 16px;
  text-align: center;
}

.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

/* タブ */
.tab-nav {
  display: flex;
  background: white;
  border-bottom: 2px solid #e5e7eb;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 0.95rem;
  cursor: pointer;
  color: #6b7280;
  font-weight: 500;
  transition: color 0.2s, border-bottom 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

.tab-content {
  display: none;
  padding: 16px;
}

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

/* 空メッセージ */
.empty-msg {
  text-align: center;
  padding: 48px 16px;
  color: #9ca3af;
  font-size: 0.95rem;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

/* 練習エリア */
.practice-area {}

.stats-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #6b7280;
  margin-bottom: 12px;
}

/* カード */
.card-wrapper {
  perspective: 1000px;
  margin-bottom: 8px;
}

.card {
  width: 100%;
  height: 220px;
  cursor: pointer;
  border-radius: 12px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card-front {
  background: white;
  border: 2px solid #3b82f6;
}

.card-back {
  background: #eff6ff;
  border: 2px solid #1d4ed8;
  transform: rotateY(180deg);
}

.card-label {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-text {
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  line-height: 1.4;
}

.flip-hint {
  text-align: center;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 6px;
  margin-bottom: 16px;
}

/* 正解ボタン */
.judge-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.btn {
  display: inline-block;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #3b82f6;
  color: white;
  width: 100%;
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn-correct {
  flex: 1;
  background: #22c55e;
  color: white;
}

.btn-wrong {
  flex: 1;
  background: #ef4444;
  color: white;
}

.btn-danger-sm {
  background: none;
  color: #ef4444;
  border: 1px solid #ef4444;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

.practice-controls {
  display: flex;
  gap: 8px;
}

.practice-controls .btn {
  flex: 1;
  font-size: 0.88rem;
  padding: 10px;
}

/* 完了エリア */
.finish-area {
  text-align: center;
  padding: 24px 0;
}

.finish-area h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.finish-area p {
  color: #6b7280;
  margin-bottom: 20px;
}

.finish-area .btn {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}

/* カード管理 */
.add-card-form {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.add-card-form h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #374151;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

/* カード一覧 */
.card-list-section {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-list-header h2 {
  font-size: 1rem;
  color: #374151;
}

#card-count {
  font-size: 0.85rem;
  color: #9ca3af;
  font-weight: 400;
}

.card-list {
  list-style: none;
}

.card-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.card-list li:last-child {
  border-bottom: none;
}

.card-list-texts {
  flex: 1;
}

.card-list-front {
  font-weight: 600;
  font-size: 0.95rem;
}

.card-list-back {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 2px;
}

.btn-delete {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
}

.btn-delete:hover {
  color: #ef4444;
}

@media (max-width: 480px) {
  .card {
    height: 200px;
  }

  .card-text {
    font-size: 1.2rem;
  }
}
