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

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

header {
  background: #4a8fe8;
  color: white;
  padding: 16px 20px;
  text-align: center;
}

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

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* フォームセクション */
.add-form {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.add-form h2 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: #555;
}

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

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

.form-group textarea {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

.form-group textarea:focus {
  outline: none;
  border-color: #4a8fe8;
}

.btn-primary {
  width: 100%;
  background: #4a8fe8;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #3a7fd8;
}

/* カード一覧セクション */
.cards-section h2 {
  font-size: 1rem;
  color: #555;
  margin-bottom: 14px;
}

#card-count {
  color: #4a8fe8;
  font-weight: 700;
}

.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* フラッシュカード */
.card-wrapper {
  perspective: 1000px;
  height: 160px;
}

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

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  text-align: center;
}

.card-front {
  background: white;
  border: 2px solid #4a8fe8;
}

.card-back {
  background: #4a8fe8;
  color: white;
  transform: rotateY(180deg);
}

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

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

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

.delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.85);
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #e04444;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
  backface-visibility: hidden;
}

.card-wrapper:hover .delete-btn {
  opacity: 1;
}

/* 空メッセージ */
.empty-msg {
  text-align: center;
  color: #aaa;
  font-size: 0.95rem;
  padding: 40px 0;
  grid-column: 1 / -1;
}

/* レスポンシブ */
@media (max-width: 480px) {
  .cards-container {
    grid-template-columns: 1fr;
  }

  .card-wrapper {
    height: 140px;
  }
}
