:root {
  --paper: #f3efe6;
  --paper-deep: #e7e0d2;
  --card: #fffdf8;
  --ink: #1c1915;
  --muted: #5e584e;
  --navy: #0f3d5e;
  --navy-ink: #0a2c44;
  --terracotta: #e07a3d;
  --line: #d8d0c2;
  --ok: #1f7a4d;
  --ok-bg: #e6f4ec;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --shadow: 0 8px 24px rgba(28, 25, 21, 0.08);
  --radius: 18px;
  --tap: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

.app {
  min-height: 100dvh;
  min-height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 16px calc(12px + var(--safe-bottom));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 12px;
}

.brand h1 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--navy);
  font-weight: 750;
}

.meta {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--muted);
}

.dir-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--navy);
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.dir-toggle:active { transform: scale(0.97); }

.dir-from, .dir-to {
  min-width: 1.6em;
  text-align: center;
}

.dir-arrow { opacity: 0.85; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen.hidden, .hidden { display: none !important; }

#screenQuestion {
  justify-content: center;
}

.status {
  margin: auto;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.prompt {
  font-size: 0.92rem;
  color: var(--muted);
  text-align: center;
  margin: 8px 0 12px;
}

.word-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  margin-bottom: 18px;
  text-align: center;
}

.word {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: clamp(1.5rem, 6.4vw, 2.15rem);
  font-weight: 700;
  color: var(--navy-ink);
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.choice {
  min-height: var(--tap);
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(28, 25, 21, 0.04);
  overflow-wrap: anywhere;
}

.choice:active {
  transform: translateY(1px);
  background: var(--paper-deep);
}

#screenResult {
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 24px 8px 16px;
  outline: none;
}

#screenResult.is-ok { background: var(--ok-bg); }
#screenResult.is-bad { background: var(--bad-bg); }

.verdict {
  font-size: clamp(2.2rem, 9vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

#screenResult.is-ok .verdict { color: var(--ok); }
#screenResult.is-bad .verdict { color: var(--bad); }

.pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: clamp(1.25rem, 5.5vw, 1.7rem);
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
  max-width: 22em;
}
.pair-verb {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--muted);
}
.pair-a, .pair-b { display: block; }

.hint {
  margin-top: 28px;
  font-size: 0.9rem;
  color: var(--muted);
}

.bottom {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 8px;
}

.tracker {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy-ink);
  margin-bottom: 10px;
}

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

.btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

.btn.ghost {
  background: transparent;
}

.btn:active { background: var(--paper-deep); }

.menu-wrap {
  margin-left: auto;
  position: relative;
}

.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 20;
}

.menu-count {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 6px 10px 8px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.menu-item:active, .menu-item:hover {
  background: var(--paper-deep);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--navy-ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  max-width: calc(100% - 32px);
  z-index: 40;
  box-shadow: var(--shadow);
}

@media (min-width: 700px) {
  body { background: var(--paper-deep); }
  .app {
    margin: 16px auto;
    min-height: calc(100dvh - 32px);
    background: var(--paper);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 20px 22px;
  }
}
