/* ---------- Tokens ---------- */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1d2b33;
  --ink-2: #5b676d;
  --hint: #8d9497;
  --line: #1d2b33;
  --line-soft: rgba(29, 43, 51, 0.16);
  --soft: rgba(29, 43, 51, 0.055);
  --olive: #5e8445;
  --terracotta: #b95b39;
  --sea: #2f6f8f;
  --ochre: #b07a22;
  --sand: #f1e8da;
  --on-accent: #ffffff;
  --dim: rgba(16, 24, 29, 0.17);
  --veil: rgba(250, 247, 242, 0.38);
  --shadow: 0 24px 60px -24px rgba(29, 43, 51, 0.38), 0 2px 6px rgba(29, 43, 51, 0.06);

  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --drawer-w: 300px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a20;
    --surface: #17242c;
    --ink: #efe8dc;
    --ink-2: #a9b2b4;
    --hint: #7f8b8f;
    --line: rgba(239, 232, 220, 0.86);
    --line-soft: rgba(239, 232, 220, 0.16);
    --soft: rgba(239, 232, 220, 0.06);
    --olive: #6f9652;
    --terracotta: #c86b47;
    --sea: #5d97b6;
    --ochre: #b98a3a;
    --sand: #22313a;
    --on-accent: #ffffff;
    --dim: rgba(0, 0, 0, 0.42);
    --veil: rgba(15, 26, 32, 0.5);
    --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.2);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ochre: #b98a3a;
  --bg: #0f1a20;
  --surface: #17242c;
  --ink: #efe8dc;
  --ink-2: #a9b2b4;
  --hint: #7f8b8f;
  --line: rgba(239, 232, 220, 0.86);
  --line-soft: rgba(239, 232, 220, 0.16);
  --soft: rgba(239, 232, 220, 0.06);
  --olive: #6f9652;
  --terracotta: #c86b47;
  --sea: #5d97b6;
  --sand: #22313a;
  --on-accent: #ffffff;
  --dim: rgba(0, 0, 0, 0.42);
  --veil: rgba(15, 26, 32, 0.5);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  transition: background-color 0.5s var(--ease), color 0.5s var(--ease);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible {
  outline: 2px solid var(--sea);
  outline-offset: 3px;
}

p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.flag {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  line-height: 1;
}

/* ---------- Layout ---------- */

.app {
  display: flex;
  height: 100dvh;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  padding: 0 24px;
  overflow: clip; /* alttaki gizli cümle kartı hiçbir kaydırmayla görünmesin */
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: calc(env(safe-area-inset-top) + 22px);
  min-height: 72px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -10px;
  border-radius: 999px;
  color: var(--ink);
  transition: background-color 0.25s var(--ease);
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--soft);
  }
}

.progress {
  font-size: 15px;
  letter-spacing: 0.005em;
  font-variant-numeric: tabular-nums;
}

.clue-btn {
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--hint);
  transition: color 0.3s var(--ease), background-color 0.25s var(--ease), opacity 0.3s var(--ease), transform 0.2s var(--ease);
}

.clue-btn .bulb-fill {
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

@media (hover: hover) {
  .clue-btn:hover:not(:disabled) {
    color: var(--ink);
    background: var(--soft);
  }
}

.clue-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.clue-btn[aria-pressed="true"] {
  color: var(--ochre);
}

.clue-btn[aria-pressed="true"] .bulb-fill {
  opacity: 0.25;
}

.clue-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.counter {
  margin-left: 6px;
  min-width: 46px;
  height: 46px;
  padding: 0 11px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.4s var(--ease), color 0.4s var(--ease);
}

.counter.bump {
  border-color: var(--olive);
  color: var(--olive);
}

.counter.drop {
  border-color: var(--terracotta);
  color: var(--terracotta);
}

.toast {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 82px);
  left: 50%;
  z-index: 25;
  width: max-content;
  max-width: calc(100% - 48px);
  padding: 10px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 0.35s var(--ease), transform 0.45s var(--ease-out);
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 6vh;
}

.word-wrap {
  position: relative;
  text-align: center;
  margin-bottom: 30px;
}

.word-row {
  position: relative;
  padding: 0 38px;
}

.info-btn {
  position: absolute;
  top: 50%;
  right: -6px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--hint);
  transform: translateY(-50%);
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
}

@media (hover: hover) {
  .info-btn:hover {
    color: var(--ink);
    background: var(--soft);
  }
}

.info-btn[aria-expanded="true"] {
  color: var(--sea);
}

