:root {
  --teal: #0d7a6f;
  --teal-dark: #095e56;
  --ink: #1a2b28;
  --muted: #5f716d;
  --faint: #9fb0ac;
  --bg: #f4f8f7;
  --card: #ffffff;
  --line: #e3ecea;
  --danger: #b3261e;
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.25rem; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.1rem; }
.brand em { font-style: normal; font-weight: 600; font-size: 0.7rem; color: var(--teal);
  border: 1.5px solid var(--teal); border-radius: 999px; padding: 0.1rem 0.55rem; margin-left: 0.25rem; vertical-align: middle; }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.topbar nav a:hover { color: var(--teal); }
#view { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.foot { text-align: center; color: var(--faint); font-size: 0.8rem; padding: 1.25rem; border-top: 1px solid var(--line); background: var(--card); }

/* ---------- map ---------- */
.hero { text-align: center; margin: 0.5rem 0 1.75rem; }
.hero h1 { font-size: 2rem; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin-top: 0.5rem; font-size: 1.02rem; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.room-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; border-top: 5px solid var(--accent, var(--teal));
  display: flex; flex-direction: column; gap: 0.6rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.room-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.07); }
.room-card h2 { font-size: 1.25rem; }
.room-icon { line-height: 0; margin-bottom: 0.15rem; }
.room-card .tag { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent, var(--teal)); }
.room-card p.desc { color: var(--muted); font-size: 0.92rem; line-height: 1.5; flex: 1; }
.room-card .meta { font-size: 0.82rem; color: var(--faint); }
.room-actions { display: flex; gap: 0.6rem; margin-top: 0.35rem; }
.btn {
  appearance: none; border: 1.5px solid var(--teal); background: var(--teal); color: #fff;
  border-radius: 10px; padding: 0.55rem 1rem; font-size: 0.92rem; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.ghost { background: transparent; color: var(--teal); }
.btn.ghost:hover { background: rgba(13,122,111,0.08); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- room ---------- */
.room-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.room-head h1 { font-size: 1.7rem; }
.room-head .tag { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent, var(--teal)); }
.room-head .spacer { flex: 1; }
.backlink { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.backlink:hover { color: var(--teal); }
.room-svg-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.room-svg-wrap svg { display: block; width: 100%; height: auto; }
.locus { cursor: pointer; }
.locus .pin { transition: transform 0.12s ease; transform-box: fill-box; transform-origin: center; }
.locus:hover .pin { transform: scale(1.15); }
.locus text { font-size: 15px; font-weight: 700; pointer-events: none; }
.locus .lbl { font-size: 13px; font-weight: 600; fill: var(--muted); pointer-events: none; }
.legend { display: flex; gap: 1.25rem; margin-top: 0.75rem; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 0.35rem; vertical-align: baseline; }

/* ---------- modal / locus panel ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,43,40,0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0;
}
@media (min-width: 720px) { .modal-backdrop { align-items: center; padding: 2rem; } }
.modal {
  background: var(--card); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto; padding: 1.5rem;
}
@media (min-width: 720px) { .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.25rem; }
.modal-head h2 { font-size: 1.45rem; flex: 1; }
.modal-head .x { background: none; border: none; font-size: 1.4rem; color: var(--faint); cursor: pointer; line-height: 1; padding: 0.2rem; }
.modal-head .x:hover { color: var(--ink); }
.drug-class { color: var(--teal); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.9rem; }
.fact { margin-bottom: 0.8rem; }
.fact h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); margin-bottom: 0.25rem; }
.fact p, .fact li { font-size: 0.96rem; line-height: 1.55; }
.fact ul { padding-left: 1.15rem; }
.blackbox { background: #fdf0ef; border: 1px solid #f3c1bd; border-radius: 10px; padding: 0.75rem 0.9rem; }
.blackbox h3 { color: var(--danger); }
.mnemonic { background: #f0f7f6; border-left: 4px solid var(--teal); border-radius: 0 10px 10px 0; padding: 0.75rem 0.9rem; font-style: italic; }
.hook-area { margin-top: 1.1rem; }
.hook-area label { display: block; font-weight: 700; margin-bottom: 0.4rem; font-size: 0.95rem; }
.hook-area textarea {
  width: 100%; min-height: 84px; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 0.7rem; font: inherit; font-size: 0.95rem; resize: vertical;
}
.hook-area textarea:focus { outline: none; border-color: var(--teal); }
.row { display: flex; gap: 0.6rem; margin-top: 0.8rem; flex-wrap: wrap; }
.drug-search { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; font: inherit; margin-bottom: 0.6rem; }
.drug-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.35rem; }
.drug-opt { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; cursor: pointer; font: inherit; }
.drug-opt:hover { border-color: var(--teal); }
.drug-opt strong { display: block; }
.drug-opt span { font-size: 0.82rem; color: var(--muted); }

/* ---------- walk mode ---------- */
.walk { max-width: 640px; margin: 0 auto; }
.walk-progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 1.25rem; }
.walk-progress i { display: block; height: 100%; background: var(--accent, var(--teal)); transition: width 0.25s ease; }
.walk-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center; border-top: 5px solid var(--accent, var(--teal)); }
.walk-card .step { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--faint); }
.walk-card h2 { font-size: 1.6rem; margin: 0.6rem 0 0.4rem; }
.walk-card .prompt { color: var(--muted); margin-bottom: 1.25rem; }
.walk-answer { background: var(--bg); border-radius: 10px; padding: 1.1rem; margin-bottom: 1.25rem; text-align: left; }
.walk-answer h3 { font-size: 1.25rem; margin-bottom: 0.3rem; }
.walk-answer .cls { color: var(--teal); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.walk-answer .hook { margin-top: 0.7rem; font-style: italic; color: var(--muted); border-left: 3px solid var(--teal); padding-left: 0.7rem; }
.grade-row { display: flex; gap: 0.75rem; justify-content: center; }
.btn.good { background: #1d7a4f; border-color: #1d7a4f; }
.btn.bad { background: transparent; color: var(--danger); border-color: var(--danger); }
.walk-done { text-align: center; }
.walk-done h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.walk-done .score { font-size: 3rem; font-weight: 800; color: var(--teal); margin: 1rem 0; }
.walk-done p { color: var(--muted); margin-bottom: 1.5rem; }
.hidden { display: none !important; }

/* ---------- game ---------- */
.game-wrap {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: #e7efe8;
}
#game { display: block; touch-action: none; cursor: crosshair; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.8rem; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
#hud-loc {
  background: rgba(255,255,255,0.94); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.35rem 0.9rem;
  font-weight: 700; font-size: 0.9rem;
}
.hud-btns { display: flex; gap: 0.5rem; }
.btn.sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; border-radius: 8px; }
#hud-act {
  position: absolute; bottom: 3.4rem; left: 50%; transform: translateX(-50%);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18); white-space: nowrap;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }
.hint {
  position: absolute; bottom: 0.55rem; left: 0; right: 0; text-align: center;
  font-size: 0.78rem; color: var(--muted); pointer-events: none;
  text-shadow: 0 1px 0 rgba(255,255,255,0.7);
}
.toast {
  position: absolute; bottom: 5.6rem; left: 50%; transform: translateX(-50%);
  background: rgba(26,43,40,0.92); color: #fff; border-radius: 10px;
  padding: 0.6rem 1rem; font-size: 0.88rem; white-space: nowrap;
  max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
