/* Fixed night palette: indigo ground, warm ink, amber accent.
   Layout: on a laptop the board is on the left, the reference picture and the panel on the right;
   on a phone the order is picture, board, panel. */
/* Rubik variable font (weights 300-900), served from this site.
   unicode-range lets the browser load the Cyrillic file only when a page shows Cyrillic text.
   font-display: swap shows the system font until Rubik is loaded. */
@font-face {
  font-family: Rubik;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(../fonts/rubik-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Rubik;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(../fonts/rubik-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  color-scheme: dark;
  --bg: #15173a;
  --panel: #20234f;
  --edge: #34386e;
  --ink: #f4efe6;
  --muted: #b9b4d6;
  --accent: #ffb35c;
  --accent-ink: #2a1a05;
  --tray: #0d0f2a;
  --font: Rubik, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  overflow-x: clip;
}
a { color: var(--accent); }

.band {
  max-width: 1000px;
  margin: 0 auto;
  padding-block: clamp(20px, 3vw, 40px);
  padding-left: max(4vw, 16px, env(safe-area-inset-left, 0px));
  padding-right: max(4vw, 16px, env(safe-area-inset-right, 0px));
}

h1 { font-weight: 700; font-size: clamp(32px, 5vw, 44px); line-height: 1.05; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-weight: 700; font-size: 22px; margin: 0 0 8px; }
.sub { margin: 0 0 20px; color: var(--muted); max-width: 60ch; }

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  grid-template-areas: "board ref" "board panel";
  grid-template-rows: auto 1fr;
  gap: 16px 24px;
  align-items: start;
}
.tray { grid-area: board; position: relative; width: 100%; max-width: 620px; }
.ref { grid-area: ref; display: block; width: 100%; max-width: 220px; margin: 0 auto; }
.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 16px;
}

/* manipulation: the page can scroll from the empty corners; board.js stops the scroll on tiles. */
#board { display: block; width: 100%; touch-action: manipulation; cursor: grab; }
#board.grabbing { cursor: grabbing; }

.win {
  margin: 12px 0 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 20px;
  text-align: center;
}
.win[hidden] { display: none; }

.stat { display: flex; align-items: baseline; gap: 8px; }
.num { font-weight: 700; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.label { color: var(--muted); font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

button, .button {
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--tray);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.row button { flex: 1 1 auto; }
button:hover, .button:hover { border-color: var(--muted); }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
.main { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
.main:hover { border-color: var(--ink); }

.soon {
  margin-top: 32px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 14px;
  max-width: 620px;
}
.soon p { margin: 0 0 16px; color: var(--muted); }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  color: var(--muted);
  font-size: 14px;
  padding-top: 0;
}

@media (max-width: 760px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "ref" "board" "panel";
    grid-template-rows: auto;
  }
  .ref { max-width: 160px; }
  /* Leave free strips at the sides for scrolling, and keep the board lower than the screen. */
  .tray { margin: 0 auto; max-width: 85%; max-width: min(85%, 66vh); }
}
