@font-face {
  font-family: "Time4en";
  src: url("./assets/fonts/time4en.otf") format("opentype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #667085;
  --paper: #fffdfa;
  --line: #ded6eb;
  --brand: #4c148f;
  --brand-dark: #35106a;
  --brand-soft: #f1e8ff;
  --blue: var(--brand);
  --green: #16845b;
  --red: #c2413c;
  --gold: #e5a11a;
  --shadow: 0 24px 70px rgba(63, 20, 120, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(138deg, rgba(76, 20, 143, 0.16), transparent 38%),
    linear-gradient(318deg, rgba(22, 132, 91, 0.11), transparent 42%),
    #f8f4fc;
  color: var(--ink);
  font-family:
    "Time4en",
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.signup-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(138deg, rgba(76, 20, 143, 0.18), transparent 38%),
    linear-gradient(318deg, rgba(22, 132, 91, 0.13), transparent 42%),
    #f8f4fc;
}

.signup-gate.hidden {
  display: none;
}

.signup-card {
  width: min(100%, 390px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow);
}

.signup-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
  filter: drop-shadow(0 10px 18px rgba(76, 20, 143, 0.18));
}

.signup-card h1 {
  margin-bottom: 8px;
  text-align: center;
}

.free-note {
  width: fit-content;
  margin: 0 auto 22px;
  padding: 6px 10px;
  border: 1px solid rgba(22, 132, 91, 0.16);
  border-radius: 8px;
  background: rgba(22, 132, 91, 0.08);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.2;
}

.signup-step[hidden] {
  display: none;
}

.signup-card label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.signup-card input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1rem;
  direction: ltr;
  text-align: left;
}

.signup-card input:focus {
  border-color: rgba(76, 20, 143, 0.54);
  outline: 3px solid rgba(76, 20, 143, 0.14);
}

.signup-card button {
  width: 100%;
  min-height: 50px;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.signup-card button:disabled {
  cursor: wait;
  opacity: 0.74;
}

.field-title {
  display: block;
  margin-top: 16px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.source-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.source-grid button {
  margin: 0;
  background: var(--brand);
}

.auth-switch {
  min-height: auto;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--blue);
  box-shadow: none;
  font-size: 0.9rem;
  font-weight: 900;
}

.privacy-note,
.signup-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.5;
}

.signup-message.error {
  color: var(--red);
}

.signup-message.success {
  color: var(--green);
}

.app {
  width: min(100%, 460px);
  min-height: min(100vh, 760px);
  padding: 24px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-home {
  flex: 0 0 auto;
  display: inline-flex;
  border-radius: 8px;
}

.brand-home:focus-visible {
  outline: 3px solid rgba(76, 20, 143, 0.18);
  outline-offset: 3px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(76, 20, 143, 0.18));
}

.brand-slogan {
  margin: 0;
  color: var(--brand-dark);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.25;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-link {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
  line-height: 1.05;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(24, 33, 47, 0.08);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.mode-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
}

.mode-button.active {
  background: var(--brand);
  color: white;
  box-shadow: 0 8px 18px rgba(76, 20, 143, 0.2);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 46px;
  align-items: stretch;
  gap: 10px;
}

.stats > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.stats > .stat-correct {
  border-color: rgba(22, 132, 91, 0.3);
  background: rgba(22, 132, 91, 0.07);
}

.stats > .stat-wrong {
  border-color: rgba(194, 65, 60, 0.3);
  background: rgba(194, 65, 60, 0.07);
}

.stat-correct strong {
  color: var(--green);
}

.stat-wrong strong {
  color: var(--red);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
  line-height: 1;
}

.stat-restart {
  width: 46px;
  height: 100%;
  min-height: 66px;
  align-self: stretch;
  color: var(--brand);
}

.irregular-panel[hidden],
.member-words-panel[hidden],
.quiz-hidden {
  display: none !important;
}

.irregular-panel,
.member-words-panel {
  min-height: 420px;
  overflow: auto;
}

.member-words-panel {
  max-height: min(62vh, 560px);
  align-self: start;
}

.irregular-list {
  display: grid;
  gap: 12px;
  padding-bottom: 4px;
}

.verb-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 28px rgba(24, 33, 47, 0.08);
}

.verb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.verb-head > div {
  min-width: 0;
}

