@font-face { font-family: 'Nunito'; src: url('../fonts/Nunito.ttf') format('truetype'); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: 'Glagolitic'; src: url('../fonts/NotoSansGlagolitic.ttf') format('truetype'); font-display: swap; }

:root {
  --red: #C8341F;
  --red-dark: #A92A18;
  --yellow: #F2B530;
  --paper: #FBF6EC;
  --paper-2: #F3EADA;
  --ink: #2A1714;
  --muted: #7A6A60;
  --line: #E6DAC7;
  --green: #2E7D4F;
  --sky: #1F3A6B;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(42, 23, 20, .08), 0 10px 30px -12px rgba(42, 23, 20, .25);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-size: clamp(16px, 1.15vw + 8px, 22px);
  line-height: 1.45;
  overflow: hidden;
  user-select: none;
}
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }
img { max-width: 100%; display: block; }

#app { height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; overflow: auto; padding: clamp(16px, 3vw, 48px); padding-top: 12px; animation: enter .35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .pop, .shake { animation: none !important; } }

/* ---------- верхня панель ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px clamp(16px, 3vw, 48px); border-bottom: 2px solid var(--line); background: var(--paper); flex: none; }
.topbar .logo { height: clamp(28px, 3vw, 40px); cursor: pointer; }
.topbar .crumb { font-weight: 800; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .crumb b { color: var(--ink); }
.topbar .spacer { flex: 1; }
.icon-btn { width: 48px; height: 48px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: var(--paper-2); font-size: 22px; flex: none; }
.icon-btn:hover { background: var(--line); }
.svg-ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.menu-item .ico { color: var(--red); }
.menu-item.main .ico { color: var(--yellow); }
.stop .medal .chest { width: 72%; }
.stop.final.locked .medal .ph { color: var(--muted); }
.stop.closed .medal { opacity: .45; filter: grayscale(.6); }
.stop .badge.lock { background: var(--paper-2); color: var(--muted); font-size: 1em; }
.contact { margin-top: 4px; }
a.mail { color: var(--red); font-weight: 800; text-decoration: none; border-bottom: 2px solid rgba(200, 52, 31, .25); user-select: text; }
a.mail:hover { border-bottom-color: var(--red); }
.license-mark { font-size: .7em; color: #b9aa9c; margin-top: 8px; letter-spacing: .04em; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; font-size: 1.05em; padding: 16px 30px; border-radius: 16px; background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-dark); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-dark); }
.btn.ghost { background: var(--paper-2); color: var(--ink); box-shadow: 0 5px 0 var(--line); }
.btn.ghost:active { box-shadow: 0 1px 0 var(--line); }
.btn.big { font-size: 1.3em; padding: 20px 44px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

h1 { font-weight: 900; font-size: clamp(30px, 3.4vw, 60px); line-height: 1.08; text-wrap: balance; }
h2 { font-weight: 900; font-size: clamp(24px, 2.4vw, 42px); line-height: 1.12; text-wrap: balance; }
h3 { font-weight: 900; font-size: 1.15em; }
.kicker { font-weight: 800; font-size: .78em; letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.lead { font-size: 1.12em; color: #4b3a33; max-width: 60ch; }
.muted { color: var(--muted); }

/* ---------- заставка ---------- */
.splash { position: fixed; inset: 0; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; z-index: 50; transition: opacity .5s; }
.splash canvas { width: min(46vmin, 360px); height: min(46vmin, 360px); }
.splash .word { font-weight: 900; font-size: clamp(40px, 6vmin, 76px); color: var(--red); letter-spacing: -.01em; opacity: 0; transform: translateY(18px); transition: opacity .5s, transform .5s cubic-bezier(.3, 1.6, .5, 1); }
.splash .word.show { opacity: 1; transform: none; }
.splash .tap { font-weight: 800; color: var(--muted); opacity: 0; transition: opacity .4s; }
.splash .tap.show { opacity: 1; }
.splash.hide { opacity: 0; pointer-events: none; }

