/* Logic Grid — Playnesta shell stylesheet (MIT).
   No fonts, images or network assets: the swatches are plain colours and the
   pet/drink glyphs are the reader's own emoji font. */

:root {
  --bg: #141b26;
  --bg-2: #1b2431;
  --bg-3: #223040;
  --line: #2f3d4f;
  --ink: #e7eef7;
  --ink-2: #9fb0c4;
  --ink-3: #6d7f94;
  --accent: #f0b429;
  --yes: #4ec98a;
  --no: #7c8ba0;
  --bad: #ef6b6b;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; }

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: calc(var(--pn-vh, 1vh) * 100);
  min-height: 0;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  min-height: 32px;
}
.title { font-size: 14px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.title small { color: var(--ink-3); font-weight: 500; margin-left: 4px; font-size: 11px; }
.spacer { flex: 1 1 auto; }
.hud { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.hud b { color: var(--ink); font-variant-numeric: tabular-nums; }
.hud .opt { color: var(--ink-3); }

/* ------------------------------------------------------------------ main */
#main {
  flex: 1 1 auto;
  display: flex;
  gap: 8px;
  padding: 8px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.panel-head .count { color: var(--accent); font-weight: 700; }

.clue-list {
  margin: 0;
  padding: 6px 6px 10px 26px;
  list-style: decimal;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  font-size: 12px;
}
.clue {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px 2px;
  border-radius: 6px;
  cursor: pointer;
}
.clue:hover { background: var(--bg-3); }
.clue.on { background: #2b3b4e; box-shadow: inset 0 0 0 1px var(--accent); }
.clue::marker { color: var(--ink-3); font-size: 11px; }
.rel { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-2); font-size: 11px; }
.rel em { font-style: normal; color: var(--accent); font-weight: 700; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
}
.chip b { font-weight: 600; }
.chip .swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip .glyph { font-style: normal; font-size: 12px; line-height: 1; }

/* ---------------------------------------------------------------- grids */
#grids {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.board {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 6px 6px;
}
.board.done { border-color: var(--yes); }
.board-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-3);
  margin-bottom: 3px;
}

.grid {
  display: grid;
  grid-template-columns: 18px repeat(var(--n), minmax(0, 1fr));
  gap: 2px;
}
.grid .corner { font-size: 9px; color: var(--ink-3); display: flex; align-items: center; justify-content: center; }
.head-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  overflow: hidden;
}
.head-cell .chip { padding: 0 3px; border: none; background: transparent; font-size: 10px; gap: 2px; }
.head-cell .chip b { font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.head-cell .chip .glyph { font-size: 12px; }
.head-cell .chip .swatch { width: 9px; height: 9px; }

.house-num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.cell {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-3);
  border-radius: 5px;
  min-height: 24px;
  min-width: 22px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .08s ease, border-color .08s ease, color .08s ease;
  touch-action: manipulation;
}
.cell:hover { border-color: var(--ink-3); }
.cell[data-state="no"] { color: var(--no); background: #172130; }
.cell[data-state="yes"] { color: #0d1a12; background: var(--yes); border-color: var(--yes); font-weight: 700; }
.cell.ref { box-shadow: inset 0 0 0 1px var(--accent); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ------------------------------------------------------------- statusbar */
#statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  min-height: 34px;
}
#status { flex: 1 1 auto; font-size: 11px; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status[data-tone="good"] { color: var(--yes); }
#status[data-tone="bad"] { color: var(--bad); }

.actions { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  border-radius: 6px;
  min-height: 24px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1405; }

/* ------------------------------------------------------------------ win */
#win {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, .72);
  padding: 12px;
  z-index: 20;
}
#win.hidden, #modal.hidden { display: none; }
.win-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  max-width: 320px;
  width: 100%;
}
.win-label { font-size: 13px; font-weight: 700; }
.win-stars { color: var(--accent); font-size: 20px; letter-spacing: 2px; margin: 4px 0 8px; }
.win-body { display: flex; justify-content: space-around; gap: 8px; font-size: 11px; color: var(--ink-2); margin-bottom: 10px; }
.win-body b { display: block; color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- modal */
#modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, .78);
  padding: 12px;
  z-index: 30;
}
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  max-width: 420px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
}
.modal-card h2 { margin: 0 0 8px; font-size: 15px; }
.modal-card ol { padding-left: 18px; margin: 6px 0 8px; }
.modal-card li { margin-bottom: 3px; }
.modal-card .muted { color: var(--ink-3); font-size: 11px; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 46px;
  transform: translate(-50%, 8px);
  background: #0b1119;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 40;
  max-width: 92%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* -------------------------------------------------------------- narrow */
@media (max-width: 620px) {
  #main { flex-direction: column; gap: 6px; padding: 6px; }
  .panel { flex: 0 0 auto; max-height: 40%; }
  #grids { flex: 1 1 auto; }
  .hud .opt { display: none; }
  .title small { display: none; }
  #statusbar { flex-wrap: wrap; padding: 4px 6px; }
  .actions { gap: 3px; row-gap: 3px; flex-wrap: wrap; justify-content: flex-end; width: 100%; }
  .btn { padding: 3px 6px; }
  #status { display: none; }
}
