/* Fonts: in the published repo the guides ship Nunito next to this folder (../guides/fonts). Missing locally -> system font. */
@font-face { font-family: Nunito; font-weight: 700; font-display: swap;
  src: url(../../guides/fonts/nunito-cyrillic-700.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Nunito; font-weight: 700; font-display: swap;
  src: url(../../guides/fonts/nunito-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f5f1e8; --fg: #2d261e; --muted: #7a6e5d; --card: #fffdf8; --line: #d9d0be;
  --accent: #d2561a; --accent-soft: rgba(210, 86, 26, .16);
  --lbl-bg: #fffdf8; --lbl-fg: #2d261e; --lbl-line: #cfc4ae;
  --lead: #3b3125; --lead-halo: rgba(255, 253, 248, .85);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1713; --fg: #ece5d8; --muted: #a89c88; --card: #262019; --line: #433b30;
    --accent: #ff944f; --accent-soft: rgba(255, 148, 79, .2);
    --lbl-bg: #2c251d; --lbl-fg: #efe8da; --lbl-line: #4d4436;
    --lead: #e9e0cf; --lead-halo: rgba(27, 23, 19, .85);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.35 Nunito, system-ui, -apple-system, 'Segoe UI', sans-serif;
  display: flex; flex-direction: column; -webkit-text-size-adjust: 100%; }

.top { display: flex; align-items: center; gap: 10px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); flex: none; min-height: 40px; }
.top .brand { flex: none; width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.top h1 { font-size: 15px; margin: 0; white-space: nowrap; }
.room-title { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#roomSel { font: inherit; font-weight: 700; padding: 3px 6px; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; min-width: 0; max-width: 46vw; text-overflow: ellipsis; }
@media (max-width: 560px) { .top { gap: 6px; padding: 6px 8px; } .top h1 { display: none; } #roomSel { flex: 1 1 auto; max-width: none; } }
.tabs { margin-left: auto; display: flex; gap: 4px; }
.tab { font: inherit; font-weight: 700; padding: 4px 10px; border: 1px solid var(--line); background: transparent; color: var(--fg);
  border-radius: 999px; cursor: pointer; }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab:disabled { opacity: .45; cursor: default; }

#map { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#zoomReset { position: absolute; right: 8px; bottom: 22px; z-index: 10; font: 700 12px Nunito, system-ui, sans-serif; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); cursor: pointer; }
#zoomReset[hidden] { display: none; }
.status { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 2px 8px; font-size: 11px; color: var(--muted); text-align: center; pointer-events: none; }

#scene { position: absolute; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 6px 22px rgba(0, 0, 0, .25); -webkit-tap-highlight-color: transparent; outline: none; user-select: none; -webkit-user-select: none; }
#scene img.base { -webkit-user-drag: none; user-select: none; display: block; width: 100%; height: 100%; pointer-events: none; }
#scene .dim { position: absolute; inset: 0; background: rgba(8, 5, 2, .45); opacity: 0; transition: opacity .18s; pointer-events: none; }
#map.has-sel #scene .dim { opacity: 1; }
#map img.hl { position: absolute; display: none; pointer-events: none; z-index: 3;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px var(--accent)); animation: glow 1.1s ease-in-out infinite alternate; }
#map.has-sel img.hl { display: block; }
@keyframes glow { from { filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 3px var(--accent)); } to { filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 9px var(--accent)); } }

#lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 1; }
#lines .halo { stroke: var(--lead-halo); stroke-width: 2.6; fill: none; }
#lines .core { stroke: var(--lead); stroke-width: 1; fill: none; }
#lines .dot { fill: var(--lead); stroke: var(--lead-halo); stroke-width: 1; }
#map.has-sel #lines g { opacity: .22; transition: opacity .15s; }
#map.has-sel #lines g.sel { opacity: 1; }
#lines g.sel .core { stroke: var(--accent); stroke-width: 2; }
#lines g.sel .halo { stroke-width: 4.5; }
#lines g.sel .dot { fill: var(--accent); }
#lines .ring { fill: none; stroke: var(--accent); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: ring 1.1s ease-out infinite; }
@keyframes ring { from { transform: scale(.55); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }

.lbl { position: absolute; z-index: 2; margin: 0; padding: 2px 5px; font: 700 13px/14px Nunito, system-ui, sans-serif; color: var(--lbl-fg);
  background: var(--lbl-bg); border: 1px solid var(--lbl-line); border-radius: 8px; text-align: center; cursor: pointer;
  display: flex; align-items: center; justify-content: center; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.lbl.eng { border-style: dashed; }
#map.has-sel .lbl:not(.sel) { opacity: .55; }
.lbl.sel { background: var(--accent); border-color: var(--accent); color: #fff; opacity: 1; transform: scale(1.06); box-shadow: 0 2px 10px rgba(0, 0, 0, .35); z-index: 4; }
.lbl:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) { img.hl, #lines .ring { animation: none; } }

/* ------------------------------------------------------------------ simulator */
[hidden] { display: none !important; }
#sim { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.sim-top { width: 100%; max-width: 640px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 42px; flex: none; }
.sim-back { font: inherit; font-weight: 700; padding: 4px 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 999px; cursor: pointer; }
.sim-attempt { margin: 0 auto; font-weight: 700; color: var(--muted); }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-weight: 700; white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
#simCount { margin-left: auto; }
.sim-stage { flex: none; display: flex; justify-content: center; }
#simScene { position: relative; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 6px 22px rgba(0, 0, 0, .25); touch-action: none; cursor: crosshair; }
#simScene img.base { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
#simScene .sprites img.sp { position: absolute; pointer-events: none; -webkit-user-drag: none; }
#simScene.blur .base, #simScene.blur .sprites { filter: blur(5px) brightness(.55); }
.sp.found { animation: found .42s ease-out forwards; }
@keyframes found {
  0% { transform: scale(1); filter: brightness(1); }
  30% { transform: scale(1.35) translateY(-4%); filter: brightness(2.2) drop-shadow(0 0 6px #fff); }
  100% { transform: scale(1.5) translateY(-16%); opacity: 0; filter: brightness(2.6); }
}
#simScene .bar { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 64%; display: flex; gap: 2px; z-index: 5; pointer-events: none; }
#simScene .bar i { position: relative; flex: 1; height: calc(var(--s, .6) * 40px); min-height: 18px; background: rgba(0, 0, 0, .55); border-radius: 4px; overflow: hidden; }
#simScene .bar u { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #f6b92b; }
#simScene .bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 calc(var(--s, .6) * 22px)/1 Nunito, system-ui, sans-serif; color: #fff; }
#simScene .bar i.on span { color: #3b2600; }
#simScene .fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.fx .pop { position: absolute; transform: translate(-50%, -50%); font: 800 calc(var(--s, .6) * 84px)/1 Nunito, system-ui, sans-serif; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); animation: pop 1s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -110%) scale(1); } }
.fx .xmark, .heat .xm { position: absolute; transform: translate(-50%, -50%); width: calc(var(--s, .6) * 64px); min-width: 24px; pointer-events: none; }
.fx .xmark { animation: xm .65s ease-out forwards; filter: drop-shadow(0 0 6px #ff2d2d); }
.heat .xm { width: calc(var(--s, .6) * 40px); min-width: 16px; opacity: .9; }
.xmark svg, .xm svg { display: block; width: 100%; fill: none; stroke: #e8332a; stroke-width: 3.4; stroke-linecap: round; }
@keyframes xm { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }
#simScene .cd { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; z-index: 7; color: #fff; text-align: center; }
#simScene .cd div { font: 700 20px/1 Nunito, system-ui, sans-serif; padding: 10px 28px; border-radius: 999px; background: rgba(40, 110, 220, .75); box-shadow: 0 0 22px rgba(70, 150, 255, .7); }
#simScene .cd b { font: 800 56px/1 Nunito, system-ui, sans-serif; text-shadow: 0 3px 8px rgba(0, 0, 0, .6); }
#simScene .heat { position: absolute; inset: 0; z-index: 6; pointer-events: none; background: rgba(8, 5, 2, .35); }
.heat .dot { position: absolute; transform: translate(-50%, -50%); width: calc(var(--s, .6) * 46px); height: calc(var(--s, .6) * 46px); min-width: 22px; min-height: 22px; border-radius: 50%;
  background: var(--c); border: 2px solid rgba(255, 255, 255, .9); display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.heat .dot.nf { background: #666; }
.heat .dot span { font: 800 clamp(9px, calc(var(--s, .6) * 22px), 14px)/1 Nunito, system-ui, sans-serif; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); font-variant-numeric: tabular-nums; }

.sim-bottom { flex: none; position: relative; max-width: 100%; padding: 0 6px; }
.sim-bottom .list { position: relative; width: 100%; height: 100%; }
.list .item { position: absolute; left: calc(var(--c, 2) * 33.333% + 3px); top: calc(var(--r, 1) * 50% + 3px); width: calc(33.333% - 6px); height: calc(50% - 6px);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 6px; font-weight: 700; font-size: 15px; line-height: 1.1;
  background: var(--lbl-bg); color: var(--lbl-fg); border: 1px solid var(--lbl-line); border-radius: 14px; box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  overflow: hidden; }
.list .item.long { font-size: 12.5px; }
.list .item.empty { visibility: hidden; }
.sim-bottom .panel { height: 100%; overflow: auto; padding: 4px 6px; }
.panel .hint { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.panel h2 { font-size: 17px; margin: 2px 0 6px; }
.panel table { width: 100%; border-collapse: collapse; font-size: 15px; }
.panel td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.panel td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.panel tr.tot td { font-size: 17px; border-bottom: 0; color: var(--accent); }
.panel .opt { display: block; font-size: 13px; margin: 6px 0; }
.panel .btns { display: flex; gap: 6px; flex-wrap: nowrap; margin-top: 8px; }
.panel button { flex: 1 1 0; min-width: 0; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: inherit; font-size: 13.5px; font-weight: 700; padding: 9px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; }
.panel button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ two-player mode */
.sim-attempt { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.pl { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--card); border: 2px solid var(--pc, var(--line)); color: var(--fg); white-space: nowrap; }
.pl b { font-variant-numeric: tabular-nums; }
.panel .pls { display: flex; gap: 6px; flex-wrap: wrap; }
.mpbox .code { font-size: 15px; margin: 2px 0 6px; }
.mpbox .code b { font-size: 24px; letter-spacing: .12em; color: var(--accent); }
.mpbox input { font: inherit; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.mpbox #mpName { width: 100%; margin-top: 3px; }
.mpbox #mpCode { width: 76px; text-align: center; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; flex: none; }
.linkrow { display: flex; gap: 6px; }
.linkrow input { flex: 1; font-size: 12px; }
.linkrow button { flex: none !important; max-width: none !important; }
.pl-list { list-style: none; margin: 8px 0 2px; padding: 0; font-size: 14px; font-weight: 700; }
.pl-list li { padding: 2px 0; }
.dotc { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; }
.panel .err { color: #ff6b5a; font-size: 13px; margin: 4px 0; }

.panel button.wide { flex: 2.4 1 0; white-space: normal; line-height: 1.15; font-size: 12.5px; max-width: none; }
.panel button.ready { background: #2e8b57; border-color: #2e8b57; color: #fff; }
.panel button:disabled { opacity: .6; cursor: default; }
.panel .res .btns { margin: 8px 0 10px; }

.list.blur { filter: blur(6px) brightness(.75); }
.mpbox #mpName { max-width: 100%; }
.mpbox #mpCode { flex: 0 0 84px; width: 84px; }
.panel button.full { max-width: none; }
.mpbox .btns { margin-top: 6px; }
