:root {
  --bg: #F4F3EE; --surface: #FFFFFF; --surface2: #FAF9F5; --line: #DAD8CF; --line2: #B4B2A9;
  --text: #2C2C2A; --text2: #5F5E5A; --muted: #888780; --accent: #185FA5; --accentbg: #E6F1FB;
  --land: #EDEBE4; --road: #FFFFFF; --roadline: #D3D1C7; --water: #B5D4F4; --park: #C0DD97; --rail: #888780;
  --food: #F5C4B3; --food-s: #993C1D; --food-t: #712B13;
  --retail: #FAC775; --retail-s: #854F0B; --retail-t: #633806;
  --service: #9FE1CB; --service-s: #0F6E56; --service-t: #085041;
  --vacant: #D3D1C7; --vacant-s: #5F5E5A; --vacant-t: #444441;
  --enter: #CECBF6; --enter-s: #534AB7; --enter-t: #3C3489;
  --other: #E6E4DC; --other-s: #888780; --other-t: #444441;
  --badge: #D85A30; --hl: #185FA5;
  --radius: 6px;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E1E1C; --surface: #2A2A28; --surface2: #252523; --line: #3D3D3A; --line2: #5F5E5A;
    --text: #EEEDE8; --text2: #B4B2A9; --muted: #888780; --accent: #85B7EB; --accentbg: #0C447C;
    --land: #2C2C2A; --road: #444441; --roadline: #3D3D3A; --water: #0C447C; --park: #27500A; --rail: #888780;
    --food: #712B13; --food-s: #F0997B; --food-t: #FAECE7;
    --retail: #633806; --retail-s: #EF9F27; --retail-t: #FAEEDA;
    --service: #085041; --service-s: #5DCAA5; --service-t: #E1F5EE;
    --vacant: #444441; --vacant-s: #888780; --vacant-t: #D3D1C7;
    --enter: #3C3489; --enter-s: #AFA9EC; --enter-t: #EEEDFE;
    --other: #3A3A37; --other-s: #888780; --other-t: #D3D1C7;
    --badge: #F0997B; --hl: #85B7EB;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
body { display: flex; flex-direction: column; }
button { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line2); border-radius: var(--radius); padding: 4px 10px; cursor: pointer; }
button:hover { background: var(--surface2); }
button:disabled { color: var(--muted); cursor: default; }
button.on { border-color: var(--accent); background: var(--accentbg); color: var(--accent); }
a, .link { color: var(--accent); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

#top { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 16px; }
#slots { display: flex; gap: 4px; flex-wrap: wrap; }
.spacer { flex: 1; }
#mysteryBtn { border-color: var(--enter-s); color: var(--enter-s); }
#guideBtn { border-color: var(--service-s); color: var(--service-s); margin-left: 8px; }
.guide h3 { font-size: 15px; color: var(--text); margin: 20px 0 6px; }
.guide p { margin: 0 0 10px; }
.guide .lead { color: var(--text2); }

main { flex: 1; min-height: 0; display: flex; }
#mapwrap { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 8px; gap: 6px; }
#legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text2); }
#legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; background: var(--c); border: 1px solid var(--s); }
#viewport { position: relative; flex: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--land); cursor: grab; touch-action: none; user-select: none; }
#viewport.drag { cursor: grabbing; }
#map { position: absolute; left: 0; top: 0; }
#map .b { cursor: pointer; }
#map .b rect { stroke-width: 1; }
#map .b:hover rect { stroke-width: 2; }
#map .b.sel rect, #map .b.hl rect { stroke: var(--hl); stroke-width: 3; }
#map text { font-size: 12px; pointer-events: none; }
#map text.v { font-size: 11px; writing-mode: vertical-rl; }
#map .lbl { fill: var(--text2); font-size: 13px; }
#map .dname { fill: var(--text2); font-size: 28px; font-weight: 600; opacity: .55; pointer-events: none; }
#map .grp { fill: var(--road); stroke: var(--line2); stroke-width: 1; }
#map .grptext { fill: var(--text2); font-size: 11px; }
#map .badge circle { fill: var(--badge); }
#map .badge text { fill: #FFFFFF; font-size: 11px; font-weight: 600; text-anchor: middle; }
#map .link-line { stroke: var(--hl); stroke-width: 2; stroke-dasharray: 6 4; fill: none; pointer-events: none; }
#outsideBtn { position: absolute; top: 8px; right: 8px; z-index: 6; font-size: 12px; }
#minimap { position: absolute; right: 8px; bottom: 8px; z-index: 6; background: var(--surface); border: 1px solid var(--line2); border-radius: 6px; cursor: pointer; }
#minimap .frame { fill: none; stroke: var(--badge); stroke-width: 2; vector-effect: non-scaling-stroke; }

#panel { width: 380px; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
#panelbar { padding: 8px 12px; border-bottom: 1px solid var(--line); }
#detail { padding: 12px 16px 24px; overflow: auto; flex: 1; line-height: 1.7; }
#detail h2 { font-size: 18px; margin: 0 0 2px; }
#detail h3 { font-size: 13px; color: var(--text2); margin: 16px 0 6px; font-weight: 600; }
#detail p { margin: 4px 0; }
.kana { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: var(--radius); background: var(--surface2); border: 1px solid var(--line); color: var(--text2); margin: 2px 4px 2px 0; }
.sub { color: var(--text2); font-size: 13px; }
.floors { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.unit { text-align: left; padding: 8px; border-radius: var(--radius); line-height: 1.4; }
.unit b { display: block; font-weight: 600; }
.unit small { color: var(--text2); }
.unit.vacant { background: var(--vacant); color: var(--vacant-t); border-color: var(--vacant-s); }
.unit.sel { border: 2px solid var(--accent); }
.unitdetail { margin-top: 10px; padding: 10px; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 3px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
.day td { padding: 3px 8px 3px 0; vertical-align: top; }
.day td:first-child { color: var(--text2); white-space: nowrap; }
.day tr.now td { font-weight: 600; }
details.secret { margin-top: 14px; border: 1px dashed var(--enter-s); border-radius: var(--radius); padding: 6px 10px; }
details.secret summary { cursor: pointer; color: var(--enter-s); }
.empty { color: var(--muted); }
.card { border: 1px solid var(--enter-s); background: var(--surface2); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.card .ct { font-size: 12px; color: var(--enter-s); font-weight: 600; }
.card.clue { border-style: dashed; }

[hidden] { display: none !important; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
#modalBox { background: var(--surface); width: min(640px, 92vw); max-height: 86vh; overflow: auto; border-radius: 12px; padding: 18px 20px; line-height: 1.7; }
#modalBox h2 { margin: 0 0 6px; font-size: 18px; }
.mtabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.answer { display: flex; gap: 6px; margin-top: 8px; position: relative; }
.answer input { flex: 1; padding: 6px 10px; border: 1px solid var(--line2); border-radius: var(--radius); background: var(--surface2); color: var(--text); font: inherit; }
.msg { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius); background: var(--surface2); }
.msg.ok { border: 1px solid var(--service-s); }
.msg.ng { border: 1px solid var(--food-s); }
.ending { white-space: pre-wrap; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #mapwrap { flex: 0 0 56%; min-height: 0; padding-bottom: 4px; }
  #minimap { width: 140px; height: auto; }
  #panel { flex: 1; min-height: 0; width: auto; border-left: 0; border-top: 1px solid var(--line); }
  #panelbar { padding: 4px 12px; }
}
.when { border: 1px solid var(--line2); background: var(--surface2); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.when .ct { font-size: 12px; color: var(--text2); }
.when b { font-size: 20px; }
