/* Self-hosted so the page pulls no third-party requests; license sits next to
   the file at fonts/OFL.txt (SIL Open Font License 1.1). */
@font-face {
  font-family: 'UnifrakturCook';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/unifrakturcook-bold.woff2') format('woff2');
}

:root {
  --bg: #faf7f3;
  --bg-tint: rgba(250, 247, 243, 0.78);
  --fg: #1d1a17;
  --muted: #75695c;
  --line: #d8cec1;
  --cell: #fffdfa;
  --signed: #e8f0e4;
  --signed-line: #6f8f62;
  --win: #fdf0cf;
  --accent: #8c3b2e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16140f;
    --bg-tint: rgba(22, 20, 15, 0.78);
    --fg: #f2ece2;
    --muted: #a99b8a;
    --line: #3a352c;
    --cell: #211e18;
    --signed: #26301f;
    --signed-line: #7fa06d;
    --win: #3a2f14;
    --accent: #e0a08c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 2rem;
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-tint), var(--bg-tint)), url("tartan-tile.svg");
  background-size: auto, 288px 288px;
  color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header { text-align: center; margin-bottom: 0.75rem; }
h1 {
  margin: 0;
  font-family: 'UnifrakturCook', 'Apple Chancery', 'Trattatello', 'Luminari', cursive;
  font-size: 2.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.tag { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; }

main { max-width: 44rem; margin: 0 auto; }

.status:empty, .note:empty { display: none; }
.status { color: var(--accent); font-size: 0.85rem; text-align: center; margin: 0 0 0.5rem; }

.banner {
  margin: 0 0 0.6rem;
  padding: 0.5rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.06em;
  background: var(--win);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.3rem;
}

.square {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  min-height: 4.6rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--cell);
  color: inherit;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
}

.square .txt {
  font-size: clamp(0.55rem, 2.9vw, 0.8rem);
  line-height: 1.15;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.square .by {
  font-size: clamp(0.52rem, 2.2vw, 0.7rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--signed-line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The QR carries its own white background, which is what keeps it scannable
   in dark mode and on the amber winning-line highlight. */
.square .qr {
  width: clamp(2.1rem, 13vw, 4rem);
  height: auto;
  align-self: center;
  border-radius: 0.15rem;
}

.square.signed { background: var(--signed); border-color: var(--signed-line); }
.square.win { background: var(--win); }
.square.free .txt { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.08em; }
.square:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

footer { display: flex; justify-content: center; margin-top: 1rem; }

.link {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
}

dialog {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--bg);
  color: var(--fg);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

.fact { margin: 0 0 0.9rem; font-size: 1.05rem; font-weight: 600; }

#free-qr {
  display: block;
  width: min(68vw, 16rem);
  height: auto;
  margin: 0 auto 0.6rem;
  background: #fff;
  padding: 0.35rem;
  border-radius: 0.4rem;
}
.caption { margin: 0; color: var(--muted); font-size: 0.82rem; text-align: center; }

dialog label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
dialog input {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--cell);
  color: var(--fg);
  font: inherit;
}

.pad-wrap { position: relative; margin: 0.7rem 0 0.3rem; }
#pad {
  display: block;
  width: 100%;
  height: 9.5rem;
  border: 1px dashed var(--line);
  border-radius: 0.45rem;
  background: var(--cell);
  touch-action: none;
}
.hint {
  position: absolute;
  left: 0.6rem;
  bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.7rem;
  pointer-events: none;
}

.note { color: var(--accent); font-size: 0.8rem; margin: 0.2rem 0 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.actions button {
  flex: 1 1 auto;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--cell);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
