/* Playnesta shell stylesheet for Number Mosaic (Playnesta-original, MIT).
   The picture is drawn with plain divs — no sprites, fonts or network assets.
   The cell size is computed in js/main.js from the space actually left by the
   clues, so one page fits the two production stages (894x670 desktop and
   348x261 phone) with no overflow in either axis. */

* { box-sizing: border-box; }

:root {
  --bg: #101a24;
  --panel: #182734;
  --panel2: #21323f;
  --ink: #eef5fa;
  --muted: #93a8b8;
  --accent: #ffcf5c;
  --fill: #4fc3f7;
  --fill-2: #29a3d6;
  --mark: #8aa4b6;
  --cell: 20px;
  --clue-w: 46px;
  --clue-h: 46px;
  --gap: 1px;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  min-height: 0;
  position: relative;
}

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.title { font-weight: 700; font-size: 14px; white-space: nowrap; }
.title small { font-weight: 500; color: var(--muted); font-size: 10px; }
.spacer { flex: 1 1 auto; min-width: 0; }
.hud {
  display: flex; align-items: baseline; gap: 4px; font-size: 11px;
  background: var(--panel); padding: 3px 8px; border-radius: 8px;
  white-space: nowrap; overflow: hidden;
}
.hud b { font-size: 13px; color: var(--accent); }
.hud .opt { color: var(--muted); }

/* ---- board ---- */
#board {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

#frame {
  display: grid;
  grid-template-columns: var(--clue-w) auto;
  grid-template-rows: var(--clue-h) auto;
  gap: 2px;
  min-height: 0;
  min-width: 0;
}

.corner { width: var(--clue-w); height: var(--clue-h); }

.col-clues {
  display: grid;
  grid-template-columns: repeat(var(--n, 5), var(--cell));
  grid-auto-rows: var(--clue-h);
  gap: var(--gap);
  align-items: end;
}

.col-clue {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
  font-size: calc(var(--cell) * 0.5);
  line-height: 1.05;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.col-clue span.done, .row-clue span.done { color: #4a5f6f; text-decoration: line-through; }

.row-clues {
  display: grid;
  grid-template-rows: repeat(var(--n, 5), var(--cell));
  grid-auto-columns: var(--clue-w);
  gap: var(--gap);
  align-items: center;
}

.row-clue {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: calc(var(--cell) * 0.12);
  font-size: calc(var(--cell) * 0.5);
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  height: var(--cell);
  min-width: 0;
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--n, 5), var(--cell));
  grid-template-rows: repeat(var(--n, 5), var(--cell));
  gap: var(--gap);
  background: #0a1017;
  border-radius: 6px;
  touch-action: none;
}

.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border-radius: 2px;
  background: var(--panel2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: pointer;
  touch-action: none;
}
.cell[data-r="4"], .cell[data-c="4"],
.cell[data-r="9"], .cell[data-c="9"],
.cell[data-r="14"], .cell[data-c="14"] { box-shadow: inset 0 0 0 1px rgba(255, 207, 92, 0.28); }

.cell.filled {
  background: linear-gradient(160deg, var(--fill), var(--fill-2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
.cell.marked::before, .cell.marked::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%; top: 48%;
  height: 2px;
  background: var(--mark);
  border-radius: 2px;
}
.cell.marked::before { transform: rotate(45deg); }
.cell.marked::after { transform: rotate(-45deg); }

.cell.hint { outline: 2px solid var(--accent); outline-offset: -2px; animation: pulse 0.9s ease-in-out 2; }
.cell.wrong { animation: shake 0.32s ease-in-out 1; }
@keyframes pulse { 50% { outline-color: transparent; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ---- status bar ---- */
#statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--panel);
  border-radius: 10px;
  padding: 5px 8px;
}
#status { font-size: 11px; color: var(--muted); min-width: 0; flex: 1 1 120px; }
#status[data-mode="win"] { color: var(--accent); }
#status[data-mode="warn"] { color: #ff9d6c; }
#status[data-mode="ok"] { color: #8ee6a8; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: var(--panel2);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 0 9px;
  min-height: 30px;
  min-width: 30px;
  cursor: pointer;
}
.btn:hover { background: #2b3f4f; }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"] { background: var(--accent); color: #17222c; }
.btn.primary { background: var(--accent); color: #17222c; min-height: 34px; padding: 0 14px; }

/* ---- win overlay ---- */
#win {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 18, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 20;
}
#win.hidden { display: none; }
.win-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 20px;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.win-label { font-size: 13px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.win-stars { font-size: 30px; color: var(--accent); letter-spacing: 4px; margin: 6px 0 2px; }
.win-body { font-size: 12px; color: var(--muted); margin-bottom: 12px; line-height: 1.45; }

/* ---- rules modal ---- */
#modal-root { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#modal-root .modal {
  pointer-events: auto;
  position: absolute;
  inset: 10%;
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 18px;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
#modal-root h2 { margin: 0 0 8px; font-size: 15px; }
#modal-root p { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--ink); }
#modal-root .muted { color: var(--muted); }

#toast {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  background: #26394a;
  color: var(--ink);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
#toast.show { opacity: 1; }

/* phone: keep the buttons tappable and the board on screen */
@media (max-width: 460px) {
  .title small { display: none; }
  .hud .opt { display: none; }
  .btn { min-height: 34px; padding: 0 10px; }
  #status { flex-basis: 100%; order: 2; }
  .actions { order: 1; flex: 1 1 100%; justify-content: center; }
}
