/* vendored from gamekit/assets — edit there and re-copy (gamekit/assets/sync.sh) */
/* gamekit.css — shared design tokens and base components for gamekit game sites.
 *
 * Mobile-first. Ships plain CSS custom properties (design tokens) plus a small
 * set of unopinionated base components (button, card, modal, toast, avatar)
 * that a game's own stylesheet builds on. Dark mode is automatic via
 * prefers-color-scheme; motion respects prefers-reduced-motion.
 *
 * No build step: a game copies this file into its asset dir (see sync.sh) and
 * loads it before its own stylesheet.
 */

:root {
  color-scheme: light dark;

  /* Brand accent — games override --gk-accent / --gk-accent-strong to reskin. */
  --gk-accent: #0f6e6a;
  --gk-accent-strong: #0b5350;
  --gk-accent-contrast: #ffffff;
  --gk-accent-soft: #e3f0ef;

  /* Neutral surfaces / ink (light theme). */
  --gk-bg: #f4f7f6;
  --gk-surface: #ffffff;
  --gk-surface-2: #eef3f2;
  --gk-ink: #14201f;
  --gk-ink-soft: #566462;
  --gk-line: #dde6e4;
  --gk-line-strong: #c6d3d1;

  /* Feedback colors. */
  --gk-danger: #c0433f;
  --gk-warn: #b8860b;
  --gk-ok: #2f8f6b;

  /* Type scale (fluid, mobile-first). Display face uses a rounded system stack
   * so headings feel game-like with zero external font requests. */
  --gk-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --gk-font-display: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui,
    var(--gk-font-sans);
  --gk-fs-xs: 0.78rem;
  --gk-fs-sm: 0.9rem;
  --gk-fs-md: 1rem;
  --gk-fs-lg: 1.15rem;
  --gk-fs-xl: clamp(1.3rem, 3vw, 1.7rem);
  --gk-fs-2xl: clamp(1.7rem, 5vw, 2.6rem);
  --gk-fs-3xl: clamp(2.1rem, 7vw, 3.2rem);

  /* Spacing scale. */
  --gk-space-1: 4px;
  --gk-space-2: 8px;
  --gk-space-3: 12px;
  --gk-space-4: 16px;
  --gk-space-5: 24px;
  --gk-space-6: 32px;
  --gk-space-7: 48px;

  /* Radii. */
  --gk-radius-sm: 8px;
  --gk-radius: 12px;
  --gk-radius-lg: 18px;
  --gk-radius-pill: 999px;

  /* Shadows. */
  --gk-shadow-sm: 0 1px 2px rgba(16, 40, 39, 0.08);
  --gk-shadow: 0 1px 2px rgba(16, 40, 39, 0.06), 0 6px 20px rgba(16, 40, 39, 0.08);
  --gk-shadow-lg: 0 24px 60px rgba(8, 20, 19, 0.28);

  /* Motion. */
  --gk-transition-fast: 0.12s ease;
  --gk-transition: 0.2s ease;

  /* Layout. */
  --gk-maxw: 1040px;
  --gk-tap: 44px; /* minimum touch target */
}

@media (prefers-color-scheme: dark) {
  :root {
    --gk-accent: #3fb6ac;
    --gk-accent-strong: #63cfc4;
    --gk-accent-contrast: #05201d;
    --gk-accent-soft: #123734;

    --gk-bg: #0d1413;
    --gk-surface: #141d1c;
    --gk-surface-2: #1b2726;
    --gk-ink: #e8f0ef;
    --gk-ink-soft: #9db3b0;
    --gk-line: #26332f;
    --gk-line-strong: #33433f;

    --gk-danger: #ef6b66;
    --gk-warn: #e0b34a;
    --gk-ok: #57c99a;

    --gk-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --gk-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
    --gk-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Base button. */
.gk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gk-space-2);
  min-height: var(--gk-tap);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--gk-radius);
  font: inherit;
  font-weight: 600;
  font-size: var(--gk-fs-md);
  line-height: 1;
  color: var(--gk-ink);
  background: var(--gk-surface);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--gk-transition-fast), border-color var(--gk-transition-fast),
    transform var(--gk-transition-fast), box-shadow var(--gk-transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.gk-btn:active {
  transform: translateY(1px) scale(0.99);
}
.gk-btn:focus-visible {
  outline: 3px solid var(--gk-accent);
  outline-offset: 2px;
}
.gk-btn--primary {
  background: var(--gk-accent);
  color: var(--gk-accent-contrast);
  border-color: var(--gk-accent);
}
.gk-btn--primary:hover {
  background: var(--gk-accent-strong);
  border-color: var(--gk-accent-strong);
}
.gk-btn--ghost {
  background: var(--gk-surface);
  color: var(--gk-accent-strong);
  border-color: var(--gk-line-strong);
}
.gk-btn--ghost:hover {
  background: var(--gk-accent-soft);
}
.gk-btn--block {
  width: 100%;
}

/* Card. */
.gk-card {
  background: var(--gk-surface);
  border: 1px solid var(--gk-line);
  border-radius: var(--gk-radius);
  box-shadow: var(--gk-shadow-sm);
  padding: var(--gk-space-4);
}

/* Avatar (initial in a circle). */
.gk-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--gk-radius-pill);
  background: linear-gradient(135deg, var(--gk-accent), var(--gk-accent-strong));
  color: var(--gk-accent-contrast);
  font-weight: 800;
  font-size: var(--gk-fs-md);
  line-height: 1;
  text-transform: uppercase;
}