.verb-head h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
}

.verb-head span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.verb-head-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.verb-sound {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(76, 20, 143, 0.2);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 8px 18px rgba(76, 20, 143, 0.1);
  cursor: pointer;
}

.verb-forms {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.verb-form {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--brand-soft);
}

.verb-form span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.verb-form strong {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.verb-sentence {
  margin: 0;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.55;
}

.verb-instruction {
  margin: -2px 4px 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.verb-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.verb-choice,
.verb-next {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.verb-choice:disabled {
  cursor: default;
  opacity: 0.72;
}

.verb-choice.is-correct-choice {
  border: 2px solid rgba(22, 132, 91, 0.44);
  background: var(--green);
  opacity: 1;
}

.verb-choice.is-wrong-choice {
  border: 2px solid rgba(194, 65, 60, 0.44);
  background: var(--red);
  opacity: 0.82;
}

.verb-next {
  width: 100%;
  margin-top: 10px;
  background: var(--brand-dark);
}

.verb-feedback {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.55;
}

.verb-feedback strong,
.verb-feedback span {
  display: block;
}

.verb-feedback .correct-answer-line {
  margin: 8px 0;
  padding: 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--green);
}

.verb-feedback .correct-answer-line strong {
  display: inline;
  font-size: 1.08rem;
}

.verb-feedback.correct {
  border: 1px solid rgba(22, 132, 91, 0.24);
  background: rgba(22, 132, 91, 0.08);
  color: var(--green);
}

.verb-feedback.wrong {
  border: 1px solid rgba(194, 65, 60, 0.24);
  background: rgba(194, 65, 60, 0.08);
  color: var(--red);
}

.verb-translation {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.5;
}

.done-message {
  margin: 14px 0 8px;
  padding: 12px;
  border: 1px solid rgba(76, 20, 143, 0.16);
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.5;
}

.member-word-form,
.member-word-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 28px rgba(76, 20, 143, 0.08);
}

.member-word-form {
  display: grid;
  gap: 8px;
}

.member-word-form[hidden] {
  display: none;
}

.member-word-form h2,
.member-word-head h3 {
  margin: 0;
  color: var(--ink);
}

.member-word-form p,
.member-word-head p,
.member-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.5;
}

.member-word-card:not(.discussion-page) .member-word-head p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.member-word-form label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 950;
}

.member-word-form input,
.member-word-form textarea,
.reply-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.member-word-form button,
.reply-form button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 950;
  cursor: pointer;
}

.member-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 850;
}

.member-message.error {
  color: var(--red);
}

.member-message.success {
  color: var(--green);
}

.member-words-list {
  display: grid;
  gap: 8px;
}

.member-word-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.member-word-head span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 950;
}

.member-replies {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.discussion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.discussion-summary span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.open-discussion,
.back-discussions {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 950;
  cursor: pointer;
}

.back-discussions {
  width: fit-content;
  margin-bottom: 12px;
  background: var(--brand-dark);
}

.discussion-page .member-word-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.member-reply {
  padding: 9px;
  border-radius: 8px;
  background: rgba(241, 232, 255, 0.58);
  text-align: start;
}

.member-reply strong,
.member-reply span {
  display: block;
  font-size: 0.85rem;
}

.member-reply strong {
  color: var(--brand);
}

.member-reply span {
  margin-top: 3px;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.45;
}

.reply-form {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  margin-top: 12px;
}

.member-empty.small {
  font-size: 0.82rem;
}

.stage {
  position: relative;
  min-height: 380px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 0.72;
  border: 1px solid rgba(24, 33, 47, 0.12);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.9), rgba(250, 246, 255, 0.96)),
    var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.card:active {
  cursor: grabbing;
}

.card.flipped {
  border-color: rgba(76, 20, 143, 0.34);
  box-shadow: 0 24px 80px rgba(76, 20, 143, 0.22);
}

.language-pill {
  position: absolute;
  top: 18px;
  inset-inline-start: 18px;
  min-width: 44px;
  height: 32px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(76, 20, 143, 0.24);
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 0.78rem;
  font-weight: 900;
}

.card-label {
  max-width: 92%;
  overflow-wrap: break-word;
  text-align: center;
  font-size: clamp(2rem, 10vw, 3.35rem);
  font-weight: 900;
  line-height: 1.05;
}