/* ---------- вхід ---------- */
.gate { max-width: 560px; margin: 6vh auto 0; text-align: center; display: flex; flex-direction: column; gap: 22px; align-items: center; }
.gate input { width: 100%; font: inherit; font-weight: 900; font-size: 1.5em; text-align: center; letter-spacing: .08em; text-transform: uppercase; padding: 16px; border-radius: 16px; border: 3px solid var(--line); background: #fff; color: var(--ink); }
.gate input:focus { border-color: var(--red); outline: none; }
.gate .err { color: var(--red); font-weight: 800; min-height: 1.4em; }

/* ---------- бібліотека ---------- */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 24px; margin-top: 26px; }
.pack-card { text-align: left; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s; }
.pack-card:hover { transform: translateY(-4px); }
.pack-card .cover { background: var(--sky); height: 190px; display: flex; align-items: flex-end; justify-content: center; position: relative; overflow: hidden; }
.pack-card .cover img { height: 170px; width: auto; }
.pack-card .cover .date { position: absolute; top: 14px; left: 14px; background: var(--yellow); color: var(--ink); font-weight: 900; padding: 4px 12px; border-radius: 99px; font-size: .8em; }
.pack-card .body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 6px; }
.pack-card.soon { opacity: .6; pointer-events: none; }
.pack-card.soon .cover { background: var(--paper-2); color: var(--muted); align-items: center; font-weight: 900; }

