/* v1.9 Strategic campaign map, achievements / records screen, account share controls, intel chips. */

/* ---------- MAP / LIST toggle ---------- */
.cm-toggle { display: inline-flex; margin-top: 12px; border: 1px solid var(--line2); }
.cm-toggle button { height: 32px; padding: 0 14px; background: transparent; border: none; color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; }
.cm-toggle button + button { border-left: 1px solid var(--line2); }
.cm-toggle button.active { background: var(--sel); color: var(--green); box-shadow: inset 0 -2px 0 var(--green); }

/* ---------- Map layout ---------- */
.cmap { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; }
.cm-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cm-globe-wrap { position: relative; background: radial-gradient(circle at 50% 45%, rgba(124,255,154,0.06), transparent 65%), #050806; border: 1px solid var(--line); padding: 8px; }
#cm-globe { display: block; width: 100%; aspect-ratio: 1; cursor: pointer; }
.cm-globe-cap { position: absolute; left: 10px; top: 8px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; color: var(--green-dim); }
.cm-ths { display: flex; flex-direction: column; gap: 4px; }
.cm-th { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #0D1310; border: 1px solid var(--line); color: #D9E0DA; text-align: left; overflow: hidden; }
.cm-th:hover { border-color: var(--line2); }
.cm-th.active { border-color: var(--green); background: var(--sel); }
.cm-th.locked { opacity: 0.55; }
.cm-th .n { flex: 0 0 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line2); font-family: var(--mono); font-size: 12px; color: var(--green); }
.cm-th.active .n { background: var(--green); color: #0B0F0C; border-color: var(--green); }
.cm-th .nm { display: flex; flex-direction: column; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.06em; line-height: 1.05; }
.cm-th .nm small { font-family: var(--mono); font-weight: 400; font-size: 9px; letter-spacing: 0.14em; color: var(--muted); margin-top: 3px; }
.cm-th i { position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--p) * 100%); background: var(--green); }
.cm-sps { display: flex; flex-direction: column; gap: 4px; }
.cm-sp { position: relative; display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 8px 10px; background: #0D1310; border: 1px solid var(--line); color: #D9E0DA; text-align: left; }
.cm-sp:hover { border-color: var(--line2); }
.cm-sp b { font-family: var(--mono); font-weight: 500; font-size: 10px; letter-spacing: 0.18em; color: var(--amber); }
.cm-sp span { grid-column: 2; font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-sp i { grid-row: 1 / span 2; width: 10px; height: 10px; border-radius: 50%; background: var(--dim); justify-self: center; }
.cm-sp.daily i, .cm-sp.weekly i { background: var(--red); }
.cm-sp.daily b { color: #FF8A73; }
.cm-sp.train b { color: var(--green); }
.cm-sp.done { opacity: 0.7; }
.cm-sp i.pulse { box-shadow: 0 0 0 0 rgba(224,83,61,0.7); animation: cm-pulse 1.6s infinite; }
@keyframes cm-pulse { 0% { box-shadow: 0 0 0 0 rgba(224,83,61,0.7); } 70% { box-shadow: 0 0 0 10px rgba(224,83,61,0); } 100% { box-shadow: 0 0 0 0 rgba(224,83,61,0); } }

.cm-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cm-head h2 { margin: 2px 0 0; font-family: var(--display); font-weight: 800; font-size: 34px; letter-spacing: 0.04em; color: #F3F6F2; line-height: 1; }
.cm-eb { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--green); }
.cm-hstats { display: flex; gap: 16px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--muted); }
.cm-hstats b { display: block; font-family: var(--display); font-size: 24px; color: #F3F6F2; line-height: 1; }
.cm-hstats .choice { color: var(--amber); } .cm-hstats .choice b { color: var(--amber); }
.cm-stage { position: relative; height: clamp(380px, 58vh, 560px); background: #070B09; border: 1px solid var(--line2); overflow: hidden; box-shadow: inset 0 0 60px rgba(0,0,0,0.6); }
#cm-topo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#cm-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.cm-stage::after { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(124,255,154,0.12); pointer-events: none; }
.cm-lock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 22px; background: rgba(5,8,6,0.88); border: 1px solid var(--line2); text-align: center; }
.cm-lock b { font-family: var(--display); font-size: 26px; letter-spacing: 0.12em; color: var(--muted); }
.cm-lock span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }

/* SVG: lines and nodes */
.cm-line { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.cm-line.won { stroke: rgba(124,255,154,0.8); }
.cm-line.open { stroke: rgba(242,181,68,0.85); stroke-dasharray: 7 6; animation: cm-dash 1.2s linear infinite; }
.cm-line.locked { stroke: rgba(140,155,145,0.35); stroke-dasharray: 2 6; }
.cm-line.branch { stroke: rgba(242,181,68,0.55); stroke-width: 1.5; stroke-dasharray: 3 5; animation: cm-dash 1.6s linear infinite; }
.cm-line.special { stroke: rgba(120,200,230,0.35); stroke-width: 1.5; stroke-dasharray: 4 5; }
.cm-line.special.open { stroke: rgba(120,200,230,0.8); }
@keyframes cm-dash { to { stroke-dashoffset: -26; } }
.cm-node { cursor: pointer; outline: none; }
.cm-node .cm-shape { fill: #0B110D; stroke: #6D7C70; stroke-width: 2; transition: fill 0.15s; }
.cm-node.won .cm-shape { fill: #12301C; stroke: var(--green); }
.cm-node.open .cm-shape { fill: #2A220E; stroke: var(--amber); }
.cm-node.locked .cm-shape { fill: rgba(10,14,12,0.85); stroke: #3E4F42; }
.cm-node.course .cm-shape { stroke: #78C8E6; } .cm-node.course.won .cm-shape { fill: #0F2A33; }
.cm-node.joint .cm-shape { stroke: #FF8A73; } .cm-node.joint.won .cm-shape { fill: #33160F; } .cm-node.joint.open .cm-shape { fill: #2A120C; }
.cm-node.locked.course .cm-shape, .cm-node.locked.joint .cm-shape { stroke: #3E4F42; }
.cm-node:hover .cm-shape, .cm-node:focus .cm-shape { stroke-width: 3; }
.cm-node.sel .cm-shape { filter: url(#cmglow); stroke-width: 3; }
.cm-node .cm-ring { fill: none; stroke: rgba(242,181,68,0.6); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: cm-ring 1.8s ease-out infinite; }
.cm-node.won .cm-ring { stroke: rgba(124,255,154,0.6); animation: none; }
.cm-node.sel .cm-ring { stroke: #F3F6F2; stroke-dasharray: 4 4; animation: cm-spin 6s linear infinite; }
@keyframes cm-ring { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes cm-spin { to { transform: rotate(360deg); } }
.cm-num { font-family: var(--mono); font-size: 12px; font-weight: 500; fill: #F3F6F2; text-anchor: middle; pointer-events: none; }
.cm-node.won .cm-num { fill: var(--green); } .cm-node.open .cm-num { fill: var(--amber); }
.cm-node.course .cm-num { fill: #A9E2F5; } .cm-node.joint .cm-num { fill: #FFC2B5; font-size: 11px; }
.cm-lockg { font-size: 11px; text-anchor: middle; opacity: 0.55; pointer-events: none; }
.cm-star { font-size: 11px; text-anchor: middle; fill: #3E4F42; pointer-events: none; } .cm-star.on { fill: var(--amber); }
.cm-label { font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; fill: #E6EBE4; paint-order: stroke; stroke: rgba(5,8,6,0.9); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.cm-node.locked .cm-label { fill: #7D8C80; }
.cm-node.sel .cm-label { fill: #FFFFFF; font-size: 14px; }
.cm-intel rect { fill: rgba(224,83,61,0.92); }
.cm-intel text { font-family: var(--mono); font-size: 8px; letter-spacing: 0.08em; fill: #FFF2EE; text-anchor: middle; }
.cm-daily { fill: none; stroke: #E0533D; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: cm-ring 1.4s ease-out infinite; }
.cm-dtag rect { fill: rgba(5,8,6,0.9); stroke: #E0533D; } .cm-dtag text { font-family: var(--mono); font-size: 8px; letter-spacing: 0.1em; fill: #FF8A73; text-anchor: middle; }
.cm-node.locked.special .cm-num, .cm-node.locked .cm-num { fill: #5B6B5E; }
.cm-compass circle { fill: rgba(5,8,6,0.6); stroke: rgba(124,255,154,0.4); }
.cm-compass path { fill: rgba(124,255,154,0.75); }
.cm-compass text, .cm-scale text { font-family: var(--mono); font-size: 9px; fill: rgba(180,200,185,0.8); text-anchor: middle; }
.cm-scale text { text-anchor: start; }
.cm-scale path { stroke: rgba(180,200,185,0.7); stroke-width: 1.5; fill: none; }

/* mission card */
.cm-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--panel-solid); border: 1px solid var(--line2); border-left: 3px solid var(--amber); }
.cm-card:empty { display: none; }
.cm-c-top { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--green); }
.cm-c-top .st { color: var(--amber); letter-spacing: 0.1em; } .cm-c-top .st i { font-style: normal; color: var(--dim); } .cm-c-top em { font-style: normal; color: var(--amber); } .cm-c-top em.lk { color: var(--muted); }
.cm-card h3 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: 0.04em; color: #F3F6F2; line-height: 1; }
.cm-c-cond { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted); min-height: 12px; }
.cm-card p { margin: 0; font-size: 13px; line-height: 1.45; color: #B4C0B6; }
.cm-c-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--amber); }
.cm-c-foot .btn { height: 42px; font-size: 18px; }
.cm-c-foot .btn:disabled { opacity: 0.35; cursor: default; filter: grayscale(1); }

/* desktop: card floats over the stage */
@media (min-width: 901px) {
  .cm-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); grid-template-areas: 'top top' 'h3 p' 'cond p' 'objs p' 'intel foot'; column-gap: 24px; row-gap: 6px; }
  .cm-card .cm-c-top { grid-area: top; } .cm-card h3 { grid-area: h3; } .cm-card .cm-c-cond { grid-area: cond; } .cm-card .mc-objs { grid-area: objs; }
  .cm-card p { grid-area: p; align-self: start; } .cm-card .intel-chip { grid-area: intel; align-self: end; } .cm-card .cm-c-foot { grid-area: foot; align-self: end; }
  .cm-stage { height: clamp(360px, 52vh, 520px); }
}

/* ---------- Intel chips ---------- */
.intel-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid rgba(224,83,61,0.6); background: rgba(224,83,61,0.10); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: #FFD3C9; }
.intel-chip b { flex: 0 0 auto; padding: 2px 6px; background: var(--red); color: #fff; font-weight: 500; letter-spacing: 0.14em; }
.intel-chip.small { font-size: 10px; padding: 5px 8px; }
.db-medals span.ach-chip { border-color: #2E7A47; color: var(--green); background: rgba(20,60,32,0.4); }
.db-medals span.intel-got { border-color: rgba(224,83,61,0.6); color: #FFB3A3; background: rgba(224,83,61,0.10); }

/* ---------- Records / achievements ---------- */
.rec-profile { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; background: var(--panel-solid); border: 1px solid var(--line); border-left: 3px solid var(--green); }
.rec-id { display: flex; flex-direction: column; gap: 4px; }
.rec-id b { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: 0.06em; color: #F3F6F2; line-height: 1; }
.rec-id span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.rec-pub { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.rec-pub a { color: var(--green); text-decoration: none; border-bottom: 1px dashed rgba(124,255,154,0.4); }
.rec-pub em { font-style: normal; color: #B4C0B6; letter-spacing: 0.04em; }
.rec-pub .btn { height: 38px; font-size: 16px; }
.ach-group { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: #0D1310; border: 1px solid var(--line); }
.ach.done { border-color: #2E7A47; background: linear-gradient(135deg, rgba(124,255,154,0.07), rgba(13,19,16,1) 60%); }
.ach-badge { position: relative; flex: 0 0 44px; width: 44px; height: 48px; display: flex; align-items: center; justify-content: center; }
.ach-badge svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ach-badge svg path { fill: #111914; stroke: #34443A; stroke-width: 1.5; }
.ach-badge span { position: relative; font-size: 18px; color: #4E5F52; }
.ach-badge.on svg path { fill: #163A22; stroke: var(--green); }
.ach-badge.on span { color: var(--green); text-shadow: 0 0 10px rgba(124,255,154,0.6); }
.ach-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ach-txt b { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: 0.06em; color: #E6EBE4; line-height: 1.05; }
.ach:not(.done) .ach-txt b { color: #B4C0B6; }
.ach-txt span { font-size: 12px; line-height: 1.35; color: var(--muted); }
.ach-bar { height: 4px; background: #1A241D; margin-top: 4px; overflow: hidden; }
.ach-bar i { display: block; height: 100%; background: var(--amber); }
.ach.done .ach-bar i { background: var(--green); }
.ach-txt small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--amber); }
.ach.done .ach-txt small { color: var(--green); }
.medal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.medal { display: grid; grid-template-columns: 28px 1fr; column-gap: 8px; padding: 10px; border: 1px solid var(--line); background: #0D1310; opacity: 0.5; }
.medal.on { opacity: 1; border-color: #5A4A1E; background: rgba(60,48,14,0.25); }
.medal i { grid-row: 1 / span 2; font-style: normal; font-size: 20px; filter: grayscale(1); } .medal.on i { filter: none; }
.medal b { font-family: var(--display); font-size: 15px; letter-spacing: 0.06em; color: #E6EBE4; } .medal.on b { color: var(--amber); }
.medal span { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* unlock toasts */
#ach-toasts { position: fixed; top: 16px; right: 16px; z-index: 40; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.ach-toast { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 12px; width: 320px; padding: 12px 14px; background: rgba(8,14,10,0.97); border: 1px solid var(--green); box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 24px rgba(124,255,154,0.15); transform: translateX(120%); opacity: 0; transition: transform 0.45s cubic-bezier(.2,.9,.3,1.2), opacity 0.3s; }
.ach-toast.in { transform: none; opacity: 1; }
.ach-toast div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ach-toast small { font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; color: var(--green); }
.ach-toast b { font-family: var(--display); font-size: 21px; font-weight: 800; letter-spacing: 0.06em; color: #F3F6F2; line-height: 1; }
.ach-toast span { font-size: 12px; color: var(--muted); }

/* account modal: public profile */
.acc-public { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line2); background: #0B110D; }
.ap-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--muted); }
.ap-row a { font-family: var(--mono); font-size: 12px; color: var(--green); text-decoration: none; }
.ap-row .btn { height: 40px; font-size: 15px; padding: 0 10px; flex: 1; white-space: nowrap; }
.ap-row .btn:disabled { opacity: 0.4; cursor: default; }
.ap-toggle { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 10px !important; cursor: pointer; }
.ap-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ap-toggle i { flex: 0 0 40px; height: 22px; border: 1px solid var(--line2); background: #0F1612; position: relative; transition: background 0.15s; }
.ap-toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.ap-toggle input:checked + i { background: #2A220E; border-color: var(--amber); }
.ap-toggle input:checked + i::after { transform: translateX(18px); background: var(--amber); }
.ap-toggle input:focus-visible + i { outline: 1px solid var(--green); }
.ap-toggle span { display: flex; flex-direction: column; gap: 3px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: #D9E0DA; }
.ap-toggle small { font-family: var(--body); font-size: 12px; letter-spacing: 0; color: var(--muted); }

/* ---------- Phones ---------- */
@media (max-width: 900px) {
  .cmap { grid-template-columns: 1fr; gap: 10px; }
  .cm-side { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: stretch; }
  .cm-globe-wrap { grid-row: 1; padding: 4px; display: flex; align-items: center; }
  .cm-globe-cap { display: none; }
  .cm-ths { grid-row: 1; display: flex; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .cm-ths::-webkit-scrollbar { display: none; }
  .cm-th { flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; min-width: 96px; }
  .cm-th .nm { font-size: 14px; } .cm-th .nm small { font-size: 8px; }
  .cm-th .n { flex: 0 0 auto; width: 22px; height: 22px; font-size: 11px; }
  .cm-sps { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .cm-sps::-webkit-scrollbar { display: none; }
  .cm-sp { flex: 0 0 auto; min-width: 150px; max-width: 220px; }
  .cm-head h2 { font-size: 26px; } .cm-hstats { gap: 12px; } .cm-hstats b { font-size: 20px; }
  .cm-stage { height: min(118vw, 560px); }
  .cm-label { font-size: 12px; }
  .cm-card h3 { font-size: 24px; }
  .cm-c-foot .btn { flex: 1 1 100%; }
  .rec-id b { font-size: 22px; }
  .ach-grid { grid-template-columns: 1fr; }
  .medal-grid { grid-template-columns: 1fr 1fr; }
  #ach-toasts { left: 10px; right: 10px; top: 58px; }
  .ach-toast { width: 100%; }
}
