/* ── Card 3D scene ── */
.card-scene {
  width: 100%;
  max-width: 400px;
  /* height fills available space, max 540px */
  height: min(540px, calc(100vh - 80px));
  perspective: 1200px;
  -webkit-perspective: 1200px;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.48s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

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

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: white;
}

.card-back {
  transform: rotateY(180deg);
  visibility: hidden; /* JS reveals at flip midpoint */
}

/* ── Card front ── */
.card-front {
  align-items: center;
  justify-content: center;
  padding: 32px 24px 48px;
  /* position:absolute from .card-face — DO NOT override */
  gap: 14px;
  user-select: none;
}

/* Background motif overlay (word type) */
.type-bg {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
  border-radius: var(--radius);
}

.card-word {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  position: relative;
  z-index: 1;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 13px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: white;
  position: relative;
  z-index: 1;
}

.card-supplements {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
  z-index: 1;
}

.supp-row {
  font-size: 0.85rem;
  color: #1a1a1a;
  text-align: center;
}

.supp-label {
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: #555;
  margin-right: 5px;
}

.reveal-hint {
  position: absolute;
  bottom: 18px;
  font-size: 0.75rem;
  color: #888;
  letter-spacing: 0.05em;
  z-index: 1;
}

.hint-area {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
}

.hint-btn {
  background: rgba(255,255,255,0.72);
  border: 1.5px dashed rgba(0,0,0,0.18);
  border-radius: 100px;
  padding: 6px 18px;
  font-size: 0.78rem;
  font-family: inherit;
  color: #666;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.hint-btn:active { background: rgba(255,255,255,0.9); }

.hint-revealed {
  font-size: 0.85rem;
  color: #333;
  font-style: italic;
  text-align: center;
  padding: 8px 20px;
  background: rgba(255,255,255,0.88);
  border-radius: 10px;
  max-width: 260px;
  line-height: 1.4;
}

/* ── Card back ── */
.card-back-top {
  width: 100%;
  flex-shrink: 0;
  position: relative;
}

.card-image-area {
  width: 100%;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}

.card-image-area img,
.card-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-hint { display: none; }

.photo-input-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  padding: 16px;
  color: rgba(0,0,0,0.45);
  line-height: 1.3;
}

.placeholder-english {
  font-size: 1.5rem;
  font-weight: 600;
}

.placeholder-photo-cue {
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.6;
  letter-spacing: 0.01em;
}

.card-back-content {
  flex: 1;
  padding: 14px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
}

.back-word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card-back-word {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.card-ipa {
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.audio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 100px;
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
  align-self: center;
  color: white;
  background: var(--blue);
  transition: transform 0.1s, opacity 0.1s;
}
.audio-btn:active { transform: scale(0.96); opacity: 0.88; }
.audio-btn.playing { opacity: 0.7; }

.audio-icon { font-size: 0.9rem; }

.personal-connection {
  font-size: 0.88rem;
  color: #aaa;
  text-align: center;
  font-style: italic;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px dashed #ddd;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.personal-connection:hover { border-color: #bbb; background: #fafafa; }
.personal-connection.has-text { color: var(--text); font-style: normal; border-style: solid; }

.pc-input {
  width: 100%;
  border: 1.5px solid var(--blue);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  min-height: 60px;
  outline: none;
  background: white;
  color: var(--text);
  box-sizing: border-box;
}

.pc-edit-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pc-save-btn {
  align-self: flex-end;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 100px;
  padding: 6px 18px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}

/* ── Spelling card front ── */
.spell-emoji {
  font-size: 3.2rem;
  position: relative;
  z-index: 1;
}

.spell-listen-hint {
  font-size: 0.82rem;
  color: #888;
  letter-spacing: 0.04em;
  text-align: center;
  position: relative;
  z-index: 1;
}

.spell-audio {
  position: relative;
  z-index: 1;
}

.spell-input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 28px;
  position: relative;
  z-index: 1;
}

.spell-input {
  width: 100%;
  border: 2px solid rgba(0,0,0,0.15);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 1.15rem;
  font-family: inherit;
  text-align: center;
  background: rgba(255,255,255,0.85);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.spell-input:focus {
  border-color: var(--blue);
  background: white;
}

.spell-check-btn {
  border: none;
  border-radius: 100px;
  padding: 11px 30px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: white;
  transition: transform 0.1s, opacity 0.1s;
}
.spell-check-btn:active { transform: scale(0.96); opacity: 0.88; }

/* ── Spelling card back ── */
.spell-result-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 20px 10px;
}

.spell-result {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 100px;
  text-align: center;
  max-width: 90%;
  word-break: break-word;
}

.spell-correct { background: #e8f5e9; color: #1b5e20; }
.spell-wrong   { background: #fde8e8; color: #b71c1c; }

/* ── Rating buttons ── */
.rating-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 14px 14px;
  flex-shrink: 0;
}

.rating-btn {
  border: none;
  border-radius: 10px;
  padding: 11px 4px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
  letter-spacing: 0.02em;
}
.rating-btn:active { transform: scale(0.94); }

.r-again { background: #fde8e8; color: #b71c1c; }
.r-hard  { background: #fff3e0; color: #e65100; }
.r-good  { background: #e8f5e9; color: #1b5e20; }
.r-easy  { background: #e3f2fd; color: #0d47a1; }
