/* chessflex.app: the app's palette (Theme.kt), light and dark. */
:root {
  --cream: #FAF6F0; --card: #FFFFFF; --ink: #1A1A2E; --muted: #5E5246; --brown: #694F3F;
  --amber: #C8935A; --amber-text: #704C25; --good: #2F6B3A; --wrong: #9A3B2A;
  --light-sq: #F0D9B5; --dark-sq: #B58863; --last: rgba(205, 210, 106, 0.55); --sel: rgba(90, 140, 74, 0.6);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #17161C; --card: #24222B; --ink: #ECE6DD; --muted: #ADA092; --brown: #B99C8B;
    --amber-text: #CB9862; --good: #7CC487; --wrong: #E58C77; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --cream: #17161C; --card: #24222B; --ink: #ECE6DD; --muted: #ADA092; --brown: #B99C8B;
  --amber-text: #CB9862; --good: #7CC487; --wrong: #E58C77; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--cream); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--amber-text); }

.top { display: flex; align-items: center; justify-content: space-between; max-width: 560px; margin: 0 auto; padding: 14px 16px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 22px; }
.brand img { width: 32px; height: 32px; border-radius: 7px; }
.top-link { font-size: 14px; }

.puzzle { max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }
.puzzle h1 { font-size: 26px; margin: 4px 0 2px; }
.status { min-height: 1.5em; margin: 0 0 10px; color: var(--muted); }
.status.good { color: var(--good); font-weight: 600; }
.status.wrong { color: var(--wrong); font-weight: 600; }

.board {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%; aspect-ratio: 1;
  border-radius: 6px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; min-width: 0; min-height: 0; overflow: hidden; }
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }
.sq.last::before, .sq.sel::before, .sq.hint::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: var(--last); }
.sq.sel::before { background: var(--sel); }
.sq.hint::before { box-shadow: inset 0 0 0 4px #E2A23B; }
.sq img { position: relative; width: 92%; height: 92%; pointer-events: none; }
.sq .rank, .sq .file { position: absolute; font-size: 11px; font-weight: 600; pointer-events: none; }
.sq .rank { top: 2px; left: 3px; }
.sq .file { bottom: 1px; right: 3px; }
.sq.light .rank, .sq.light .file { color: #B58863; }
.sq.dark .rank, .sq.dark .file { color: #F0D9B5; }
.ghost { position: fixed; pointer-events: none; z-index: 10; }
.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.caption { font-size: 22px; font-weight: 700; text-align: center; margin: 12px 0 0; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin: 14px 0 6px; }
.controls[hidden] { display: none; }
button {
  font: inherit; font-size: 15px; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--brown) 35%, transparent); background: var(--card); color: var(--ink);
}
button:disabled { opacity: 0.4; cursor: default; }
.step { min-width: 90px; text-align: center; font-weight: 600; }

.cta { margin-top: 26px; padding: 18px; border-radius: 14px; background: color-mix(in srgb, var(--amber) 12%, var(--card)); }
.cta h2 { font-size: 18px; margin: 0 0 6px; }
.cta p { margin: 0 0 12px; color: var(--muted); }
.stores { display: flex; gap: 10px; flex-wrap: wrap; }
.store { padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--cream); text-decoration: none; font-weight: 600; }

.foot { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 18px 16px 30px; font-size: 13px; color: var(--muted); }

/* Home and the puzzle list */
.home { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
.home h1 { font-size: 30px; line-height: 1.2; margin: 10px 0 8px; }
.home .lead { color: var(--muted); margin: 0 0 18px; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.list a { display: block; padding: 14px 16px; border-radius: 12px; background: var(--card); text-decoration: none; color: var(--ink); }
.list small { color: var(--muted); }

/* Poster frames (?frame=k) for social posts: 1080 × 1350 (Instagram portrait) */
body.frame { width: 1080px; height: 1350px; overflow: hidden; background: #FAF6F0; color: #1A1A2E; }
body.frame .top, body.frame .controls, body.frame .cta, body.frame .foot { display: none !important; }
body.frame .puzzle { max-width: none; width: 1080px; padding: 70px 90px 0; }
body.frame .puzzle h1 { font-size: 64px; text-align: center; margin: 0 0 6px; }
body.frame .status { font-size: 34px; text-align: center; color: #5E5246; min-height: 52px; }
body.frame .board { width: 900px; }
body.frame .sq .rank, body.frame .sq .file { font-size: 22px; }
body.frame .caption { font-size: 58px; margin-top: 34px; }
body.frame::after {
  content: "chessflex.app"; position: fixed; bottom: 36px; left: 0; right: 0; text-align: center;
  font-size: 30px; font-weight: 700; color: #694F3F; letter-spacing: 1px;
}

/* ChessFlex Daily (d/<n>/): the position, the QR, why the app */
.daily { max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }
.daily .kicker { margin: 4px 0 0; color: var(--amber-text); font-weight: 700; font-size: 14px; letter-spacing: 0.4px; }
.daily h1 { font-size: 26px; margin: 2px 0 12px; }
.board.still .sq { cursor: default; }
.scan { display: flex; gap: 18px; align-items: center; margin-top: 22px; padding: 18px; border-radius: 14px; background: var(--card); }
.scan .qr { flex: none; width: 200px; height: 200px; image-rendering: pixelated; border-radius: 8px; background: #FFFFFF; }
.scan h2, .why h2 { font-size: 18px; margin: 0 0 6px; }
.scan p { margin: 0 0 10px; color: var(--muted); }
.store.open { display: inline-block; background: var(--amber-text); color: #FFFFFF; }
.why { margin-top: 18px; padding: 18px; border-radius: 14px; background: color-mix(in srgb, var(--amber) 12%, var(--card)); }
.why ul { margin: 0 0 14px; padding-left: 20px; }
.why li { margin: 0 0 6px; }
.days { display: flex; justify-content: space-between; margin-top: 18px; font-size: 15px; }
@media (max-width: 520px) {
  .scan { flex-direction: column; text-align: center; }
  .scan .qr { width: 240px; height: 240px; }
}
@media (hover: hover) and (pointer: fine) { .on-phone { display: none; } }
