/* Shikaku — Playnesta shell stylesheet (MIT).
   No fonts, images or network assets: the board is a grid of paper cells and
   the rectangles are plain borders. */

:root {
  --bg: #111621;
  --bg-2: #18202e;
  --bg-3: #202a3b;
  --line: #2e3a4f;
  --paper: #f2eee3;
  --paper-2: #e9e3d3;
  --grid: #b9b09b;
  --ink: #f2f5fa;
  --ink-2: #b9c4d6;
  --ink-3: #7f8ca3;
  --board-ink: #2a2f3a;
  --accent: #4fc3b0;
  --accent-2: #e0a458;
  --good: #6fd39a;
  --bad: #e5796a;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 30%, #1b2434 0%, var(--bg) 72%);
  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: 4px; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.hud b { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 0; }
.hud .opt { color: var(--ink-3); margin-left: 4px; }

/* ------------------------------------------------------------------ main */
#main {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  min-height: 0;
  overflow: hidden;
}

#board {
  position: relative;
  width: 320px;
  height: 320px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n, 5), 1fr);
  grid-template-rows: repeat(var(--n, 5), 1fr);
  gap: 1px;
  padding: 3px;
  background: var(--grid);
  border: 2px solid var(--grid);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .38), inset 0 0 0 2px rgba(255, 255, 255, .35);
  overflow: hidden;
}

.cell {
  position: relative;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--board-ink);
  font-size: var(--clue, 14px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: background .12s ease, opacity .12s ease;
}
.cell.clue { background: var(--paper-2); }
.cell.clue span { transform: translateY(-1px); }
.cell.row-done, .cell.col-done { background: #e2ddcb; }
.cell.row-done.col-done { background: #d9d3bd; }
.cell.row-done span, .cell.col-done span { opacity: .45; }
.cell:first-child { border-top-left-radius: 5px; }

/* --------------------------------------------------------------- shapes */
#rects, #preview {
  position: absolute;
  inset: 5px;
  pointer-events: none;
}

.rect {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(79, 195, 176, .16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
  pointer-events: auto;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  animation: drop .14s ease-out;
}
.rect:hover { background: rgba(79, 195, 176, .3); }
.rect.tint-1 { border-color: var(--accent-2); background: rgba(224, 164, 88, .17); }
.rect.tint-1:hover { background: rgba(224, 164, 88, .32); }
.rect.tint-2 { border-color: #8f86e0; background: rgba(143, 134, 224, .17); }
.rect.tint-2:hover { background: rgba(143, 134, 224, .32); }

@keyframes drop {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}

#preview {
  border: 2px dashed var(--accent);
  border-radius: 6px;
  background: rgba(79, 195, 176, .16);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}
#preview.bad {
  border-color: var(--bad);
  background: rgba(229, 121, 106, .16);
}
#preview span {
  font-size: calc(var(--cell, 32px) * .5);
  font-weight: 800;
  color: #eafffb;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}

#won {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
}
#won span {
  font-size: calc(var(--cell, 32px) * 2.2);
  color: var(--good);
  text-shadow: 0 4px 18px rgba(0, 0, 0, .5);
  animation: pop .35s ease-out;
}
@keyframes pop {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}

/* ------------------------------------------------------------ statusbar */
#statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  min-height: 38px;
}
#status { font-size: 11px; color: var(--ink-2); min-width: 0; flex: 1 1 auto; }
#status[data-tone="good"] { color: var(--good); }
#status[data-tone="bad"] { color: var(--bad); }
.actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  padding: 0 7px;
  min-height: 26px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.icon { padding: 0 8px; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d201d; font-weight: 700; }
.puzzle-no {
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: center;
}

/* -------------------------------------------------------------- win card */
#win {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, .55);
  z-index: 20;
}
.win-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 240px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  text-align: center;
}
.win-label { font-size: 15px; font-weight: 700; color: var(--good); margin-bottom: 10px; }
.win-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 14px; }
.win-body div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.win-body span { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.win-body b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- modal */
#modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, .6);
  z-index: 30;
  padding: 12px;
}
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  max-width: 520px;
  max-height: 92%;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.modal-card h2 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0 0 8px; font-size: 12px; line-height: 1.55; color: var(--ink-2); }
.modal-card ol { margin: 0 0 8px; padding-left: 18px; font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.modal-card li { margin-bottom: 4px; }
.modal-card b { color: var(--ink); }
.muted { color: var(--ink-3) !important; font-size: 11px !important; }
.modal-card .btn { margin-top: 6px; }

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

.hidden { display: none !important; }

@media (max-width: 430px) {
  .title small { display: none; }
  .hud .opt { margin-left: 2px; }
  #statusbar { padding: 4px 6px; }
  .btn { padding: 0 5px; font-size: 10px; }
  .puzzle-no { min-width: 30px; }
}