.status {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 15;
  padding: 16px 18px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: 50% 0;
  transition:
    opacity 0.28s var(--ease),
    transform 0.4s var(--ease-out),
    visibility 0s linear 0.28s;
}

.status.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.28s var(--ease),
    transform 0.4s var(--ease-out),
    visibility 0s;
}

.status-msg {
  font-size: 15.5px;
  line-height: 1.4;
  color: var(--ink-2);
  text-wrap: balance;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

.dots {
  display: inline-flex;
  gap: 5px;
  margin-right: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-soft);
  transition: background-color 0.3s var(--ease);
}

.dot.on {
  background: var(--olive);
}

.dot.next {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--olive);
}

#statusToday.done {
  color: var(--olive);
}

.status-rule {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--hint);
  text-wrap: balance;
}

.word {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 64px;
  line-height: 1.06;
  letter-spacing: -0.028em;
  white-space: nowrap;
}

.word.wrap {
  white-space: normal;
  text-wrap: balance;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--hint);
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.005em;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

.hint .flag {
  font-size: 22px;
}

@media (hover: hover) {
  .hint:hover {
    background: var(--soft);
  }
}

.hint:active {
  transform: scale(0.98);
}

/* Anlam başta gizli; ipucuyla ya da cevaptan sonra yumuşakça belirir (yer kaplamaya devam eder). */
.hint {
  transition:
    background-color 0.25s var(--ease),
    color 0.25s var(--ease),
    opacity 0.4s var(--ease),
    filter 0.45s var(--ease),
    transform 0.5s var(--ease-out);
}

.hint.concealed {
  opacity: 0;
  filter: blur(8px);
  transform: translateY(6px);
  pointer-events: none;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.opt {
  position: relative;
  height: 56px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 17px;
  line-height: 1.15;
  transition:
    background-color 0.22s var(--ease),
    border-color 0.22s var(--ease),
    color 0.22s var(--ease),
    opacity 0.3s var(--ease),
    transform 0.2s var(--ease);
}

.opt span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.opt.long {
  font-size: 15px;
}

.opt.xlong {
  font-size: 13.5px;
}

@media (hover: hover) {
  .opt:hover:not(:disabled) {
    background: var(--soft);
  }
}

.opt:active:not(:disabled) {
  transform: scale(0.97);
}

.opt:disabled {
  cursor: default;
}

.opt.correct {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--on-accent);
  animation: pop 0.42s var(--ease-out);
}

.opt.wrong {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--on-accent);
  animation: shake 0.38s var(--ease);
}

.opt.half {
  background: var(--ochre);
  border-color: var(--ochre);
  color: var(--on-accent);
  animation: pop 0.42s var(--ease-out);
}

.opt.faded {
  opacity: 0.35;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.045); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.empty {
  text-align: center;
  color: var(--ink-2);
  font-size: 16px;
}

.empty .chip {
  margin-top: 16px;
}

/* ---------- Bottom ---------- */

.bottom {
  padding-bottom: calc(env(safe-area-inset-bottom) + 26px);
}

.sentence-btn {
  width: 100%;
  height: 58px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 17px;
  letter-spacing: 0.005em;
  transition: background-color 0.25s var(--ease), transform 0.2s var(--ease), opacity 0.3s var(--ease);
}

@media (hover: hover) {
  .sentence-btn:hover {
    background: var(--soft);
  }
}

.sentence-btn:active {
  transform: scale(0.985);
}

/* ---------- Sentence sheet ---------- */

.dim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
}

.dim.on {
  opacity: 1;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px 26px calc(env(safe-area-inset-bottom) + 28px);
  background: var(--surface);
  border-radius: 30px 30px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(calc(100% + 40px));
  transition: transform 0.55s var(--ease-out);
  touch-action: none;
}

.sheet.open {
  transform: translateY(0);
}

.sheet.dragging {
  transition: none;
}

.handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 20px;
  border-radius: 99px;
  background: var(--line-soft);
}

.sline {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
}

.sline .flag {
  flex: none;
  font-size: 19px;
}

.sline .fit {
  min-width: 0;
}

.s-es {
  font-size: 18px;
  font-weight: 560;
  letter-spacing: -0.005em;
}

.s-tr {
  margin-top: 8px;
  font-size: 16px;
  color: var(--hint);
}

.s-tr .fit {
  transition: filter 0.4s var(--ease), opacity 0.4s var(--ease);
}