/* Modal + backdrop with focus-trappable dialog. */
.gk-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gk-space-4);
  padding-bottom: calc(var(--gk-space-4) + env(safe-area-inset-bottom));
  background: rgba(8, 20, 19, 0.55);
  animation: gk-fade var(--gk-transition);
}
.gk-modal[hidden] {
  display: none;
}
.gk-modal__panel {
  width: 100%;
  max-width: 400px;
  max-height: calc(100dvh - 2 * var(--gk-space-4));
  overflow-y: auto;
  background: var(--gk-surface);
  border-radius: var(--gk-radius-lg);
  box-shadow: var(--gk-shadow-lg);
  padding: var(--gk-space-5);
  animation: gk-rise var(--gk-transition);
}
.gk-modal__title {
  margin: 0 0 var(--gk-space-4);
  font-family: var(--gk-font-display);
  font-size: var(--gk-fs-xl);
  color: var(--gk-ink);
}
.gk-modal__close {
  float: right;
  border: 0;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gk-ink-soft);
  cursor: pointer;
  min-width: var(--gk-tap);
  min-height: var(--gk-tap);
}

/* Form fields for the auth modal. */
.gk-field {
  display: block;
  margin-bottom: var(--gk-space-3);
}
.gk-field__label {
  display: block;
  margin-bottom: var(--gk-space-1);
  font-size: var(--gk-fs-sm);
  font-weight: 600;
  color: var(--gk-ink-soft);
}
.gk-input {
  width: 100%;
  min-height: var(--gk-tap);
  padding: 10px 12px;
  border: 1px solid var(--gk-line-strong);
  border-radius: var(--gk-radius-sm);
  background: var(--gk-surface);
  color: var(--gk-ink);
  font: inherit;
  font-size: var(--gk-fs-md);
}
.gk-input:focus-visible {
  outline: 3px solid var(--gk-accent);
  outline-offset: 1px;
  border-color: var(--gk-accent);
}
.gk-form__error {
  min-height: 1.2em;
  margin: var(--gk-space-2) 0 0;
  color: var(--gk-danger);
  font-size: var(--gk-fs-sm);
}
.gk-form__switch {
  margin-top: var(--gk-space-4);
  text-align: center;
  font-size: var(--gk-fs-sm);
  color: var(--gk-ink-soft);
}
.gk-form__switch button {
  border: 0;
  background: none;
  color: var(--gk-accent-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: var(--gk-space-1);
}
.gk-divider {
  display: flex;
  align-items: center;
  gap: var(--gk-space-3);
  margin: var(--gk-space-4) 0;
  color: var(--gk-ink-soft);
  font-size: var(--gk-fs-sm);
}
.gk-divider::before,
.gk-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gk-line);
}
.gk-btn--google {
  background: var(--gk-surface);
  color: var(--gk-ink);
  border-color: var(--gk-line-strong);
}

/* Toast (transient, bottom-centered, respects safe area). */
.gk-toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gk-space-5) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--gk-space-2);
  pointer-events: none;
  width: min(92vw, 420px);
}
.gk-toast {
  background: var(--gk-ink);
  color: var(--gk-bg);
  padding: 12px 16px;
  border-radius: var(--gk-radius);
  box-shadow: var(--gk-shadow);
  font-size: var(--gk-fs-sm);
  text-align: center;
  animation: gk-rise var(--gk-transition);
}

/* Leaderboard widget. */
.gk-lb-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.gk-lb-table th {
  text-align: left;
  font-size: var(--gk-fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gk-ink-soft);
  padding: 6px 10px;
  border-bottom: 1px solid var(--gk-line);
}
.gk-lb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--gk-line);
  font-size: var(--gk-fs-sm);
}
.gk-lb-table tbody tr:last-child td {
  border-bottom: 0;
}
.gk-lb-rank {
  font-weight: 700;
  color: var(--gk-accent-strong);
  white-space: nowrap;
}
.gk-lb-name {
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gk-lb-time {
  font-weight: 700;
}
.gk-lb-you {
  background: var(--gk-accent-soft);
}
.gk-lb-own {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: var(--gk-space-2);
  padding: 8px 10px;
  border-radius: var(--gk-radius-sm);
  background: var(--gk-accent-soft);
  font-size: var(--gk-fs-sm);
  font-variant-numeric: tabular-nums;
}
.gk-lb-own .gk-lb-name {
  flex: 1;
  font-weight: 600;
}
.gk-lb-state {
  padding: var(--gk-space-5) var(--gk-space-3);
  text-align: center;
  color: var(--gk-ink-soft);
  font-size: var(--gk-fs-sm);
}
.gk-lb-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gk-space-3);
}

@keyframes gk-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes gk-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
