/* =========================================================
   恐ロシヤ — 100語で組み立てるロシア語パズル
   ========================================================= */
:root {
  --paper: #f4ecdd;
  --paper-2: #ece0cc;
  --card: #fffaf1;
  --ink: #191410;
  --ink-soft: #6b5f52;
  --red: #d13b2e;
  --red-dark: #a52a20;
  --blue: #2b3f68;
  --gold: #e0a63c;
  --green: #3d7357;
  --line: rgba(25, 20, 16, 0.16);
  --serif: "Georgia", "Iowan Old Style", "Hiragino Mincho ProN", "Yu Mincho", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; }

.paper {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 680px at 50% -8%, #fff9ee 0%, rgba(255, 249, 238, 0) 62%),
    radial-gradient(900px 620px at 108% 100%, #e9dac1 0%, rgba(233, 218, 193, 0) 58%),
    var(--paper);
}
.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
}

@media (min-width: 1000px) {
  body::before,
  body::after {
    position: fixed;
    top: 50%;
    font-family: var(--serif);
    font-size: 0.78rem;
    letter-spacing: 0.55em;
    color: rgba(25, 20, 16, 0.24);
    writing-mode: vertical-rl;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 0;
  }
  body::before { content: "СЛОВА · ПАЗЛ · РОССИЯ"; left: max(24px, calc(50vw - 420px)); }
  body::after { content: "200 СЛОВ · 193 ЗАДАЧИ"; right: max(24px, calc(50vw - 420px)); }
}

