* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #1f1a35;
  --panel: #2b2448;
  --panel-2: #382f5d;
  --ink: #f8f2ff;
  --muted: #cfc2ef;
  --line: rgba(191, 162, 255, .34);
  --violet: #bfa2ff;
  --gold: #f4d878;
  --mint: #87efc0;
  --red: #ff8c8c;
}
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    linear-gradient(145deg, #1f1a35, #2a2347 52%, #17181f 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { font: inherit; }
.shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 30px; }
.topbar, .meta, .controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar { justify-content: space-between; min-height: 56px; margin-bottom: 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 22px; font-weight: 900; text-decoration: none; }
.brand span { display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid var(--violet); border-radius: 8px; background: #171225; color: var(--violet); }
.meta span { min-height: 36px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: rgba(0, 0, 0, .22); font-weight: 850; }
.layout { display: grid; grid-template-columns: minmax(0, 700px) minmax(320px, 430px); gap: 18px; align-items: start; }
.map-panel, .ledger { border: 1px solid var(--line); border-radius: 8px; background: rgba(43, 36, 72, .9); box-shadow: 0 24px 70px rgba(0, 0, 0, .35); padding: clamp(18px, 3vw, 28px); }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(34px, 7vw, 62px); line-height: .95; }
h2 { font-size: clamp(24px, 4vw, 38px); line-height: 1; }
h3 { margin: 18px 0 8px; color: var(--gold); font-size: 14px; text-transform: uppercase; }
.bridge-map {
  --cols: 5;
  --rows: 5;
  position: relative;
  width: min(100%, 650px);
  aspect-ratio: var(--cols) / var(--rows);
  margin-top: 22px;
  border: 1px solid rgba(248, 242, 255, .16);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(rgba(248,242,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(248,242,255,.07) 1px, transparent 1px),
    rgba(255,255,255,.035);
  background-size: calc(100% / var(--cols)) calc(100% / var(--rows));
}
.bridges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.bridges line { stroke: var(--gold); stroke-width: .08; stroke-linecap: round; filter: drop-shadow(0 0 .05rem rgba(244,216,120,.55)); }
.island {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  width: clamp(46px, 9vw, 64px);
  height: clamp(46px, 9vw, 64px);
  place-items: center;
  border: 2px solid rgba(248, 242, 255, .7);
  border-radius: 999px;
  background: var(--violet);
  color: #171225;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
}
.island small { margin-top: -8px; font-size: 10px; font-weight: 900; }
.island.selected { outline: 3px solid var(--mint); outline-offset: 3px; }
.island:hover, .island:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.island-list, .bridge-list { display: grid; gap: 8px; }
.island-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bridge-list { max-height: 220px; overflow: auto; padding-right: 2px; }
.island-list span, .bridge-list button, .rule-list li {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
  font-weight: 850;
}
.bridge-list button { width: 100%; cursor: pointer; }
.bridge-list button.active { color: var(--gold); border-color: rgba(244, 216, 120, .65); background: rgba(244, 216, 120, .12); }
.island-list .ok, .rule-list .ok { color: var(--mint); border-color: rgba(135, 239, 192, .55); }
.island-list .bad, .rule-list .bad { color: var(--red); border-color: rgba(255, 140, 140, .6); }
.rule-list { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.controls button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #171225;
  background: var(--violet);
  font-weight: 900;
  cursor: pointer;
}
.controls button:nth-child(2) { background: #f0e8ff; }
#undo-button { background: var(--gold); }
#submit-button { background: var(--mint); }
.status { min-height: 48px; color: #fffaff; font-weight: 760; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .shell { width: min(100% - 18px, 720px); }
  .island-list { grid-template-columns: 1fr; }
}
