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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  min-height: 100vh;
}

.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: #1e40af;
}

/* タブ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  transition: all 0.15s;
}

.tab-btn.active {
  background: #fff;
  color: #1e40af;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.tab-content {
  display: block;
}

.tab-content.hidden {
  display: none;
}

/* 統計バー */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stats-bar strong {
  color: #1e40af;
  font-size: 1.1rem;
}

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

.card {
  width: 100%;
  min-height: 220px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
  cursor: pointer;
  border-radius: 14px;
}

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

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  text-align: center;
}

.card-front {
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}

.card-back {
  background: #fff;
  color: #1e293b;
  transform: rotateY(180deg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  border: 2px solid #3b82f6;
}

.card-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.7;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.card-text {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-all;
}

.card-hint {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 12px;
}

/* 判定ボタン */
.judge-btns {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.judge-btns.hidden {
  display: none;
}

.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

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

.btn-correct {
  background: #22c55e;
  color: #fff;
}

.btn-wrong {
  background: #ef4444;
  color: #fff;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  width: 100%;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  margin-left: auto;
}

.btn-ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #cbd5e1;
}

.mt-16 { margin-top: 16px; }

/* カード一覧 */
.card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-list-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-list-texts {
  flex: 1;
  min-width: 0;
}

.card-list-front {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
  word-break: break-all;
}

.card-list-back {
  font-size: 0.85rem;
  color: #64748b;
  word-break: break-all;
}

.card-list-stats {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 1.1rem;
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

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

/* 追加フォーム */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.add-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.add-form input,
.add-form textarea {
  padding: 10px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  resize: vertical;
}

.add-form input:focus,
.add-form textarea:focus {
  border-color: #3b82f6;
}

.add-form textarea {
  min-height: 80px;
}

.add-msg {
  text-align: center;
  color: #22c55e;
  font-weight: 700;
  margin-top: 10px;
}

.add-msg.hidden { display: none; }

/* 空メッセージ */
.empty-msg {
  text-align: center;
  color: #94a3b8;
  padding: 40px 20px;
  font-size: 0.9rem;
  line-height: 1.7;
}