.s-tr.concealed .fit {
  filter: blur(6px);
  opacity: 0.7;
  -webkit-user-select: none;
  user-select: none;
}

.reveal-tag {
  display: none;
  flex: none;
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ochre) 16%, transparent);
  color: var(--ochre);
  font-size: 12.5px;
  font-weight: 600;
}

.s-tr.concealed {
  cursor: pointer;
}

.s-tr.concealed .reveal-tag {
  display: block;
}

.snote {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.snote:empty {
  display: none;
}

.snote span {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink-2);
  font-size: 13.5px;
}

.snote b {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Drawer ---------- */

.drawer {
  flex: none;
  width: var(--drawer-w);
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top) + 26px) 24px calc(env(safe-area-inset-bottom) + 28px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  --field: var(--surface);
  background: var(--bg);
  border-right: 1px solid var(--line-soft);
  transition: background-color 0.5s var(--ease), border-color 0.5s var(--ease);
  scrollbar-width: thin;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}

.brand {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand span {
  color: var(--terracotta);
}

.drawer-close {
  margin: 0 -10px 0 0;
}

.rule {
  flex: none;
  height: 1px;
  margin: 2px 0;
  border: 0;
  background: var(--line-soft);
}

.field-label {
  display: block;
  margin-bottom: 10px;
  font-size: 15px;
  color: var(--ink-2);
}

/* Dropdown: opens inline, height animates */
.dd-btn {
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 0 18px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--field);
  font-size: 17px;
  text-align: left;
  transition: border-color 0.25s var(--ease), background-color 0.5s var(--ease);
}

@media (hover: hover) {
  .dd-btn:hover {
    border-color: var(--hint);
  }
}

.dd.open .dd-btn {
  border-color: var(--sea);
}

.dd-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-chev {
  flex: none;
  color: var(--hint);
  transition: transform 0.4s var(--ease-out);
}

.dd.open .dd-chev {
  transform: rotate(180deg);
}

.dd-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.42s var(--ease-out);
}

.dd.open .dd-panel {
  grid-template-rows: 1fr;
}

.dd-clip {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s linear 0.42s;
}

.dd.open .dd-clip {
  visibility: visible;
  transition: visibility 0s;
}

.dd-list {
  margin-top: 8px;
  max-height: 296px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--field);
  scrollbar-width: thin;
}

.dd-opt {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 15.5px;
  text-align: left;
  color: var(--ink-2);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

@media (hover: hover) {
  .dd-opt:hover {
    background: var(--soft);
  }
}

.dd-opt[aria-selected="true"] {
  color: var(--ink);
}

.dd-check {
  flex: none;
  color: var(--sea);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s var(--ease), transform 0.3s var(--ease-out);
}

.dd-opt[aria-selected="true"] .dd-check {
  opacity: 1;
  transform: none;
}

.chip {
  padding: 7px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.2;
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease), transform 0.15s var(--ease);
}

@media (hover: hover) {
  .chip:hover {
    border-color: var(--ink-2);
  }
}

.chip:active {
  transform: scale(0.96);
}

.chip[aria-pressed="true"] {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}

.chip-accent {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #fff;
}

@media (hover: hover) {
  .chip-accent:hover {
    border-color: var(--terracotta);
    filter: brightness(1.06);
  }
}

/* Segmented control with sliding thumb */
.seg {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 5px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--soft);
}

.seg button {
  position: relative;
  z-index: 1;
  height: 44px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}

.seg button[aria-checked="true"] {
  color: var(--sea);
  font-weight: 600;
}

.seg-thumb {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  border-radius: 10px;
  background: var(--field);
  box-shadow: 0 0 0 1px var(--line-soft), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.45s var(--ease-out), width 0.45s var(--ease-out), background-color 0.5s var(--ease);
}

.fact-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 18px;
  background: var(--sand);
  color: var(--terracotta);
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.2s var(--ease), background-color 0.5s var(--ease);
}

.fact-btn svg {
  transition: transform 0.3s var(--ease-out);
}

@media (hover: hover) {
  .fact-btn:hover svg {
    transform: translateX(3px);
  }
}

.fact-btn:active {
  transform: scale(0.98);
}

.soon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 12px 18px;
  border: 1px dashed var(--line-soft);
  border-radius: 18px;
  color: var(--hint);
  font-size: 15px;
}

.soon-tag {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Yedekleme */
.backup-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.backup-btn {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--field);
  font-size: 14.5px;
  transition: border-color 0.25s var(--ease), transform 0.2s var(--ease), background-color 0.5s var(--ease);
}

