/* «Острова снов» (assets/js/mapgame.js). Темы: тёмная (ночное небо, серебристый туман), светлая (пергамент, молочный туман),
   ночная (тёплая, без синего). Фон карты — картинки художника «0бф» (через --mg-board, не <img>: ночной фильтр сайта их не трогает). */
.mg-page { --mg-fog1: rgba(196, 192, 222, .5); --mg-fog2: rgba(120, 116, 160, .62); --mg-cell: rgba(29, 35, 80, .55); --mg-cellopen: rgba(48, 56, 112, .5);
  --mg-haze: rgba(150, 146, 190, .2); --mg-edge: rgba(232, 200, 114, .22); --mg-ok: #e8c872; --mg-side: rgba(232, 200, 114, .8); --mg-card: #141432; }
:root[data-theme="light"] .mg-page { --mg-fog1: rgba(255, 255, 255, .86); --mg-fog2: rgba(226, 220, 238, .9); --mg-cell: rgba(255, 253, 248, .6); --mg-cellopen: rgba(255, 253, 248, .92);
  --mg-haze: rgba(236, 228, 247, .7); --mg-edge: rgba(75, 46, 131, .2); --mg-ok: #b07a00; --mg-side: #4b2e83; --mg-card: #fff; }
:root[data-theme="night"] .mg-page { --mg-fog1: rgba(120, 72, 52, .55); --mg-fog2: rgba(70, 36, 24, .7); --mg-cell: rgba(42, 17, 10, .6); --mg-cellopen: rgba(70, 30, 16, .55);
  --mg-haze: rgba(120, 70, 46, .25); --mg-edge: rgba(227, 164, 98, .24); --mg-ok: #e3a462; --mg-side: rgba(227, 164, 98, .85); --mg-card: #1c0b07; }

.mg { margin-top: 8px; }
.mg-warn { background: rgba(240, 144, 138, .16); border: 1px solid rgba(240, 144, 138, .5); border-radius: 12px; padding: 10px 14px; }
.mg .chip.is-on, .mg-sheet .chip.is-on { background: var(--gold); color: var(--btn-text); border-color: var(--gold); }
:root[data-theme="light"] .mg .chip.is-on, :root[data-theme="light"] .mg-sheet .chip.is-on { background: var(--violet); color: #fff; border-color: var(--violet); }
.chip--sm { font-size: .82rem; padding: 4px 10px; min-height: 32px; }
.btns--col { flex-direction: column; align-items: stretch; }
.btns--col .btn { width: 100%; }
.btns--wrap { flex-wrap: wrap; }
.btn--sm { font-size: .88rem; padding: 6px 14px; }
.mg-x { background: none; border: 0; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 4px 8px; min-width: 32px; min-height: 32px; cursor: pointer; }

/* подготовка */
.mg-form fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 14px; }
.mg-form legend { font-family: var(--ui); font-weight: 700; padding: 0 6px; color: var(--gold); }
:root[data-theme="light"] .mg-form legend { color: var(--violet); }
.mg-seg { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.mg-prows { display: grid; gap: 12px; }
.mg-prow { background: var(--surface); border-radius: 14px; padding: 10px; }
.mg-prow__top { display: flex; gap: 8px; align-items: center; }
.mg-prow__top input[type=text], .mg-form input[type=text], .mg-add input, .mg-sheet input[type=text] { flex: 1; min-width: 0; font: inherit; font-family: var(--ui); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
:root[data-theme="light"] .mg-prow__top input, :root[data-theme="light"] .mg-form input[type=text], :root[data-theme="light"] .mg-sheet input[type=text] { background: #fbf8f2; }
.mg-me { font-family: var(--ui); font-size: .85rem; white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.mg-toks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mg-tokbtn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; padding: 0; }
.mg-tokbtn.is-on { border-color: var(--gold); }
.mg-tok { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; vertical-align: middle; font-size: 20px; line-height: 1; }
.mg-recall { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-family: var(--ui); font-size: .85rem; }
.mg-recall .mg-seg { margin: 0; }
.mg-more summary { cursor: pointer; font-family: var(--ui); margin-top: 8px; }
.mg-more label, .mg-heavy { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; margin: 8px 0; }
.mg-resume { background: var(--surface); border-radius: 16px; padding: 14px; margin-bottom: 14px; }

/* игра: верх */
.mg-top { position: sticky; top: 58px; z-index: 5; background: var(--page-bg); background-attachment: fixed; padding: 6px 0; }
.mg-seats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.mg-seat { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface); border: 2px solid transparent; font-family: var(--ui); font-size: .86rem; }
.mg-seat.is-cur { border-color: var(--c); }
.mg-seat b { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-meta { font-family: var(--ui); font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.mg-strip { margin: 8px 0; }
.mg-lms__row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.mg-lm { flex: 0 0 auto; width: 76px; display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-family: var(--ui); font-size: .74rem; line-height: 1.15; cursor: pointer; position: relative; }
.mg-lm span { text-align: center; }
.mg-lm i { font-style: normal; font-weight: 700; color: var(--gold); font-size: .8rem; }
:root[data-theme="light"] .mg-lm i { color: var(--violet); }
.mg-lm--rare { border-color: rgba(232, 200, 114, .55); }
.mg-lm.is-taken { opacity: .8; border-color: var(--c); }
.mg-lm.is-fogged { opacity: .55; }
.mg-lm__img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.mg-lm__e { font-size: 26px; line-height: 40px; height: 40px; }
.mg-goals { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.mg-goals .chip { flex: 0 0 auto; }
.mg-goals .kicker { margin: 0 4px 0 0; }

/* игра: карта и панель */
.mg-main { display: grid; gap: 14px; }
@media (min-width: 900px) { .mg-main { grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); align-items: start; } .mg-act { position: sticky; top: 140px; } }
.mg-boardwrap { scroll-margin-top: 120px; }
.mg-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 6px; }
.mg-tab { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--text); font-family: var(--ui); font-size: .84rem; cursor: pointer; min-height: 40px; }
.mg-tab.is-on { border-color: var(--c); background: var(--surface); }
.mg-board { position: relative; aspect-ratio: 1; max-width: 640px; margin: 0 auto; border-radius: 22px; overflow: hidden;
  background: var(--mg-board, radial-gradient(circle at 50% 50%, var(--bg2), var(--bg0))) center / cover no-repeat; }
:root[data-theme="light"] .mg-board { background: var(--mg-board-light, radial-gradient(circle, #fffdf8, #ece4f7)) center / cover no-repeat; }
:root[data-theme="night"] .mg-board { background: var(--mg-board-night, radial-gradient(circle, #2a110a, #120705)) center / cover no-repeat; }
.mg-svg { display: block; width: 100%; height: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.mg-cell { fill: var(--mg-cell); stroke: var(--mg-edge); stroke-width: 1; transition: fill .5s; }
.mg-cell.is-fog { fill: url(#mgFog); }
.mg-cell.is-haze { fill: var(--mg-haze); }
.mg-cell.is-open { fill: var(--mg-cellopen); }
.mg-cell.is-east.is-fog { fill: rgba(220, 210, 255, .55); }
.mg-cell.is-ok { fill: rgba(232, 200, 114, .28); stroke: var(--mg-ok); stroke-width: 2.4; cursor: pointer; animation: mgPulse 1.6s ease-in-out infinite; }
.mg-cell.is-ok:focus-visible { outline: none; stroke-width: 4; }
@keyframes mgPulse { 50% { fill-opacity: .55; } }
.mg-fogtex { pointer-events: none; opacity: .75; }
.mg-side { fill: var(--mg-side); font: 600 11px var(--ui); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.mg-line { fill: none; stroke-width: 3; stroke-linecap: round; opacity: .85; pointer-events: none; }
.mg-line--jump { stroke-dasharray: 5 6; stroke-width: 2.2; }
.mg-pl { cursor: pointer; }
.mg-pl:focus-visible { outline: none; }
.mg-pl:focus-visible .mg-pl__b { stroke-width: 4; }
.mg-pl__b { fill: rgba(255, 255, 255, .1); stroke: var(--c); stroke-width: 2; }
:root[data-theme="light"] .mg-pl__b { fill: rgba(255, 255, 255, .8); }
.mg-pl__ring { fill: none; opacity: .55; stroke-width: 1.5; }
.mg-pl__b.is-trap { stroke-dasharray: 3 3; }
.mg-pl__glow { fill: #e8c872; opacity: .7; }
.mg-pl__e { text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.mg-pl__sign { fill: var(--gold); font-size: 11px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
:root[data-theme="light"] .mg-pl__sign { fill: var(--violet); }
.mg-pl__lm { text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.mg-pl__name { fill: var(--text); font: 500 8.5px var(--ui); text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--bg0); stroke-width: 2.5px; }
:root[data-theme="light"] .mg-pl__name { stroke: #fffdf8; }
.mg-pl.is-fresh .mg-pl__b { animation: mgPop .7s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes mgPop { 0% { transform: scale(.2); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.mg-board.is-grown .mg-line:not(.mg-line--jump) { animation: mgGrow 1.4s ease-out; }
@keyframes mgGrow { 0% { stroke-width: 9; opacity: 1; } 100% { stroke-width: 3; opacity: .85; } }
.mg-pl.is-common .mg-pl__b { stroke-width: 3.5; filter: drop-shadow(0 0 6px #e8c872); }
.mg-legend { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.mg-shelf { display: block; margin-bottom: 6px; }
.mg-shelf .chip { margin: 2px; }
.mg-act { background: var(--surface); border-radius: 18px; padding: 14px; }
.mg-act:empty { display: none; }
.mg-act__h { font-size: 1.15rem; margin: 4px 0 8px; }
.mg-who { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--ui); }
.mg-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.mg-compass { display: grid; grid-template-columns: repeat(3, 56px); gap: 6px; justify-content: center; margin: 10px 0; }
.mg-compass__b { height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 700 1rem var(--ui); cursor: pointer; }
.mg-compass__b:hover, .mg-compass__b:focus-visible { border-color: var(--gold); }
.mg-compass__c { display: grid; place-items: center; font-size: 26px; }
.mg-compass.mg-compass--guide { grid-template-columns: repeat(3, minmax(34px, 48px)); gap: 4px; }
.mg-compass__label { display: grid; place-items: center; min-height: 32px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); font: 700 .9rem var(--ui); }
.mg-flags { display: grid; gap: 8px; }
.mg-flag { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface-2); }
:root[data-theme="light"] .mg-flag { background: #faf6ee; }
.mg-flag > span { flex: 1 1 100%; font-family: var(--ui); font-weight: 600; }
.mg-q { border-top: 1px solid var(--line-2); margin-top: 12px; padding-top: 10px; }
.mg-q .kicker { margin: 0 0 4px; }
.mg-lmask .chip { margin: 4px 4px 0 0; }
.mg-lmask .mg-lm__img, .mg-lmask .mg-lm__e { width: 24px; height: 24px; font-size: 18px; line-height: 24px; }
.mg-found { font-family: var(--ui); }
.mg-fcard { display: grid; justify-items: center; text-align: center; gap: 4px; margin: 8px auto; padding: 12px; max-width: 240px; border-radius: 16px; background: var(--mg-card); border: 1px solid var(--line); }
.mg-fcard img { width: 120px; border-radius: 10px; }
.mg-fcard > span { font-size: 44px; }
.mg-fcard p { margin: 0; font-size: .9rem; }
.mg-fcard--trap { border-color: rgba(240, 144, 138, .7); }
.mg-fcard--clear { border-color: rgba(139, 224, 168, .7); }
.mg-fcard.is-flip { animation: mgFlip .5s ease-out; }
@keyframes mgFlip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }

/* шторка */
.mg-sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.mg-sheet__bg { position: absolute; inset: 0; background: rgba(5, 6, 16, .62); }
.mg-sheet__box { position: relative; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; background: var(--bg1); border-radius: 22px 22px 0 0; padding: 20px 18px 24px; box-shadow: var(--shadow); animation: mgUp .25s ease-out; overscroll-behavior: contain; }
:root[data-theme="light"] .mg-sheet__box { background: #fff; }
:root[data-theme="night"] .mg-sheet__box { background: #1c0b07; }
@keyframes mgUp { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 700px) { .mg-sheet { align-items: center; padding: 20px; } .mg-sheet__box { border-radius: 22px; padding: 26px 28px; } }
@media (prefers-reduced-motion: reduce) { .mg-sheet__box, .mg-fcard.is-flip, .mg-pl.is-fresh .mg-pl__b, .mg-board.is-grown .mg-line, .mg-cell.is-ok, .mg-ncard__face, .mg-toast { animation: none; } }
html.mg-lock { overflow: hidden; }
.mg-sheet h2 { font-size: 1.2rem; margin-top: 0; }
.mg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mg-chips .kicker { flex: 1 1 100%; margin: 4px 0 0; }
.mg-grp { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 100%; }
.mg-seq { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 48px; padding: 8px; border-radius: 14px; border: 1px dashed var(--line); margin: 8px 0; }
.mg-step { display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--surface-2); font-family: var(--ui); font-size: .9rem; }
:root[data-theme="light"] .mg-step { background: #ece4f7; }
.mg-new { font-style: normal; font-size: .7rem; color: var(--gold); }
:root[data-theme="light"] .mg-new { color: var(--violet); }
.mg-how { min-width: 40px; min-height: 40px; border-radius: 50%; border: 1px solid var(--gold); background: none; color: var(--text); font-size: 1rem; cursor: pointer; }
.mg-add { display: flex; gap: 8px; margin: 8px 0; }
.mg-diary summary { cursor: pointer; font-family: var(--ui); font-size: .9rem; margin: 6px 0; }
.mg-pass { display: grid; justify-items: center; text-align: center; gap: 6px; }
.mg-pass .mg-tok { width: 64px; height: 64px; font-size: 44px; }
.mg-ncard { perspective: 800px; display: grid; justify-items: center; }
.mg-ncard__back { display: none; }
.mg-ncard__face { text-align: center; padding: 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); animation: mgFlip .6s ease-out; }
.mg-ncard__e { font-size: 44px; }
.mg-src { font-size: .78rem; color: var(--muted); }
.mg-ev { background: var(--surface); border-radius: 12px; padding: 8px 12px; }
.mg-ev--fog { display: flex; gap: 10px; align-items: center; }
.mg-lmcard { display: flex; gap: 12px; align-items: center; }
.mg-lmcard .mg-lm__img { width: 72px; height: 72px; flex: 0 0 auto; }
.mg-lmcard .mg-lm__e { font-size: 44px; line-height: 72px; height: 72px; }
.mg-list { padding-left: 1.2em; }

/* финал */
.mg-end { margin-top: 10px; }
.mg-score { list-style: none; padding: 0; display: grid; gap: 8px; }
.mg-score li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 14px; background: var(--surface); border-left: 4px solid var(--c); }
.mg-hl { flex: 1 1 100%; font-size: .85rem; color: var(--muted); }
.mg-endboard { max-width: 560px; margin: 8px auto; border-radius: 22px; overflow: hidden; background: radial-gradient(circle, var(--bg2), var(--bg0)); }
:root[data-theme="light"] .mg-endboard { background: radial-gradient(circle, #fffdf8, #ece4f7); }
.mg-endmaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.mg-endmaps figure { margin: 0; border-radius: 18px; overflow: hidden; border: 2px solid var(--c); background: radial-gradient(circle, var(--bg2), var(--bg0)); }
:root[data-theme="light"] .mg-endmaps figure { background: radial-gradient(circle, #fffdf8, #ece4f7); }
.mg-endmaps figcaption { text-align: center; font-family: var(--ui); padding: 6px; }
.mg-intent { background: var(--surface); border-radius: 16px; padding: 12px 14px; margin: 12px 0; }
body.mg-playing .mg-page > .post__head { display: none; }
body.mg-playing .mg-page > .post__head + .mg { margin-top: 0; }
.mg-toasts.is-top { bottom: auto; top: calc(66px + env(safe-area-inset-top)); }
.mg-toasts { position: fixed; z-index: 80; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.mg-toast { max-width: 460px; padding: 10px 16px; border-radius: 14px; background: var(--bg1); border: 1px solid var(--gold); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-family: var(--ui); font-size: .92rem; animation: mgUp .25s ease-out; transition: opacity .4s; }
:root[data-theme="light"] .mg-toast { background: #fff; }
.mg-toast.is-out { opacity: 0; }
.mg-rules table { font-size: .92rem; }
@media (max-width: 380px) { .mg-lm { width: 76px; } .mg-compass { grid-template-columns: repeat(3, 50px); } .mg-compass__b { height: 50px; } }

/* 04.11 — по проверке «подруг»: телефон, касания, читаемость */
.mg-form fieldset { min-width: 0; }
.mg-prow > input[type=text] { width: 100%; box-sizing: border-box; }
.mg-prow__top { justify-content: space-between; margin-top: 6px; }
.mg-recall { flex-direction: column; align-items: flex-start; }
body.mg-playing .vk-sticky, body.mg-playing .to-top { display: none !important; }
.mg-act, .mg-sheet__box, .mg-end, .mg-form { font-family: var(--ui); }
.mg-act p, .mg-sheet__box p { line-height: 1.45; }
.mg-seats { flex-wrap: nowrap; }
.mg-seat { border: 2px solid transparent; color: var(--text); font: inherit; font-family: var(--ui); font-size: .86rem; cursor: pointer; min-height: 40px; }
.mg-seat.is-view { background: var(--surface-2); outline: 1px dashed var(--c); }
.mg-seat small { font-size: .7rem; color: var(--muted); }
.mg-seat .mg-fora { display: inline; white-space: nowrap; }
.mg-meta__b { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline dotted; cursor: pointer; }
.mg-viewing { font-family: var(--ui); font-size: .85rem; color: var(--muted); }
.mg-tabs:empty { display: none; }
.mg-cell.is-ok { fill: rgba(255, 238, 180, .5); stroke: var(--mg-ok); stroke-width: 2.6; }
:root[data-theme="light"] .mg-cell.is-ok { fill: rgba(176, 122, 0, .22); }
.mg-cell.is-fog { fill: url(#mgFog); opacity: .95; }
.mg-cell.is-haze { fill: var(--mg-haze); }
.mg-page { --mg-fog1: rgba(206, 202, 232, .62); --mg-fog2: rgba(140, 136, 182, .74); --mg-haze: rgba(150, 146, 190, .1); }
:root[data-theme="light"] .mg-page { --mg-fog1: rgba(255, 255, 255, .95); --mg-fog2: rgba(214, 206, 232, .95); --mg-haze: rgba(236, 228, 247, .35); }
:root[data-theme="night"] .mg-page { --mg-fog1: rgba(140, 86, 62, .66); --mg-fog2: rgba(84, 44, 28, .8); --mg-haze: rgba(120, 70, 46, .12); }
.mg-side { font-size: 13px; }
.mg-act input[type=text], .mg-sheet input[type=text] { width: 100%; box-sizing: border-box; font: 400 16px var(--ui); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); margin: 6px 0; }
:root[data-theme="light"] .mg-act input[type=text] { background: #fbf8f2; }
@media (max-width: 600px) { .mg-lms__row { flex-wrap: wrap; overflow: visible; } .mg-lm { width: calc(33.3% - 6px); } .mg-goals { flex-wrap: wrap; overflow: visible; } }
.mg-sheet__box { padding-bottom: 0; }
.mg-sticky { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); margin-top: 16px; background: var(--bg1); border-top: 1px solid var(--line); box-shadow: 0 -8px 16px rgba(0, 0, 0, .25); }
.mg-sticky .btn { flex: 1; }
:root[data-theme="light"] .mg-sticky { background: #fff; box-shadow: 0 -8px 16px rgba(29, 35, 80, .08); }
:root[data-theme="night"] .mg-sticky { background: #1c0b07; }
.mg-x--close { font-size: 1.6rem; min-width: 48px; min-height: 48px; border-radius: 50%; border: 1px solid var(--line); }
.mg-how { position: relative; }
.mg-how.is-open { background: var(--gold); color: var(--btn-text); }
.mg-howpick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; padding: 8px; border-radius: 12px; background: var(--surface); }
.mg-flags3 { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.mg-marks { font-size: .9rem; color: var(--muted); }
.mg-link { background: none; border: 0; padding: 6px 0; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; min-height: 32px; }
.mg-lab { font-family: var(--ui); font-weight: 600; margin: 6px 0; }
.mg-tips { font-family: var(--ui); padding-left: 1.2em; }
.mg-tips li { margin: 4px 0; }
.mg-big { font-size: 1.2rem; font-weight: 600; }
.mg-sub { color: var(--muted); }
.mg-legendc { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; font-family: var(--ui); font-size: .9rem; }
.mg-legendc i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: -1px; }
.mg-whenq { font-family: var(--ui); font-weight: 600; margin: 6px 0 2px; }
.mg-toasts.is-top { top: calc(118px + env(safe-area-inset-top)); bottom: auto; }
.mg-toast { font-size: .88rem; padding: 8px 14px; }
.mg-page .mg .mg-legend { font-family: var(--ui); font-size: .82rem; line-height: 1.45; color: var(--muted); }
.mg-hl .mg-sub, .mg-endlist .mg-sub { display: block; font-size: .82rem; }
.mg-seats { overflow-x: auto; scrollbar-width: none; }
.mg-seats::-webkit-scrollbar { display: none; }
@media (max-width: 380px) { .mg-seat small { display: none; } .mg-seat { padding-left: 4px; padding-right: 10px; gap: 4px; } }
.mg-qfound { margin-top: 4px; }
.chip--own { border-style: dashed; }
.mg-sheet[style*="height"] { bottom: auto; }

/* Общий экран: один видимый ход и доступные элементы управления рядом с картой. */
.mg-turnlabel { margin: 0 0 5px; color: var(--text); font-family: var(--ui); }
.mg-mode-rules, .mg-turnscore { color: var(--text); font-weight: 600; }
.mg-medal { margin: 4px 0; color: var(--text); font: .85rem/1.4 var(--ui); }
.mg-medal span, .mg-optional summary span { color: var(--muted); }
.mg-seat b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mg-placechoices, .mg-optional { margin: 12px 0; }
.mg-placechoices summary, .mg-optional summary { min-height: 42px; padding: 10px 0; cursor: pointer; box-sizing: border-box; }
.mg-placechoices summary:focus-visible, .mg-optional summary:focus-visible, .mg-act__h:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.mg-cellchoices { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mg-cellchoices .chip, .mg-compass .mg-compass__b, .mg-act .mg-link { min-height: 44px; }
.mg-pl__name { font-size: 13px; }
.mg-back-to-play { display: none; }
.mg-playing .mg-back-to-play { display: block; }
@media (max-width: 899px) {
  .mg-main .mg-act { grid-row: 1; }
}
@media (min-width: 900px) {
  .mg-main .mg-act { top: 190px; }
}
@media (max-width: 480px) {
  .mg-seat b { max-width: 11ch; }
  .mg-medal { font-size: .78rem; }
  .mg-top:has(.mg-medal) { position: static; }
}

/* The date and primary action stay fixed below the scrolling dream form. */
.mg-sheet__box:has(.mg-dream-content) {
  display: flex;
  flex-direction: column;
  height: min(80svh, 720px);
  box-sizing: border-box;
  overflow: hidden;
  padding-bottom: 0;
}
.mg-dream-content { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 0 3px 14px; scroll-padding-block: 12px; }
.mg-dream-content .mg-howpick { scroll-margin-block: 10px; }
.mg-dream-footer { flex: none; border-top: 1px solid var(--line); padding: 6px 3px 0; }
.mg-dream-footer .mg-sticky { position: static; margin-top: 0; border: 0; box-shadow: none; }
.mg-dream-date { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mg-dream-date .mg-seg { margin: 0; }
.mg-dream-date .chip { min-height: 40px; }
@media (max-width: 420px) {
  .mg-dream-content .mg-add { flex-wrap: wrap; }
  .mg-dream-content .mg-add input { flex: 1 1 100%; }
}

/* Keep the overview compact, with a larger map that scrolls inside the current panel. */
.mg-boardwrap, .mg-endmaps figure, .mg-map-viewport { min-width: 0; }
.mg-map-controls { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.mg-map-controls .chip { min-height: 44px; }
.mg-map-hint { margin: 2px 0 8px; }
.mg-map-viewport { width: 100%; }
.mg-map-viewport.is-zoomed {
  max-height: min(58svh, 480px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-sizing: border-box;
}
.mg-map-viewport.is-zoomed > :is(.mg-board, .mg-svg) {
  width: max(640px, 140%);
  max-width: none;
  height: auto;
  margin: 0;
  border-radius: 0;
}
.mg-map-viewport.is-zoomed .mg-svg { touch-action: pan-x pan-y pinch-zoom; }
.mg-map-viewport.is-zoomed .mg-pl__name { font-size: 14px; }
.mg-map-viewport:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mg-endboard .mg-map-frame, .mg-endmaps .mg-map-frame { padding: 8px; }
@media (max-width: 480px) {
  .mg-map-viewport .mg-pl__name { font-weight: 650; stroke-width: 3.3px; }
  .mg-map-viewport:not(.is-zoomed) .mg-pl__name { font-size: 15px; }
}

/* Site tips must never sit above interactive game dialogs. */
html.mg-lock .amb-toast, body.mg-playing .amb-toast { display: none; }
.mg-seat:disabled { opacity: .6; cursor: default; }
.mg-placement-note { margin: 0 0 4px; }

.mg-map-labels { pointer-events: none; }
.mg-name-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }
.mg-png-layout { position: fixed; left: -9999px; top: 0; width: 640px; height: 640px; visibility: hidden; pointer-events: none; }
