/* ============================================================
   Maian Games — thành phần giao diện dùng chung
   Nạp sau tokens.css. Game nào cũng dùng bộ này để kho trông đồng bộ.
   ============================================================ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Chạm hai lần liên tiếp không phóng to trang nữa — cả kho game đều vậy.
   Phải áp cho MỌI phần tử: touch-action không di truyền, đặt mỗi ở body thì
   ngón chạm vào thẻ game hay ô cờ vẫn rơi vào mặc định và trang vẫn phóng to.
   Vuốt hai ngón vẫn phóng to được, không lấy mất của người cần. */
*, *::before, *::after { touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* --- thanh tiêu đề --- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px var(--pad);
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
  text-decoration: none;
  color: inherit;
}
.brand-name {
  font-family: var(--f-display);
  font-stretch: 112%;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* --- nút --- */
.iconbtn {
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}
.iconbtn:hover { background: var(--panel-hi); }
.iconbtn:active { transform: scale(.94); }

.btn {
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 13px;
  min-height: var(--tap);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  white-space: nowrap;
  transition: filter .16s ease, transform .16s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.leaf { background: var(--leaf); color: var(--leaf-ink); }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- chip --- */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .04em;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  cursor: default;
}
button.chip { cursor: pointer; min-height: 30px; }
.chip.on {
  color: var(--leaf);
  border-color: color-mix(in srgb, var(--leaf) 45%, var(--line));
}
button.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* --- hộp thoại --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }
.dialog {
  width: min(300px, 100%);
  padding: 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  animation: pop .18s ease-out;
}
@keyframes pop {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.dialog h2 {
  margin: 0;
  font-family: var(--f-display);
  font-stretch: 112%;
  font-weight: 800;
  font-size: 22px;
}
.dialog .score {
  font-family: var(--f-mono);
  font-size: 32px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.dialog p { margin: 0; font-size: 13.5px; color: var(--muted); }
.dialog .row { display: flex; gap: 8px; }
.dialog .row .btn { flex: 1; }

/* --- thông báo ngắn --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: 12px;
  background: var(--panel-hi);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .tick { color: var(--leaf); }

/* --- tiện ích --- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
