:root {
  --page-width: min(94vw, 480px);
  --bg: #f3f4f9;
  --surface: #ffffff;
  --text: #34384c;
  --muted: #8a8fa8;
  --accent: #7c8cf0;
  --accent-on: #5f6fe0;
  --accent-soft: #e6e9fd;
  --board: #e4e7f4;
  --cell: #f4f5fb;
  --line: #d9dcee;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Frame */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: var(--page-width);
  margin: 0 auto;
  padding: 14px 0 10px;
}
.site-header.home { display: block; padding-top: 28px; }
.site-title { font-weight: 700; font-size: 18px; }
.home .site-title { font-size: 32px; }
.back {
  justify-self: start;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-on);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.game { position: relative; width: var(--page-width); margin: 0 auto; }
.site-footer { width: var(--page-width); margin: 18px auto 20px; text-align: center; font-size: 12px; color: var(--muted); }

/* Controls */
button, select {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
select { background: var(--surface); color: var(--text); border: 1.5px solid var(--line); }
button:active { transform: scale(.97); }
button:disabled { opacity: .35; }
button.on { background: var(--accent-on); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; font-size: 16px; }
.top b { font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; line-height: 1.4; }

.score-box { background: var(--surface); border-radius: 14px; padding: 8px 16px; min-width: 72px; text-align: center; }
.score-box span { display: block; font-size: 10px; color: var(--muted); letter-spacing: 1.5px; font-weight: 600; }
.score-box b { font-size: 20px; }

/* End-of-game panel; put it inside a position:relative parent */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(243, 244, 249, .88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.overlay.show { display: flex; }
.overlay p { margin: 0; font-size: 34px; font-weight: 700; text-align: center; }

/* Menu */
.sub { margin: 0 0 18px; color: var(--muted); }
.menu-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.menu-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 10px 16px;
  background: var(--surface);
  border-radius: 22px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
}
.menu-card:active { transform: scale(.97); }
.menu-card .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 20px;
  background: var(--tint, var(--accent-soft));
  font-size: 32px;
  line-height: 1;
}
.menu-card small { font-weight: 400; font-size: 12px; color: var(--muted); }
.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-on);
  font-size: 11px;
  font-weight: 700;
}
.link { padding: 0; background: none; color: inherit; font: inherit; text-decoration: underline; }
.brand { justify-self: end; font-size: 12px; font-weight: 600; color: var(--muted); }
.tld { color: var(--accent-on); }
.site-footer .links { margin-top: 6px; }
