.map-panel .panel-heading { padding: 13px 17px 12px; }
.map-panel .zoom-level { color: #4e6252; background: #e7ecdc; }
.map-surface { background: #f3eddb; }
.map-surface .station {
  border: none;
  padding: 3px 5px;
  background: transparent;
  color: #393d32;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.map-surface .station[data-depth="0"],
.map-surface[data-map-compact] .station[data-depth="0"],
.map-surface[data-map-small] .station[data-depth="0"] {
  width: 112px;
  min-height: 40px;
  border: 1px solid #ab9f817b;
  border-radius: 17px 17px 13px 13px / 7px;
  background: #fff9e9f5;
  box-shadow: inset 0 -2px #e0d4b46b, 0 1px 3px #55472c30;
  gap: 2px;
}
.map-surface[data-map-compact] .station[data-depth="0"] { width: 99px; }
.map-surface[data-map-small] .station[data-depth="0"] { width: 86px; }
.map-surface .station[data-depth="0"] .station-title {
  color: var(--station-ink);
  font: 800 15px/1.18 var(--serif);
  letter-spacing: .045em;
}
.map-surface .station[data-depth="0"] .station-gloss { font-size: 10px; }
.map-surface .station[data-depth="1"] {
  width: 102px;
  min-height: 43px;
  padding: 4px 6px;
  gap: 2px;
  border: 1px solid #a59c82;
  border-bottom: 2px solid var(--station-ink);
  background: #fffaeaf5;
  border-radius: 10px 3px;
  box-shadow: 0 1px 3px #554a3420;
}
.map-surface .station[data-depth="1"] .station-title {
  color: #43453a;
  font: 680 12px/1.18 var(--sans);
  letter-spacing: 0;
}
.map-surface .station[data-depth="1"] .station-gloss { color: var(--station-ink); font-size: 9px; }
.map-surface .station[data-depth="2"] {
  width: 101px;
  min-height: 40px;
  gap: 2px;
  border-radius: 4px;
  background: #fffaf0ed;
  border: 1px solid #c1b49a;
  box-shadow: 0 1px 2px #594a3120;
}
.map-surface[data-narrow-street] .station[data-depth="2"] { width: 82px; }
.map-surface .station[data-depth="2"] .station-title { font: 750 15px/1.18 var(--japanese); }
.map-surface .station-gloss { color: #635e4c; font-weight: 550; line-height: 1.2; }
.map-surface .station:not([aria-current]):hover {
  color: #383e33;
  border-color: var(--station-ink);
  background: #fffdf6;
  box-shadow: 0 2px 6px #66573a40;
}
.map-surface .station[data-depth][aria-current] { border-color: var(--station-ink); box-shadow: 0 0 0 1px var(--station-ink), 0 2px 5px #5e523634; }
.map-surface .station[data-depth="2"][aria-current] { background: var(--station-ink); }
.map-surface .station[data-depth="2"][aria-current] :is(.station-title,.station-gloss) { color: #fffbee; }
.map-surface .station:focus-visible { outline: 2px solid #293e35; outline-offset: 3px; }
.map-surface .compass { color: #5b6455; }
.map-surface .compass i {
  background: conic-gradient(#405e57 0 45deg,#869589 45deg 90deg,#f5edda 90deg 180deg,#a39c87 180deg 270deg,#596f64 270deg);
  filter: drop-shadow(0 1px 1px #65563644);
}
.map-surface .map-legend { color: #5e604f; padding: 4px 7px; border: 1px solid #cfc4aabf; background: #fff9e8eb; }
.map-surface .locate-word, .map-surface .zoom-button {
  background: #fffaf0; color: #425347; border-color: #bdb69e; box-shadow: 0 2px 4px #69573624;
}
.map-surface .locate-word:not(:disabled):hover, .map-surface .zoom-button:not(:disabled):hover { background: #f2e8d6; }
.map-surface .zoom-button:disabled { color: #a09a88; }
.city-directory { border-bottom: 1px solid #e0d7c2; background: #faf7ed; }
:root[data-theme="city"] .city-directory { display:none; }
.city-directory summary {
  align-items: center; display: flex; justify-content: space-between;
  color: #525b49; padding: 10px 17px; font-size: 12px; font-weight: 650; cursor: pointer; list-style: none;
}
.city-directory summary::-webkit-details-marker { display: none; }
.directory-chevron { font-size: 16px; font-weight: 500; line-height: 1; }
.city-directory[open] .directory-chevron { transform: rotate(180deg); }
.directory-links { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 15px 12px; }
.directory-links button {
  padding: 5px 9px; border: 1px solid #d8ceba; background: #fffdf4; color: #536048; border-radius: 5px;
  font-size: 12px; line-height: 1.4;
}
.directory-links button:hover { border-color: #7f8b70; background: #f1f1e3; }
@media (pointer: coarse) {
  .map-surface .zoom-button, .map-surface .locate-word { width: 40px; height: 40px; }
  .directory-links button { min-height: 39px; }
}
.map-surface[data-portrait-city] .compass { transform: rotate(90deg); }
.map-surface[data-portrait-city] .compass span { transform: rotate(-90deg); }

/* Keep the symbol and label in the same keyboard and touch target. */
.map-surface .station[data-depth] {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  justify-items: start;
  column-gap: 5px;
  row-gap: 2px;
  min-height: 46px;
  padding: 5px 6px;
  text-align: left;
  border-radius: 8px;
}
.map-surface .station[hidden] { display: none; }
.map-surface .station[data-depth="0"] { min-height: 51px; }
.map-surface .station[data-depth="0"] .station-title { font-size: 13px; letter-spacing: 0; }
.map-surface .station-title, .map-surface .station-gloss { grid-column: 2; min-width: 0; }
.map-surface .station-gloss { overflow-wrap: anywhere; }
.map-surface .meaning-icon {
  grid-area: 1 / 1 / 3 / 2;
  align-self: center;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 30px;
  border-radius: 9px;
  background: #f0e9d8;
  background: color-mix(in srgb, var(--station-ink) 13%, #fff9e9);
  font: 21px/1 "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
  letter-spacing: -1px;
}
.map-surface .meaning-icon small {
  position: absolute;
  right: -1px;
  bottom: -2px;
  min-width: 13px;
  height: 13px;
  padding: 0 2px;
  border: 1px solid #fff9ed;
  border-radius: 7px;
  background: var(--station-ink);
  color: white;
  font: 700 9px/11px var(--sans);
  text-align: center;
  letter-spacing: 0;
}
.map-surface .station[data-depth="2"] { min-height: 48px; }
.map-surface .station[data-depth="2"] .station-title { font-size: 14px; }
.map-surface .station[data-depth="2"]:is([aria-current],:focus-visible) .meaning-icon { background: #fff5df; }
.map-surface[data-map-small] .station[data-depth="0"],
.map-surface[data-narrow-street] .station[data-depth="2"] {
  grid-template-columns: 23px minmax(0,1fr);
  padding: 4px;
  column-gap: 4px;
}
.map-surface[data-map-small] .station[data-depth="0"] .meaning-icon,
.map-surface[data-narrow-street] .station[data-depth="2"] .meaning-icon {
  width: 23px;
  height: 26px;
  font-size: 17px;
}

.map-surface .meaning-icon.meaning-icon-pair { font-size: 14px; letter-spacing: -2px; }

/* A vocabulary marker reads vertically like a map pin. The complete width
   remains available for the Japanese spelling and its reading below. */
.map-surface .station[data-depth="2"],
.map-surface .station[data-depth="2"]:is([aria-current],:hover),
.map-surface[data-narrow-street] .station[data-depth="2"] {
  --word-plate-top:25px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 1px;
  min-height: 65px;
  padding: 0 3px 3px;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  isolation: isolate;
}
.map-surface .station[data-depth="2"][hidden] { display: none; }
.map-surface .station[data-depth="2"]::before {
  content: "";
  position: absolute;
  inset: var(--word-plate-top) 0 0;
  z-index: -1;
  border-radius: 8px;
  border: 1px solid #baac94;
  background: #fffaf0f7;
  box-shadow: 0 2px 4px #58472b20;
}
.map-surface .station[data-depth="2"][aria-current]::before {
  background: var(--station-ink);
  border-color: var(--station-ink);
}
.map-surface .station[data-depth="2"]:hover::before { border-color: var(--station-ink); }
.map-surface .station[data-depth="2"] .meaning-icon {
  align-self: center;
  width: 33px;
  height: 32px;
  border: 1px solid #bea98f;
  border-radius: 50%;
  background: #fff7e8;
  box-shadow: 0 1px 3px #58472b22;
  font-size: 23px;
}
.map-surface .station[data-depth="2"] .meaning-icon-pair { width: 39px; font-size: 16px; }
.map-surface .station[data-depth="2"] .meaning-icon small { right: -3px; bottom: -1px; }
.map-surface .station[data-depth="2"] .station-title,
.map-surface .station[data-depth="2"] .station-gloss { width: 100%; }

#overview-map { position: absolute; inset: 0; }
.map-panel .panel-heading > div { min-width: 0; }
.map-panel .map-breadcrumb { row-gap: 4px; }
.map-panel .zoom-level { flex: none; }
.map-panel .task-progress { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:8px; }
.map-panel .task-progress .mobile-current { margin:0; }
@media (min-width:761px) {
  .map-panel .task-progress:has(.route-count[hidden]) { display:none; }
  /* Keep the canvas the same size when entering a task or opening its directory. */
  .map-panel .route.task-progress {
    grid-area:surface;
    align-self:end;
    justify-self:start;
    z-index:2;
    margin:0 0 12px 12px;
    padding:4px 8px;
    border:1px solid var(--rule);
    border-radius:5px;
    background:var(--card);
    pointer-events:none;
  }
  .city-directory { position:relative; z-index:3; }
  .city-directory[open] .directory-links {
    position:absolute;
    inset:auto 0 100%;
    max-height:min(30vh, 15rem);
    padding-top:12px;
    background:inherit;
    border-block:1px solid var(--rule);
  }
}
.directory-links { max-height: min(45vh, 24rem); overflow-y: auto; overscroll-behavior: contain; }
.directory-links button[aria-current="location"] { font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }

.map-surface { overflow: clip; }
#map-geography, #atlas-detail, #atlas-names {
  position:absolute; inset:0; width:100%; height:100%; pointer-events:none;
}
#map-geography { overflow:hidden; isolation:isolate; }
#atlas-detail { z-index:2; }
#atlas-names { z-index:3; }
#overview-map[aria-hidden="true"] { pointer-events:none; }
#overview-map[aria-hidden="true"] .compass { visibility:hidden; }
#overview-map [data-station] { opacity:var(--topic-visibility,1) !important; }
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .station {
  grid-template: "title title" auto "icon count" auto / auto auto;
  justify-content:center; align-content:center; column-gap:3px; min-height:43px; text-align:center;
}
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .station-title { grid-area:title; }
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .station-gloss { grid-area:count; }
.map-surface[data-map-theme="city"][data-map-compact] #overview-map .meaning-icon {
  grid-area:icon; justify-self:end; width:16px; height:16px; font-size:14px; background:transparent;
}
#atlas-names .atlas-place-name {
  position:absolute; left:0; top:0; width:max-content; box-sizing:border-box;
  display:flex; flex-direction:column; align-items:center; text-align:center; pointer-events:none;
  padding:2px 3px; gap:2px; color:#352e24; line-height:1.18; text-wrap:balance;
  overflow-wrap:anywhere; text-shadow:0 1px 2px #fff8dc,1px 0 2px #fff8dc,-1px 0 2px #fff8dc;
}
.atlas-place-name b { font-size:var(--place-size); font-weight:750; }
.atlas-place-name:not(.sense) { transform-origin:50% 38%; min-width:min-content; }
.atlas-place-name:not(.sense) b:lang(ko) { word-break:keep-all; }
.atlas-place-name small {
  flex:none; white-space:nowrap; font-size:12px; font-weight:550; line-height:1.25;
  font-variant-numeric:tabular-nums;
}
.atlas-place-name.sense b { font-family:var(--jp-serif,var(--serif,serif)); }
[data-map-theme="space"] #atlas-names .atlas-place-name {
  color:#f0f3ff; text-shadow:0 1px 3px #020912,1px 0 3px #061122,-1px 0 3px #061122;
}
[data-map-theme="space"] .atlas-place-name small { color:#cbdae9; }
/* Buttons keep their generous hit areas. Pointer and keyboard feedback
   follow the projected label as it scales with the map. */
#semantic-map.semantic-camera .semantic-pin > * { visibility:hidden; }
#semantic-map.semantic-camera .semantic-pin:is(:hover,.is-hovered,[aria-current],:focus-visible) {
  border-color:transparent; background:transparent; outline:none;
}
#overview-map .compass { pointer-events:none; }

/* The warm paper shows through the geography. Landmarks and word icons live
   on a separate layer and keep their original contrast at every zoom level. */
[data-map-theme="city"] #map-geography { background:#fffaf0; }
[data-map-theme="city"] #map-canvas { opacity:.58; }
[data-map-theme="city"] #atlas-names .atlas-place-name {
  background:#fffaf0e6;
  border-radius:5px;
  color:#332b24;
  text-shadow:none;
  box-shadow:0 1px 2px #6e58391c;
}
[data-map-theme="city"] #atlas-names .atlas-place-name.sense {
  background:#fffdf7f5;
  box-shadow:0 0 0 1px #a78e676b, 0 2px 4px #5e493322;
}
[data-map-theme="city"] #atlas-names .atlas-place-name small { color:#534b40; }
[data-map-theme="city"] #atlas-names .atlas-place-name.current {
  box-shadow:0 0 0 1.5px #996142, 0 2px 4px #5e493322;
}
[data-map-theme="city"] #atlas-names .atlas-place-name.hovered { background:#ffedce; }
[data-map-theme="space"] #atlas-names .atlas-place-name:is(.hovered,.current) {
  background:#101e32e8; border-radius:5px; box-shadow:0 0 0 1px #87b7d6;
}
#atlas-names .atlas-place-name.keyboard-focus { outline:2px solid currentColor; outline-offset:2px; }
[data-map-theme="city"] #atlas-names .atlas-place-name.root-hub {
  color:#683918; background:#fff0d4; box-shadow:0 0 0 1.5px #a56738;
}
[data-map-theme="space"] #atlas-names .atlas-place-name.root-hub {
  color:#ffe4a8; background:#211e2f; border-radius:5px; box-shadow:0 0 0 1px #cda56d;
}
#atlas-names .root-hub small { font-size:10px; line-height:1; }
.map-breadcrumb .crumb-definition { font-weight:500; }

.map-panel {
  --master-check:#44694e;
  --master-check-shadow:0 1px 2px #fff9e9;
}
:root[data-theme="space"] .map-panel {
  --master-check:#ecd29b;
  --master-check-shadow:0 1px 2px #080e20,0 0 3px #080e20;
}
/* The stem meets the rounded upper-left corner of the word plate. */
[data-map-theme="city"] :is(.station,.atlas-place-name,.semantic-map:not(.semantic-camera) .semantic-pin)[data-mastery="word"]::after {
  --street-sprout:url("data:image/webp;base64,UklGRiYCAABXRUJQVlA4WAoAAAAQAAAAIwAAHAAAQUxQSB4BAAABkLtt2/G36p/Ytu1ksm07k22sST3a7mRzs2138ma7fe7q+z393oiYANLRiIQmGXMO3Li/QQ+h68ynDAAXFVhMvYP2ev3ibsFwq27l72D4u7telV8hPEg6x76HkOuJyCxteO6qJZP1HgKz65DeN6GwVS+h/eN4o7HWAKRcQ3QR4otR/5g9EW0mok4Z3hUSUS1LLtkSkclxGT4mE22G8LQz/ev5UIYnjsbPDPFyC9IOeSDDshA2cC2HhO5HZV978S+frDEmsXH/cwmeMn87PxVO/283dp01mJl/VDqQ3n5N0xctnKoP2M08QcrtH+KdhzKqARaqM7qAt47KqBnoUmfxCvvV0Xa8NlY3DgSpK2OUqIsHWtTFMHepM9lyxksGVlA4IOIAAACQBgCdASokAB0APj0aiEMiIaEarAYAIAPEsgBajcwATGqcAbgG2AuwDeSgIN7XAyi48p4KNPj5r+yJmWpAAP72A6M5xvTCqygaZbRi9zvuKbbUFufcEshBpZ+vPB8pis09/fzM4Kspl+dD88z5Ovfl+bMG/45nWwxg7d6SgWMNW6AKjfQL4pTwimJSwJyk1Uu2zIf+5/+sa+vtAstLrYEybfFcC//6Tw4d0oAB5DnBs9SjB7NO14z/5bx+iawjP/c31a2mTr8hIWBr1kok/n/p4kNY5wvyjn8kY4DhRgkAAAAA");
  content:""; position:absolute; pointer-events:none;
  width:9px; height:7px;
  inset-inline-start:-3px; inset-block-start:calc(var(--word-plate-top, 0px) - 5px);
  background:var(--street-sprout-paint, var(--street-sprout)) center / contain no-repeat;
}
/* The category check follows both the name and the count as the map zooms. */
.map-panel :is(.station,.atlas-place-name,.directory-links button)[data-mastery|="category"]::after,
.semantic-map:not(.semantic-camera) .semantic-pin[data-mastery|="category"]::after {
  content:"✓"; content:"✓" / "";
  position:absolute; pointer-events:none;
  inset-inline-start:50%; inset-block-start:calc(100% + 1px); transform:translateX(-50%);
  color:var(--master-check); text-shadow:var(--master-check-shadow);
  font:700 12px/1 system-ui,sans-serif; letter-spacing:0;
}
.map-panel .directory-links button[data-mastery|="category"] { position:relative; padding-block-end:15px; }
.map-panel .directory-links button[data-mastery|="category"]::after { inset-block-start:auto; inset-block-end:1px; }
@media (forced-colors:active) {
  #semantic-map.semantic-camera .semantic-pin { forced-color-adjust:none; }
  #atlas-names .atlas-place-name.keyboard-focus { outline-color:Highlight; }
  .map-panel, :root[data-theme="space"] .map-panel {
    --master-check:CanvasText; --master-check-shadow:none;
  }
  [data-map-theme="city"] [data-mastery="word"]::after {
    --street-sprout-paint:CanvasText;
    forced-color-adjust:none;
    -webkit-mask:var(--street-sprout) center / contain no-repeat;
    mask:var(--street-sprout) center / contain no-repeat;
  }
}
