@font-face { font-family: Lexend; font-weight: 400; font-display: swap; src: url(fonts/lexend-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Lexend; font-weight: 500; font-display: swap; src: url(fonts/lexend-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Lexend; font-weight: 600; font-display: swap; src: url(fonts/lexend-latin-600-normal.woff2) format('woff2'); }

:root {
  --bg: #FDFBF7;
  --blob-a: rgba(244, 180, 120, .42);
  --blob-b: rgba(120, 175, 225, .30);
  --glass: rgba(255, 252, 246, .66);
  --hair: rgba(70, 55, 30, .14);
  --edge: rgba(255, 255, 255, .85);
  --text: #2B2620;
  --muted: #655C50;
  --fill: rgba(90, 70, 40, .08);
  --fill-strong: rgba(90, 70, 40, .15);
  --accent: #0066CC;
  --on-accent: #FFFFFF;
  --green-bg: #DCF2DF;
  --yellow-bg: #FFF0BF;
  --yellow-mark: #FFD84D;
  --neutral-bg: rgba(90, 70, 40, .08);
  --shadow: 0 24px 60px rgba(90, 65, 30, .24), 0 4px 14px rgba(90, 65, 30, .12);
}
:root[data-theme="dark"] {
  --bg: #18181B;
  --blob-a: rgba(88, 80, 214, .34);
  --blob-b: rgba(20, 150, 150, .24);
  --glass: rgba(40, 40, 45, .62);
  --hair: rgba(255, 255, 255, .13);
  --edge: rgba(255, 255, 255, .10);
  --text: #F4F4F5;
  --muted: #B4B4BC;
  --fill: rgba(255, 255, 255, .08);
  --fill-strong: rgba(255, 255, 255, .15);
  --accent: #0071E3;
  --on-accent: #FFFFFF;
  --green-bg: rgba(48, 209, 88, .20);
  --yellow-bg: rgba(255, 214, 10, .18);
  --yellow-mark: #FFD60A;
  --neutral-bg: rgba(255, 255, 255, .08);
  --shadow: 0 30px 70px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(60vmax 60vmax at 8% 4%, var(--blob-a), transparent 70%),
    radial-gradient(70vmax 70vmax at 96% 92%, var(--blob-b), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Lexend, system-ui, 'Noto Color Emoji', sans-serif;
  font-size: 18px;
  letter-spacing: .06em;
  line-height: 1.7;
  text-align: left;
  display: flex;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden;
}

.window {
  width: 100%;
  max-width: 540px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  -webkit-backdrop-filter: blur(34px) saturate(170%);
  backdrop-filter: blur(34px) saturate(170%);
  border: 1px solid var(--hair);
  border-radius: 22px;
  box-shadow: var(--shadow), inset 0 1px 0 var(--edge);
  overflow: hidden;
}

.titlebar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 6px 10px 6px 16px;
  border-bottom: 1px solid var(--hair);
}
.dots { display: flex; gap: 7px; flex: none; }
.dots i { width: 12px; height: 12px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .18); }
.d-red { background: #FF5F57; } .d-yellow { background: #FEBC2E; } .d-green { background: #28C840; }
.titlebar h1 { flex: 1; min-width: 0; font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-btn {
  flex: none; width: 48px; height: 48px; border-radius: 14px; border: 0;
  background: var(--fill); color: var(--text); font: inherit; font-size: 24px; line-height: 1; letter-spacing: 0;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer;
}
.bar-btn[hidden] { display: none; }
#back { font-size: 34px; padding-bottom: 5px; }

#view { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 18px; -webkit-overflow-scrolling: touch; }

.stack { display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.stack.tight { gap: 10px; min-height: 0; }
.center-fill { justify-content: center; }
.trainer .controls { margin-top: auto; }

.section-title { font-size: 17px; font-weight: 500; color: var(--muted); }
.section-title.big { font-size: 24px; color: var(--text); line-height: 1.45; }
.body-text { font-size: 18px; }
.meaning { font-size: 17px; color: var(--muted); }
.clear-form { font-size: 18px; }
.phrase { font-size: clamp(25px, 7.2vw, 32px); font-weight: 500; line-height: 1.5; }
.phrase.npc { font-size: clamp(22px, 6.2vw, 27px); }
.sound { font-size: 20px; font-weight: 500; word-spacing: .12em; }
.hint { font-size: 16px; color: var(--muted); }
.tip-en { font-size: 24px; font-weight: 500; line-height: 1.5; }
.speaking { color: var(--accent); }
:root[data-theme="dark"] .speaking { color: #64B5FF; }
.giant { font-size: 84px; line-height: 1.2; }
.giant.small { font-size: 60px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  min-height: 150px; padding: 16px; border-radius: 20px;
  background: var(--fill); border: 1px solid var(--hair);
  color: var(--text); text-decoration: none; font-size: 17px; font-weight: 500; line-height: 1.45;
}
.list .tile { flex-direction: row; align-items: center; justify-content: flex-start; min-height: 84px; gap: 14px; }
.tile.hero { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.tile.chest { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-start; min-height: 84px; gap: 14px; }
.tile.accent { background: var(--fill-strong); }
.tile-ico { font-size: 40px; line-height: 1.1; letter-spacing: 0; }
.tile-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.badge { min-width: 44px; padding: 2px 12px; border-radius: 999px; background: var(--fill-strong); font-size: 18px; }

.btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 66px; padding: 10px 16px;
  border: 1px solid var(--hair); border-radius: 18px; background: var(--fill); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active, .tile:active, .option:active, .pic:active { transform: scale(.98); }
.ico { font-size: 28px; line-height: 1; letter-spacing: 0; }
.btn.primary, .btn.mic { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.mic { min-height: 84px; font-size: 21px; }
.btn.mic .ico { font-size: 34px; }
.btn.huge { min-height: 104px; font-size: 26px; }
.giant-mic { min-height: 180px; font-size: 22px; }
.giant-mic .ico { font-size: 60px; }
.btn.listening { background: #C93A3A; animation: breathe 1.3s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 10px rgba(201, 58, 58, .28); } }
.btn.tall { flex-direction: column; justify-content: center; gap: 2px; padding: 8px 4px; font-size: 16px; min-height: 76px; }
.btn.nav { justify-content: center; width: 76px; flex: none; }
.btn.continue { justify-content: flex-start; }
.btn.pulse { background: var(--accent); color: var(--on-accent); animation: nudge 1.3s ease-in-out infinite; }
@keyframes nudge { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .btn.pulse, .btn.listening { animation: none; } }

.controls { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.row.nav-row { grid-template-columns: 76px 1fr 76px; }
.row.nav-row.wide { grid-template-columns: 76px 76px; justify-content: space-between; }
.panel .btn.mic { min-height: 66px; font-size: 16px; padding: 8px 10px; }
.panel .btn.mic .ico { font-size: 26px; }
.panel .row .btn { font-size: 16px; padding: 8px 10px; }

.progress { display: flex; align-items: center; gap: 12px; }
.progress-text { font-size: 15px; color: var(--muted); flex: none; }
.bar, .time { flex: 1; height: 8px; border-radius: 99px; background: var(--fill-strong); overflow: hidden; display: block; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.time-fill { display: block; height: 100%; width: 100%; background: #28C840; border-radius: 99px; }

.word {
  display: inline; padding: 0 2px; margin-right: .22em; border: 0; border-radius: 6px; background: none; color: inherit;
  font: inherit; letter-spacing: inherit; cursor: pointer; text-align: left; touch-action: manipulation;
}
.word.marked { background: var(--yellow-mark); color: #1C1C1E; }

.panel { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 18px; }
.panel.green { background: var(--green-bg); }
.panel.yellow { background: var(--yellow-bg); }
.panel.neutral { background: var(--neutral-bg); }
.panel-head { font-weight: 500; font-size: 19px; }
.hard-word { font-size: 28px; font-weight: 600; line-height: 1.35; }
.panel-slot:empty { display: none; }

.syll-list { display: flex; flex-direction: column; gap: 8px; }
.syll {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 62px; padding: 8px 14px;
  border: 1px solid var(--hair); border-radius: 14px; background: var(--fill); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.syll-word { font-size: 20px; font-weight: 500; }
.syll-sound { font-size: 16px; color: var(--muted); }

.speaker { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 500; color: var(--muted); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--fill-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 25px; letter-spacing: 0; }
.trainer { gap: 11px; }

.option {
  display: flex; flex-direction: column; width: 100%; min-height: 72px; padding: 12px 16px;
  border: 2px solid var(--hair); border-radius: 18px; background: var(--fill); color: var(--text); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation;
}
.option.chosen { border-color: var(--accent); }
.option-en { font-size: 20px; font-weight: 500; line-height: 1.45; }
.option-de { font-size: 15px; color: var(--muted); }

.pics { display: flex; flex-direction: column; gap: 12px; }
.pic {
  height: clamp(104px, 18vh, 150px); border: 2px solid var(--hair); border-radius: 22px; background: var(--fill);
  font-size: clamp(60px, 11vh, 84px); line-height: 1; letter-spacing: 0; cursor: pointer; touch-action: manipulation; color: var(--text);
}
.pic.right { background: var(--green-bg); border-color: #28C840; }
.pic.dim { opacity: .4; }

.clock { font-size: 56px; font-weight: 600; letter-spacing: .08em; line-height: 1.2; }
