:root {
  --bg: #0f0f16;
  --panel: #1b1b24;
  --btn: #23232e;
  --btn-hover: #2e2e3d;
  --border: #33333f;
  --fg: #e8e8f0;
  --muted: #9a9ab0;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd4;

  /* Match the GameKit widget to the theme. */
  --gk-panel: var(--panel);
  --gk-btn: var(--btn);
  --gk-btn-hover: var(--btn-hover);
  --gk-border: var(--border);
  --gk-fg: var(--fg);
  --gk-muted: var(--muted);
  --gk-accent: var(--accent);
  --gk-accent-hover: var(--accent-hover);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* track the mobile toolbar so the game fills the screen */
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--border);
  flex: none; /* never let the bar grow; the game takes the rest */
}

.topbar .left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

/* Nothing in the bar should wrap to a second line. */
.title,
.back,
#account .gk-btn,
#account .gk-menu-item {
  white-space: nowrap;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
}
.back:hover { color: var(--fg); }

.title {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.title span { color: var(--accent); }

.topbar .right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* The game fills all remaining space below the top bar, edge to edge. */
main {
  flex: 1;
  min-height: 0;
  display: block;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
  touch-action: none; /* stop scroll/zoom while playing */
}

/* Mobile: back button becomes a plain arrow (no label), bar tightened. */
@media (max-width: 680px) {
  .back-label { display: none; }
  .topbar { gap: 0.6rem; padding: 0.7rem 0.9rem; }
  .topbar .left { gap: 0.7rem; }
}
