* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #111; color: #fff; font-family: "Hiragino Sans", "Yu Gothic", "PingFang SC", -apple-system, sans-serif; overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
#app { height: 100%; display: flex; flex-direction: column; touch-action: manipulation; }
#topbar { padding: 12px 16px; background: #1a1a1a; font-size: 14px; }
#cardstage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; touch-action: manipulation; }
.flash-card { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.flash-card {
  width: min(90vw, 360px);
  aspect-ratio: 9 / 16;
  max-height: 75vh;
  border-radius: 18px;
  padding: 32px 28px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.flash-card.color-blue   { background: #5A9AD4; }
.flash-card.color-green  { background: #4FA896; }
.flash-card.color-purple { background: #8A6FB8; }
.flash-card.color-coral  { background: #D97B5F; }
.flash-card.color-teal   { background: #3E8A9E; }
.flash-card.color-pink   { background: #C75F87; }
.card-id {
  position: absolute; top: 24px; right: 24px;
  width: 38px; height: 38px;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 500;
}
.front-center { flex: 1; display: flex; align-items: center; justify-content: center; }
.front-word { font-size: clamp(64px, 18vw, 110px); font-weight: 600; letter-spacing: 4px; }
.hint-bottom { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: 12px; opacity: 0.5; letter-spacing: 1px; }
.back-head { font-size: 34px; font-weight: 600; margin-right: 50px; }
.back-kana { font-size: 14px; opacity: 0.85; margin-bottom: 14px; }
.section-title { font-size: 18px; font-weight: 500; margin: 12px 0 6px; opacity: 0.95; }
.section-body { font-size: 17px; line-height: 1.7; opacity: 0.95; }
.sentence-row { padding: 8px 10px; border-radius: 8px; margin: 4px -10px; cursor: pointer; transition: background 0.15s; }
.sentence-row:hover, .sentence-row:active { background: rgba(255,255,255,0.14); }
.sentence-row.brainwash-playing { background: rgba(255,255,255,0.28); box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.sentence-row .jp { font-size: 16px; line-height: 1.5; }
.sentence-row .cn { font-size: 13px; opacity: 0.75; margin-top: 2px; }
.flash-card.back { padding-top: 28px; overflow-y: auto; }
#topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: #1a1a1a; font-size: 13px; flex-shrink: 0; min-height: 44px; }
.topbar-left { font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.topbar-center { opacity: 0.8; text-align: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.topbar-right select, .topbar-right button {
  background: #2a2a2a; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.topbar-right button.brainwash-btn { background: #E85D4A; color: #fff; border-color: #E85D4A; }
.topbar-warn { color: #ffb74d; margin-left: 8px; font-size: 12px; white-space: nowrap; }
body.brainwash-on #topbar { background: #E85D4A; }
body.brainwash-on #cardstage { background: rgba(0,0,0,0.3); }
.brainwash-exit {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
}
.brainwash-current-example {
  color: #fff; font-size: 15px; opacity: 0.95; text-align: center;
}
@keyframes pulse {
  0%   { transform: scale(1.0); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1.0); }
}
.front-word.pulse { animation: pulse 0.35s ease-out; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #222; color: #eee; border-radius: 12px;
  padding: 20px; width: min(90vw, 460px); max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 12px; font-size: 18px; }
.modal label { display: block; margin: 10px 0 4px; font-size: 13px; opacity: 0.8; }
.modal input, .modal textarea {
  width: 100%; background: #111; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 8px; font-family: inherit; font-size: 14px;
}
.modal textarea { min-height: 60px; resize: vertical; }
.modal .row { display: flex; gap: 8px; margin-top: 16px; }
.modal button {
  flex: 1; background: #2a2a2a; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 10px; font-size: 14px; cursor: pointer;
}
.modal button.primary { background: #5A9AD4; border-color: #5A9AD4; }
.modal button.danger { background: #c0392b; border-color: #c0392b; }
.settings-btn {
  background: #2a2a2a; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
}
.fatal-error {
  padding: 40px 20px; text-align: center;
}
.fatal-error h2 { color: #ff6b6b; margin-bottom: 12px; }
.fatal-error button {
  margin-top: 16px; background: #5A9AD4; color: #fff;
  border: none; border-radius: 6px; padding: 10px 20px; cursor: pointer;
}
