:root {
  --bg: #05070f;
  --bg2: #0c111f;
  --ink: #eef1fb;
  --muted: #8790ad;
  --line: #1e2640;
  --gold: #ffd98a;
  --ice: #9fd8ff;
  --bad: #ff8a8a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--ink); font-family: 'Gowun Dodum', system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }

#sky { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; cursor: grab; }
#sky.dragging { cursor: grabbing; }
#sky.pointing { cursor: pointer; }

.top {
  position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.mark {
  font: 700 12px 'IBM Plex Mono', monospace; background: var(--ink); color: var(--bg);
  border-radius: 5px; padding: 3px 6px; letter-spacing: .04em;
}
.top-right { display: flex; align-items: center; gap: 14px; }
.me { color: var(--muted); font-size: 14px; }
.me b { color: var(--gold); font: 500 15px 'IBM Plex Mono', monospace; margin-left: 4px; }
.icon-btn, .text-btn { background: none; border: none; padding: 4px; opacity: .85; }
.icon-btn:hover, .text-btn:hover { opacity: 1; }
.text-btn { font-size: 16px; }

.dots {
  position: fixed; left: 50%; bottom: max(36px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: clamp(18px, 4.2vw, 56px); align-items: center;
}
.dot { position: relative; width: 22px; height: 22px; border: none; background: none; padding: 0; display: grid; place-items: center; }
.dot::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .35); transition: all .3s; }
.dot.partial::before { background: rgba(255, 255, 255, .7); }
.dot.linkable::before { background: var(--ice); box-shadow: 0 0 10px var(--ice); }
.dot.done::before { background: #fff; box-shadow: 0 0 8px #fff, 0 0 18px rgba(255, 217, 138, .8); width: 11px; height: 11px; }
.dot.boss::before { background: none; border: 1px dashed rgba(255, 255, 255, .35); }
.dot.boss.open::before { border: none; background: var(--ice); box-shadow: 0 0 12px var(--ice); animation: pulse 2s infinite; }
.dot.boss.done::before { background: #fff; box-shadow: 0 0 10px #fff, 0 0 22px var(--ice); animation: none; }
.dot:hover::before, .dot:focus-visible::before { transform: scale(1.35); }
.dot:focus-visible { outline: none; }

.tip {
  position: fixed; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 14px));
  background: rgba(12, 17, 31, .92); border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px;
  font-size: 13px; white-space: nowrap;
}
.tip small { display: block; color: var(--muted); font: 500 11px 'IBM Plex Mono', monospace; margin-top: 2px; }

.hint {
  position: fixed; left: 50%; bottom: max(76px, calc(env(safe-area-inset-bottom) + 40px)); transform: translateX(-50%);
  margin: 0; font-size: 13px; color: var(--muted); text-align: center; width: max-content; max-width: calc(100vw - 32px);
  pointer-events: none;
}

@keyframes pulse { 50% { opacity: .4; } }

/* dialogs */
.dlg {
  border: 1px solid var(--line); border-radius: 16px; background: rgba(12, 17, 31, .96); color: var(--ink);
  width: min(480px, calc(100vw - 32px)); padding: 22px;
}
.dlg.wide-dlg { width: min(640px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(2, 3, 8, .6); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dlg-head h3 { margin: 0; flex: 1; font-size: 18px; font-weight: 400; }
.x { background: none; border: none; font-size: 24px; color: var(--muted); line-height: 1; padding: 0 4px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.gudegi { border-color: #c58cff; color: #d8b4ff; }
.tag.boss { border-color: var(--ice); color: var(--ice); }
.question { font-size: 17px; line-height: 1.7; margin: 8px 0 18px; white-space: pre-wrap; }
.answer-row { display: flex; gap: 8px; }
input {
  flex: 1; width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: 16px 'IBM Plex Mono', monospace;
}
input:focus { outline: 2px solid var(--ice); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin: 10px 0; }
label input { font-family: 'Gowun Dodum', sans-serif; }
.primary { background: var(--ink); color: var(--bg); border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; }
.primary:hover { background: #fff; }
.primary:disabled { opacity: .5; cursor: default; }
.primary.wide { width: 100%; margin-top: 12px; }
.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; }
.msg.bad { color: var(--bad); }
.msg.good { color: var(--gold); }
.muted { color: var(--muted); font-size: 13px; }
.story p { line-height: 1.8; margin: 0 0 10px; }
.howto { margin: 4px 0 12px; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.howto b { color: var(--ink); font-weight: 400; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.tabs button.on { border-color: var(--ink); }
.rank-scroll { max-height: 60vh; overflow: auto; }
table.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank th { text-align: left; color: var(--muted); font-weight: 400; padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg2); }
.rank td { padding: 8px; border-bottom: 1px solid rgba(30, 38, 64, .6); }
.rank td.num { font-family: 'IBM Plex Mono', monospace; text-align: right; }
.rank tr.mine td { color: var(--gold); }
.rank .empty { color: var(--muted); text-align: center; padding: 24px; }

.toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -10px); opacity: 0;
  background: rgba(12, 17, 31, .92); border: 1px solid rgba(255, 217, 138, .5); color: var(--gold); padding: 10px 18px; border-radius: 999px;
  transition: all .3s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(255, 138, 138, .5); color: var(--bad); }

@media (max-width: 600px) {
  .top { padding: 14px 16px; }
  .brand { font-size: 16px; }
  #me-name { display: none; }
  .dots { gap: 14px; bottom: max(24px, env(safe-area-inset-bottom)); }
  .hint { bottom: max(60px, calc(env(safe-area-inset-bottom) + 36px)); font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
