@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;
  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(16px, 4vw, 48px);
  --cell: clamp(40px, 5.2vw, 46px);
  --clue-w: clamp(54px, 14vw, 92px);
  --clue-h: clamp(76px, 18vw, 108px);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(69, 240, 255, 0.05), transparent 70%), var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(69, 240, 255, 0.3); }
[hidden] { display: none !important; }
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(60px); }
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
}
a { color: var(--cyan); }

.site-header {
  padding: 26px var(--space-gutter) 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.lab-link {
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.15s, text-shadow 0.15s;
}
.lab-link:hover { color: var(--cyan); text-shadow: var(--glow-cyan); }
.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}
.wordmark {
  margin: 6px 0 4px;
  font-family: var(--pixel);
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.55), 3px 3px 0 var(--magenta);
}
.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}
.cursor { color: var(--cyan); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

main {
  flex: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px var(--space-gutter) 72px;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
.play-panel, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.play-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(69, 240, 255, 0.4);
}
.puzzle-title, .win-title {
  margin: 6px 0 0;
  font-family: var(--pixel);
  font-size: clamp(13px, 3vw, 18px);
  color: var(--text);
}
.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.hud p {
  margin: 0;
  padding: 10px;
  min-height: 52px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.hud span {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}
.hud output {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--gold);
}
.board-scroll {
  overflow: auto;
  padding: 8px;
  background: #080811;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.nonogram {
  display: grid;
  grid-template-columns: var(--clue-w) repeat(15, var(--cell));
  grid-template-rows: var(--clue-h) repeat(15, var(--cell));
  width: max-content;
  min-width: 100%;
}
.corner, .row-clue, .col-clue {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: clamp(9px, 2.5vw, 12px);
}
.corner {
  display: grid;
  place-items: center;
  color: var(--gold);
}
.row-clue {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 7px;
}
.col-clue {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding: 7px 0;
}
.row-clue.is-complete, .col-clue.is-complete { color: rgba(154, 160, 181, 0.38); }
.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  min-width: 40px;
  min-height: 40px;
  border: 1px solid #30304a;
  background: #10101a;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
  font-family: var(--mono);
  font-size: 14px;
  touch-action: manipulation;
  transition: background 0.12s, box-shadow 0.12s, transform 0.12s var(--ease-out);
}
.cell:nth-child(2n) { background: #12121e; }
.cell[data-state="fill"] { background: var(--cyan); box-shadow: inset 0 0 0 2px rgba(5, 5, 13, 0.35); }
.cell[data-state="mark"]::before,
.cell[data-state="mark"]::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  top: calc(50% - 1px);
  height: 2px;
  background: var(--magenta);
}
.cell[data-state="mark"]::before { transform: rotate(45deg); }
.cell[data-state="mark"]::after { transform: rotate(-45deg); }
.cell:hover { box-shadow: inset 0 0 0 2px rgba(69, 240, 255, 0.22); }
.nonogram.is-solved .cell[data-solution="1"] {
  background: var(--paint, var(--green));
  animation: bloom 0.45s var(--ease-out) both;
}
.nonogram.is-solved .cell[data-state="mark"]::before,
.nonogram.is-solved .cell[data-state="mark"]::after { display: none; }
@keyframes bloom {
  from { transform: scale(0.75); filter: brightness(0.7); }
}
.status-line, .privacy-note, .win-meta, .hint-mark {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 12.5px;
}
.action-row, .date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  min-width: 40px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn:hover:not(:disabled) {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.btn:disabled { opacity: 0.48; cursor: not-allowed; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field-label {
  display: block;
  margin: 14px 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #5e5e80;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: 13px var(--mono);
}
.past-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.past-list .btn {
  justify-content: flex-start;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
}
.win-panel { border-color: rgba(65, 255, 139, 0.45); }
.win-title { color: var(--green); text-shadow: 0 0 12px rgba(65, 255, 139, 0.45); }
.art-preview {
  display: grid;
  grid-template-columns: repeat(15, 10px);
  grid-auto-rows: 10px;
  gap: 1px;
  width: max-content;
  margin-top: 14px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.art-preview span { width: 10px; height: 10px; background: transparent; }
.art-preview span.is-on { background: var(--paint); }
.hint-mark { color: var(--gold); }

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s var(--ease-out) both;
}
.toast-info { border-left-color: var(--cyan); }
.toast-success { border-left-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

@media (min-width: 768px) {
  .play-head { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .hud { min-width: 330px; }
}
@media (min-width: 1024px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) 310px; align-items: start; }
  .play-panel, .panel { padding: 18px; }
}
@media (max-width: 420px) {
  .hud output { font-size: 15px; }
  .past-list { grid-template-columns: 1fr; }
  .wordmark { letter-spacing: 1px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor, .nonogram.is-solved .cell[data-solution="1"] { animation: none; }
}
