:root {
  --bg: #12131a;
  --panel: #1b1d27;
  --line: #2a2d3a;
  --light: #c9b892;
  --dark: #6d5c43;
  --accent: #e0b877;
  --move: #4fd18b;
  --capture: #e05c5c;
  --sel: #6cb4f5;
  --text: #e6e6ea;
  --muted: #8b8fa3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
}

header {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 16px; z-index: 20;
}

h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .2px; }
h1 small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }

#status { flex: 1; font-size: 14px; color: var(--muted); }
#status b { color: var(--accent); }
#status .warn { color: var(--capture); }

button {
  background: #262a38; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 13px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
button:hover:not(:disabled) { background: #303648; border-color: #3d4457; }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: #2b6b47; border-color: #38875a; }
button.primary:hover:not(:disabled) { background: #358255; }

#viewport {
  position: fixed; inset: 56px 0 0 0; overflow: auto; padding: 28px;
}

#field { display: inline-block; min-width: 100%; }

.timeline {
  display: flex; align-items: center; gap: 22px; margin-bottom: 22px;
}

.tl-label {
  width: 76px; flex: none; font-size: 12px; color: var(--muted);
  text-align: right; line-height: 1.4;
}
.tl-label b { display: block; color: var(--text); font-size: 14px; }

.board-wrap { position: relative; }

.board-caption {
  font-size: 11px; color: var(--muted); margin-bottom: 4px; text-align: center;
}

.board {
  display: grid; grid-template-columns: repeat(8, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
  border: 2px solid #333747; border-radius: 4px; overflow: hidden;
  --cell: 34px;
}
.board.playable { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,184,119,.18); }
.board.done { opacity: .55; }
.board.past { opacity: .5; }

.sq {
  width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .72); line-height: 1; cursor: default;
  position: relative; user-select: none;
}
.sq.l { background: var(--light); }
.sq.d { background: var(--dark); }
.sq.pick { cursor: pointer; }
.sq.sel { box-shadow: inset 0 0 0 3px var(--sel); }
.sq.move::after {
  content: ''; position: absolute; width: 30%; height: 30%;
  border-radius: 50%; background: var(--move); opacity: .85;
}
.sq.cap { box-shadow: inset 0 0 0 3px var(--capture); cursor: pointer; }
.sq .p { line-height: 1; }
.sq .p.w {
  color: #fbf7ef;
  text-shadow: 0 0 1px #1a1a1a, 0 0 2px #1a1a1a, 1px 1px 0 #22252e, -1px -1px 0 #22252e,
               1px -1px 0 #22252e, -1px 1px 0 #22252e;
}
.sq .p.b {
  color: #14161d;
  text-shadow: 0 0 1px #d8d2c4, 1px 1px 0 rgba(240,236,226,.75), -1px -1px 0 rgba(240,236,226,.75),
               1px -1px 0 rgba(240,236,226,.75), -1px 1px 0 rgba(240,236,226,.75);
}

#rules {
  position: fixed; inset: 0; background: rgba(8,9,13,.88); z-index: 30;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
#rules.on { display: flex; }
#rules .box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  max-width: 620px; max-height: 84vh; overflow: auto; padding: 26px 30px;
  line-height: 1.6; font-size: 14px;
}
#rules h2 { margin-top: 0; font-size: 18px; }
#rules h3 { font-size: 14px; color: var(--accent); margin: 20px 0 6px; }
#rules code { background: #262a38; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
#rules ul { padding-left: 20px; margin: 6px 0; }