/* ---------- сторінка набору ---------- */
.pack-head { display: flex; flex-direction: column; gap: 8px; }
.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 20px; margin-top: 28px; }
.menu-item { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 24px; text-align: left; display: flex; flex-direction: column; gap: 10px; min-height: 190px; transition: transform .15s; }
.menu-item:hover { transform: translateY(-4px); }
.menu-item .ico { font-size: 2.4em; line-height: 1; }
.menu-item.main { background: var(--red); color: #fff; grid-column: span 2; }
.menu-item.main .muted { color: #ffe3d8; }
@media (max-width: 640px) { .menu-item.main { grid-column: auto; } }

/* ---------- мапа часу ---------- */
.map-wrap { display: flex; flex-direction: column; gap: 22px; height: 100%; }
.timeline { flex: 1; min-height: 300px; position: relative; display: grid; grid-template-columns: repeat(6, 1fr); align-items: center; gap: 10px; }
.timeline::before { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 10px; transform: translateY(-50%); background: repeating-linear-gradient(90deg, var(--red) 0 18px, transparent 18px 30px); opacity: .35; border-radius: 6px; }
.stop { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.stop:nth-child(even) { transform: translateY(-14%); }
.stop:nth-child(odd) { transform: translateY(14%); }
.stop .medal { width: clamp(84px, 9vw, 150px); aspect-ratio: 1; border-radius: 50%; background: #fff; box-shadow: var(--shadow); border: 5px solid var(--paper-2); display: flex; align-items: center; justify-content: center; overflow: hidden; transition: transform .15s; }
.stop:hover .medal { transform: scale(1.06); }
.stop .medal img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.stop .medal .ph { font-size: 2.6em; }
.stop .year { font-weight: 900; color: var(--red); font-size: 1.1em; }
.stop .who { font-weight: 800; font-size: .9em; line-height: 1.2; max-width: 11em; }
.stop.done .medal { border-color: var(--green); }
.stop .badge { position: absolute; top: -6px; right: calc(50% - clamp(48px, 5vw, 82px)); width: 44px; height: 44px; border-radius: 12px; background: var(--yellow); font-weight: 900; font-size: 1.3em; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.stop.final .medal { background: #fff3d6; border-color: var(--yellow); }
.stop.final.locked .medal { background: var(--paper-2); border-color: var(--line); }
.stop.final .medal .ph { filter: none; }
@media (max-width: 760px) {
  .map-wrap { height: auto; }
  .timeline { flex: none; grid-template-columns: repeat(2, 1fr); row-gap: 28px; }
  .timeline::before { display: none; }
  .stop:nth-child(n) { transform: none; }
}

.letters { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.letters .lbl { font-weight: 800; color: var(--muted); margin-right: 6px; }
.slot { width: clamp(52px, 5vw, 80px); aspect-ratio: 1; border-radius: 14px; border: 3px dashed var(--line); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: clamp(28px, 3vw, 48px); color: var(--red); background: #fff; }
.slot.on { border: 3px solid var(--yellow); background: #fff8e6; }

/* ---------- зупинка ---------- */
.stop-screen { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 48px); align-items: start; }
@media (max-width: 900px) { .stop-screen { grid-template-columns: 1fr; } }
.video-box { background: var(--ink); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.video-box video { width: 100%; height: 100%; }
.video-box.soon { background: repeating-linear-gradient(45deg, var(--paper-2) 0 22px, #efe4d2 22px 44px); color: var(--muted); flex-direction: column; gap: 10px; text-align: center; padding: 20px; font-weight: 800; }
.video-box.soon .big { font-size: 2.6em; }
.speech { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; position: relative; }
.stop-side { display: flex; flex-direction: column; gap: 18px; }

/* ---------- завдання ---------- */
.task { display: flex; flex-direction: column; gap: 22px; align-items: center; text-align: center; max-width: 1300px; margin: 0 auto; }
.task .prompt { font-size: 1.15em; font-weight: 700; max-width: 52ch; }
.chips { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.chip { background: #fff; border-radius: 16px; padding: 16px 26px; font-weight: 900; font-size: 1.2em; box-shadow: 0 5px 0 var(--line); border: 3px solid transparent; transition: transform .1s; }
.chip:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.chip.picked { background: var(--paper-2); color: var(--muted); box-shadow: none; pointer-events: none; }
.chip.sel { border-color: var(--yellow); background: #fff8e6; }
.chip.good { border-color: var(--green); background: #e8f4ec; color: var(--green); pointer-events: none; }
.chip.wide { font-size: 1em; max-width: 22em; }
.answer-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 80px; align-items: center; }
.answer-row .ans { background: var(--red); color: #fff; border-radius: 16px; padding: 14px 24px; font-weight: 900; font-size: 1.2em; }
.answer-row .ans.num { background: var(--sky); }
.answer-row .ph { color: var(--muted); font-weight: 700; }
.glag-word { display: flex; gap: 14px; justify-content: center; }
.glag-word .g { font-family: 'Glagolitic', 'Segoe UI Historic', serif; font-size: clamp(56px, 7vw, 110px); line-height: 1; width: 1.3em; height: 1.4em; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 16px; box-shadow: var(--shadow); color: var(--sky); }
.glag-word .g.cur { outline: 5px solid var(--yellow); }
.keys { display: grid; grid-template-columns: repeat(5, auto); gap: 10px; justify-content: center; }
.key { background: #fff; border-radius: 14px; box-shadow: 0 4px 0 var(--line); padding: 8px 14px; display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.2em; }
.key .gl { font-family: 'Glagolitic', 'Segoe UI Historic', serif; font-size: 1.6em; color: var(--sky); line-height: 1; }
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
@media (max-width: 640px) { .keys { grid-template-columns: repeat(2, auto); } }
.quiz-q { font-weight: 900; font-size: 1.4em; max-width: 30ch; }
.progress-dots { display: flex; gap: 8px; }
.progress-dots i { width: 14px; height: 14px; border-radius: 4px; background: var(--line); }
.progress-dots i.on { background: var(--red); }

.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pop { animation: pop .45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- нагорода ---------- */
.reward { position: fixed; inset: 0; background: rgba(42, 23, 20, .55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px; }
.reward .card { background: var(--paper); border-radius: 26px; padding: 36px 44px; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; max-width: 560px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.reward .big-letter { width: 150px; height: 150px; border-radius: 26px; background: var(--yellow); display: flex; align-items: center; justify-content: center; font-size: 96px; font-weight: 900; color: var(--red); }
.fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 45; }

/* ---------- фінал ---------- */
.final { display: flex; flex-direction: column; align-items: center; gap: 26px; text-align: center; }
.chest { width: clamp(180px, 22vw, 300px); }
.diploma { background: #fff; border: 10px double var(--red); border-radius: 20px; padding: 36px clamp(20px, 4vw, 60px); max-width: 900px; width: 100%; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.diploma input { font: inherit; font-weight: 900; font-size: 1.6em; text-align: center; border: none; border-bottom: 3px solid var(--line); background: transparent; width: min(100%, 560px); color: var(--ink); padding: 6px; }
.diploma .dtitle { font-weight: 900; font-size: clamp(38px, 5vw, 72px); color: var(--red); letter-spacing: .06em; }

/* ---------- списки ---------- */
.list { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; max-width: 980px; }
.row { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 18px 22px; display: flex; align-items: center; gap: 18px; text-align: left; }
.row .grow { flex: 1; min-width: 0; }
.row.off { opacity: .55; }
.player { margin-top: 22px; max-width: 1100px; }
.player video { width: 100%; border-radius: var(--radius); background: #000; }
.teacher { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; margin-top: 22px; }
@media (max-width: 900px) { .teacher { grid-template-columns: 1fr; } }
.card-soft { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; display: flex; flex-direction: column; gap: 12px; }
table.plan { border-collapse: collapse; width: 100%; }
table.plan td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plan td:first-child { font-weight: 900; color: var(--red); white-space: nowrap; width: 1%; }
ul.clean { list-style: none; display: flex; flex-direction: column; gap: 10px; }
ul.clean li { padding-left: 22px; position: relative; }
ul.clean li::before { content: ''; position: absolute; left: 0; top: .5em; width: 10px; height: 10px; background: var(--red); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px; font-weight: 800; z-index: 60; }

@media print {
  body { overflow: visible; }
  .topbar, .no-print { display: none !important; }
  .screen { padding: 0; animation: none; }
  .diploma { border-width: 12px; }
}
