.level-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.level-head h1 { margin: 0; }
.level-head .num { color: var(--muted); font-weight: 600; font-size: .95rem; }
.progress { display: flex; gap: 6px; flex-wrap: wrap; }
.progress button {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper);
  font: inherit; font-size: .8rem; font-weight: 700; color: var(--muted); cursor: pointer;
}
.progress button.done { background: var(--good); border-color: var(--good); color: #fff; }
.progress button.current { border-color: var(--accent); color: var(--accent); }
.progress button.done.current { background: var(--accent); border-color: var(--accent); color: #fff; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.map-panel { display: flex; flex-direction: column; gap: 14px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.dot.P { background: var(--purple); }
.dot.O { background: var(--orange); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
.swatch.water { background: #a9d3ec; }

.grid-wrap { display: flex; justify-content: center; }
.grid { width: min(100%, 600px); touch-action: none; user-select: none; -webkit-user-select: none; }
.grid svg.map { display: block; width: 100%; height: auto; overflow: visible; }
.map polygon.cell { cursor: crosshair; transition: fill .08s ease; }
.map polygon.cell.water { cursor: not-allowed; }
.map polygon.cell:hover:not(.water) { filter: brightness(.95); }
.map .edges line { pointer-events: none; stroke-linecap: round; }
.map .edges line.same { stroke: rgba(29,36,51,.12); stroke-width: 1.5; }
.map .edges line.border { stroke: #1d2433; stroke-width: 4; }
.map .edges line.shore { stroke: rgba(29,36,51,.45); stroke-width: 2.5; }
.map .edges line.outer { stroke: #1d2433; stroke-width: 6; }
.map .marks * { pointer-events: none; }
.map .voter { stroke: rgba(0,0,0,.18); stroke-width: 2; }
.map .voter.P { fill: var(--purple); }
.map .voter.O { fill: var(--orange); }
.map .voter.bad { stroke: var(--bad); stroke-width: 4; stroke-dasharray: 6 5; }
.map text.place { font-size: 15px; font-weight: 700; fill: #3b4253; text-anchor: middle; letter-spacing: .02em; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 4px; }
.map text.mark { font-size: 22px; text-anchor: middle; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .btn { padding: 8px 12px; font-size: .95rem; }

.palette { display: flex; gap: 8px; flex-wrap: wrap; }
.palette button {
  width: 46px; height: 46px; border-radius: 10px; border: 2px solid rgba(0,0,0,.12);
  font: inherit; font-weight: 700; cursor: pointer; color: #1d2433; position: relative;
}
.palette button.active { border-color: #1d2433; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #1d2433; }
.palette button.eraser { background: var(--paper); }
.palette button .full { position: absolute; right: 3px; bottom: 1px; font-size: 10px; color: var(--good); }

.dcards { display: flex; flex-direction: column; gap: 6px; }
.dcard {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: .92rem;
}
.dcard .chip { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(0,0,0,.12); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.dcard .meta { display: flex; flex-direction: column; gap: 2px; }
.dcard .meta .line { display: flex; gap: 8px; align-items: center; }
.dcard .bar { height: 8px; border-radius: 4px; background: var(--orange); overflow: hidden; width: 100%; max-width: 160px; }
.dcard .bar i { display: block; height: 100%; background: var(--purple); }
.dcard .warn { color: var(--bad); font-size: .8rem; font-weight: 600; }
.dcard.empty { opacity: .5; }

.score .big { font-size: 1.4rem; font-weight: 700; }
.seatbar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin: 6px 0 2px; }
.seatbar div { display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .9rem; transition: width .25s ease; }
.seatbar .P { background: var(--purple); }
.seatbar .O { background: var(--orange); }
.seatbar .T { background: #9aa3b2; }
.seatbar .none { background: #e9e8e3; color: var(--muted); }
.votebar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; }
.votebar .P { background: var(--purple); }
.votebar .O { background: var(--orange); }
.stat { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: .95rem; }
.stat:first-of-type { border-top: 0; }
.stat b { text-align: right; }

.goals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.goals li { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.goals li .tick { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px; display: grid; place-items: center; font-size: .8rem; font-weight: 800; background: #eef1f7; color: var(--muted); }
.goals li.met .tick { background: var(--good); color: #fff; }
.goals li.met { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }

dialog { border: 0; border-radius: 16px; padding: 0; max-width: 620px; width: calc(100% - 32px); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,24,33,.55); backdrop-filter: blur(2px); }
dialog .inner { padding: 26px 28px; }
dialog h2 { font-size: 1.6rem; }
dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
dialog.success .inner { border-top: 8px solid var(--good); }
dialog .result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
dialog .result div { background: #f4f5f8; border-radius: 10px; padding: 10px 12px; }
dialog .result b { display: block; font-size: 1.3rem; }
dialog .result span { font-size: .85rem; color: var(--muted); }

.levels-list { display: grid; gap: 8px; }
.levels-list button { display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font: inherit; cursor: pointer; }
.levels-list button:hover { background: #fafaf8; }
.levels-list .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #eef1f7; color: var(--muted); font-size: .85rem; flex: 0 0 28px; }
.levels-list .done .n { background: var(--good); color: #fff; }

.hintbox { display: none; }
.hintbox.show { display: block; }

@keyframes pop { 0% { transform: scale(.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
dialog[open] { animation: pop .18s ease-out; }