.backup-btn svg {
  color: var(--hint);
}

@media (hover: hover) {
  .backup-btn:hover {
    border-color: var(--hint);
  }
}

.backup-btn:active {
  transform: scale(0.97);
}

.backup-note {
  margin-top: 9px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--hint);
}

/* İlerleme çubukları */
.stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 14px;
}

.stat-label {
  color: var(--ink-2);
}

.stat-num {
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

.stat-num b {
  font-weight: 600;
  color: var(--ink);
}

.bar {
  height: 6px;
  border-radius: 99px;
  background: var(--soft);
  overflow: hidden;
}

.bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.8s var(--ease-out), background-color 0.5s var(--ease);
}

.stat[data-kind="half"] .bar-fill {
  background: var(--ochre);
}

.stat[data-kind="learned"] .bar-fill {
  background: var(--olive);
}

.stat[data-kind="unseen"] .bar-fill {
  background: var(--hint);
}

.scrim {
  display: none;
}

@media (min-width: 900px) {
  .menu-btn,
  .drawer-close {
    display: none;
  }
}

@media (max-width: 899px) {
  .drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(86vw, 330px);
    background: var(--surface);
    border-right: 0;
    box-shadow: var(--shadow);
    --field: var(--bg);
    transform: translateX(-104%);
    transition: transform 0.5s var(--ease-out), background-color 0.5s var(--ease), visibility 0s linear 0.5s;
    visibility: hidden;
    touch-action: pan-y;
    scrollbar-width: none;
  }

  .drawer::-webkit-scrollbar {
    display: none;
  }

  .drawer.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.5s var(--ease-out), background-color 0.5s var(--ease), visibility 0s;
  }

  .drawer.dragging {
    transition: none;
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: var(--dim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s var(--ease);
  }

  .scrim.on {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ---------- Fun fact cards ---------- */

.fact-card {
  width: 100%;
  max-width: 412px;
  padding: 22px 24px 24px;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.fact-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--terracotta);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.fact-label .flag,
.fact-label span:first-child {
  font-size: 15px;
  letter-spacing: 0;
}

.fact-text {
  font-size: 17px;
  line-height: 1.48;
  text-wrap: pretty;
}

/* Intro: blurred first word behind, fact at the bottom */
.intro {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 24px 24px calc(env(safe-area-inset-bottom) + 26px);
  background: var(--veil);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: opacity 0.6s var(--ease), visibility 0s linear 0.6s;
}

.intro-inner {
  width: 100%;
  max-width: 412px;
  transition: transform 0.6s var(--ease-out);
}

.intro.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro.hide .intro-inner {
  transform: translateY(24px);
}

.intro.show .intro-inner {
  animation: rise 0.8s var(--ease-out) both;
}

.tap-hint {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-2);
  animation: breathe 2.8s ease-in-out infinite;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: none; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (min-width: 900px) {
  .intro {
    padding-left: calc(var(--drawer-w) + 24px);
  }
}

/* Generator: card drops in from above */
.fact-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--dim);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0s linear 0.35s;
}

.fact-layer.on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s var(--ease);
}

.fact-layer .fact-card {
  transform-origin: 50% 0;
}

.fact-card.drop {
  animation: drop 1s both;
}

.fact-card.fall {
  animation: fall 0.42s cubic-bezier(0.5, 0, 0.9, 0.5) both;
}

@keyframes drop {
  0% {
    transform: translateY(-110vh) rotate(-7deg);
    animation-timing-function: cubic-bezier(0.55, 0, 0.85, 0.35);
  }
  52% {
    transform: translateY(16px) rotate(2.2deg);
    animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1);
  }
  70% {
    transform: translateY(-9px) rotate(-1deg);
    animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
  }
  85% {
    transform: translateY(3px) rotate(0.35deg);
    animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
  }
  100% {
    transform: none;
  }
}

@keyframes fall {
  to {
    transform: translateY(70vh) rotate(8deg);
    opacity: 0;
  }
}

.fact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ---------- Small / short screens ---------- */

@media (max-width: 360px) {
  .main {
    padding: 0 18px;
  }

  .options {
    gap: 12px;
  }
}

@media (max-height: 640px) {
  .topbar {
    padding-top: calc(env(safe-area-inset-top) + 12px);
  }

  .word-wrap {
    margin-bottom: 20px;
  }

  .opt {
    height: 50px;
  }

  .sentence-btn {
    height: 52px;
  }

  .bottom {
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
