@font-face {
  font-family: "SilkscreenLocal";
  src: url("assets/fonts/Silkscreen-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #f6f5f2;
  --panel: #eaebe7;
  --border: #d4d3cf;
  --line: #c8c7c3;
  --block: #565349;
  --text: #565349;
  --accent: #565349;
  --shadow: 0 12px 28px rgba(0,0,0,.14);
  --font: "SilkscreenLocal", "Courier New", "Liberation Mono", monospace;
  --ui-font: "SilkscreenLocal", "Courier New", "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(circle at 30% 20%, #fefdfb 0%, var(--bg) 55%, #e5e5e2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  line-height: 1.35;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app {
  width: min(100%, 1000px);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .9rem;
  gap: .75rem;
  flex-shrink: 0;
}

h1 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-family: var(--ui-font);
  font-weight: 400;
  letter-spacing: .03em;
  color: var(--accent);
}

.controls {
  display: flex;
  gap: .5rem;
  align-items: center;
}

button {
  border-radius: .65rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: .45rem .8rem;
  font: inherit;
  font-family: var(--ui-font);
  font-weight: 400;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

button:focus-visible,
.cell:focus-visible {
  outline: 3px solid #004a99;
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: -999px;
  padding: .5rem .75rem;
  background: #000;
  color: #fff;
  z-index: 999;
}

.skip-link:focus-visible {
  left: 1rem;
  top: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.2);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.grid-wrap {
  position: relative;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 0;
  overflow: hidden;
  margin: 0 auto;
  /* width and height set by JS for square cells */
}

.grid {
  display: grid;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.cell {
  border: 0;
  outline: 1px solid var(--line);
  outline-offset: -1px;
  background-color: #fff;
  transition: background .1s ease;
  border-radius: 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.cell:active {
  transform: none;
  box-shadow: none;
}

.cell.active {
  background-color: var(--block);
}

@media (max-width: 520px) {
  body { padding: .65rem; }
  button { font-size: .8rem; padding: .45rem .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
