@font-face { font-family: 'MC'; src: url('../media/minecraft.ttf') format('truetype'); font-display: swap; }
:root {
  --stone: #7d7d7d; --stone-hi: #a9a9a9; --stone-lo: #3f3f3f;
  --green: #5aa73a; --red: #c8463a; --gold: #f2c94c;
  --panel: #c6c6c6; --ink: #262626;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b4a6a; }
body {
  font-family: 'MC', 'Courier New', monospace; color: #fff;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
  image-rendering: pixelated;
}
#app { position: fixed; inset: 0; background: #6ab4e8 url('../media/bg.jpg') center bottom / cover no-repeat; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding: calc(8px + var(--safe-t)) 12px calc(8px + var(--safe-b)); }
.screen.show { display: flex; }
button { font-family: inherit; cursor: pointer; }
small { font-size: .7em; opacity: .85; }

/* панели и кнопки в стиле игры */
.panel {
  background: var(--panel); color: var(--ink);
  border: 3px solid #fff; border-right-color: #555; border-bottom-color: #555;
  box-shadow: 0 0 0 3px #1e1e1e;
}
.mc-btn {
  /* кнопка как в меню Minecraft: ровный серый камень, чёрная обводка, светлый край сверху-слева, тёмный снизу-справа */
  position: relative; color: #fff; font-size: clamp(14px, 2.4vmin + 6px, 22px); line-height: 1.15;
  padding: .55em .8em; min-height: 48px;
  background: #727272 url('../media/btn-noise.png') repeat; background-size: 64px 64px;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #aaa, inset -2px -3px 0 #555;
  text-shadow: 2px 2px 0 #383838;
}
.mc-btn:active:not(:disabled) { box-shadow: inset 2px 3px 0 #555, inset -2px -2px 0 #aaa; }
.mc-btn:disabled { opacity: .45; cursor: default; }
.mc-btn.green { background-color: #3c8527; box-shadow: inset 2px 2px 0 #6cc349, inset -2px -3px 0 #1d4d11; }
.mc-btn.small { font-size: clamp(12px, 1.8vmin + 6px, 18px); min-height: 40px; padding: .4em .7em; }
.mc-btn.wide { width: 100%; }
.mc-btn small { display: block; font-size: .65em; }
.icon-btn {
  width: 44px; height: 44px; flex: none; color: #fff; font-size: 22px; display: grid; place-items: center; padding: 0;
  background: #727272 url('../media/btn-noise.png') repeat; background-size: 64px 64px;
  border: 2px solid #000; box-shadow: inset 2px 2px 0 #aaa, inset -2px -3px 0 #555;
}
.ic-sound { width: 26px; height: 26px; display: block; background: url('../media/mute.png') center / contain no-repeat; filter: invert(1); }
body:not(.muted) .ic-sound { -webkit-mask: none; background-image: none; }
body:not(.muted) .ic-sound::before { content: '\266A'; font-style: normal; font-size: 24px; line-height: 26px; color: #fff; display: block; text-align: center; }

/* загрузка */
.loader { margin: auto; text-align: center; color: #fff; text-shadow: 2px 2px 0 #000; }
.cube { width: 48px; height: 48px; margin: 0 auto 10px; background: #5d8a2e; border-top: 14px solid #7cb342; box-shadow: 0 0 0 3px #1e1e1e; animation: spin 1s steps(8) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* меню */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.logo { margin: 0; font-size: clamp(26px, 5vmin + 8px, 52px); color: #fff; text-shadow: 3px 3px 0 #3b3b3b; letter-spacing: 1px; line-height: 1; }
.logo span { display: block; color: var(--gold); font-size: .62em; }
.menu-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px 2px 4px; max-width: 980px; width: 100%; margin: 0 auto; }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.pack { display: flex; flex-direction: column; align-items: stretch; text-align: left; padding: 10px; gap: 6px; min-height: 120px; }
.pack .p-title { font-size: clamp(15px, 2vmin + 8px, 21px); color: #fff; }
.pack .p-sub { font-size: .7em; color: #e8e8e8; }
.pack .p-best { margin-top: auto; font-size: .75em; color: var(--gold); }
.pack .p-icons { display: flex; gap: 4px; }
.pack .p-icons img { width: 32px; height: 32px; image-rendering: pixelated; }
.pack.cont .p-best::after { content: ' · продолжить'; color: #b7ffa0; }
.craft-entry { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 64px; font-size: clamp(18px, 2.6vmin + 8px, 26px); }
.craft-ic { width: 40px; height: 40px; background: url('../media/craft-grid.png') center / contain no-repeat; }
.menu-row { display: flex; gap: 12px; }
.menu-row .mc-btn { flex: 1; }

/* тест */
.quizbar { display: flex; align-items: center; gap: 8px; }
.counters { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: clamp(13px, 1.8vmin + 6px, 20px); text-shadow: 2px 2px 0 #222; }
.counters .ok { color: #8dff6a; } .counters .bad { color: #ff7a6a; }
.fifty { background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; color: #fff; text-shadow: 1px 1px 0 #000; }
.fifty img { width: clamp(64px, 9vmin + 30px, 110px); }
.fifty:disabled { opacity: .35; }
.quiz-body { flex: 1; min-height: 0; display: grid; gap: 12px; padding-top: 10px; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
.qcard { display: flex; flex-direction: column; min-height: 0; padding: 8px; }
.qtext { margin: 0 0 8px; text-align: center; font-size: clamp(15px, 2.2vmin + 7px, 24px); line-height: 1.25; }
.qimg { flex: 1; min-height: 0; display: grid; place-items: center; background: #4b4b4b; border: 3px solid #555; border-right-color: #fff; border-bottom-color: #fff; overflow: hidden; }
.qimg img { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: auto; }
.qimg img.icon { width: 70%; height: 70%; max-width: 256px; max-height: 256px; object-fit: contain; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ans { width: 100%; }
.ans.right { background-color: #3c8527; box-shadow: inset 2px 2px 0 #6cc349, inset -2px -3px 0 #1d4d11; }
.ans.wrong { background-color: #9a2b20; box-shadow: inset 2px 2px 0 #e07568, inset -2px -3px 0 #4a120d; }
.ans.gone { visibility: hidden; }
.ans:disabled { opacity: 1; filter: brightness(.7) saturate(.6); }
.ans.right:disabled, .ans.wrong:disabled { filter: none; }
.progress { height: 8px; margin-top: 8px; background: #333; box-shadow: 0 0 0 2px #111; }
.progress div { height: 100%; width: 0; background: var(--green); transition: width .3s; }
@media (min-aspect-ratio: 11/10) {
  .quiz-body { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); grid-template-rows: minmax(0, 1fr); }
  .answers { grid-template-columns: 1fr; align-content: center; gap: 14px; }
  .ans { min-height: max(52px, 13vh); }
}

/* результат */
#scr-result { align-items: center; justify-content: center; overflow-y: auto; }
.result { max-width: 560px; width: 100%; padding: 16px; text-align: center; margin: auto; }
.result h2 { margin: 0 0 4px; font-size: clamp(22px, 3vmin + 10px, 34px); }
.r-pack { margin: 0; opacity: .8; }
.r-score { font-size: clamp(20px, 3vmin + 8px, 30px); margin: 8px 0; } .r-score b { color: #2d7a12; font-size: 1.6em; }
.r-rank-label { margin: 0; opacity: .7; }
.r-rank { margin: 2px 0 6px; font-size: clamp(20px, 3vmin + 8px, 30px); color: #8a5a00; }
.r-desc { margin: 0 0 12px; line-height: 1.3; }
.r-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.r-btns .green { grid-column: 1 / -1; }

/* собери предмет */
.craft-body { flex: 1; min-height: 0; display: grid; gap: 10px; padding-top: 8px; grid-template-columns: 1fr; align-content: start; justify-items: center; overflow-y: auto; }
.craft-task { width: 100%; max-width: 560px; padding: 8px 10px; text-align: center; }
.craft-task p { margin: 0; }
.target { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0; font-size: clamp(16px, 2.2vmin + 8px, 24px); }
.target canvas { width: 56px; height: 56px; }
.c-msg { font-size: .85em; min-height: 2.4em; }
.c-msg.good { color: #2d7a12; } .c-msg.bad { color: #a12a1e; }
.craft-table { display: flex; align-items: center; gap: 10px; }
.grid { --cell: clamp(48px, 9vmin + 16px, 86px); display: grid; grid-template-columns: repeat(3, var(--cell)); gap: 4px; padding: 6px; background: #c6c6c6; box-shadow: 0 0 0 3px #1e1e1e; }
.cell { width: var(--cell); height: var(--cell); background: #8b8b8b; border: 3px solid #373737; border-right-color: #fff; border-bottom-color: #fff; display: grid; place-items: center; padding: 0; }
.cell canvas, .slot canvas { width: 80%; height: 80%; image-rendering: pixelated; pointer-events: none; }
.cell.hint { outline: 3px solid var(--gold); }
.arrow { font-size: 36px; color: #fff; text-shadow: 2px 2px 0 #333; }
.out { width: clamp(60px, 10vmin + 20px, 100px); height: clamp(60px, 10vmin + 20px, 100px); background: #8b8b8b; border: 3px solid #373737; border-right-color: #fff; border-bottom-color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 3px #1e1e1e; }
.out canvas { width: 80%; height: 80%; image-rendering: pixelated; }
.out.done { background: #9fd38a; }
.inventory { width: 100%; max-width: 720px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 8px; }
.slot { --s: clamp(70px, 7vmin + 34px, 90px); width: var(--s); height: calc(var(--s) + 22px); background: #8b8b8b; border: 3px solid #373737; border-right-color: #fff; border-bottom-color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3px 2px; color: #1e1e1e; font-size: clamp(10px, 1vmin + 5px, 13px); line-height: 1.05; }
.slot canvas { width: 70%; height: auto; aspect-ratio: 1; }
.slot span { display: block; margin-top: 2px; max-width: 100%; text-align: center; overflow-wrap: normal; word-break: keep-all; }
.slot.sel { background: #b8e3a6; outline: 3px solid var(--gold); }
.craft-actions { display: flex; gap: 10px; }
@media (min-aspect-ratio: 13/10) {
  .craft-body { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: 'task task' 'table inv' 'act inv'; justify-items: stretch; align-items: start; }
  .craft-task { grid-area: task; justify-self: center; }
  .craft-table { grid-area: table; }
  .inventory { grid-area: inv; align-self: start; align-content: flex-start; }
  .craft-actions { grid-area: act; justify-content: center; }
}

/* модалка, тост, перекрытие на время рекламы */
.modal { position: absolute; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal.show { display: flex; }
.modal-box { max-width: 620px; width: 100%; max-height: 100%; display: flex; flex-direction: column; padding: 14px; gap: 10px; }
#modal-body { overflow-y: auto; line-height: 1.35; font-size: clamp(13px, 1.6vmin + 7px, 18px); }
#modal-body h3 { margin: 0 0 8px; }
.rev { padding: 8px 0; border-bottom: 2px dashed #9a9a9a; }
.rev .y { color: #a12a1e; } .rev .c { color: #2d7a12; }
.toast { position: absolute; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: rgba(20,20,20,.9); padding: 10px 16px; border: 2px solid #777; display: none; z-index: 30; max-width: 90%; text-align: center; }
.toast.show { display: block; }
.adcover { position: absolute; inset: 0; background: rgba(30,50,80,.85); display: none; z-index: 40; }
.adcover.show { display: flex; }

/* подсветка при наведении — только там, где есть мышь (на телефоне она «залипает» после касания) */
@media (hover: hover) {
  .mc-btn:hover:not(:disabled) { background-color: #7e89c2; box-shadow: inset 2px 2px 0 #c3cbf2, inset -2px -3px 0 #5a639a; border-color: #fff; color: #ffffa0; }
  .mc-btn.green:hover:not(:disabled) { background-color: #4a9e31; border-color: #fff; }
  .icon-btn:hover { background-color: #7e89c2; border-color: #fff; }
}
