/* Shared theme and controls for every game. */
:root {
  --bg: #14162b;
  --panel: #1e2140;
  --line: #2e3260;
  --text: #f3f4ff;
  --muted: #9aa0c8;
  --accent: #ffcf3f;
  --red: #ff4d6d;
  --green: #3ddc97;
  --blue: #4da3ff;
  --purple: #b57bff;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  /* Stops pull-to-refresh and the scroll chain to the browser (Chrome, Firefox; Safari in part). */
  overscroll-behavior: none;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

h1 { font-size: 36px; margin: 8px 0 0; letter-spacing: -1px; }
h1 .dot, .title-big .dot { color: var(--red); }
/* A screen title that looks like the h1 (each page keeps one real h1). */
.title-big { font-size: 36px; margin: 8px 0 0; letter-spacing: -1px; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.panel h3:first-child { margin-top: 0; }

.screen { display: flex; flex-direction: column; gap: 16px; }

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.center { text-align: center; }
.center-block { align-self: center; }
.error { color: var(--red); text-align: center; min-height: 1em; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap > * { flex: 1; }

input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 12px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 8px;
  max-width: 55%;
}

button { font: inherit; cursor: pointer; }

.btn {
  background: var(--accent);
  color: #1b1b1b;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  text-decoration: none;
}
.btn.big { padding: 18px; font-size: 18px; }
.btn.small { padding: 12px 16px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  padding: 4px;
  font-size: 14px;
}

.home-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  align-self: flex-start;
  padding: 4px 0;
}

/* Segmented control */
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1;
  background: none;
  border: 0;
  color: var(--muted);
  border-radius: 9px;
  padding: 10px 6px;
  font-weight: 600;
}
.seg button.on { background: var(--line); color: var(--text); }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 16px; }
.stepper button {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 22px;
}
.stepper span { font-size: 22px; font-weight: 700; min-width: 24px; text-align: center; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}
.chip.on { background: var(--accent); color: #1b1b1b; border-color: var(--accent); font-weight: 600; }

/* "Leave the game?" sheet that the back gesture opens */
.leave-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 9, 20, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.leave-sheet .panel { width: 100%; max-width: 448px; }
.leave-sheet p { margin: 0; }

/* Small message at the bottom ("Link copied") */
.kit-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1100;
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  overflow-wrap: anywhere;
  pointer-events: none;
}