.app {
  position: relative;
  width: min(540px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  padding: 4px 18px 120px;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 18px;
  background: rgba(244, 236, 221, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: block;
  object-fit: cover;
  border-radius: 9px;
  background: var(--red);
  box-shadow: 2px 2px 0 var(--ink);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 0.94rem; letter-spacing: 0.08em; }
.brand-sub { font-size: 0.58rem; letter-spacing: 0.18em; color: var(--ink-soft); }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.1s, box-shadow 0.1s;
  touch-action: manipulation;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.off { color: var(--ink-soft); background: var(--paper-2); }
.back-btn { font-family: var(--sans); }
.game-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.game-title .gt-kicker { font-size: 0.6rem; letter-spacing: 0.2em; color: var(--red); font-weight: 700; }
.game-title .gt-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- hero ---------- */
.hero { position: relative; padding: 14px 0 10px; }
.hero-kicker {
  font-size: 0.66rem;
  letter-spacing: 0.26em;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
}
.hero-title {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.6rem, 12vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0.02em;
}
.hero-title .ru {
  display: block;
  font-size: 0.3em;
  letter-spacing: 0.32em;
  color: var(--ink-soft);
  margin-bottom: 9px;
  font-weight: 400;
}
.hero-catch { display: inline-block; color: var(--ink); font-size: 1.05rem; letter-spacing: 0.04em; margin-bottom: 2px; }
.hero-sub {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  font-size: 0.92rem;
  line-height: 1.85;
  color: var(--ink-soft);
  max-width: 21em;
}
.hero-stamp {
  position: absolute;
  top: 18px;
  right: -2px;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  border-radius: 50%;
  color: var(--red);
  transform: rotate(9deg);
  font-family: var(--serif);
  line-height: 1;
  text-align: center;
  opacity: 0.92;
  pointer-events: none;
}
.hero-stamp b { display: block; font-size: 1.65rem; }
.hero-stamp span { display: block; font-size: 0.52rem; letter-spacing: 0.18em; margin-top: 2px; }
.hero-stamp::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(209, 59, 46, 0.55);
  border-radius: 50%;
}
.hero-stats {
  display: flex;
  gap: 0;
  margin: 22px 0 0;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.hero-stat {
  flex: 1;
  padding: 10px 6px 9px;
  text-align: center;
  border-left: 1px solid var(--line);
}
.hero-stat:first-child { border-left: 0; }
.hero-stat b { display: block; font-family: var(--serif); font-size: 1.32rem; line-height: 1.1; }
.hero-stat span { display: block; font-size: 0.62rem; color: var(--ink-soft); letter-spacing: 0.06em; margin-top: 3px; }

/* ---------- progress card ---------- */
.progress-card {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 10px 0 -2px rgba(25, 20, 16, 0.14);
  position: relative;
  overflow: hidden;
}
.progress-card::after {
  content: "Ж";
  position: absolute;
  right: 6px;
  bottom: -34px;
  font-family: var(--serif);
  font-size: 7rem;
  line-height: 1;
  color: rgba(244, 236, 221, 0.07);
  pointer-events: none;
}
.pc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pc-label { font-size: 0.72rem; letter-spacing: 0.12em; color: rgba(244, 236, 221, 0.72); }
.pc-frac { font-family: var(--serif); font-size: 1.1rem; }
.pc-bar { height: 9px; margin: 11px 0 10px; border-radius: 99px; background: rgba(244, 236, 221, 0.18); overflow: hidden; }
.pc-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), #f0c46e); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.pc-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.74rem; color: rgba(244, 236, 221, 0.82); }
.pc-bottom .stars { color: var(--gold); letter-spacing: 0.1em; }
.pc-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(244, 236, 221, 0.32);
  border-radius: 99px;
  background: transparent;
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.pc-link:active { transform: translateY(1px); }

/* ---------- stage / levels ---------- */
.stage { margin-top: 38px; }
.stage-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.stage-no {
  font-family: var(--serif);
  font-size: 2.6rem;
  line-height: 0.9;
  color: transparent;
  -webkit-text-stroke: 1.4px rgba(25, 20, 16, 0.32);
  letter-spacing: -0.03em;
}
.stage-meta { display: flex; flex-direction: column; line-height: 1.35; }
.stage-ru { font-family: var(--serif); font-size: 0.8rem; letter-spacing: 0.16em; color: var(--red); }
.stage-ja { font-weight: 800; font-size: 0.98rem; letter-spacing: 0.04em; }
.stage-count { margin-left: auto; font-size: 0.66rem; color: var(--ink-soft); letter-spacing: 0.08em; }

.level {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}
.level + .level { margin-top: 12px; }
.level:nth-child(even) { transform: rotate(0.3deg); }
.level:nth-child(odd) { transform: rotate(-0.3deg); }
.level:not(.locked):active { transform: translate(2px, 2px) rotate(0); box-shadow: 2px 2px 0 var(--ink); }
.level .num svg { width: 19px; height: 19px; }
.level .num {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1;
}
.level.done .num { background: var(--green); border-color: var(--green); color: #fff; }
.level.current .num { background: var(--red); border-color: var(--red); color: #fff; }
.level .body { flex: 1; min-width: 0; }
.level .title { display: block; font-weight: 800; font-size: 0.98rem; letter-spacing: 0.03em; line-height: 1.35; }
.level .pattern {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.level .side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.level .stars { font-size: 0.8rem; letter-spacing: 0.12em; color: var(--gold); }
.level .stars .off { color: rgba(25, 20, 16, 0.18); }
.level .count { font-size: 0.58rem; color: var(--ink-soft); letter-spacing: 0.06em; }
.level.locked {
  cursor: not-allowed;
  background: #eee3d1;
  border-color: rgba(25, 20, 16, 0.3);
  box-shadow: none;
  color: rgba(25, 20, 16, 0.44);
}
.level.locked .num { border-color: rgba(25, 20, 16, 0.3); background: transparent; }
.level.locked .pattern { color: rgba(25, 20, 16, 0.38); }
.level.current { outline: 3px solid rgba(209, 59, 46, 0.22); outline-offset: 3px; }

.quote {
  margin: 44px 0 8px;
  padding: 18px 20px;
  border: 2px dashed rgba(25, 20, 16, 0.28);
  border-radius: 16px;
  text-align: center;
}
.quote .ru { font-family: var(--serif); font-size: 1.05rem; }
.quote .ja { display: block; margin-top: 4px; font-size: 0.72rem; color: var(--ink-soft); }
.quote .who { display: block; margin-top: 8px; font-size: 0.58rem; letter-spacing: 0.16em; color: var(--ink-soft); }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(540px, 100%);
  transform: translateX(-50%);
  padding: 7px 10px calc(7px + var(--safe-b));
  background: rgba(244, 236, 221, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 0 3px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--red); }
.tab.active svg { stroke-width: 2.2; }
body[data-view="game"] .tabbar { display: none; }

/* ---------- words ---------- */
.page-head { padding: 8px 0 6px; }
.page-kicker { font-size: 0.62rem; letter-spacing: 0.22em; font-weight: 700; color: var(--red); }
.page-title { margin: 6px 0 0; font-family: var(--serif); font-size: 2rem; line-height: 1.15; letter-spacing: 0.02em; }
.page-lead { margin: 8px 0 0; font-size: 0.82rem; color: var(--ink-soft); line-height: 1.8; }
.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 14px 0 12px;
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1.5px solid rgba(25, 20, 16, 0.35);
  border-radius: 99px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.word-list { border-top: 2px solid var(--ink); }
.word {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px dashed rgba(25, 20, 16, 0.24);
}
.word-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.word-main:active { opacity: 0.62; }
.word-ru { font-family: var(--serif); font-size: 1.36rem; line-height: 1.3; }
.word-ja { font-size: 0.82rem; font-weight: 700; color: var(--ink); margin-top: 1px; }
.word-meta { font-size: 0.58rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.word-srs { display: inline-block; margin-left: 6px; color: var(--ink-soft); font-weight: 700; }
.word-srs.next { color: var(--blue); }
.word-srs.due { color: var(--red); }
.word-note { display: block; margin-top: 3px; font-size: 0.62rem; color: var(--ink-soft); font-style: normal; }
.word-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.word-play {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 2px 2px 0 var(--ink);
  color: var(--ink);
  flex: 0 0 auto;
}
.word-play svg { width: 15px; height: 15px; margin-left: 1px; }
.word-play.playing { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 0.8s infinite; }
.word-undo {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px dashed rgba(25, 20, 16, 0.35);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.word-undo:active { background: rgba(25, 20, 16, 0.08); }
.word-all-empty { padding: 40px 0; text-align: center; color: var(--ink-soft); font-size: 0.85rem; }

/* ---------- how to ---------- */
.how-step {
  display: flex;
  gap: 13px;
  margin-top: 16px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.how-step .n {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-family: var(--serif);
  font-size: 1.05rem;
}
.how-step h3 { margin: 2px 0 4px; font-size: 0.95rem; letter-spacing: 0.03em; }
.how-step p { margin: 0; font-size: 0.8rem; line-height: 1.8; color: var(--ink-soft); }
.how-note {
  margin-top: 22px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(43, 63, 104, 0.07);
  border: 1px solid rgba(43, 63, 104, 0.16);
  font-size: 0.78rem;
  line-height: 1.85;
  color: #26334f;
}
.how-note b { color: var(--blue); }
.how-note .example { font-family: var(--serif); font-size: 1rem; }
.tips { margin: 10px 0 0; padding-left: 18px; font-size: 0.78rem; line-height: 1.9; color: var(--ink-soft); }
.tips li::marker { color: var(--red); }

/* ---------- game ---------- */
body[data-view="game"] .view { padding-bottom: 150px; }
.game-progress { display: flex; justify-content: center; gap: 5px; margin: 2px 0 16px; }
.gp-dot { width: 20px; height: 4px; border-radius: 99px; background: rgba(25, 20, 16, 0.14); transition: width 0.2s, background 0.2s; }
.gp-dot.done { background: var(--green); }
.gp-dot.now { width: 30px; background: var(--red); }

.prompt {
  position: relative;
  padding: 18px 18px 16px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.prompt::before {
  content: "Я";
  position: absolute;
  right: 12px;
  top: 6px;
  font-family: var(--serif);
  font-size: 3.4rem;
  line-height: 1;
  color: rgba(209, 59, 46, 0.09);
  pointer-events: none;
}
.prompt-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--red);
}
.prompt-label::before { content: ""; width: 16px; height: 2px; background: var(--red); }
.prompt-ja {
  position: relative;
  margin: 8px 0 0;
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.7;
  letter-spacing: 0.02em;
}
.prompt-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 10px; }
.prompt-count { font-size: 0.62rem; color: var(--ink-soft); letter-spacing: 0.08em; }
.mistakes { display: flex; align-items: center; gap: 4px; font-size: 0.6rem; color: var(--ink-soft); }
.mistakes i { width: 7px; height: 7px; border-radius: 50%; background: rgba(25, 20, 16, 0.14); }
.mistakes i.on { background: var(--red); }

.answer-zone {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 104px;
  margin-top: 16px;
  padding: 13px;
  border: 2px dashed rgba(25, 20, 16, 0.32);
  border-radius: 16px;
  background: rgba(236, 224, 204, 0.55);
  transition: border-color 0.2s, background 0.2s;
}
.answer-zone.empty { justify-content: center; align-items: center; }
.answer-zone #placed { display: contents; }
.answer-zone:not(.empty) .placeholder { display: none; }
.answer-zone .placeholder { font-size: 0.72rem; color: var(--ink-soft); text-align: center; line-height: 1.7; }
.answer-zone.shake { animation: shake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.answer-zone.correct { border-style: solid; border-color: var(--green); background: rgba(61, 115, 87, 0.08); }
.answer-zone.wrong { border-color: var(--red); }

.bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; min-height: 46px; }
.tile {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 13px;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.35;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tile:not(.used):active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tile.used { opacity: 0.22; pointer-events: none; box-shadow: none; transform: translate(1px, 1px); }
.tile.placed {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--red);
  animation: tilePop 0.18s ease-out;
}
.tile.placed:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--red); }

.game-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 35;
  display: flex;
  gap: 10px;
  width: min(540px, 100%);
  padding: 14px 18px calc(14px + var(--safe-b));
  transform: translateX(-50%);
  background: linear-gradient(to top, var(--paper) 62%, rgba(244, 236, 221, 0));
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
  touch-action: manipulation;
}
.btn:active { transform: translate(2px, 2px); box-shadow: none !important; }
.btn.primary { flex: 1; background: var(--red); border-color: var(--red-dark); color: #fff; box-shadow: 3px 3px 0 var(--ink); }
.btn.primary:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
.btn.ghost { flex: 0 0 auto; background: var(--card); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn.ghost:disabled { opacity: 0.35; }
.btn.wide { width: 100%; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--red); }

/* ---------- sheet ---------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(25, 20, 16, 0.46);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.sheet-wrap.open { opacity: 1; pointer-events: auto; }
.sheet-card {
  width: min(540px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + var(--safe-b));
  border-top: 3px solid var(--ink);
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  transform: translateY(40px);
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}
.sheet-wrap.open .sheet-card { transform: none; }
.sheet-kicker {
  font-family: var(--serif);
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  color: var(--red);
  text-align: center;
}
.sheet-kicker.good { color: var(--green); }
.sheet-title { margin: 2px 0 12px; font-size: 1.35rem; font-weight: 800; text-align: center; letter-spacing: 0.04em; }
.sheet-ru {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1.45;
  text-align: center;
  word-break: break-word;
}
.sheet-ja { margin: 6px 0 0; text-align: center; font-size: 0.82rem; color: var(--ink-soft); }
.audio-row { display: flex; justify-content: center; margin: 14px 0 4px; }
.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.audio-btn svg { width: 16px; height: 16px; }
.audio-btn.playing { background: var(--red); border-color: var(--red-dark); color: #fff; }
.forms { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0 0; }
.form-chip {
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(43, 63, 104, 0.09);
  color: var(--blue);
  font-family: var(--serif);
  font-size: 0.74rem;
}
.sheet-note {
  margin: 16px 0 0;
  padding: 13px 15px;
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: rgba(224, 166, 60, 0.1);
  font-size: 0.79rem;
  line-height: 1.8;
}
.sheet-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 9px; }
.sheet-actions .btn { width: 100%; }
.sheet-tiny { margin-top: 10px; text-align: center; font-size: 0.62rem; color: var(--ink-soft); }

/* ---------- result ---------- */
.result { position: relative; padding: 26px 0 10px; text-align: center; }
.result-kicker { font-family: var(--serif); font-size: 0.68rem; letter-spacing: 0.28em; color: var(--red); }
.result-title { margin: 6px 0 0; font-family: var(--serif); font-size: 2.5rem; line-height: 1.1; }
.result-sub { margin: 10px 0 0; color: var(--ink-soft); font-size: 0.85rem; }
.big-stars { margin: 16px 0 4px; font-size: 2.6rem; letter-spacing: 0.1em; color: var(--gold); line-height: 1; }
.big-stars .off { color: rgba(25, 20, 16, 0.14); }
.result-stats {
  display: flex;
  margin: 22px 0 0;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.result-stat { flex: 1; padding: 11px 6px; border-left: 1px solid var(--line); }
.result-stat:first-child { border-left: 0; }
.result-stat b { display: block; font-family: var(--serif); font-size: 1.3rem; line-height: 1.1; }
.result-stat span { display: block; margin-top: 3px; font-size: 0.6rem; color: var(--ink-soft); }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.result-small { margin-top: 12px; border: 0; background: none; color: var(--ink-soft); font-size: 0.72rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 8px;
  height: 12px;
  background: var(--c);
  border-radius: 2px;
  animation: fall var(--d) cubic-bezier(0.2, 0.6, 0.4, 1) var(--delay) forwards;
  transform: rotate(var(--r));
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-b));
  z-index: 80;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 16px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- empty / misc ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- animations ---------- */
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
@keyframes tilePop {
  0% { transform: scale(0.86); }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(209, 59, 46, 0.35); }
  50% { box-shadow: 0 0 0 7px rgba(209, 59, 46, 0); }
}
@keyframes fall {
  0% { transform: translateY(0) rotate(var(--r)); opacity: 1; }
  100% { transform: translateY(78vh) rotate(calc(var(--r) + 260deg)); opacity: 0; }
}

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

@media (max-width: 380px) {
  .view { padding-left: 14px; padding-right: 14px; }
  .topbar { padding: 0 14px; }
  .prompt-ja { font-size: 1.18rem; }
  .tile { font-size: 1.02rem; padding: 8px 11px; }
  .hero-stamp { width: 64px; height: 64px; }
  .hero-stamp b { font-size: 1.4rem; }
}

/* ---------- special motion lesson ---------- */
.level.special { background: #eef2f8; border-color: var(--blue); }
.level.special .num { background: var(--blue); border-color: var(--blue); color: #fff; }
.level.special.current { outline-color: rgba(43, 63, 104, 0.25); }
.level.special.locked { background: #eee3d1; border-color: rgba(25, 20, 16, 0.3); }
.level.special.locked .num { background: transparent; border-color: rgba(25, 20, 16, 0.3); color: rgba(25, 20, 16, 0.44); }
.level .badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 0.52rem;
  font-style: normal;
  letter-spacing: 0.12em;
  vertical-align: 2px;
}
.level.locked .badge { background: rgba(25, 20, 16, 0.3); }

.chip.motion { border-color: var(--blue); color: var(--blue); }
.chip.motion.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.motion-lead {
  margin: 2px 0 14px;
  font-size: 0.8rem;
  line-height: 1.85;
  color: var(--ink-soft);
}
.motion-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 14px;
  margin-bottom: 12px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.motion-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.motion-ru { font-family: var(--serif); font-size: 1.5rem; line-height: 1.2; }
.motion-ja { font-size: 0.76rem; color: var(--ink-soft); }
.motion-play { width: 42px; height: 42px; padding: 0; border-radius: 50%; align-self: center; }
.motion-ex {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}
.ex-ru { font-family: var(--serif); font-size: 1.05rem; }
.ex-ja { font-size: 0.7rem; color: var(--ink-soft); }

/* ---------- SRS flashcards ---------- */
.srs-teaser {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "kicker count" "title count" "sub count";
  gap: 0 10px;
  width: 100%;
  margin-top: 14px;
  padding: 13px 16px;
  border: 2px solid var(--blue);
  border-radius: 16px;
  background: #eef2f8;
  color: var(--ink);
  text-align: left;
  box-shadow: 3px 3px 0 var(--blue);
  cursor: pointer;
  touch-action: manipulation;
}
.srs-teaser:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--blue); }
.srs-teaser .st-kicker { grid-area: kicker; font-size: 0.54rem; letter-spacing: 0.14em; color: var(--blue); font-weight: 700; }
.srs-teaser .st-title { grid-area: title; font-weight: 800; font-size: 0.92rem; line-height: 1.4; }
.srs-teaser .st-sub { grid-area: sub; font-size: 0.66rem; color: var(--ink-soft); }
.srs-teaser .st-count {
  grid-area: count;
  align-self: center;
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1;
  color: var(--blue);
  white-space: nowrap;
}
.srs-teaser .st-count i { font-style: normal; font-size: 0.58rem; margin-left: 2px; }

.srs-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 14px; }
.srs-remaining { font-size: 0.72rem; color: var(--ink-soft); }
.srs-remaining b { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }
.srs-left { font-size: 0.66rem; color: var(--ink-soft); }
.srs-bar { height: 7px; margin: 8px 0 10px; border-radius: 99px; background: rgba(25, 20, 16, 0.12); overflow: hidden; }
.srs-bar i { display: block; height: 100%; border-radius: 99px; background: var(--blue); transition: width 0.3s; }
.srs-chips { display: flex; gap: 6px; margin-bottom: 14px; }
.srs-chips span { padding: 3px 8px; border-radius: 99px; background: rgba(43, 63, 104, 0.09); color: var(--blue); font-size: 0.6rem; }

.flashcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  min-height: 0;
  padding: 28px 22px;
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 6px 6px 0 var(--ink);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  animation: cardIn 0.22s ease-out;
  touch-action: manipulation;
}
.flashcard::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(25, 20, 16, 0.18);
  border-radius: 15px;
  pointer-events: none;
}
.flashcard:focus-visible { outline: 3px solid rgba(209, 59, 46, 0.45); outline-offset: 4px; }
.fc-face { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; justify-content: flex-start; padding-top: 6px; }
.fc-back { display: none; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.flashcard.flipped .fc-front { display: none; }
.flashcard.flipped .fc-back { display: flex; }
.fc-kicker { font-size: 0.58rem; letter-spacing: 0.24em; color: var(--red); font-weight: 700; }
.fc-ru { margin: 8px 0 4px; font-family: var(--serif); font-size: clamp(2rem, 9vw, 2.7rem); line-height: 1.35; word-break: break-word; }
.fc-ru.long { font-size: clamp(1.4rem, 6vw, 2rem); }
.fc-ja { margin: 8px 0 2px; font-size: 1.9rem; font-weight: 800; }
.fc-meta { font-size: 0.7rem; color: var(--ink-soft); }
.fc-note { max-width: 300px; margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: rgba(224, 166, 60, 0.12); font-size: 0.72rem; line-height: 1.7; }
.fc-audio {
  position: absolute;
  top: 0;
  right: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}
.fc-audio svg { width: 17px; height: 17px; }
.fc-audio-row { margin-top: 14px; }
.fc-tap { margin-top: 22px; font-size: 0.62rem; color: var(--ink-soft); letter-spacing: 0.05em; }
.flashcard.leaving { animation: cardOut 0.18s ease-in forwards; }

.rate-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 16px; }
.rate-row[hidden] { display: none; }
.rate {
  padding: 8px 3px 7px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  touch-action: manipulation;
}
.rate:active { transform: translate(2px, 2px); box-shadow: none; }
.rate small { display: block; margin-top: 2px; font-size: 0.54rem; font-weight: 400; opacity: 0.8; }
.rate.again { background: #f7ded9; border-color: var(--red); color: var(--red-dark); }
.rate.hard { background: #f8e9cd; border-color: #b7842c; color: #7a5514; }
.rate.good { background: #dde7f6; border-color: var(--blue); color: var(--blue); }
.rate.easy { background: #dcebe1; border-color: var(--green); color: var(--green); }

.srs-done { padding: 24px 0 8px; text-align: center; }
.srs-done-mark { width: 70px; height: 70px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: #fff; font-size: 2rem; box-shadow: 3px 3px 0 var(--ink); }
.srs-done-kicker { font-family: var(--serif); font-size: 0.62rem; letter-spacing: 0.22em; color: var(--red); }
.srs-done-title { margin: 4px 0 0; font-family: var(--serif); font-size: 2rem; line-height: 1.2; }
.srs-done-lead { margin: 8px 0 0; font-size: 0.78rem; line-height: 1.8; color: var(--ink-soft); }
.srs-done-stats { display: flex; margin: 20px 0 0; border: 2px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: var(--shadow-sm); overflow: hidden; }
.srs-done-stats div { flex: 1; padding: 10px 4px; border-left: 1px solid var(--line); }
.srs-done-stats div:first-child { border-left: 0; }
.srs-done-stats b { display: block; font-family: var(--serif); font-size: 1.3rem; line-height: 1.1; }
.srs-done-stats span { display: block; margin-top: 2px; font-size: 0.58rem; color: var(--ink-soft); }
.srs-next { margin: 14px 0 18px; font-size: 0.72rem; color: var(--ink-soft); }
.srs-next b { color: var(--ink); }
.srs-done .btn { margin-top: 8px; }

@keyframes cardIn { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardOut { to { transform: translateX(-18px) scale(0.96); opacity: 0; } }

body[data-view="cards"] .page-head { padding: 2px 0 0; }
body[data-view="cards"] .page-lead { display: none; }
body[data-view="cards"] .page-title { font-size: 1.75rem; margin-top: 2px; }

/* ---------- examples & verb tags ---------- */
.fc-examples {
  width: 100%;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  text-align: left;
}
.fc-ex-title { margin-bottom: 6px; font-size: 0.62rem; letter-spacing: 0.16em; color: var(--red); font-weight: 700; }
.fc-examples ul { margin: 0; padding: 0; list-style: none; }
.fc-examples li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed rgba(25, 20, 16, 0.1);
}
.fc-examples li:first-child { border-top: 0; }
.ex-text { flex: 1; min-width: 0; }
.ex-ru { display: block; font-family: var(--serif); font-size: 1.02rem; line-height: 1.42; }
.ex-ja { display: block; font-size: 0.8rem; line-height: 1.5; color: var(--ink-soft); }
.ex-audio {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}
.ex-audio svg { width: 12px; height: 12px; }
.fc-examples mark { padding: 0 2px; border-radius: 3px; background: rgba(224, 166, 60, 0.35); color: var(--ink); }

.verb-block {
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid rgba(43, 63, 104, 0.14);
  border-radius: 12px;
  background: rgba(43, 63, 104, 0.06);
  text-align: left;
}
.vb-title { margin-bottom: 5px; font-size: 0.56rem; letter-spacing: 0.16em; color: var(--blue); font-weight: 700; }
.vrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 3px 0; }
.vrow b { margin-right: 2px; font-family: var(--serif); font-size: 0.95rem; }
.vtag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(25, 20, 16, 0.07);
  color: var(--ink-soft);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.4;
}
.vtag.inf { background: rgba(43, 63, 104, 0.12); color: var(--blue); }

@media (max-height: 720px) {
  .flashcard { height: 310px; padding: 14px 16px; }
  .fc-audio-row { margin-top: 8px; }
}

/* iOS/Safari で結合アキュートが空白になる問題の対策。
   テキストから U+0301 を外し、母音を span.st で包んで
   text-emphasis でアクセントを描く。 */
.st {
  position: relative;
  display: inline;
}
.st::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.12em;
  width: 0.22em;
  height: 0.06em;
  margin-left: -0.11em;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(-28deg);
  pointer-events: none;
}
