/* --- Base --- */
* { box-sizing: border-box; }

body {
  font-family: Arial, sans-serif;
  background-color: #0f0f0f;
  color: #ffffff;
  text-align: center;
  margin: 0;
  padding: 2rem;
}

.container {
  max-width: 1650px;
  width: 97%;
  margin: 0 auto;
}

.hero {
  margin-bottom: 1.5rem;
  max-height: 180px;
  opacity: 1;
  overflow: hidden;
  transform: translateY(0);
  transition: max-height 0.45s ease, opacity 0.35s ease, margin 0.45s ease, transform 0.45s ease;
}

h1 {
  font-size: 4rem;
  margin: 0 0 0.6rem;
  color: #ffa07a;
}

.tagline {
  font-size: 1.1rem;
  margin: 0;
  color: #ffd580;
}

.control-card,
.typing-box {
  background: #171717;
  border: 1px solid #2d2d2d;
  border-radius: 22px;
  padding: 1.8rem 2rem;
}

.control-card {
  margin-bottom: 1.6rem;
}

.app-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
  min-height: 54px;
}

.mini-title {
  display: none;
  min-width: 132px;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  background: #242424;
  border: 1px solid #4a4a4a;
  color: #ffa07a;
  font-size: 1rem;
  font-weight: 800;
}

audio {
  width: min(620px, 100%);
  flex: 1 1 430px;
  max-width: 720px;
}

.language-dock {
  display: none;
  min-width: 260px;
}

body.compact-header .hero {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

body.compact-header-settled .hero {
  display: none;
}

body.compact-header .app-top-row {
  justify-content: center;
}

body.compact-header .mini-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.compact-header .language-dock {
  display: flex;
  justify-content: center;
}

body.compact-header .language-dock .site-language-panel {
  position: static;
  width: 100%;
  max-width: 360px;
  justify-content: center;
  margin: 0;
  box-shadow: none;
  animation: dockLanguage 0.35s ease both;
}

@keyframes dockLanguage {
  from {
    transform: translateY(-10px);
  }
  to {
    transform: translateY(0);
  }
}

.button-group {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 0.4rem 0 1rem;
}

button {
  background-color: #f5a179;
  border: none;
  border-radius: 14px;
  color: #000;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

button:hover {
  background-color: #ffb08d;
  transform: scale(1.03);
}

button.mode-active {
  background-color: #71ff6a;
  color: #071107;
}

.translation-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  color: #ffd580;
  font-size: 1.05rem;
  font-weight: 700;
}

.translation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.translation-toggle input {
  width: 22px;
  height: 22px;
  accent-color: #f5a179;
}

.translation-select-label {
  color: #d7f8ff;
}

#translationLanguage,
#wordPack {
  background: #0f0f0f;
  border: 2px solid #f5a179;
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.65rem 0.8rem;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin: 0.8rem 0 1rem;
}

.stat {
  font-size: 1.1rem;
  font-weight: 700;
  color: #00c8ff;
}

.progress-panel {
  max-width: 1180px;
  margin: 1rem auto 0;
  padding: 1rem;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  background: #111;
  text-align: left;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.8rem;
}

.progress-head h3 {
  margin: 0;
  color: #ffd580;
  font-size: 1.35rem;
}

.small-action {
  width: auto;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.progress-card {
  min-height: 92px;
  padding: 0.9rem;
  border: 1px solid #343434;
  border-radius: 8px;
  background: #181818;
}

.progress-card strong {
  display: block;
  margin-bottom: 0.45rem;
  color: #71ff6a;
}

.progress-card span {
  display: block;
  color: #d7f8ff;
  line-height: 1.4;
}

#prompt {
  margin: 0.5rem 0 0;
  font-size: 2.6rem;
  color: #ffc107;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#prompt.prompt-freestyle {
  color: #71ff6a;
}

.prompt-label {
  color: #ffc107;
}

.prompt-guide {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

.prompt-char {
  display: inline-block;
  min-width: 0.62em;
  border-radius: 4px;
  margin: 0 1px 0.08em;
  padding: 0 0.03em;
}

.prompt-correct {
  color: #66ff99;
  background: rgba(102, 255, 153, 0.12);
}

.prompt-wrong {
  color: #ff7676;
  background: rgba(255, 102, 102, 0.18);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 0.12em;
}

.prompt-pending {
  color: #a7a7a7;
}

.prompt-next {
  color: #101010;
  background: #ffc266;
  box-shadow: 0 0 0 2px rgba(255, 194, 102, 0.28);
}

.translation-line {
  margin: 0.85rem auto 0;
  max-width: 1100px;
  color: #d7f8ff;
  font-size: 1.45rem;
  line-height: 1.35;
}

.typing-box {
  min-height: 290px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#output {
  font-size: 3rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  width: 100%;
}

.speak-btn {
  position: fixed;
  top: 10px;
  left: 10px;
  font-size: 114px;
  cursor: pointer;
  user-select: none;
}

@media (max-width: 900px) {
  body { padding: 1rem; }
  h1 { font-size: 2.5rem; }
  #prompt { font-size: 2rem; }
  #output { font-size: 2rem; }
  .control-card, .typing-box { padding: 1.2rem; }
  .app-top-row { align-items: stretch; flex-direction: column; }
  .mini-title { width: 100%; }
  audio { flex-basis: auto; }
  .language-dock { min-width: 0; width: 100%; }
  button { width: 100%; }
  .button-group { flex-direction: column; }
  .translation-controls { align-items: stretch; flex-direction: column; }
  .translation-toggle { justify-content: center; }
  #translationLanguage, #wordPack { width: 100%; }
  .translation-line { font-size: 1.15rem; }
  .progress-head { align-items: stretch; flex-direction: column; }
  .small-action { width: 100%; }
  .progress-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .progress-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .hero,
  button,
  body.compact-header .language-dock .site-language-panel {
    transition: none;
    animation: none;
  }
}
