/* Playnesta shell stylesheet for Kakuro (Playnesta-original, MIT).
   The grid, the diagonal clue triangles and the keypad are drawn with CSS —
   no sprites, fonts or network assets. Layout is viewport-relative: #board is a
   flex box that gives up its leftover height, and js/main.js sizes the square
   cells from whatever is left, so one page fits the 894x670 desktop stage and
   the 348x261 phone stage with no overflow in either axis. */

* { box-sizing: border-box; }

:root {
  --bg: #0e1620;
  --panel: #16222e;
  --panel2: #1d2c3a;
  --ink: #eaf2f8;
  --muted: #93a6b6;
  --accent: #4fc3f7;
  --black-cell: #101a24;
  --paper: #f3f7fa;
  --paper-ink: #10222f;
  --bad: #e8563f;
  --dup: #e0b229;
  --cell: 40px;
}

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;
}

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

.topbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; }
.title { font-weight: 700; font-size: 15px; }
.title small { font-weight: 500; color: var(--muted); font-size: 11px; }
.spacer { flex: 1; }
.hud {
  display: flex; align-items: baseline; gap: 5px; font-size: 12px;
  background: var(--panel); padding: 4px 10px; border-radius: 8px; flex-wrap: wrap;
}
.hud b { font-size: 14px; color: var(--accent); }
.hud .opt { color: var(--muted); }

#tiers { display: flex; gap: 3px; }
.btn.tier { text-transform: capitalize; padding: 4px 7px; font-size: 11px; }

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

#grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  gap: 1px;
  background: #24384a;
  border: 1px solid #24384a;
  border-radius: 6px;
  overflow: hidden;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.46);
  font-weight: 600;
  line-height: 1;
}

.cell.black {
  background: var(--black-cell);
  position: relative;
  color: var(--ink);
}
/* the diagonal that splits a clue cell into its two triangles */
.cell.black.clued::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right, transparent 49.4%, #3d5568 49.4%, #3d5568 50.6%, transparent 50.6%);
}
.cell .clue {
  position: absolute;
  font-size: calc(var(--cell) * 0.3);
  font-weight: 700;
  color: #cfe0ec;
  padding: 1px 2px;
}
.cell .clue.across { top: 0; right: 1px; }
.cell .clue.down { bottom: 0; left: 1px; }

.cell.white {
  background: var(--paper);
  color: var(--paper-ink);
  cursor: pointer;
  border: 0;
  padding: 0;
  font-family: inherit;
  touch-action: manipulation;
}
.cell.white.given { background: #dde7ee; color: #0d1b25; }
.cell.white.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.cell.white.bad { background: #f7c9c1; color: #6d1a0e; }
.cell.white.dup { background: #f6dfa6; color: #5c4307; }

/* ---- keypad + status ---- */
#pad {
  flex: 0 0 auto;
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  justify-content: center;
}
#pad .btn {
  flex: 1 1 0;
  max-width: 42px;
  min-width: 0;
  padding: 5px 0;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}
#pad .btn[data-digit] { background: var(--panel2); }

.btn {
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid #2b4356;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: #06202c; border-color: var(--accent); font-weight: 700; }

#statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
}
#status { font-size: 12px; color: var(--muted); flex: 1 1 180px; }
#status[data-mode="win"] { color: var(--accent); font-weight: 700; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---- overlays ---- */
#win { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6, 14, 20, 0.82); z-index: 20; }
#win.hidden { display: none; }
.win-card { background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 18px 22px; text-align: center; max-width: 80vw; }
.win-label { font-size: 18px; font-weight: 800; color: var(--accent); }
.win-body { font-size: 13px; color: var(--muted); margin: 8px 0 14px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(6, 14, 20, 0.85); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 12px; }
.modal { background: var(--panel); border-radius: 12px; padding: 16px 18px; max-width: 520px; max-height: 86%; overflow: auto; }
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.rules-body h3 { margin: 10px 0 4px; font-size: 13px; color: var(--accent); }
.rules-body p { margin: 0; font-size: 13px; line-height: 1.45; color: #d5e3ec; }
.modal-buttons { margin-top: 14px; text-align: right; }

@media (max-width: 460px) {
  .title { font-size: 12px; }
  .title small { display: none; }
  .hud { font-size: 10px; padding: 3px 6px; gap: 3px; }
  .hud b { font-size: 12px; }
  #pad .btn { font-size: 13px; padding: 5px 0; }
  #status { font-size: 11px; flex-basis: 100%; }
  .actions .btn { padding: 5px 7px; font-size: 11px; }
}