.phrase-mode .card-label {
  font-size: clamp(1.45rem, 7vw, 2.35rem);
  line-height: 1.18;
}

.card-subtitle {
  max-width: 100%;
  color: var(--muted);
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.card-meta {
  max-width: 100%;
  min-height: 42px;
  color: #3f4b5f;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.is-done .card-meta {
  min-height: 0;
  font-size: 1rem;
  font-weight: 950;
}

.card-meta:empty {
  display: none;
}

.retry-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  display: none;
  background: var(--brand);
  color: #ffffff;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(76, 20, 143, 0.16);
}

.sound-button {
  position: absolute;
  left: calc(50% - 168px);
  top: 20px;
  z-index: 2;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(76, 20, 143, 0.24);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 12px 28px rgba(76, 20, 143, 0.14);
  cursor: pointer;
}

.sound-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.actions {
  position: absolute;
  left: 50%;
  bottom: 56px;
  z-index: 2;
  width: min(100% - 56px, 304px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.answer-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(24, 33, 47, 0.14);
}

.answer-button span {
  display: inline-block;
  margin-inline-end: 6px;
}

.answer-button.correct {
  background: var(--green);
}

.answer-button.wrong {
  background: var(--red);
}

.is-done .actions {
  display: none;
}

.is-done .retry-button {
  display: inline-grid;
  place-items: center;
}

.verb-retry {
  width: 100%;
  margin-top: 12px;
}

.stage-status {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 2;
  width: min(100% - 56px, 304px);
  transform: translateX(-50%);
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.35;
}

.footer {
  min-height: 28px;
  display: grid;
  gap: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 0.94rem;
  font-weight: 700;
}

.whatsapp-share {
  min-height: 58px;
  padding: 12px;
  border: 1px solid rgba(22, 132, 91, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #16845b, #21a66f);
  color: #ffffff;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(22, 132, 91, 0.18);
  transition:
    filter 160ms ease,
    transform 160ms ease;
}

.whatsapp-share:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.whatsapp-share svg {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.whatsapp-share span {
  min-width: 0;
  color: inherit;
  font-size: 0.9rem;
  font-weight: 950;
  line-height: 1.45;
}

.social-footer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(76, 20, 143, 0.08);
}

.social-footer strong {
  color: var(--brand);
  font-size: 0.92rem;
}

.social-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.social-links a {
  width: 44px;
  height: 44px;
  padding: 8px;
  border: 1px solid rgba(76, 20, 143, 0.16);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(241, 232, 255, 0.64);
  color: var(--brand);
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.social-links a:hover {
  border-color: rgba(76, 20, 143, 0.34);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.version-label {
  color: rgba(102, 112, 133, 0.72);
  font-size: 0.76rem;
  font-weight: 800;
  direction: ltr;
}

.social-links svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.is-done .card {
  cursor: default;
}

@media (max-width: 430px) {
  .app {
    min-height: 100vh;
    padding: 18px;
    gap: 14px;
  }

  .stage {
    min-height: 360px;
  }

  .topbar {
    gap: 10px;
  }

  .brand {
    gap: 9px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .brand-slogan {
    max-width: 86px;
    font-size: 0.88rem;
  }

  .login-link {
    min-height: 36px;
    padding: 0 8px;
    font-size: 0.76rem;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr) 42px;
    gap: 8px;
  }

  .stat-restart {
    width: 42px;
    min-height: 64px;
  }

  .card {
    width: min(100%, 330px);
    padding: 22px;
  }

  .mode-button {
    font-size: 0.74rem;
    line-height: 1.25;
    padding: 4px;
  }

  .mode-switch {
    grid-template-columns: repeat(2, 1fr);
  }

  .verb-forms {
    grid-template-columns: 1fr;
  }

  .verb-head {
    align-items: flex-start;
  }

  .verb-head-side {
    gap: 6px;
  }

  .verb-sound {
    width: 36px;
    height: 36px;
  }

  .verb-choice-grid {
    grid-template-columns: 1fr;
  }

  .reply-form {
    grid-template-columns: 1fr;
  }

  .discussion-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .member-words-panel {
    max-height: none;
  }

  .sound-button {
    left: calc(50% - 150px);
    top: 18px;
  }
}
