/* Chanland plot map v2 (2026-10-30): the map fills the screen; everything else floats over it as large symbol buttons,
   sized for a phone inside Telegram's in-app browser (and as a Telegram Mini App). No external fonts: the live site's
   CSP only allows its own files. */
:root {
  --paper: #efece4; --ink: #10333a; --ink-2: #4c6a6f; --line: rgba(16, 51, 58, .14);
  --glass: rgba(255, 255, 255, .9); --solid: #ffffff; --press: rgba(16, 51, 58, .08);
  --accent: #0b6e6c; --accent-ink: #ffffff; --live: #1f9d63; --warn: #d08a12; --off: #9aa7a9; --danger: #c2412d;
  --amber: #f5c55b; --aqua: #6bcbd0; --violet: #ba9ce7;
  --sel: #0b6e6c; --sel-fill: rgba(11, 110, 108, .28);
  --shadow: 0 6px 24px rgba(16, 40, 44, .18), 0 1px 3px rgba(16, 40, 44, .12);
  --lift: 12px; --k: 1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1719; --ink: #e4efee; --ink-2: #9db4b6; --line: rgba(228, 239, 238, .14);
    --glass: rgba(24, 37, 40, .9); --solid: #182528; --press: rgba(228, 239, 238, .1);
    --accent: #3fb8b0; --accent-ink: #062224; --live: #3ccf8a; --off: #5d6f72; --danger: #ef6a52;
    --sel: #1aa39d; --sel-fill: rgba(26, 163, 157, .3);
    --shadow: 0 6px 24px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1719; --ink: #e4efee; --ink-2: #9db4b6; --line: rgba(228, 239, 238, .14);
  --glass: rgba(24, 37, 40, .9); --solid: #182528; --press: rgba(228, 239, 238, .1);
  --accent: #3fb8b0; --accent-ink: #062224; --live: #3ccf8a; --off: #5d6f72; --danger: #ef6a52;
  --sel: #1aa39d; --sel-fill: rgba(26, 163, 157, .3);
  --shadow: 0 6px 24px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
/* (iOS browsers, Telegram's in-app browser among them, float their bottom bar over the page) */
:root.lift { --lift: 62px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--paper); color: var(--ink);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans Khmer", "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .38; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg.i { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the map ---------- */
#map { position: fixed; inset: 0; overflow: hidden; touch-action: none; cursor: grab; background: var(--paper); }
#map.dragging { cursor: grabbing; }
#map.paint { cursor: crosshair; box-shadow: inset 0 0 0 4px var(--sel); }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#stage.moving { will-change: transform; }
#plan { display: block; overflow: visible; }
#plan image { image-rendering: auto; }
/* (the colors multiply onto the plan, the way a highlighter marks paper: white paper takes the color, black print
   and lines stay black. Plain see-through fills tinted the printed numbers and "5x20" purple) */
#plots { mix-blend-mode: multiply; }
.plot { fill: transparent; stroke: none; }
.plot.c-amber { fill: var(--amber); fill-opacity: .62; }
.plot.c-aqua { fill: var(--aqua); fill-opacity: .62; }
.plot.c-violet { fill: var(--violet); fill-opacity: .62; }
.plot.sel { stroke: var(--sel); stroke-width: calc(3px * var(--k)); stroke-linejoin: round; }
.plot.sel:not(.c-amber):not(.c-aqua):not(.c-violet) { fill: var(--sel-fill); }
.plot.pulse { animation: pulse 1.5s ease-out 2; }
@keyframes pulse { 0% { stroke: #e0532f; stroke-width: calc(7px * var(--k)); } 100% { stroke: #e0532f; stroke-width: 0; } }
/* (the found plot: the same two flashes, then 3 s of rest, over and over while it stays picked) */
.plot.beacon { animation: beacon 6s ease-out infinite; }
@keyframes beacon {
  0% { stroke: #e0532f; stroke-width: calc(7px * var(--k)); }
  25% { stroke: #e0532f; stroke-width: 0; }
  25.01% { stroke: #e0532f; stroke-width: calc(7px * var(--k)); }
  50% { stroke: #e0532f; stroke-width: 0; }
  50.01%, 100% { stroke: var(--sel); stroke-width: calc(3px * var(--k)); }
}
#numbers { display: none; pointer-events: none; }
#map.near #numbers { display: inline; }
#numbers circle { fill: #fff; stroke: #243d41; stroke-width: .3; }
#numbers text { font: 600 4.6px/1 -apple-system, "Segoe UI", Roboto, sans-serif; fill: #10333a; text-anchor: middle; dominant-baseline: central; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--ink-2); font-size: 15px; }
#loading .spin { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- floating chrome ---------- */
.glass { background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); box-shadow: var(--shadow); }
#top { position: fixed; z-index: 5; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none; }
#top > * { pointer-events: auto; }
#brand { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px 0 8px; border-radius: 26px; min-width: 0; }
#brand .mark { width: 36px; height: 36px; border-radius: 11px; background: #173d43; color: #fff; display: grid; place-items: center; flex: none; position: relative; }
#brand .mark svg { width: 22px; height: 22px; }
#live { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%; background: var(--off); border: 2.5px solid var(--solid); }
#live.on { background: var(--live); }
#live.busy { background: var(--warn); animation: blink 0.8s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .35; } }
#brand b { font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
#counts { display: flex; gap: 8px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }
#counts span { display: flex; align-items: center; gap: 4px; }
#counts i, .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.round { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.round:active, .key:active, .row:active, .sw:active { transform: scale(.94); }

#hint { position: fixed; z-index: 4; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 72px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 22px; font-size: 15px; font-weight: 600;
  background: var(--sel); color: #fff; box-shadow: var(--shadow); white-space: nowrap; }
#hint svg { width: 20px; height: 20px; }
#toast { position: fixed; z-index: 30; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 72px); transform: translate(-50%, -8px); opacity: 0;
  max-width: calc(100% - 32px); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; min-height: 48px;
  border-radius: 24px; background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 600; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast .msg { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; white-space: nowrap; padding-right: 8px; }
#toast .msg svg { width: 20px; height: 20px; }
#toast button { height: 36px; padding: 0 14px; border-radius: 18px; background: rgba(255, 255, 255, .16); display: flex; align-items: center; gap: 6px; flex: none; }
#toast button svg { width: 20px; height: 20px; }

#zoom { position: fixed; z-index: 4; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + var(--lift) + 92px); display: flex; flex-direction: column; gap: 10px; }
#zoom .pm { display: none; }
@media (hover: hover) and (pointer: fine) { #zoom .pm { display: grid; } }

/* the dock: four symbols, thumb height */
#dock { position: fixed; z-index: 6; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + var(--lift)); transform: translateX(-50%);
  display: flex; gap: 6px; padding: 7px; border-radius: 34px; }
#dock .round { width: 58px; height: 58px; position: relative; }
#dock .round svg { width: 28px; height: 28px; }
#dock .on { background: var(--sel); color: #fff; }
#dock .busy svg { opacity: .25; }
#dock .busy::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
a.btn { color: inherit; text-decoration: none; }
.badge { position: absolute; top: 9px; right: 11px; width: 11px; height: 11px; border-radius: 50%; background: #e0532f; border: 2px solid var(--solid); }

/* ---------- the plot card (replaces the dock while plots are picked) ---------- */
#card { position: fixed; z-index: 7; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + var(--lift)); transform: translateX(-50%);
  width: min(440px, calc(100% - 20px)); border-radius: 28px; padding: 16px 16px 16px 20px; background: var(--solid); box-shadow: var(--shadow); }
#card .head { display: flex; align-items: flex-start; gap: 14px; }
#card .num { font-size: 40px; line-height: 1; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
#card .num small { font-size: 15px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
#card .num svg { width: 30px; height: 30px; color: var(--sel); }
#card .meta { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px; background: var(--press); font-size: 14px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip svg { width: 16px; height: 16px; }
.ava { width: 22px; height: 22px; border-radius: 50%; background: #173d43; color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; flex: none; margin-left: -6px; }
#card .list { margin-top: 10px; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; max-height: 44px; overflow: auto; -webkit-user-select: text; user-select: text; }
#card .close { width: 44px; height: 44px; margin: -6px -6px 0 0; border-radius: 50%; background: var(--press); }
#card .close svg { width: 22px; height: 22px; }
.swatches { display: flex; gap: 12px; margin-top: 16px; align-items: center; }
.sw { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; position: relative; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .12); color: #10333a; transition: transform .12s; }
.sw svg { width: 30px; height: 30px; stroke-width: 3; }
.sw.erase { background: var(--press); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); margin-left: auto; }
.sw.now::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid var(--ink); }
.sw.saving::before { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--ink); animation: spin .7s linear infinite; }
#card .confirm { display: flex; gap: 10px; margin-top: 16px; }
#card .confirm .btn { height: 64px; font-size: 18px; }
#card .confirm .btn.go { color: #10333a; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
#card .lock { margin-top: 12px; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
#card .lock svg { width: 18px; height: 18px; }

/* ---------- sheets ---------- */
#scrim { position: fixed; inset: 0; z-index: 20; background: rgba(6, 20, 23, .38); opacity: 0; pointer-events: none; transition: opacity .2s; }
#scrim.show { opacity: 1; pointer-events: auto; }
#scrim.clear { background: transparent; }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translate(-50%, calc(100% + 40px)); visibility: hidden;
  transition: transform .24s cubic-bezier(.2, .8, .2, 1), visibility 0s .24s;
  width: min(480px, 100%); max-height: calc(100% - env(safe-area-inset-top, 0px) - 24px); overflow: auto; overscroll-behavior: contain;
  background: var(--solid); border-radius: 28px 28px 0 0; box-shadow: var(--shadow);
  padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + var(--lift) + 12px); }
.sheet.show { transform: translate(-50%, 0); visibility: visible; transition: transform .24s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 4px 0 12px; font-size: 20px; display: flex; align-items: center; gap: 10px; text-wrap: balance; }
.sheet h2 svg { width: 24px; height: 24px; }
.sheet p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }

/* number pad */
/* (the number box looks like a text box being typed in: an outline and a blinking cursor) */
#pad .show-num { display: flex; align-items: center; justify-content: center; height: 64px; margin-bottom: 8px; border-radius: 18px; background: var(--press);
  box-shadow: inset 0 0 0 2px var(--accent); font-size: 38px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
#pad .show-num svg { width: 26px; height: 26px; color: var(--ink-2); margin-right: 12px; }
#pad .show-num .caret { width: 3px; height: 40px; margin-left: 3px; border-radius: 2px; background: var(--accent); animation: caret 1.05s steps(1) infinite; }
#pad .show-num .ph { opacity: .28; margin-left: 2px; }
@keyframes caret { 50% { opacity: 0; } }
#pad .show-num.bad { color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--press)); }
#pad .show-num.bad .caret { background: var(--danger); }
#pad .show-num.shake { animation: shake .45s; }
@keyframes shake { 15% { transform: translateX(-11px); } 35% { transform: translateX(10px); } 55% { transform: translateX(-8px); } 75% { transform: translateX(5px); } 90% { transform: translateX(-2px); } }
#pad .twins { display: flex; gap: 8px; margin-bottom: 8px; }
#pad .twins button { flex: 1; height: 52px; border-radius: 16px; background: var(--press); font-weight: 650; display: flex; align-items: center; justify-content: center; gap: 6px; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { height: 60px; border-radius: 18px; background: var(--press); font-size: 26px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.key.go { background: var(--accent); color: var(--accent-ink); }

/* rows (menu, activity) */
.row { width: 100%; min-height: 58px; display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-radius: 16px; text-align: left; font-size: 16px; font-weight: 600; }
.row + .row { margin-top: 2px; }
.row:hover { background: var(--press); }
.row .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--press); display: grid; place-items: center; flex: none; }
.row .ic svg { width: 22px; height: 22px; }
.row .txt { flex: 1; min-width: 0; }
.row .txt small { display: block; font-weight: 500; font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.danger { color: var(--danger); }
.row .when { font-size: 14px; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
#acts .ava { width: 40px; height: 40px; font-size: 14px; margin: 0; border-radius: 12px; }
.empty { padding: 26px 8px; text-align: center; color: var(--ink-2); }
.empty svg { width: 34px; height: 34px; display: block; margin: 0 auto 8px; }

/* help: symbol legend */
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.legend div { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 16px; background: var(--press); font-size: 14.5px; font-weight: 600; }
.legend .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--solid); display: grid; place-items: center; flex: none; }
.legend .ic svg { width: 22px; height: 22px; }
.legend .dots { display: flex; gap: 3px; }

/* forms and buttons in sheets */
.field { width: 100%; height: 56px; border-radius: 16px; border: 2px solid var(--line); background: var(--solid); color: var(--ink); padding: 0 16px; font: 600 18px/1 inherit; font-family: inherit; -webkit-user-select: text; user-select: text; }
.btns { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; height: 56px; border-radius: 18px; background: var(--press); font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn svg { width: 22px; height: 22px; }
.linkbox { font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; padding: 12px; border-radius: 14px; background: var(--press); -webkit-user-select: all; user-select: all; }
.notes p { font-size: 14px; }
#nolink { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--paper); }
#nolink svg { width: 54px; height: 54px; color: var(--ink-2); }
#nolink h2 { margin: 12px 0 6px; }
#nolink p { color: var(--ink-2); max-width: 30ch; margin: 0 auto; }

@media (min-width: 720px) {
  #card { left: 16px; transform: none; width: 400px; bottom: 16px; }
  #dock { bottom: 16px; }
  .sheet { bottom: 16px; border-radius: 28px; padding-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; transition-duration: .01s !important; } }
