/* Myɛn — the listening room. Deep slate, one glowing ear, a Duun keyboard. */

:root {
  --slate: #1b2233;
  --slate-deep: #131829;
  --slate-soft: #242e45;
  --line: #35415f;
  --cream: #f0ead9;
  --cream-dim: #96a0bd;
  --gold: #d9a441;
  --laterite: #c96a50;
  --leaf: #7ea34f;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { height: 100%; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 60% at 50% -10%, #232c44, var(--slate) 60%, var(--slate-deep));
  color: var(--cream);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

[lang^="dux"] { font-family: "Andika", sans-serif; }

#top {
  display: flex;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 20px 4px;
}

#top h1 { font-size: 1.75rem; font-weight: 400; color: var(--gold); font-family: "Andika", sans-serif; }
#top h1 .sub { display: block; font-family: "Space Grotesk", sans-serif; font-size: 0.76rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cream-dim); }

#tone-toggle {
  margin-left: auto;
  border: 1.5px solid var(--line);
  background: var(--slate-soft);
  color: var(--cream-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

#tone-toggle[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }

/* ---------- stage ---------- */

#stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 18px calc(14px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

#score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cream-dim);
  margin: 6px 2px 4px;
}

#score { color: var(--gold); }

#listen-row { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 10px; }

#listen {
  width: 92px;
  height: 92px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #e8c168, var(--gold) 60%, #a87724);
  color: var(--slate-deep);
  display: grid;
  place-items: center;
  box-shadow: 0 0 40px rgba(217, 164, 65, 0.35);
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
}

#listen:active { transform: scale(0.92); }
#listen svg { width: 40px; height: 40px; }

#listen.playing::before, #listen.playing::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--gold);
  animation: ripple 1.4s ease-out infinite;
}

#listen.playing::after { animation-delay: 0.7s; }

@keyframes ripple {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(1.7); opacity: 0; }
}

#slow {
  width: 54px;
  height: 54px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--slate-soft);
  color: var(--cream);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}

#gloss-hint { text-align: center; margin-top: 12px; font-size: 0.9rem; color: var(--cream-dim); min-height: 1.4em; }

/* written word */
#written {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 2px;
  min-height: 74px;
  margin: 10px 0 2px;
  font-size: 2.6rem;
  color: var(--cream);
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
  flex-wrap: wrap;
}

#written .caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--gold);
  align-self: center;
  animation: blink 1.05s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

#written.good { border-color: var(--leaf); color: #cde3ae; }
#written.bad { animation: shake 0.4s ease; border-color: var(--laterite); }

@keyframes shake {
  20% { transform: translateX(-9px); }
  45% { transform: translateX(8px); }
  70% { transform: translateX(-5px); }
  90% { transform: translateX(3px); }
}

#feedback { text-align: center; min-height: 1.5em; margin: 8px 0 6px; font-size: 0.92rem; font-weight: 700; color: var(--cream-dim); }
#feedback .answer { font-family: "Andika", sans-serif; color: var(--gold); font-size: 1.15rem; font-weight: 400; }
#feedback.win { color: var(--leaf); }

/* ---------- keyboard ---------- */

#keyboard { margin-top: auto; display: flex; flex-direction: column; gap: 7px; }

.krow { display: flex; gap: 6px; justify-content: center; }

.key {
  flex: 1;
  max-width: 44px;
  height: 52px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 10px;
  background: var(--slate-soft);
  color: var(--cream);
  font-family: "Andika", sans-serif;
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.08s, background 0.12s;
  padding: 0;
}

.key:active { transform: translateY(2px); background: var(--line); }

.key.special { max-width: 62px; font-size: 1rem; color: var(--cream-dim); }
.key.tone { color: var(--gold); font-size: 1.5rem; }
.key.ok { max-width: 92px; background: var(--gold); border-color: #a87724; color: var(--slate-deep); font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 0.9rem; }
.key.duun { color: #e8c168; }

#foot {
  display: flex;
  justify-content: space-between;
  padding: 8px 18px calc(10px + env(safe-area-inset-bottom));
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cream-dim);
}

#foot a { color: var(--gold); text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
