/* Shared look for the site and every game page. */

/* Lilita One (SIL Open Font License) — the chunky display face for titles. */
@font-face {
  font-family: "Lilita One";
  src: url("fonts/lilita-one.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #f6efe4;
  --panel: #fffaf2;
  --ink: #3a2f25;
  --ink-soft: #7a6a58;
  --line: #e4d6c2;
  --accent: #e0662f;
  --accent-ink: #ffffff;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Lilita One", var(--font);
}

/* Night pages — the space games. */
.dark {
  --bg: #070b1a;
  --panel: #111833;
  --ink: #e8ecff;
  --ink-soft: #8d96bd;
  --line: #222b52;
  --accent: #ff7a3d;
}
.dark .overlay {
  background: rgba(7, 11, 26, 0.78);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

button {
  font: inherit;
  cursor: pointer;
}

/* Game buttons are chunky: a lit top, a thick edge underneath in a darker
   shade of the accent, pressed in on tap. */
.btn {
  --edge: color-mix(in srgb, var(--accent) 60%, #000);
  border: 0;
  border-radius: 14px;
  padding: 9px 18px 10px;
  background: linear-gradient(color-mix(in srgb, var(--accent) 70%, #fff), var(--accent));
  color: var(--accent-ink);
  font-family: var(--display);
  font-weight: 400;
  font-synthesis: none;
  font-size: 17px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 0 var(--edge), 0 7px 14px rgba(0, 0, 0, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transition: transform 70ms ease, box-shadow 70ms ease, filter 120ms ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--edge), 0 2px 6px rgba(0, 0, 0, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.btn small { font-family: var(--font); font-weight: 700; letter-spacing: 0; }
.btn:disabled { opacity: 0.45; filter: grayscale(0.5); transform: none; }
.btn.quiet {
  --edge: color-mix(in srgb, var(--ink) 28%, transparent);
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--edge), inset 0 0 0 2px color-mix(in srgb, var(--ink) 20%, transparent);
}
.btn.quiet:active { box-shadow: 0 1px 0 var(--edge), inset 0 0 0 2px color-mix(in srgb, var(--ink) 20%, transparent); }

/* The bar across the top of every game: back to the site, the game's name,
   and sound on/off. */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px 0;
}
.topbar .back {
  text-decoration: none;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 6px 2px;
}
.topbar .title {
  flex: 1;
  text-align: center;
  font-family: var(--display);
  font-weight: 400;
  font-synthesis: none;
  font-size: 19px;
  letter-spacing: 0.04em;
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }

/* Full-board message: game over, you won. */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  text-align: center;
  border-radius: inherit;
  background: rgba(246, 239, 228, 0.82);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  z-index: 10;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.overlay h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 38px;
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0.03em;
}
.overlay p { margin: 0; color: var(--ink-soft); }
.overlay .row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* A wide screen (see fitScreen in canvas.js) lets the top bar span it. */
body.wide .topbar { max-width: none; padding-left: 24px; padding-right: 24px; }

/* A card that pops up over the game: how to play, a win, a loss.
   .sheet is the dimmed overlay, .kcard the card on it, .ribbon its banner. */
.sheet { background: rgba(10, 8, 30, 0.6) !important; padding: 20px; }
.kcard {
  width: min(300px, calc(100vw - 60px));
  margin: 0 auto;
  padding: 22px 20px 24px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(#4a38a0, #2a1f66);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18), 0 20px 40px rgba(0, 0, 0, 0.5);
  display: grid;
  gap: 12px;
  text-align: center;
}
.kcard h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; color: #ffd23a; }
.kcard p { color: #e8e4ff; }
.kcard .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kcard .row .btn { padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.ribbon {
  margin: -46px auto 0;
  padding: 8px 26px 12px;
  font-family: var(--display);
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  background: linear-gradient(#ff6a5a, #c8281e);
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
  white-space: nowrap;
}
.ribbon.lose { background: linear-gradient(#8a90b0, #4a5070); }

/* Coloured buttons for menus: .btn.green, .blue, .red, .gold; .big for the
   main call. */
.btn.green, .btn.blue, .btn.red, .btn.purple { --accent-ink: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn.green { --accent: #2bb048; }
.btn.blue { --accent: #3270e0; }
.btn.red { --accent: #e0443a; }
.btn.purple { --accent: #8a4ae0; }
.btn.gold { --accent: #f6c020; --accent-ink: #4a2a00; }
.btn.big { font-size: 21px; padding: 11px 26px 13px; border-radius: 16px; }
.btn small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.9; text-shadow: none; }

/* A title screen is its own place: the logo up top, the game's scene (drawn
   on the canvas) in the middle, the ways to play at the bottom. */
.overlay.title-screen {
  background: none !important;
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 9% 18px 5%;
}
body.wide .overlay.title-screen { padding: 5% 24px 4%; }
.overlay .logo, .logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-synthesis: none;
  line-height: 1;
  font-size: clamp(44px, 11vh, 96px);
  letter-spacing: 0.02em;
  color: var(--logo, var(--accent));
  text-align: center;
  text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 2px 2px #fff, -2px 2px #fff, 2px -2px #fff, -2px -2px #fff, 0 8px 0 rgba(0, 0, 0, 0.35);
}
.tag { margin: 10px 0 0; font-family: var(--display); font-size: 17px; color: #fff; opacity: 0.92; letter-spacing: 0.03em; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.menu { width: 100%; max-width: 420px; display: grid; gap: 14px; }
body.wide .menu { max-width: 880px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; width: 100%; }
.modes.one { grid-template-columns: 1fr; max-width: 260px; margin: 0 auto; }
body.wide .modes { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
body.wide .modes.one { grid-template-columns: 1fr; }
.links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-soft); }
.link { background: none; border: 0; color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }

/* How to play: a starred list on a .kcard. */
.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; text-align: left; color: #e8e4ff; font-size: 14px; line-height: 1.4; }
.rules li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
.rules li::before { content: "★"; color: #ffd23a; text-align: center; }
.rules b { color: #fff; }
.trophy { width: 96px; height: 96px; margin: 0 auto; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)); }
